* 重构多语翻译类

This commit is contained in:
Sunny 2024-09-10 23:31:49 +08:00
parent 6543a103a4
commit fd053e6553
22 changed files with 315 additions and 283 deletions

View File

@ -62,7 +62,7 @@ namespace Sunny.UI
/// <returns>打开是否成功</returns> /// <returns>打开是否成功</returns>
public static bool OpenDialog(ref string filename, string filter = "", string defaultExt = "") 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 try
{ {
@ -89,7 +89,7 @@ namespace Sunny.UI
/// <returns>保存是否成功</returns> /// <returns>保存是否成功</returns>
public static bool SaveDialog(ref string filename, string filter = "", string defaultExt = "") 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 try
{ {
od.FileName = filename; od.FileName = filename;

View File

@ -20,341 +20,336 @@
* 2021-07-24: V3.0.5 * 2021-07-24: V3.0.5
******************************************************************************/ ******************************************************************************/
using System.Globalization;
namespace Sunny.UI 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 汉语 - 香港
/// <summary>
/// 2052 简体中文
/// </summary>
public const int LCID_ZH_CN = 2052;
/// <summary>
/// 1028 繁体中文
/// </summary>
public const int LCID_ZH_TW = 1028;
/// <summary>
/// 1033 英语
/// </summary>
public const int LCID_EN_US = 1033;
/// <summary>
/// 2052 简体中文
/// </summary>
public static CultureInfo SimplifiedChinese = CultureInfo.GetCultureInfo(LCID_ZH_CN);
/// <summary>
/// 1028 繁体中文
/// </summary>
public static CultureInfo TraditionalChinese = CultureInfo.GetCultureInfo(LCID_ZH_TW);
/// <summary>
/// 1033 英语
/// </summary>
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";
}
/// <summary> /// <summary>
/// 多语言字符串定义 /// 多语言字符串定义
/// </summary> /// </summary>
public static class UILocalize public abstract class UILocalize
{ {
public abstract CultureInfo CultureInfo { get; }
/// <summary> /// <summary>
/// 提示 /// 提示
/// </summary> /// </summary>
public static string InfoTitle = "提示"; public virtual string InfoTitle { get; set; } = "提示";
/// <summary> /// <summary>
/// 正确 /// 正确
/// </summary> /// </summary>
public static string SuccessTitle = "正确"; public virtual string SuccessTitle { get; set; } = "正确";
/// <summary> /// <summary>
/// 警告 /// 警告
/// </summary> /// </summary>
public static string WarningTitle = "警告"; public virtual string WarningTitle { get; set; } = "警告";
/// <summary> /// <summary>
/// 错误 /// 错误
/// </summary> /// </summary>
public static string ErrorTitle = "错误"; public virtual string ErrorTitle { get; set; } = "错误";
/// <summary> /// <summary>
/// 提示 /// 提示
/// </summary> /// </summary>
public static string AskTitle = "提示"; public virtual string AskTitle { get; set; } = "提示";
/// <summary> /// <summary>
/// 输入 /// 输入
/// </summary> /// </summary>
public static string InputTitle = "输入"; public virtual string InputTitle { get; set; } = "输入";
/// <summary> /// <summary>
/// 选择 /// 选择
/// </summary> /// </summary>
public static string SelectTitle = "选择"; public virtual string SelectTitle { get; set; } = "选择";
/// <summary> /// <summary>
/// 全部关闭 /// 全部关闭
/// </summary> /// </summary>
public static string CloseAll = "全部关闭"; public virtual string CloseAll { get; set; } = "全部关闭";
/// <summary> /// <summary>
/// 确定 /// 确定
/// </summary> /// </summary>
public static string OK = "确定"; public virtual string OK { get; set; } = "确定";
/// <summary> /// <summary>
/// 取消 /// 取消
/// </summary> /// </summary>
public static string Cancel = "取消"; public virtual string Cancel { get; set; } = "取消";
/// <summary> /// <summary>
/// [ 无数据 ] /// [ 无数据 ]
/// </summary> /// </summary>
public static string GridNoData = "[ 无数据 ]"; public virtual string GridNoData { get; set; } = "[ 无数据 ]";
/// <summary> /// <summary>
/// 数据加载中,请稍候... /// 数据加载中,请稍候...
/// </summary> /// </summary>
public static string GridDataLoading = "数据加载中,请稍候..."; public virtual string GridDataLoading { get; set; } = "数据加载中,请稍候...";
/// <summary> /// <summary>
/// 数据源必须为DataTable或者List /// 数据源必须为DataTable或者List
/// </summary> /// </summary>
public static string GridDataSourceException = "数据源必须为DataTable或者List"; public virtual string GridDataSourceException { get; set; } = "数据源必须为DataTable或者List";
/// <summary> /// <summary>
/// "系统正在处理中,请稍候..." /// "系统正在处理中,请稍候..."
/// </summary> /// </summary>
public static string SystemProcessing = "系统正在处理中,请稍候..."; public virtual string SystemProcessing { get; set; } = "系统正在处理中,请稍候...";
/// <summary> /// <summary>
/// 星期一 /// 星期一
/// </summary> /// </summary>
public static string Monday = "一"; public virtual string Monday { get; set; } = "一";
/// <summary> /// <summary>
/// 星期二 /// 星期二
/// </summary> /// </summary>
public static string Tuesday = "二"; public virtual string Tuesday { get; set; } = "二";
/// <summary> /// <summary>
/// 星期三 /// 星期三
/// </summary> /// </summary>
public static string Wednesday = "三"; public virtual string Wednesday { get; set; } = "三";
/// <summary> /// <summary>
/// 星期四 /// 星期四
/// </summary> /// </summary>
public static string Thursday = "四"; public virtual string Thursday { get; set; } = "四";
/// <summary> /// <summary>
/// 星期五 /// 星期五
/// </summary> /// </summary>
public static string Friday = "五"; public virtual string Friday { get; set; } = "五";
/// <summary> /// <summary>
/// 星期六 /// 星期六
/// </summary> /// </summary>
public static string Saturday = "六"; public virtual string Saturday { get; set; } = "六";
/// <summary> /// <summary>
/// 星期日 /// 星期日
/// </summary> /// </summary>
public static string Sunday = "日"; public virtual string Sunday { get; set; } = "日";
/// <summary> /// <summary>
/// 上一页 /// 上一页
/// </summary> /// </summary>
public static string Prev = "上一页"; public virtual string Prev { get; set; } = "上一页";
/// <summary> /// <summary>
/// 下一页 /// 下一页
/// </summary> /// </summary>
public static string Next = "下一页"; public virtual string Next { get; set; } = "下一页";
/// <summary> /// <summary>
/// 第 /// 第
/// </summary> /// </summary>
public static string SelectPageLeft = "第"; public virtual string SelectPageLeft { get; set; } = "第";
/// <summary> /// <summary>
/// 页 /// 页
/// </summary> /// </summary>
public static string SelectPageRight = "页"; public virtual string SelectPageRight { get; set; } = "页";
/// <summary> /// <summary>
/// 一月 /// 一月
/// </summary> /// </summary>
public static string January = "一月"; public virtual string January { get; set; } = "一月";
/// <summary> /// <summary>
/// 二月 /// 二月
/// </summary> /// </summary>
public static string February = "二月"; public virtual string February { get; set; } = "二月";
/// <summary> /// <summary>
/// 三月 /// 三月
/// </summary> /// </summary>
public static string March = "三月"; public virtual string March { get; set; } = "三月";
/// <summary> /// <summary>
/// 四月 /// 四月
/// </summary> /// </summary>
public static string April = "四月"; public virtual string April { get; set; } = "四月";
/// <summary> /// <summary>
/// 五月 /// 五月
/// </summary> /// </summary>
public static string May = "五月"; public virtual string May { get; set; } = "五月";
/// <summary> /// <summary>
/// 六月 /// 六月
/// </summary> /// </summary>
public static string June = "六月"; public virtual string June { get; set; } = "六月";
/// <summary> /// <summary>
/// 七月 /// 七月
/// </summary> /// </summary>
public static string July = "七月"; public virtual string July { get; set; } = "七月";
/// <summary> /// <summary>
/// 八月 /// 八月
/// </summary> /// </summary>
public static string August = "八月"; public virtual string August { get; set; } = "八月";
/// <summary> /// <summary>
/// 九月 /// 九月
/// </summary> /// </summary>
public static string September = "九月"; public virtual string September { get; set; } = "九月";
/// <summary> /// <summary>
/// 十月 /// 十月
/// </summary> /// </summary>
public static string October = "十月"; public virtual string October { get; set; } = "十月";
/// <summary> /// <summary>
/// 十一月 /// 十一月
/// </summary> /// </summary>
public static string November = "十一月"; public virtual string November { get; set; } = "十一月";
/// <summary> /// <summary>
/// 十二月 /// 十二月
/// </summary> /// </summary>
public static string December = "十二月"; public virtual string December { get; set; } = "十二月";
/// <summary> /// <summary>
/// 今天 /// 今天
/// </summary> /// </summary>
public static string Today = "今天"; public virtual string Today { get; set; } = "今天";
/// <summary> /// <summary>
/// 搜索 /// 搜索
/// </summary> /// </summary>
public static string Search = "搜索"; public virtual string Search { get; set; } = "搜索";
/// <summary> /// <summary>
/// 清除 /// 清除
/// </summary> /// </summary>
public static string Clear = "清除"; public virtual string Clear { get; set; } = "清除";
public static string Open = "打开"; public virtual string Open { get; set; } = "打开";
public static string Save = "保存"; public virtual string Save { get; set; } = "保存";
public static string All = "全部"; public virtual string All { get; set; } = "全部";
}
/// <summary>
/// 多语言字符串帮助类
/// </summary>
public static class UILocalizeHelper
{
/// <summary>
/// 设置为英文
/// </summary>
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();
}
/// <summary>
/// 设置为中文
/// </summary>
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();
}
} }
} }

