diff --git a/SunnyUI/Common/UFile.cs b/SunnyUI/Common/UFile.cs index 25f9d5f1..15968cfd 100644 --- a/SunnyUI/Common/UFile.cs +++ b/SunnyUI/Common/UFile.cs @@ -62,7 +62,7 @@ namespace Sunny.UI /// 打开是否成功 public static bool OpenDialog(ref string filename, string filter = "", string defaultExt = "") { - using OpenFileDialog od = new OpenFileDialog { Title = UILocalize.Open }; + using OpenFileDialog od = new OpenFileDialog { Title = UIStyles.Localize.Open }; try { @@ -89,7 +89,7 @@ namespace Sunny.UI /// 保存是否成功 public static bool SaveDialog(ref string filename, string filter = "", string defaultExt = "") { - using SaveFileDialog od = new SaveFileDialog { Title = UILocalize.Save }; + using SaveFileDialog od = new SaveFileDialog { Title = UIStyles.Localize.Save }; try { od.FileName = filename; diff --git a/SunnyUI/Common/ULocalize.cs b/SunnyUI/Common/ULocalize.cs index 413b34cb..9403b32d 100644 --- a/SunnyUI/Common/ULocalize.cs +++ b/SunnyUI/Common/ULocalize.cs @@ -20,341 +20,336 @@ * 2021-07-24: V3.0.5 内置字符串已经处理完国际化 ******************************************************************************/ +using System.Globalization; + namespace Sunny.UI { + public static class CultureInfos + { + //语言文件对应ID网址 + //https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms912047(v=winembedded.10)?redirectedfrom=MSDN + //ID语言 ID语言 + //1025 阿拉伯语 + //1041 日语 + //1028 繁体中文 + //1042 朝鲜语 + //1029 捷克语 + //1043 荷兰语 + //1030 丹麦语 + //1044 挪威语 + //1031 德语 + //1045 波兰语 + //1032 希腊语 + //1046 葡萄牙语 - 巴西 + //1033 英语 + //1049 俄语 + //1034 西班牙语 + //1053 瑞典语 + //1035 芬兰语 + //1054 泰语 + //1036 法语 + //1055 土耳其语 + //1037 希伯来语 + //2052 简体中文 + //1038 匈牙利语 + //2070 葡萄牙语 + //1040 意大利语 + //3076 汉语 - 香港 + + /// + /// 2052 简体中文 + /// + public const int LCID_ZH_CN = 2052; + + /// + /// 1028 繁体中文 + /// + public const int LCID_ZH_TW = 1028; + + /// + /// 1033 英语 + /// + public const int LCID_EN_US = 1033; + + /// + /// 2052 简体中文 + /// + public static CultureInfo SimplifiedChinese = CultureInfo.GetCultureInfo(LCID_ZH_CN); + + /// + /// 1028 繁体中文 + /// + public static CultureInfo TraditionalChinese = CultureInfo.GetCultureInfo(LCID_ZH_TW); + + /// + /// 1033 英语 + /// + public static CultureInfo English = CultureInfo.GetCultureInfo(LCID_EN_US); + } + + public class UILocalize_ZH_CN : UILocalize + { + public override CultureInfo CultureInfo => CultureInfos.SimplifiedChinese; + } + + public class UILocalize_EN_US : UILocalize + { + public override CultureInfo CultureInfo => CultureInfos.English; + public override string InfoTitle { get; set; } = "Info"; + public override string SuccessTitle { get; set; } = "Success"; + public override string WarningTitle { get; set; } = "Warning"; + public override string ErrorTitle { get; set; } = "Error"; + public override string AskTitle { get; set; } = "Query"; + public override string InputTitle { get; set; } = "Input"; + public override string SelectTitle { get; set; } = "Select"; + public override string CloseAll { get; set; } = "Close all"; + public override string OK { get; set; } = "OK"; + public override string Cancel { get; set; } = "Cancel"; + public override string GridNoData { get; set; } = "[ No data ]"; + public override string GridDataLoading { get; set; } = "Data loading, please wait..."; + public override string GridDataSourceException { get; set; } = "The data source must be DataTable or List"; + public override string SystemProcessing { get; set; } = "The system is processing, please wait..."; + public override string Monday { get; set; } = "MON"; + public override string Tuesday { get; set; } = "TUE"; + public override string Wednesday { get; set; } = "WED"; + public override string Thursday { get; set; } = "THU"; + public override string Friday { get; set; } = "FRI"; + public override string Saturday { get; set; } = "SAT"; + public override string Sunday { get; set; } = "SUN"; + public override string Prev { get; set; } = "Prev"; + public override string Next { get; set; } = "Next"; + public override string SelectPageLeft { get; set; } = "Page"; + public override string SelectPageRight { get; set; } = ""; + public override string January { get; set; } = "Jan."; + public override string February { get; set; } = "Feb."; + public override string March { get; set; } = "Mar."; + public override string April { get; set; } = "Apr."; + public override string May { get; set; } = "May"; + public override string June { get; set; } = "Jun."; + public override string July { get; set; } = "Jul."; + public override string August { get; set; } = "Aug."; + public override string September { get; set; } = "Sep."; + public override string October { get; set; } = "Oct."; + public override string November { get; set; } = "Nov."; + public override string December { get; set; } = "Dec."; + public override string Today { get; set; } = "Today"; + public override string Search { get; set; } = "Search"; + public override string Clear { get; set; } = "Clear"; + public override string Open { get; set; } = "Open"; + public override string Save { get; set; } = "Save"; + public override string All { get; set; } = "All"; + } + /// /// 多语言字符串定义 /// - public static class UILocalize + public abstract class UILocalize { + public abstract CultureInfo CultureInfo { get; } + /// /// 提示 /// - public static string InfoTitle = "提示"; + public virtual string InfoTitle { get; set; } = "提示"; /// /// 正确 /// - public static string SuccessTitle = "正确"; + public virtual string SuccessTitle { get; set; } = "正确"; /// /// 警告 /// - public static string WarningTitle = "警告"; + public virtual string WarningTitle { get; set; } = "警告"; /// /// 错误 /// - public static string ErrorTitle = "错误"; + public virtual string ErrorTitle { get; set; } = "错误"; /// /// 提示 /// - public static string AskTitle = "提示"; + public virtual string AskTitle { get; set; } = "提示"; /// /// 输入 /// - public static string InputTitle = "输入"; + public virtual string InputTitle { get; set; } = "输入"; /// /// 选择 /// - public static string SelectTitle = "选择"; + public virtual string SelectTitle { get; set; } = "选择"; /// /// 全部关闭 /// - public static string CloseAll = "全部关闭"; + public virtual string CloseAll { get; set; } = "全部关闭"; /// /// 确定 /// - public static string OK = "确定"; + public virtual string OK { get; set; } = "确定"; /// /// 取消 /// - public static string Cancel = "取消"; + public virtual string Cancel { get; set; } = "取消"; /// /// [ 无数据 ] /// - public static string GridNoData = "[ 无数据 ]"; + public virtual string GridNoData { get; set; } = "[ 无数据 ]"; /// /// 数据加载中,请稍候... /// - public static string GridDataLoading = "数据加载中,请稍候..."; + public virtual string GridDataLoading { get; set; } = "数据加载中,请稍候..."; /// /// 数据源必须为DataTable或者List /// - public static string GridDataSourceException = "数据源必须为DataTable或者List"; + public virtual string GridDataSourceException { get; set; } = "数据源必须为DataTable或者List"; /// /// "系统正在处理中,请稍候..." /// - public static string SystemProcessing = "系统正在处理中,请稍候..."; + public virtual string SystemProcessing { get; set; } = "系统正在处理中,请稍候..."; /// /// 星期一 /// - public static string Monday = "一"; + public virtual string Monday { get; set; } = "一"; /// /// 星期二 /// - public static string Tuesday = "二"; + public virtual string Tuesday { get; set; } = "二"; /// /// 星期三 /// - public static string Wednesday = "三"; + public virtual string Wednesday { get; set; } = "三"; /// /// 星期四 /// - public static string Thursday = "四"; + public virtual string Thursday { get; set; } = "四"; /// /// 星期五 /// - public static string Friday = "五"; + public virtual string Friday { get; set; } = "五"; /// /// 星期六 /// - public static string Saturday = "六"; + public virtual string Saturday { get; set; } = "六"; /// /// 星期日 /// - public static string Sunday = "日"; + public virtual string Sunday { get; set; } = "日"; /// /// 上一页 /// - public static string Prev = "上一页"; + public virtual string Prev { get; set; } = "上一页"; /// /// 下一页 /// - public static string Next = "下一页"; + public virtual string Next { get; set; } = "下一页"; /// /// 第 /// - public static string SelectPageLeft = "第"; + public virtual string SelectPageLeft { get; set; } = "第"; /// /// 页 /// - public static string SelectPageRight = "页"; + public virtual string SelectPageRight { get; set; } = "页"; /// /// 一月 /// - public static string January = "一月"; + public virtual string January { get; set; } = "一月"; /// /// 二月 /// - public static string February = "二月"; + public virtual string February { get; set; } = "二月"; /// /// 三月 /// - public static string March = "三月"; + public virtual string March { get; set; } = "三月"; /// /// 四月 /// - public static string April = "四月"; + public virtual string April { get; set; } = "四月"; /// /// 五月 /// - public static string May = "五月"; + public virtual string May { get; set; } = "五月"; /// /// 六月 /// - public static string June = "六月"; + public virtual string June { get; set; } = "六月"; /// /// 七月 /// - public static string July = "七月"; + public virtual string July { get; set; } = "七月"; /// /// 八月 /// - public static string August = "八月"; + public virtual string August { get; set; } = "八月"; /// /// 九月 /// - public static string September = "九月"; + public virtual string September { get; set; } = "九月"; /// /// 十月 /// - public static string October = "十月"; + public virtual string October { get; set; } = "十月"; /// /// 十一月 /// - public static string November = "十一月"; + public virtual string November { get; set; } = "十一月"; /// /// 十二月 /// - public static string December = "十二月"; + public virtual string December { get; set; } = "十二月"; /// /// 今天 /// - public static string Today = "今天"; + public virtual string Today { get; set; } = "今天"; /// /// 搜索 /// - public static string Search = "搜索"; + public virtual string Search { get; set; } = "搜索"; /// /// 清除 /// - public static string Clear = "清除"; + public virtual string Clear { get; set; } = "清除"; - public static string Open = "打开"; - public static string Save = "保存"; + public virtual string Open { get; set; } = "打开"; + public virtual string Save { get; set; } = "保存"; - public static string All = "全部"; - } - - /// - /// 多语言字符串帮助类 - /// - public static class UILocalizeHelper - { - /// - /// 设置为英文 - /// - public static void SetEN() - { - UILocalize.InfoTitle = "Info"; - UILocalize.SuccessTitle = "Success"; - UILocalize.WarningTitle = "Warning"; - UILocalize.ErrorTitle = "Error"; - UILocalize.AskTitle = "Query"; - UILocalize.InputTitle = "Input"; - UILocalize.SelectTitle = "Select"; - UILocalize.CloseAll = "Close all"; - UILocalize.OK = "OK"; - UILocalize.Cancel = "Cancel"; - UILocalize.GridNoData = "[ No data ]"; - UILocalize.GridDataLoading = "Data loading, please wait..."; - UILocalize.GridDataSourceException = "The data source must be DataTable or List"; - UILocalize.SystemProcessing = "The system is processing, please wait..."; - - UILocalize.Monday = "MON"; - UILocalize.Tuesday = "TUE"; - UILocalize.Wednesday = "WED"; - UILocalize.Thursday = "THU"; - UILocalize.Friday = "FRI"; - UILocalize.Saturday = "SAT"; - UILocalize.Sunday = "SUN"; - - UILocalize.Prev = "Prev"; - UILocalize.Next = "Next"; - UILocalize.SelectPageLeft = "Page"; - UILocalize.SelectPageRight = ""; - - UILocalize.January = "Jan."; - UILocalize.February = "Feb."; - UILocalize.March = "Mar."; - UILocalize.April = "Apr."; - UILocalize.May = "May"; - UILocalize.June = "Jun."; - UILocalize.July = "Jul."; - UILocalize.August = "Aug."; - UILocalize.September = "Sep."; - UILocalize.October = "Oct."; - UILocalize.November = "Nov."; - UILocalize.December = "Dec."; - - UILocalize.Today = "Today"; - - UILocalize.Search = "Search"; - UILocalize.Clear = "Clear"; - - UILocalize.Open = "Open"; - UILocalize.Save = "Save"; - - UILocalize.All = "All"; - - UIStyles.Translate(); - } - - /// - /// 设置为中文 - /// - public static void SetCH() - { - UILocalize.InfoTitle = "提示"; - UILocalize.SuccessTitle = "正确"; - UILocalize.WarningTitle = "警告"; - UILocalize.ErrorTitle = "错误"; - UILocalize.AskTitle = "提示"; - UILocalize.InputTitle = "输入"; - UILocalize.SelectTitle = "选择"; - UILocalize.CloseAll = "全部关闭"; - UILocalize.OK = "确定"; - UILocalize.Cancel = "取消"; - UILocalize.GridNoData = "[ 无数据 ]"; - UILocalize.GridDataLoading = "数据加载中,请稍候..."; - UILocalize.GridDataSourceException = "数据源必须为DataTable或者List"; - UILocalize.SystemProcessing = "系统正在处理中,请稍候..."; - - UILocalize.Monday = "一"; - UILocalize.Tuesday = "二"; - UILocalize.Wednesday = "三"; - UILocalize.Thursday = "四"; - UILocalize.Friday = "五"; - UILocalize.Saturday = "六"; - UILocalize.Sunday = "日"; - - UILocalize.Prev = "上一页"; - UILocalize.Next = "下一页"; - - UILocalize.SelectPageLeft = "第"; - UILocalize.SelectPageRight = "页"; - - UILocalize.January = "一月"; - UILocalize.February = "二月"; - UILocalize.March = "三月"; - UILocalize.April = "四月"; - UILocalize.May = "五月"; - UILocalize.June = "六月"; - UILocalize.July = "七月"; - UILocalize.August = "八月"; - UILocalize.September = "九月"; - UILocalize.October = "十月"; - UILocalize.November = "十一月"; - UILocalize.December = "十二月"; - - UILocalize.Today = "今天"; - - UILocalize.Search = "搜索"; - UILocalize.Clear = "清除"; - - UILocalize.Open = "打开"; - UILocalize.Save = "保存"; - - UILocalize.All = "全部"; - - UIStyles.Translate(); - } + public virtual string All { get; set; } = "全部"; } } \ No newline at end of file diff --git a/SunnyUI/Controls/DropItem/UIColorItem.cs b/SunnyUI/Controls/DropItem/UIColorItem.cs index 6c4c5f4c..bd377ac8 100644 --- a/SunnyUI/Controls/DropItem/UIColorItem.cs +++ b/SunnyUI/Controls/DropItem/UIColorItem.cs @@ -27,8 +27,8 @@ namespace Sunny.UI public void Translate() { - btnOK.Text = UILocalize.OK; - btnCancel.Text = UILocalize.Cancel; + btnOK.Text = UIStyles.Localize.OK; + btnCancel.Text = UIStyles.Localize.Cancel; } private LabelRotate m_colorSample; diff --git a/SunnyUI/Controls/DropItem/UIComboDataGridViewItem.cs b/SunnyUI/Controls/DropItem/UIComboDataGridViewItem.cs index 2be01c97..bf9d526e 100644 --- a/SunnyUI/Controls/DropItem/UIComboDataGridViewItem.cs +++ b/SunnyUI/Controls/DropItem/UIComboDataGridViewItem.cs @@ -84,10 +84,10 @@ namespace Sunny.UI public void Translate() { - btnOK.Text = UILocalize.OK; - btnCancel.Text = UILocalize.Cancel; - btnClear.Text = UILocalize.Clear; - btnSearch.Text = UILocalize.Search; + btnOK.Text = UIStyles.Localize.OK; + btnCancel.Text = UIStyles.Localize.Cancel; + btnClear.Text = UIStyles.Localize.Clear; + btnSearch.Text = UIStyles.Localize.Search; } public bool ShowButtons diff --git a/SunnyUI/Controls/DropItem/UIComboTreeViewItem.cs b/SunnyUI/Controls/DropItem/UIComboTreeViewItem.cs index 7477b638..9fc58545 100644 --- a/SunnyUI/Controls/DropItem/UIComboTreeViewItem.cs +++ b/SunnyUI/Controls/DropItem/UIComboTreeViewItem.cs @@ -52,9 +52,9 @@ namespace Sunny.UI public void Translate() { - btnOK.Text = UILocalize.OK; - btnCancel.Text = UILocalize.Cancel; - uiCheckBox1.Text = UILocalize.All; + btnOK.Text = UIStyles.Localize.OK; + btnCancel.Text = UIStyles.Localize.Cancel; + uiCheckBox1.Text = UIStyles.Localize.All; } private void InitializeComponent() diff --git a/SunnyUI/Controls/DropItem/UIDateItem.cs b/SunnyUI/Controls/DropItem/UIDateItem.cs index 1b23e052..0b5f83e9 100644 --- a/SunnyUI/Controls/DropItem/UIDateItem.cs +++ b/SunnyUI/Controls/DropItem/UIDateItem.cs @@ -382,18 +382,18 @@ namespace Sunny.UI public void Translate() { months.Clear(); - months.Add(UILocalize.January); - months.Add(UILocalize.February); - months.Add(UILocalize.March); - months.Add(UILocalize.April); - months.Add(UILocalize.May); - months.Add(UILocalize.June); - months.Add(UILocalize.July); - months.Add(UILocalize.August); - months.Add(UILocalize.September); - months.Add(UILocalize.October); - months.Add(UILocalize.November); - months.Add(UILocalize.December); + months.Add(UIStyles.Localize.January); + months.Add(UIStyles.Localize.February); + months.Add(UIStyles.Localize.March); + months.Add(UIStyles.Localize.April); + months.Add(UIStyles.Localize.May); + months.Add(UIStyles.Localize.June); + months.Add(UIStyles.Localize.July); + months.Add(UIStyles.Localize.August); + months.Add(UIStyles.Localize.September); + months.Add(UIStyles.Localize.October); + months.Add(UIStyles.Localize.November); + months.Add(UIStyles.Localize.December); } private void TopPanel_Click(object sender, EventArgs e) @@ -788,7 +788,7 @@ namespace Sunny.UI int width = p3.Width / 7; int height = (p3.Height - 30 * SizeMultiple) / 6; using Font font = SizeMultiple == 1 ? this.Font : new Font(this.Font.FontFamily, this.Font.Size * 1.5f); - string[] weeks = { UILocalize.Sunday, UILocalize.Monday, UILocalize.Tuesday, UILocalize.Wednesday, UILocalize.Thursday, UILocalize.Friday, UILocalize.Saturday }; + string[] weeks = { UIStyles.Localize.Sunday, UIStyles.Localize.Monday, UIStyles.Localize.Tuesday, UIStyles.Localize.Wednesday, UIStyles.Localize.Thursday, UIStyles.Localize.Friday, UIStyles.Localize.Saturday }; for (int i = 0; i < weeks.Length; i++) { e.Graphics.DrawString(weeks[i], font, ForeColor, new Rectangle(width * i, 4 * SizeMultiple, width, 19 * SizeMultiple), ContentAlignment.MiddleCenter); @@ -826,8 +826,8 @@ namespace Sunny.UI { using Font SubFont = this.Font.DPIScaleFont(SizeMultiple == 1 ? 10.5f : 15.75f); e.Graphics.FillRectangle(p3.FillColor, p3.Width - width * 4 + 1, p3.Height - height + 1, width * 4 - 2, height - 2); - e.Graphics.DrawString(UILocalize.Today + " " + DateTime.Now.DateString(), SubFont, isToday ? b3.SymbolColor : Color.DarkGray, new Rectangle(p3.Width - width * 4, p3.Height - height - 1, Width, height), ContentAlignment.MiddleLeft); - SizeF sf = TextRenderer.MeasureText(UILocalize.Today, SubFont); + e.Graphics.DrawString(UIStyles.Localize.Today + " " + DateTime.Now.DateString(), SubFont, isToday ? b3.SymbolColor : Color.DarkGray, new Rectangle(p3.Width - width * 4, p3.Height - height - 1, Width, height), ContentAlignment.MiddleLeft); + SizeF sf = TextRenderer.MeasureText(UIStyles.Localize.Today, SubFont); e.Graphics.DrawRectangle(b3.SymbolColor, new Rectangle(p3.Width - width * 4 + 1, p3.Height - height + 1, (int)sf.Width - 2, height - 4)); } } diff --git a/SunnyUI/Controls/DropItem/UIDateTimeItem.cs b/SunnyUI/Controls/DropItem/UIDateTimeItem.cs index e6719c0d..a8738e42 100644 --- a/SunnyUI/Controls/DropItem/UIDateTimeItem.cs +++ b/SunnyUI/Controls/DropItem/UIDateTimeItem.cs @@ -780,21 +780,21 @@ namespace Sunny.UI public void Translate() { months.Clear(); - months.Add(UILocalize.January); - months.Add(UILocalize.February); - months.Add(UILocalize.March); - months.Add(UILocalize.April); - months.Add(UILocalize.May); - months.Add(UILocalize.June); - months.Add(UILocalize.July); - months.Add(UILocalize.August); - months.Add(UILocalize.September); - months.Add(UILocalize.October); - months.Add(UILocalize.November); - months.Add(UILocalize.December); + months.Add(UIStyles.Localize.January); + months.Add(UIStyles.Localize.February); + months.Add(UIStyles.Localize.March); + months.Add(UIStyles.Localize.April); + months.Add(UIStyles.Localize.May); + months.Add(UIStyles.Localize.June); + months.Add(UIStyles.Localize.July); + months.Add(UIStyles.Localize.August); + months.Add(UIStyles.Localize.September); + months.Add(UIStyles.Localize.October); + months.Add(UIStyles.Localize.November); + months.Add(UIStyles.Localize.December); - btnOK.Text = UILocalize.OK; - btnCancel.Text = UILocalize.Cancel; + btnOK.Text = UIStyles.Localize.OK; + btnCancel.Text = UIStyles.Localize.Cancel; } private int activeDay = -1; @@ -1267,7 +1267,7 @@ namespace Sunny.UI int width = p3.Width / 7; int height = (p3.Height - 30 * SizeMultiple) / 6; using Font font = SizeMultiple == 1 ? this.Font : new Font(this.Font.FontFamily, this.Font.Size * 1.5f); - string[] weeks = { UILocalize.Sunday, UILocalize.Monday, UILocalize.Tuesday, UILocalize.Wednesday, UILocalize.Thursday, UILocalize.Friday, UILocalize.Saturday }; + string[] weeks = { UIStyles.Localize.Sunday, UIStyles.Localize.Monday, UIStyles.Localize.Tuesday, UIStyles.Localize.Wednesday, UIStyles.Localize.Thursday, UIStyles.Localize.Friday, UIStyles.Localize.Saturday }; for (int i = 0; i < weeks.Length; i++) { e.Graphics.DrawString(weeks[i], font, ForeColor, new Rectangle(width * i, 4 * SizeMultiple, width, 19 * SizeMultiple), ContentAlignment.MiddleCenter); @@ -1303,8 +1303,8 @@ namespace Sunny.UI { using Font SubFont = this.Font.DPIScaleFont(SizeMultiple == 1 ? 10.5f : 15.75f); e.Graphics.FillRectangle(p3.FillColor, p3.Width - width * 4 + 1, p3.Height - height + 1, width * 4 - 2, height - 2); - e.Graphics.DrawString(UILocalize.Today + " " + DateTime.Now.DateString(), SubFont, isToday ? b3.SymbolColor : Color.DarkGray, new Rectangle(p3.Width - width * 4, p3.Height - height - 1, Width, height), ContentAlignment.MiddleLeft); - SizeF sf = TextRenderer.MeasureText(UILocalize.Today, SubFont); + e.Graphics.DrawString(UIStyles.Localize.Today + " " + DateTime.Now.DateString(), SubFont, isToday ? b3.SymbolColor : Color.DarkGray, new Rectangle(p3.Width - width * 4, p3.Height - height - 1, Width, height), ContentAlignment.MiddleLeft); + SizeF sf = TextRenderer.MeasureText(UIStyles.Localize.Today, SubFont); e.Graphics.DrawRectangle(b3.SymbolColor, new Rectangle(p3.Width - width * 4 + 1, p3.Height - height + 1, (int)sf.Width - 2, height - 4)); } } diff --git a/SunnyUI/Controls/DropItem/UITimeItem.cs b/SunnyUI/Controls/DropItem/UITimeItem.cs index 5d9216d7..5a70013a 100644 --- a/SunnyUI/Controls/DropItem/UITimeItem.cs +++ b/SunnyUI/Controls/DropItem/UITimeItem.cs @@ -403,8 +403,8 @@ namespace Sunny.UI public void Translate() { - btnOK.Text = UILocalize.OK; - btnCancel.Text = UILocalize.Cancel; + btnOK.Text = UIStyles.Localize.OK; + btnCancel.Text = UIStyles.Localize.Cancel; } public override void SetDPIScale() diff --git a/SunnyUI/Controls/UICalendar.cs b/SunnyUI/Controls/UICalendar.cs index fe547772..9e997cfb 100644 --- a/SunnyUI/Controls/UICalendar.cs +++ b/SunnyUI/Controls/UICalendar.cs @@ -313,18 +313,18 @@ namespace Sunny.UI public void Translate() { months.Clear(); - months.Add(UILocalize.January); - months.Add(UILocalize.February); - months.Add(UILocalize.March); - months.Add(UILocalize.April); - months.Add(UILocalize.May); - months.Add(UILocalize.June); - months.Add(UILocalize.July); - months.Add(UILocalize.August); - months.Add(UILocalize.September); - months.Add(UILocalize.October); - months.Add(UILocalize.November); - months.Add(UILocalize.December); + months.Add(UIStyles.Localize.January); + months.Add(UIStyles.Localize.February); + months.Add(UIStyles.Localize.March); + months.Add(UIStyles.Localize.April); + months.Add(UIStyles.Localize.May); + months.Add(UIStyles.Localize.June); + months.Add(UIStyles.Localize.July); + months.Add(UIStyles.Localize.August); + months.Add(UIStyles.Localize.September); + months.Add(UIStyles.Localize.October); + months.Add(UIStyles.Localize.November); + months.Add(UIStyles.Localize.December); } private void TopPanel_Click(object sender, EventArgs e) @@ -677,7 +677,7 @@ namespace Sunny.UI { int width = p3.Width / 7; int height = (p3.Height - 30) / 6; - string[] weeks = { UILocalize.Sunday, UILocalize.Monday, UILocalize.Tuesday, UILocalize.Wednesday, UILocalize.Thursday, UILocalize.Friday, UILocalize.Saturday }; + string[] weeks = { UIStyles.Localize.Sunday, UIStyles.Localize.Monday, UIStyles.Localize.Tuesday, UIStyles.Localize.Wednesday, UIStyles.Localize.Thursday, UIStyles.Localize.Friday, UIStyles.Localize.Saturday }; for (int i = 0; i < weeks.Length; i++) { e.Graphics.DrawString(weeks[i], Font, ForeColor, new Rectangle(width * i, 4, width, 19), ContentAlignment.MiddleCenter); diff --git a/SunnyUI/Controls/UIMiniPagination.cs b/SunnyUI/Controls/UIMiniPagination.cs index e3ab1f71..941c137f 100644 --- a/SunnyUI/Controls/UIMiniPagination.cs +++ b/SunnyUI/Controls/UIMiniPagination.cs @@ -259,7 +259,7 @@ namespace Sunny.UI { if (!(value is DataTable || value is IList)) { - throw new Exception(UILocalize.GridDataSourceException); + throw new Exception(UIStyles.Localize.GridDataSourceException); } } diff --git a/SunnyUI/Controls/UIPagination.cs b/SunnyUI/Controls/UIPagination.cs index 4ae76bd3..16abbe2d 100644 --- a/SunnyUI/Controls/UIPagination.cs +++ b/SunnyUI/Controls/UIPagination.cs @@ -170,9 +170,9 @@ namespace Sunny.UI try { - b0.Text = UILocalize.Prev; - b16.Text = UILocalize.Next; - btnSelect.Text = UILocalize.SelectTitle; + b0.Text = UIStyles.Localize.Prev; + b16.Text = UIStyles.Localize.Next; + btnSelect.Text = UIStyles.Localize.SelectTitle; Size sf = TextRenderer.MeasureText(b0.Text, b0.Font); b0.Width = b0.SymbolSize + sf.Width + 10; @@ -182,8 +182,8 @@ namespace Sunny.UI btnSelect.Width = TextRenderer.MeasureText(btnSelect.Text, btnSelect.Font).Width + 16; - uiLabel1.Text = UILocalize.SelectPageLeft; - uiLabel2.Text = UILocalize.SelectPageRight; + uiLabel1.Text = UIStyles.Localize.SelectPageLeft; + uiLabel2.Text = UIStyles.Localize.SelectPageRight; edtPage.Left = uiLabel1.Right + 3; uiLabel2.Left = edtPage.Right + 3; btnSelect.Left = uiLabel2.Right + 3; @@ -309,7 +309,7 @@ namespace Sunny.UI { if (!(value is DataTable || value is IList)) { - throw new Exception(UILocalize.GridDataSourceException); + throw new Exception(UIStyles.Localize.GridDataSourceException); } } diff --git a/SunnyUI/Forms/UIBaseForm.cs b/SunnyUI/Forms/UIBaseForm.cs index 8ac17740..7d0529ed 100644 --- a/SunnyUI/Forms/UIBaseForm.cs +++ b/SunnyUI/Forms/UIBaseForm.cs @@ -696,7 +696,7 @@ namespace Sunny.UI } } - public void Translate() + public virtual void Translate() { List controls = this.GetInterfaceControls("ITranslate"); foreach (var control in controls) diff --git a/SunnyUI/Forms/UIEditForm.cs b/SunnyUI/Forms/UIEditForm.cs index 3a97eb47..eabd2796 100644 --- a/SunnyUI/Forms/UIEditForm.cs +++ b/SunnyUI/Forms/UIEditForm.cs @@ -43,8 +43,8 @@ namespace Sunny.UI { InitializeComponent(); - btnOK.Text = UILocalize.OK; - btnCancel.Text = UILocalize.Cancel; + btnOK.Text = UIStyles.Localize.OK; + btnCancel.Text = UIStyles.Localize.Cancel; base.TopMost = true; } @@ -331,8 +331,8 @@ namespace Sunny.UI { InitializeComponent(); - btnOK.Text = UILocalize.OK; - btnCancel.Text = UILocalize.Cancel; + btnOK.Text = UIStyles.Localize.OK; + btnCancel.Text = UIStyles.Localize.Cancel; base.TopMost = true; Option = option; diff --git a/SunnyUI/Forms/UIFormHelper.cs b/SunnyUI/Forms/UIFormHelper.cs index 9757e111..c11765df 100644 --- a/SunnyUI/Forms/UIFormHelper.cs +++ b/SunnyUI/Forms/UIFormHelper.cs @@ -92,32 +92,32 @@ namespace Sunny.UI { public static void Show(string message, bool showMask = false, int delay = 0) { - Show(message, UILocalize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask, delay); + Show(message, UIStyles.Localize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask, delay); } public static void ShowInfo(string message, bool showMask = false, int delay = 0) { - Show(message, UILocalize.InfoTitle, UIStyles.Style, UIMessageBoxButtons.OK, showMask, delay); + Show(message, UIStyles.Localize.InfoTitle, UIStyles.Style, UIMessageBoxButtons.OK, showMask, delay); } public static void ShowSuccess(string message, bool showMask = false, int delay = 0) { - Show(message, UILocalize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask, delay); + Show(message, UIStyles.Localize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask, delay); } public static void ShowWarning(string message, bool showMask = false, int delay = 0) { - Show(message, UILocalize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask, delay); + Show(message, UIStyles.Localize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask, delay); } public static void ShowError(string message, bool showMask = false, int delay = 0) { - Show(message, UILocalize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask, delay); + Show(message, UIStyles.Localize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask, delay); } public static bool ShowAsk(string message, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Ok) { - return ShowMessageDialog(message, UILocalize.AskTitle, true, UIStyle.Blue, showMask, defaultButton); + return ShowMessageDialog(message, UIStyles.Localize.AskTitle, true, UIStyle.Blue, showMask, defaultButton); } public static bool Show(string message, string title, UIStyle style = UIStyle.Blue, UIMessageBoxButtons buttons = UIMessageBoxButtons.OK, bool showMask = false, int delay = 0) @@ -144,27 +144,27 @@ namespace Sunny.UI public static void ShowInfo2(string message, bool showMask = false, int delay = 0) { - ShowMessageDialog2(UILocalize.InfoTitle, message, UINotifierType.INFO, showMask, UIMessageDialogButtons.Ok, delay); + ShowMessageDialog2(UIStyles.Localize.InfoTitle, message, UINotifierType.INFO, showMask, UIMessageDialogButtons.Ok, delay); } public static void ShowSuccess2(string message, bool showMask = false, int delay = 0) { - ShowMessageDialog2(UILocalize.SuccessTitle, message, UINotifierType.OK, showMask, UIMessageDialogButtons.Ok, delay); + ShowMessageDialog2(UIStyles.Localize.SuccessTitle, message, UINotifierType.OK, showMask, UIMessageDialogButtons.Ok, delay); } public static void ShowWarning2(string message, bool showMask = false, int delay = 0) { - ShowMessageDialog2(UILocalize.WarningTitle, message, UINotifierType.WARNING, showMask, UIMessageDialogButtons.Ok, delay); + ShowMessageDialog2(UIStyles.Localize.WarningTitle, message, UINotifierType.WARNING, showMask, UIMessageDialogButtons.Ok, delay); } public static void ShowError2(string message, bool showMask = false, int delay = 0) { - ShowMessageDialog2(UILocalize.ErrorTitle, message, UINotifierType.ERROR, showMask, UIMessageDialogButtons.Ok, delay); + ShowMessageDialog2(UIStyles.Localize.ErrorTitle, message, UINotifierType.ERROR, showMask, UIMessageDialogButtons.Ok, delay); } public static bool ShowAsk2(string message, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Ok) { - return ShowMessageDialog2(UILocalize.AskTitle, message, UINotifierType.Ask, showMask, defaultButton); + return ShowMessageDialog2(UIStyles.Localize.AskTitle, message, UINotifierType.Ask, showMask, defaultButton); } public static bool ShowMessageDialog2(string title, string message, UINotifierType noteType, bool showMask = false, @@ -285,7 +285,7 @@ namespace Sunny.UI private static UIInputForm CreateInputForm(bool checkEmpty, string desc) { UIInputForm frm = new UIInputForm(); - frm.Text = UILocalize.InputTitle; + frm.Text = UIStyles.Localize.InputTitle; frm.Label.Text = desc; frm.CheckInputEmpty = checkEmpty; return frm; @@ -501,7 +501,7 @@ namespace Sunny.UI public static bool ShowSelectDialog(this Form owner, ref int selectIndex, IList items, UIStyle style, bool showMask = false) { - return owner.ShowSelectDialog(ref selectIndex, items, UILocalize.SelectTitle, "", style, showMask); + return owner.ShowSelectDialog(ref selectIndex, items, UIStyles.Localize.SelectTitle, "", style, showMask); } public static bool ShowSelectDialog(this Form owner, ref int selectIndex, IList items, bool showMask = false) @@ -646,7 +646,7 @@ namespace Sunny.UI /// 显示遮罩层 public static void ShowSuccessDialog(this Form owner, string message, bool showMask = false, int delay = 0) { - owner.ShowSuccessDialog(UILocalize.SuccessTitle, message, UIStyle.Green, showMask, delay); + owner.ShowSuccessDialog(UIStyles.Localize.SuccessTitle, message, UIStyle.Green, showMask, delay); } /// @@ -668,7 +668,7 @@ namespace Sunny.UI /// 显示遮罩层 public static void ShowInfoDialog(this Form owner, string message, bool showMask = false, int delay = 0) { - owner.ShowInfoDialog(UILocalize.InfoTitle, message, UIStyles.Style, showMask, delay); + owner.ShowInfoDialog(UIStyles.Localize.InfoTitle, message, UIStyles.Style, showMask, delay); } /// @@ -690,7 +690,7 @@ namespace Sunny.UI /// 显示遮罩层 public static void ShowWarningDialog(this Form owner, string message, bool showMask = false, int delay = 0) { - owner.ShowWarningDialog(UILocalize.WarningTitle, message, UIStyle.Orange, showMask, delay); + owner.ShowWarningDialog(UIStyles.Localize.WarningTitle, message, UIStyle.Orange, showMask, delay); } /// @@ -712,7 +712,7 @@ namespace Sunny.UI /// 显示遮罩层 public static void ShowErrorDialog(this Form owner, string message, bool showMask = false, int delay = 0) { - owner.ShowErrorDialog(UILocalize.ErrorTitle, message, UIStyle.Red, showMask, delay); + owner.ShowErrorDialog(UIStyles.Localize.ErrorTitle, message, UIStyle.Red, showMask, delay); } /// @@ -735,7 +735,7 @@ namespace Sunny.UI /// 结果 public static bool ShowAskDialog(this Form owner, string message, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Ok) { - return UIMessageBox.ShowMessageDialog(owner, message, UILocalize.AskTitle, true, UIStyles.Style, showMask, defaultButton); + return UIMessageBox.ShowMessageDialog(owner, message, UIStyles.Localize.AskTitle, true, UIStyles.Style, showMask, defaultButton); } /// @@ -760,7 +760,7 @@ namespace Sunny.UI /// 显示遮罩层 public static void ShowSuccessDialog2(this Form owner, string message, bool showMask = false, int delay = 0) { - owner.ShowSuccessDialog2(UILocalize.SuccessTitle, message, showMask, delay); + owner.ShowSuccessDialog2(UIStyles.Localize.SuccessTitle, message, showMask, delay); } /// @@ -782,7 +782,7 @@ namespace Sunny.UI /// 显示遮罩层 public static void ShowInfoDialog2(this Form owner, string message, bool showMask = false, int delay = 0) { - owner.ShowInfoDialog2(UILocalize.InfoTitle, message, showMask, delay); + owner.ShowInfoDialog2(UIStyles.Localize.InfoTitle, message, showMask, delay); } /// @@ -804,7 +804,7 @@ namespace Sunny.UI /// 显示遮罩层 public static void ShowWarningDialog2(this Form owner, string message, bool showMask = false, int delay = 0) { - owner.ShowWarningDialog2(UILocalize.WarningTitle, message, showMask, delay); + owner.ShowWarningDialog2(UIStyles.Localize.WarningTitle, message, showMask, delay); } /// @@ -826,7 +826,7 @@ namespace Sunny.UI /// 显示遮罩层 public static void ShowErrorDialog2(this Form owner, string message, bool showMask = false, int delay = 0) { - owner.ShowErrorDialog2(UILocalize.ErrorTitle, message, showMask, delay); + owner.ShowErrorDialog2(UIStyles.Localize.ErrorTitle, message, showMask, delay); } /// @@ -849,7 +849,7 @@ namespace Sunny.UI /// 结果 public static bool ShowAskDialog2(this Form owner, string message, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Cancel) { - return UIMessageBox.ShowMessageDialog2(owner, UILocalize.AskTitle, message, UINotifierType.Ask, showMask, defaultButton); + return UIMessageBox.ShowMessageDialog2(owner, UIStyles.Localize.AskTitle, message, UINotifierType.Ask, showMask, defaultButton); } /// @@ -944,42 +944,42 @@ namespace Sunny.UI public static void ShowInfoNotifier(this Form form, string desc, bool isDialog = false, int timeout = 2000) { - UINotifierHelper.ShowNotifier(desc, UINotifierType.INFO, UILocalize.InfoTitle, isDialog, timeout); + UINotifierHelper.ShowNotifier(desc, UINotifierType.INFO, UIStyles.Localize.InfoTitle, isDialog, timeout); } public static void ShowSuccessNotifier(this Form form, string desc, bool isDialog = false, int timeout = 2000) { - UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, isDialog, timeout); + UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UIStyles.Localize.SuccessTitle, isDialog, timeout); } public static void ShowWarningNotifier(this Form form, string desc, bool isDialog = false, int timeout = 2000) { - UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, isDialog, timeout); + UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UIStyles.Localize.WarningTitle, isDialog, timeout); } public static void ShowErrorNotifier(this Form form, string desc, bool isDialog = false, int timeout = 2000) { - UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, isDialog, timeout); + UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UIStyles.Localize.ErrorTitle, isDialog, timeout); } public static void ShowInfoNotifier(this Form form, string desc, EventHandler clickEvent, int timeout = 2000) { - UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.INFO, UILocalize.InfoTitle, timeout); + UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.INFO, UIStyles.Localize.InfoTitle, timeout); } public static void ShowSuccessNotifier(this Form form, string desc, EventHandler clickEvent, int timeout = 2000) { - UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.OK, UILocalize.SuccessTitle, timeout); + UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.OK, UIStyles.Localize.SuccessTitle, timeout); } public static void ShowWarningNotifier(this Form form, string desc, EventHandler clickEvent, int timeout = 2000) { - UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.WARNING, UILocalize.WarningTitle, timeout); + UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.WARNING, UIStyles.Localize.WarningTitle, timeout); } public static void ShowErrorNotifier(this Form form, string desc, EventHandler clickEvent, int timeout = 2000) { - UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.ERROR, UILocalize.ErrorTitle, timeout); + UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.ERROR, UIStyles.Localize.ErrorTitle, timeout); } #endregion 一些辅助窗口 diff --git a/SunnyUI/Forms/UIMessageForm.cs b/SunnyUI/Forms/UIMessageForm.cs index 8497370d..1cb9aad8 100644 --- a/SunnyUI/Forms/UIMessageForm.cs +++ b/SunnyUI/Forms/UIMessageForm.cs @@ -36,8 +36,8 @@ namespace Sunny.UI { InitializeComponent(); - btnOK.Text = UILocalize.OK; - btnCancel.Text = UILocalize.Cancel; + btnOK.Text = UIStyles.Localize.OK; + btnCancel.Text = UIStyles.Localize.Cancel; } /// diff --git a/SunnyUI/Forms/UIMessageForm2.cs b/SunnyUI/Forms/UIMessageForm2.cs index 0f613096..e78ccaa9 100644 --- a/SunnyUI/Forms/UIMessageForm2.cs +++ b/SunnyUI/Forms/UIMessageForm2.cs @@ -33,8 +33,8 @@ namespace Sunny.UI InitializeComponent(); Text = title; Message = message; - btnOK.Text = UILocalize.OK; - btnCancel.Text = UILocalize.Cancel; + btnOK.Text = UIStyles.Localize.OK; + btnCancel.Text = UIStyles.Localize.Cancel; foreColor = Color.Black; diff --git a/SunnyUI/Forms/UINotifier.cs b/SunnyUI/Forms/UINotifier.cs index 7963f6f4..341b7c18 100644 --- a/SunnyUI/Forms/UINotifier.cs +++ b/SunnyUI/Forms/UINotifier.cs @@ -223,7 +223,7 @@ namespace Sunny.UI Size.Height + 50); ok_button.Size = new Size(120, 40); ok_button.Location = new Point(noteContent.Right - ok_button.Width, Size.Height - 55); - ok_button.Text = UILocalize.OK; + ok_button.Text = UIStyles.Localize.OK; ok_button.Click += onOkButtonClick; Controls.Add(ok_button); @@ -706,7 +706,7 @@ namespace Sunny.UI private void UINotifier_Shown(object sender, EventArgs e) { - closeAllToolStripMenuItem.Text = UILocalize.CloseAll; + closeAllToolStripMenuItem.Text = UIStyles.Localize.CloseAll; } private void noteContent_Click(object sender, EventArgs e) diff --git a/SunnyUI/Forms/UIStatusForm.cs b/SunnyUI/Forms/UIStatusForm.cs index 497b6e2d..3d8979e4 100644 --- a/SunnyUI/Forms/UIStatusForm.cs +++ b/SunnyUI/Forms/UIStatusForm.cs @@ -28,15 +28,15 @@ namespace Sunny.UI public UIStatusForm() { InitializeComponent(); - Text = UILocalize.InfoTitle; - Description = UILocalize.SystemProcessing; + Text = UIStyles.Localize.InfoTitle; + Description = UIStyles.Localize.SystemProcessing; timer1.Start(); } public UIStatusForm(int max, string desc, int decimalPlaces = 1) { InitializeComponent(); - Text = UILocalize.InfoTitle; + Text = UIStyles.Localize.InfoTitle; Maximum = max; Description = desc; Value = 0; diff --git a/SunnyUI/Forms/UIWaitForm.cs b/SunnyUI/Forms/UIWaitForm.cs index 5db8e790..3372d0f8 100644 --- a/SunnyUI/Forms/UIWaitForm.cs +++ b/SunnyUI/Forms/UIWaitForm.cs @@ -26,14 +26,14 @@ namespace Sunny.UI public UIWaitForm() { InitializeComponent(); - base.Text = UILocalize.InfoTitle; - SetDescription(UILocalize.SystemProcessing); + base.Text = UIStyles.Localize.InfoTitle; + SetDescription(UIStyles.Localize.SystemProcessing); } public UIWaitForm(string desc) { InitializeComponent(); - base.Text = UILocalize.InfoTitle; + base.Text = UIStyles.Localize.InfoTitle; SetDescription(desc); } diff --git a/SunnyUI/Frames/UIPage.cs b/SunnyUI/Frames/UIPage.cs index fb8b4d09..7067d360 100644 --- a/SunnyUI/Frames/UIPage.cs +++ b/SunnyUI/Frames/UIPage.cs @@ -55,7 +55,7 @@ using System.Windows.Forms; namespace Sunny.UI { [DefaultEvent("Initialize")] - public partial class UIPage : Form, IStyleInterface, ISymbol, IZoomScale + public partial class UIPage : Form, IStyleInterface, ISymbol, IZoomScale, ITranslate { public UIPage() { @@ -1122,6 +1122,11 @@ namespace Sunny.UI ReceiveParams?.Invoke(this, e); } + public virtual void Translate() + { + + } + public event OnReceiveParams ReceiveParams; } } \ No newline at end of file diff --git a/SunnyUI/Style/UIStyles.cs b/SunnyUI/Style/UIStyles.cs index ebce0e01..c62b9083 100644 --- a/SunnyUI/Style/UIStyles.cs +++ b/SunnyUI/Style/UIStyles.cs @@ -30,6 +30,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; +using System.Globalization; using System.Runtime.InteropServices; using System.Windows.Forms; using static System.Drawing.FontConverter; @@ -236,6 +237,11 @@ namespace Sunny.UI MenuColors.TryAdd(UIMenuStyle.Custom, new UIMenuCustomColor()); MenuColors.TryAdd(UIMenuStyle.Black, new UIMenuBlackColor()); MenuColors.TryAdd(UIMenuStyle.White, new UIMenuWhiteColor()); + + UILocalize lch = new UILocalize_ZH_CN(); + UILocalize len = new UILocalize_EN_US(); + Localizes.TryAdd(lch.CultureInfo.LCID, lch); + Localizes.TryAdd(len.CultureInfo.LCID, len); } /// @@ -389,5 +395,31 @@ namespace Sunny.UI form.Translate(); } } + + private static CultureInfo _CultureInfo = CultureInfos.SimplifiedChinese; + public static CultureInfo CultureInfo + { + get => _CultureInfo; + set + { + if (value.LCID != _CultureInfo.LCID) + { + if (Localizes.TryGetValue(value.LCID, out var cultureInfo)) + { + _CultureInfo = cultureInfo.CultureInfo; + } + else + { + _CultureInfo = CultureInfos.SimplifiedChinese; + } + + UIStyles.Translate(); + } + } + } + + public static ConcurrentDictionary Localizes = new(); + public static UILocalize Localize => Localizes[CultureInfo.LCID]; + public static int LCID => Localize.CultureInfo.LCID; } } diff --git a/SunnyUI/Common/UTranslate.cs b/SunnyUI/Style/UTranslate.cs similarity index 100% rename from SunnyUI/Common/UTranslate.cs rename to SunnyUI/Style/UTranslate.cs