View File

@ -27,8 +27,8 @@ namespace Sunny.UI
public void Translate() public void Translate()
{ {
btnOK.Text = UILocalize.OK; btnOK.Text = UIStyles.Localize.OK;
btnCancel.Text = UILocalize.Cancel; btnCancel.Text = UIStyles.Localize.Cancel;
} }
private LabelRotate m_colorSample; private LabelRotate m_colorSample;

View File

@ -84,10 +84,10 @@ namespace Sunny.UI
public void Translate() public void Translate()
{ {
btnOK.Text = UILocalize.OK; btnOK.Text = UIStyles.Localize.OK;
btnCancel.Text = UILocalize.Cancel; btnCancel.Text = UIStyles.Localize.Cancel;
btnClear.Text = UILocalize.Clear; btnClear.Text = UIStyles.Localize.Clear;
btnSearch.Text = UILocalize.Search; btnSearch.Text = UIStyles.Localize.Search;
} }
public bool ShowButtons public bool ShowButtons

View File

@ -52,9 +52,9 @@ namespace Sunny.UI
public void Translate() public void Translate()
{ {
btnOK.Text = UILocalize.OK; btnOK.Text = UIStyles.Localize.OK;
btnCancel.Text = UILocalize.Cancel; btnCancel.Text = UIStyles.Localize.Cancel;
uiCheckBox1.Text = UILocalize.All; uiCheckBox1.Text = UIStyles.Localize.All;
} }
private void InitializeComponent() private void InitializeComponent()

View File

@ -382,18 +382,18 @@ namespace Sunny.UI
public void Translate() public void Translate()
{ {
months.Clear(); months.Clear();
months.Add(UILocalize.January); months.Add(UIStyles.Localize.January);
months.Add(UILocalize.February); months.Add(UIStyles.Localize.February);
months.Add(UILocalize.March); months.Add(UIStyles.Localize.March);
months.Add(UILocalize.April); months.Add(UIStyles.Localize.April);
months.Add(UILocalize.May); months.Add(UIStyles.Localize.May);
months.Add(UILocalize.June); months.Add(UIStyles.Localize.June);
months.Add(UILocalize.July); months.Add(UIStyles.Localize.July);
months.Add(UILocalize.August); months.Add(UIStyles.Localize.August);
months.Add(UILocalize.September); months.Add(UIStyles.Localize.September);
months.Add(UILocalize.October); months.Add(UIStyles.Localize.October);
months.Add(UILocalize.November); months.Add(UIStyles.Localize.November);
months.Add(UILocalize.December); months.Add(UIStyles.Localize.December);
} }
private void TopPanel_Click(object sender, EventArgs e) private void TopPanel_Click(object sender, EventArgs e)
@ -788,7 +788,7 @@ namespace Sunny.UI
int width = p3.Width / 7; int width = p3.Width / 7;
int height = (p3.Height - 30 * SizeMultiple) / 6; int height = (p3.Height - 30 * SizeMultiple) / 6;
using Font font = SizeMultiple == 1 ? this.Font : new Font(this.Font.FontFamily, this.Font.Size * 1.5f); 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++) 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); 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); 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.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); 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(UILocalize.Today, SubFont); 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)); e.Graphics.DrawRectangle(b3.SymbolColor, new Rectangle(p3.Width - width * 4 + 1, p3.Height - height + 1, (int)sf.Width - 2, height - 4));
} }
} }

View File

@ -780,21 +780,21 @@ namespace Sunny.UI
public void Translate() public void Translate()
{ {
months.Clear(); months.Clear();
months.Add(UILocalize.January); months.Add(UIStyles.Localize.January);
months.Add(UILocalize.February); months.Add(UIStyles.Localize.February);
months.Add(UILocalize.March); months.Add(UIStyles.Localize.March);
months.Add(UILocalize.April); months.Add(UIStyles.Localize.April);
months.Add(UILocalize.May); months.Add(UIStyles.Localize.May);
months.Add(UILocalize.June); months.Add(UIStyles.Localize.June);
months.Add(UILocalize.July); months.Add(UIStyles.Localize.July);
months.Add(UILocalize.August); months.Add(UIStyles.Localize.August);
months.Add(UILocalize.September); months.Add(UIStyles.Localize.September);
months.Add(UILocalize.October); months.Add(UIStyles.Localize.October);
months.Add(UILocalize.November); months.Add(UIStyles.Localize.November);
months.Add(UILocalize.December); months.Add(UIStyles.Localize.December);
btnOK.Text = UILocalize.OK; btnOK.Text = UIStyles.Localize.OK;
btnCancel.Text = UILocalize.Cancel; btnCancel.Text = UIStyles.Localize.Cancel;
} }
private int activeDay = -1; private int activeDay = -1;
@ -1267,7 +1267,7 @@ namespace Sunny.UI
int width = p3.Width / 7; int width = p3.Width / 7;
int height = (p3.Height - 30 * SizeMultiple) / 6; int height = (p3.Height - 30 * SizeMultiple) / 6;
using Font font = SizeMultiple == 1 ? this.Font : new Font(this.Font.FontFamily, this.Font.Size * 1.5f); 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++) 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); 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); 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.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); 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(UILocalize.Today, SubFont); 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)); e.Graphics.DrawRectangle(b3.SymbolColor, new Rectangle(p3.Width - width * 4 + 1, p3.Height - height + 1, (int)sf.Width - 2, height - 4));
} }
} }

View File

@ -403,8 +403,8 @@ namespace Sunny.UI
public void Translate() public void Translate()
{ {
btnOK.Text = UILocalize.OK; btnOK.Text = UIStyles.Localize.OK;
btnCancel.Text = UILocalize.Cancel; btnCancel.Text = UIStyles.Localize.Cancel;
} }
public override void SetDPIScale() public override void SetDPIScale()

View File

@ -313,18 +313,18 @@ namespace Sunny.UI
public void Translate() public void Translate()
{ {
months.Clear(); months.Clear();
months.Add(UILocalize.January); months.Add(UIStyles.Localize.January);
months.Add(UILocalize.February); months.Add(UIStyles.Localize.February);
months.Add(UILocalize.March); months.Add(UIStyles.Localize.March);
months.Add(UILocalize.April); months.Add(UIStyles.Localize.April);
months.Add(UILocalize.May); months.Add(UIStyles.Localize.May);
months.Add(UILocalize.June); months.Add(UIStyles.Localize.June);
months.Add(UILocalize.July); months.Add(UIStyles.Localize.July);
months.Add(UILocalize.August); months.Add(UIStyles.Localize.August);
months.Add(UILocalize.September); months.Add(UIStyles.Localize.September);
months.Add(UILocalize.October); months.Add(UIStyles.Localize.October);
months.Add(UILocalize.November); months.Add(UIStyles.Localize.November);
months.Add(UILocalize.December); months.Add(UIStyles.Localize.December);
} }
private void TopPanel_Click(object sender, EventArgs e) private void TopPanel_Click(object sender, EventArgs e)
@ -677,7 +677,7 @@ namespace Sunny.UI
{ {
int width = p3.Width / 7; int width = p3.Width / 7;
int height = (p3.Height - 30) / 6; 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++) for (int i = 0; i < weeks.Length; i++)
{ {
e.Graphics.DrawString(weeks[i], Font, ForeColor, new Rectangle(width * i, 4, width, 19), ContentAlignment.MiddleCenter); e.Graphics.DrawString(weeks[i], Font, ForeColor, new Rectangle(width * i, 4, width, 19), ContentAlignment.MiddleCenter);

View File

@ -259,7 +259,7 @@ namespace Sunny.UI
{ {
if (!(value is DataTable || value is IList)) if (!(value is DataTable || value is IList))
{ {
throw new Exception(UILocalize.GridDataSourceException); throw new Exception(UIStyles.Localize.GridDataSourceException);
} }
} }

View File

@ -170,9 +170,9 @@ namespace Sunny.UI
try try
{ {
b0.Text = UILocalize.Prev; b0.Text = UIStyles.Localize.Prev;
b16.Text = UILocalize.Next; b16.Text = UIStyles.Localize.Next;
btnSelect.Text = UILocalize.SelectTitle; btnSelect.Text = UIStyles.Localize.SelectTitle;
Size sf = TextRenderer.MeasureText(b0.Text, b0.Font); Size sf = TextRenderer.MeasureText(b0.Text, b0.Font);
b0.Width = b0.SymbolSize + sf.Width + 10; b0.Width = b0.SymbolSize + sf.Width + 10;
@ -182,8 +182,8 @@ namespace Sunny.UI
btnSelect.Width = TextRenderer.MeasureText(btnSelect.Text, btnSelect.Font).Width + 16; btnSelect.Width = TextRenderer.MeasureText(btnSelect.Text, btnSelect.Font).Width + 16;
uiLabel1.Text = UILocalize.SelectPageLeft; uiLabel1.Text = UIStyles.Localize.SelectPageLeft;
uiLabel2.Text = UILocalize.SelectPageRight; uiLabel2.Text = UIStyles.Localize.SelectPageRight;
edtPage.Left = uiLabel1.Right + 3; edtPage.Left = uiLabel1.Right + 3;
uiLabel2.Left = edtPage.Right + 3; uiLabel2.Left = edtPage.Right + 3;
btnSelect.Left = uiLabel2.Right + 3; btnSelect.Left = uiLabel2.Right + 3;
@ -309,7 +309,7 @@ namespace Sunny.UI
{ {
if (!(value is DataTable || value is IList)) if (!(value is DataTable || value is IList))
{ {
throw new Exception(UILocalize.GridDataSourceException); throw new Exception(UIStyles.Localize.GridDataSourceException);
} }
} }

View File

@ -696,7 +696,7 @@ namespace Sunny.UI
} }
} }
public void Translate() public virtual void Translate()
{ {
List<Control> controls = this.GetInterfaceControls("ITranslate"); List<Control> controls = this.GetInterfaceControls("ITranslate");
foreach (var control in controls) foreach (var control in controls)

View File

@ -43,8 +43,8 @@ namespace Sunny.UI
{ {
InitializeComponent(); InitializeComponent();
btnOK.Text = UILocalize.OK; btnOK.Text = UIStyles.Localize.OK;
btnCancel.Text = UILocalize.Cancel; btnCancel.Text = UIStyles.Localize.Cancel;
base.TopMost = true; base.TopMost = true;
} }
@ -331,8 +331,8 @@ namespace Sunny.UI
{ {
InitializeComponent(); InitializeComponent();
btnOK.Text = UILocalize.OK; btnOK.Text = UIStyles.Localize.OK;
btnCancel.Text = UILocalize.Cancel; btnCancel.Text = UIStyles.Localize.Cancel;
base.TopMost = true; base.TopMost = true;
Option = option; Option = option;

View File

@ -92,32 +92,32 @@ namespace Sunny.UI
{ {
public static void Show(string message, bool showMask = false, int delay = 0) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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, 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) private static UIInputForm CreateInputForm(bool checkEmpty, string desc)
{ {
UIInputForm frm = new UIInputForm(); UIInputForm frm = new UIInputForm();
frm.Text = UILocalize.InputTitle; frm.Text = UIStyles.Localize.InputTitle;
frm.Label.Text = desc; frm.Label.Text = desc;
frm.CheckInputEmpty = checkEmpty; frm.CheckInputEmpty = checkEmpty;
return frm; 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) 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) public static bool ShowSelectDialog(this Form owner, ref int selectIndex, IList items, bool showMask = false)
@ -646,7 +646,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param> /// <param name="showMask">显示遮罩层</param>
public static void ShowSuccessDialog(this Form owner, string message, bool showMask = false, int delay = 0) 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);
} }
/// <summary> /// <summary>
@ -668,7 +668,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param> /// <param name="showMask">显示遮罩层</param>
public static void ShowInfoDialog(this Form owner, string message, bool showMask = false, int delay = 0) 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);
} }
/// <summary> /// <summary>
@ -690,7 +690,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param> /// <param name="showMask">显示遮罩层</param>
public static void ShowWarningDialog(this Form owner, string message, bool showMask = false, int delay = 0) 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);
} }
/// <summary> /// <summary>
@ -712,7 +712,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param> /// <param name="showMask">显示遮罩层</param>
public static void ShowErrorDialog(this Form owner, string message, bool showMask = false, int delay = 0) 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);
} }
/// <summary> /// <summary>
@ -735,7 +735,7 @@ namespace Sunny.UI
/// <returns>结果</returns> /// <returns>结果</returns>
public static bool ShowAskDialog(this Form owner, string message, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Ok) 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);
} }
/// <summary> /// <summary>
@ -760,7 +760,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param> /// <param name="showMask">显示遮罩层</param>
public static void ShowSuccessDialog2(this Form owner, string message, bool showMask = false, int delay = 0) 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);
} }
/// <summary> /// <summary>
@ -782,7 +782,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param> /// <param name="showMask">显示遮罩层</param>
public static void ShowInfoDialog2(this Form owner, string message, bool showMask = false, int delay = 0) 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);
} }
/// <summary> /// <summary>
@ -804,7 +804,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param> /// <param name="showMask">显示遮罩层</param>
public static void ShowWarningDialog2(this Form owner, string message, bool showMask = false, int delay = 0) 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);
} }
/// <summary> /// <summary>
@ -826,7 +826,7 @@ namespace Sunny.UI
/// <param name="showMask">显示遮罩层</param> /// <param name="showMask">显示遮罩层</param>
public static void ShowErrorDialog2(this Form owner, string message, bool showMask = false, int delay = 0) 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);
} }
/// <summary> /// <summary>
@ -849,7 +849,7 @@ namespace Sunny.UI
/// <returns>结果</returns> /// <returns>结果</returns>
public static bool ShowAskDialog2(this Form owner, string message, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Cancel) 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);
} }
/// <summary> /// <summary>
@ -944,42 +944,42 @@ namespace Sunny.UI
public static void ShowInfoNotifier(this Form form, string desc, bool isDialog = false, int timeout = 2000) 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) 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) 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) 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) 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) 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) 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) 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 #endregion

View File

@ -36,8 +36,8 @@ namespace Sunny.UI
{ {
InitializeComponent(); InitializeComponent();
btnOK.Text = UILocalize.OK; btnOK.Text = UIStyles.Localize.OK;
btnCancel.Text = UILocalize.Cancel; btnCancel.Text = UIStyles.Localize.Cancel;
} }
/// <summary> /// <summary>

View File

@ -33,8 +33,8 @@ namespace Sunny.UI
InitializeComponent(); InitializeComponent();
Text = title; Text = title;
Message = message; Message = message;
btnOK.Text = UILocalize.OK; btnOK.Text = UIStyles.Localize.OK;
btnCancel.Text = UILocalize.Cancel; btnCancel.Text = UIStyles.Localize.Cancel;
foreColor = Color.Black; foreColor = Color.Black;

View File

@ -223,7 +223,7 @@ namespace Sunny.UI
Size.Height + 50); Size.Height + 50);
ok_button.Size = new Size(120, 40); ok_button.Size = new Size(120, 40);
ok_button.Location = new Point(noteContent.Right - ok_button.Width, Size.Height - 55); 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; ok_button.Click += onOkButtonClick;
Controls.Add(ok_button); Controls.Add(ok_button);
@ -706,7 +706,7 @@ namespace Sunny.UI
private void UINotifier_Shown(object sender, EventArgs e) 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) private void noteContent_Click(object sender, EventArgs e)

View File

@ -28,15 +28,15 @@ namespace Sunny.UI
public UIStatusForm() public UIStatusForm()
{ {
InitializeComponent(); InitializeComponent();
Text = UILocalize.InfoTitle; Text = UIStyles.Localize.InfoTitle;
Description = UILocalize.SystemProcessing; Description = UIStyles.Localize.SystemProcessing;
timer1.Start(); timer1.Start();
} }
public UIStatusForm(int max, string desc, int decimalPlaces = 1) public UIStatusForm(int max, string desc, int decimalPlaces = 1)
{ {
InitializeComponent(); InitializeComponent();
Text = UILocalize.InfoTitle; Text = UIStyles.Localize.InfoTitle;
Maximum = max; Maximum = max;
Description = desc; Description = desc;
Value = 0; Value = 0;

View File

@ -26,14 +26,14 @@ namespace Sunny.UI
public UIWaitForm() public UIWaitForm()
{ {
InitializeComponent(); InitializeComponent();
base.Text = UILocalize.InfoTitle; base.Text = UIStyles.Localize.InfoTitle;
SetDescription(UILocalize.SystemProcessing); SetDescription(UIStyles.Localize.SystemProcessing);
} }
public UIWaitForm(string desc) public UIWaitForm(string desc)
{ {
InitializeComponent(); InitializeComponent();
base.Text = UILocalize.InfoTitle; base.Text = UIStyles.Localize.InfoTitle;
SetDescription(desc); SetDescription(desc);
} }

View File

@ -55,7 +55,7 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
[DefaultEvent("Initialize")] [DefaultEvent("Initialize")]
public partial class UIPage : Form, IStyleInterface, ISymbol, IZoomScale public partial class UIPage : Form, IStyleInterface, ISymbol, IZoomScale, ITranslate
{ {
public UIPage() public UIPage()
{ {
@ -1122,6 +1122,11 @@ namespace Sunny.UI
ReceiveParams?.Invoke(this, e); ReceiveParams?.Invoke(this, e);
} }
public virtual void Translate()
{
}
public event OnReceiveParams ReceiveParams; public event OnReceiveParams ReceiveParams;
} }
} }

View File

@ -30,6 +30,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Globalization;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using static System.Drawing.FontConverter; using static System.Drawing.FontConverter;
@ -236,6 +237,11 @@ namespace Sunny.UI
MenuColors.TryAdd(UIMenuStyle.Custom, new UIMenuCustomColor()); MenuColors.TryAdd(UIMenuStyle.Custom, new UIMenuCustomColor());
MenuColors.TryAdd(UIMenuStyle.Black, new UIMenuBlackColor()); MenuColors.TryAdd(UIMenuStyle.Black, new UIMenuBlackColor());
MenuColors.TryAdd(UIMenuStyle.White, new UIMenuWhiteColor()); 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);
} }
/// <summary> /// <summary>
@ -389,5 +395,31 @@ namespace Sunny.UI
form.Translate(); 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<int, UILocalize> Localizes = new();
public static UILocalize Localize => Localizes[CultureInfo.LCID];
public static int LCID => Localize.CultureInfo.LCID;
} }
} }