* 重构多语翻译类
This commit is contained in:
parent
fd053e6553
commit
98c7a8f81e
@ -372,14 +372,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
internal static void HideComboDropDown(this Control ctrl)
|
internal static void HideComboDropDown(this Control ctrl)
|
||||||
{
|
{
|
||||||
var ctrls = ctrl?.FindForm()?.GetInterfaceControls("IHideDropDown", true);
|
var ctrls = ctrl?.FindForm()?.GetInterfaceControls<IHideDropDown>(true);
|
||||||
if (ctrls == null) return;
|
if (ctrls == null) return;
|
||||||
foreach (var control in ctrls)
|
foreach (var control in ctrls)
|
||||||
{
|
{
|
||||||
if (control is IHideDropDown item)
|
control.HideDropDown();
|
||||||
{
|
|
||||||
item.HideDropDown();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,21 +387,22 @@ namespace Sunny.UI
|
|||||||
/// <param name="interfaceName">接口名称</param>
|
/// <param name="interfaceName">接口名称</param>
|
||||||
/// <param name="includeChild"></param>
|
/// <param name="includeChild"></param>
|
||||||
/// <returns>控件列表</returns>
|
/// <returns>控件列表</returns>
|
||||||
public static List<Control> GetInterfaceControls(this Control ctrl, string interfaceName, bool includeChild = false)
|
public static List<T> GetInterfaceControls<T>(this Control ctrl, bool includeChild = false, bool includeUIPage = true)
|
||||||
{
|
{
|
||||||
List<Control> values = new List<Control>();
|
List<T> values = new();
|
||||||
if (ctrl.IsNull()) return values;
|
if (ctrl.IsNull()) return values;
|
||||||
|
|
||||||
foreach (Control obj in ctrl.Controls)
|
foreach (Control obj in ctrl.Controls)
|
||||||
{
|
{
|
||||||
if (obj.GetType().GetInterface(interfaceName) != null)
|
if (obj is T it && it != null)
|
||||||
{
|
{
|
||||||
values.Add(obj);
|
values.Add(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeChild && obj.Controls.Count > 0)
|
if (includeChild && obj.Controls.Count > 0)
|
||||||
{
|
{
|
||||||
values.AddRange(obj.GetInterfaceControls(interfaceName, true));
|
if (obj is not UIPage || includeUIPage)
|
||||||
|
values.AddRange(obj.GetInterfaceControls<T>(includeChild, includeUIPage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 = UIStyles.Localize.Open };
|
using OpenFileDialog od = new OpenFileDialog { Title = UIStyles.CurrentResources.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 = UIStyles.Localize.Save };
|
using SaveFileDialog od = new SaveFileDialog { Title = UIStyles.CurrentResources.Save };
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
od.FileName = filename;
|
od.FileName = filename;
|
||||||
|
@ -59,42 +59,42 @@ namespace Sunny.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 2052 简体中文
|
/// 2052 简体中文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int LCID_ZH_CN = 2052;
|
public const int LCID_zh_CN = 2052;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 1028 繁体中文
|
/// 1028 繁体中文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int LCID_ZH_TW = 1028;
|
public const int LCID_zh_TW = 1028;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 1033 英语
|
/// 1033 英语
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int LCID_EN_US = 1033;
|
public const int LCID_en_US = 1033;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 2052 简体中文
|
/// 2052 简体中文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static CultureInfo SimplifiedChinese = CultureInfo.GetCultureInfo(LCID_ZH_CN);
|
public static readonly CultureInfo zh_CN = CultureInfo.GetCultureInfo(LCID_zh_CN);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 1028 繁体中文
|
/// 1028 繁体中文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static CultureInfo TraditionalChinese = CultureInfo.GetCultureInfo(LCID_ZH_TW);
|
public static readonly CultureInfo zh_TW = CultureInfo.GetCultureInfo(LCID_zh_TW);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 1033 英语
|
/// 1033 英语
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static CultureInfo English = CultureInfo.GetCultureInfo(LCID_EN_US);
|
public static readonly CultureInfo en_US = CultureInfo.GetCultureInfo(LCID_en_US);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UILocalize_ZH_CN : UILocalize
|
public class zh_CN_Resources : UIBuiltInResources
|
||||||
{
|
{
|
||||||
public override CultureInfo CultureInfo => CultureInfos.SimplifiedChinese;
|
public override CultureInfo CultureInfo => CultureInfos.zh_CN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UILocalize_EN_US : UILocalize
|
public class en_US_Resources : UIBuiltInResources
|
||||||
{
|
{
|
||||||
public override CultureInfo CultureInfo => CultureInfos.English;
|
public override CultureInfo CultureInfo => CultureInfos.en_US;
|
||||||
public override string InfoTitle { get; set; } = "Info";
|
public override string InfoTitle { get; set; } = "Info";
|
||||||
public override string SuccessTitle { get; set; } = "Success";
|
public override string SuccessTitle { get; set; } = "Success";
|
||||||
public override string WarningTitle { get; set; } = "Warning";
|
public override string WarningTitle { get; set; } = "Warning";
|
||||||
@ -143,7 +143,7 @@ namespace Sunny.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 多语言字符串定义
|
/// 多语言字符串定义
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class UILocalize
|
public abstract class UIBuiltInResources
|
||||||
{
|
{
|
||||||
public abstract CultureInfo CultureInfo { get; }
|
public abstract CultureInfo CultureInfo { get; }
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void Translate()
|
public void Translate()
|
||||||
{
|
{
|
||||||
btnOK.Text = UIStyles.Localize.OK;
|
btnOK.Text = UIStyles.CurrentResources.OK;
|
||||||
btnCancel.Text = UIStyles.Localize.Cancel;
|
btnCancel.Text = UIStyles.CurrentResources.Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LabelRotate m_colorSample;
|
private LabelRotate m_colorSample;
|
||||||
|
@ -84,10 +84,10 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void Translate()
|
public void Translate()
|
||||||
{
|
{
|
||||||
btnOK.Text = UIStyles.Localize.OK;
|
btnOK.Text = UIStyles.CurrentResources.OK;
|
||||||
btnCancel.Text = UIStyles.Localize.Cancel;
|
btnCancel.Text = UIStyles.CurrentResources.Cancel;
|
||||||
btnClear.Text = UIStyles.Localize.Clear;
|
btnClear.Text = UIStyles.CurrentResources.Clear;
|
||||||
btnSearch.Text = UIStyles.Localize.Search;
|
btnSearch.Text = UIStyles.CurrentResources.Search;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShowButtons
|
public bool ShowButtons
|
||||||
|
@ -52,9 +52,9 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void Translate()
|
public void Translate()
|
||||||
{
|
{
|
||||||
btnOK.Text = UIStyles.Localize.OK;
|
btnOK.Text = UIStyles.CurrentResources.OK;
|
||||||
btnCancel.Text = UIStyles.Localize.Cancel;
|
btnCancel.Text = UIStyles.CurrentResources.Cancel;
|
||||||
uiCheckBox1.Text = UIStyles.Localize.All;
|
uiCheckBox1.Text = UIStyles.CurrentResources.All;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
|
@ -382,18 +382,18 @@ namespace Sunny.UI
|
|||||||
public void Translate()
|
public void Translate()
|
||||||
{
|
{
|
||||||
months.Clear();
|
months.Clear();
|
||||||
months.Add(UIStyles.Localize.January);
|
months.Add(UIStyles.CurrentResources.January);
|
||||||
months.Add(UIStyles.Localize.February);
|
months.Add(UIStyles.CurrentResources.February);
|
||||||
months.Add(UIStyles.Localize.March);
|
months.Add(UIStyles.CurrentResources.March);
|
||||||
months.Add(UIStyles.Localize.April);
|
months.Add(UIStyles.CurrentResources.April);
|
||||||
months.Add(UIStyles.Localize.May);
|
months.Add(UIStyles.CurrentResources.May);
|
||||||
months.Add(UIStyles.Localize.June);
|
months.Add(UIStyles.CurrentResources.June);
|
||||||
months.Add(UIStyles.Localize.July);
|
months.Add(UIStyles.CurrentResources.July);
|
||||||
months.Add(UIStyles.Localize.August);
|
months.Add(UIStyles.CurrentResources.August);
|
||||||
months.Add(UIStyles.Localize.September);
|
months.Add(UIStyles.CurrentResources.September);
|
||||||
months.Add(UIStyles.Localize.October);
|
months.Add(UIStyles.CurrentResources.October);
|
||||||
months.Add(UIStyles.Localize.November);
|
months.Add(UIStyles.CurrentResources.November);
|
||||||
months.Add(UIStyles.Localize.December);
|
months.Add(UIStyles.CurrentResources.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 = { UIStyles.Localize.Sunday, UIStyles.Localize.Monday, UIStyles.Localize.Tuesday, UIStyles.Localize.Wednesday, UIStyles.Localize.Thursday, UIStyles.Localize.Friday, UIStyles.Localize.Saturday };
|
string[] weeks = { UIStyles.CurrentResources.Sunday, UIStyles.CurrentResources.Monday, UIStyles.CurrentResources.Tuesday, UIStyles.CurrentResources.Wednesday, UIStyles.CurrentResources.Thursday, UIStyles.CurrentResources.Friday, UIStyles.CurrentResources.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(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);
|
e.Graphics.DrawString(UIStyles.CurrentResources.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);
|
SizeF sf = TextRenderer.MeasureText(UIStyles.CurrentResources.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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -780,21 +780,21 @@ namespace Sunny.UI
|
|||||||
public void Translate()
|
public void Translate()
|
||||||
{
|
{
|
||||||
months.Clear();
|
months.Clear();
|
||||||
months.Add(UIStyles.Localize.January);
|
months.Add(UIStyles.CurrentResources.January);
|
||||||
months.Add(UIStyles.Localize.February);
|
months.Add(UIStyles.CurrentResources.February);
|
||||||
months.Add(UIStyles.Localize.March);
|
months.Add(UIStyles.CurrentResources.March);
|
||||||
months.Add(UIStyles.Localize.April);
|
months.Add(UIStyles.CurrentResources.April);
|
||||||
months.Add(UIStyles.Localize.May);
|
months.Add(UIStyles.CurrentResources.May);
|
||||||
months.Add(UIStyles.Localize.June);
|
months.Add(UIStyles.CurrentResources.June);
|
||||||
months.Add(UIStyles.Localize.July);
|
months.Add(UIStyles.CurrentResources.July);
|
||||||
months.Add(UIStyles.Localize.August);
|
months.Add(UIStyles.CurrentResources.August);
|
||||||
months.Add(UIStyles.Localize.September);
|
months.Add(UIStyles.CurrentResources.September);
|
||||||
months.Add(UIStyles.Localize.October);
|
months.Add(UIStyles.CurrentResources.October);
|
||||||
months.Add(UIStyles.Localize.November);
|
months.Add(UIStyles.CurrentResources.November);
|
||||||
months.Add(UIStyles.Localize.December);
|
months.Add(UIStyles.CurrentResources.December);
|
||||||
|
|
||||||
btnOK.Text = UIStyles.Localize.OK;
|
btnOK.Text = UIStyles.CurrentResources.OK;
|
||||||
btnCancel.Text = UIStyles.Localize.Cancel;
|
btnCancel.Text = UIStyles.CurrentResources.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 = { UIStyles.Localize.Sunday, UIStyles.Localize.Monday, UIStyles.Localize.Tuesday, UIStyles.Localize.Wednesday, UIStyles.Localize.Thursday, UIStyles.Localize.Friday, UIStyles.Localize.Saturday };
|
string[] weeks = { UIStyles.CurrentResources.Sunday, UIStyles.CurrentResources.Monday, UIStyles.CurrentResources.Tuesday, UIStyles.CurrentResources.Wednesday, UIStyles.CurrentResources.Thursday, UIStyles.CurrentResources.Friday, UIStyles.CurrentResources.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(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);
|
e.Graphics.DrawString(UIStyles.CurrentResources.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);
|
SizeF sf = TextRenderer.MeasureText(UIStyles.CurrentResources.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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,8 +403,8 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public void Translate()
|
public void Translate()
|
||||||
{
|
{
|
||||||
btnOK.Text = UIStyles.Localize.OK;
|
btnOK.Text = UIStyles.CurrentResources.OK;
|
||||||
btnCancel.Text = UIStyles.Localize.Cancel;
|
btnCancel.Text = UIStyles.CurrentResources.Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetDPIScale()
|
public override void SetDPIScale()
|
||||||
|
@ -83,6 +83,9 @@ namespace Sunny.UI
|
|||||||
UseMnemonic = true;
|
UseMnemonic = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
public override string[] FormTranslatorProperties => ["Text"];
|
||||||
|
|
||||||
[DefaultValue(true)]
|
[DefaultValue(true)]
|
||||||
[Description("如果为true,&符号后面的第一次字符将做按钮的助记键"), Category("SunnyUI")]
|
[Description("如果为true,&符号后面的第一次字符将做按钮的助记键"), Category("SunnyUI")]
|
||||||
public bool UseMnemonic { get; set; }
|
public bool UseMnemonic { get; set; }
|
||||||
|
@ -313,18 +313,18 @@ namespace Sunny.UI
|
|||||||
public void Translate()
|
public void Translate()
|
||||||
{
|
{
|
||||||
months.Clear();
|
months.Clear();
|
||||||
months.Add(UIStyles.Localize.January);
|
months.Add(UIStyles.CurrentResources.January);
|
||||||
months.Add(UIStyles.Localize.February);
|
months.Add(UIStyles.CurrentResources.February);
|
||||||
months.Add(UIStyles.Localize.March);
|
months.Add(UIStyles.CurrentResources.March);
|
||||||
months.Add(UIStyles.Localize.April);
|
months.Add(UIStyles.CurrentResources.April);
|
||||||
months.Add(UIStyles.Localize.May);
|
months.Add(UIStyles.CurrentResources.May);
|
||||||
months.Add(UIStyles.Localize.June);
|
months.Add(UIStyles.CurrentResources.June);
|
||||||
months.Add(UIStyles.Localize.July);
|
months.Add(UIStyles.CurrentResources.July);
|
||||||
months.Add(UIStyles.Localize.August);
|
months.Add(UIStyles.CurrentResources.August);
|
||||||
months.Add(UIStyles.Localize.September);
|
months.Add(UIStyles.CurrentResources.September);
|
||||||
months.Add(UIStyles.Localize.October);
|
months.Add(UIStyles.CurrentResources.October);
|
||||||
months.Add(UIStyles.Localize.November);
|
months.Add(UIStyles.CurrentResources.November);
|
||||||
months.Add(UIStyles.Localize.December);
|
months.Add(UIStyles.CurrentResources.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 = { UIStyles.Localize.Sunday, UIStyles.Localize.Monday, UIStyles.Localize.Tuesday, UIStyles.Localize.Wednesday, UIStyles.Localize.Thursday, UIStyles.Localize.Friday, UIStyles.Localize.Saturday };
|
string[] weeks = { UIStyles.CurrentResources.Sunday, UIStyles.CurrentResources.Monday, UIStyles.CurrentResources.Tuesday, UIStyles.CurrentResources.Wednesday, UIStyles.CurrentResources.Thursday, UIStyles.CurrentResources.Friday, UIStyles.CurrentResources.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);
|
||||||
|
@ -40,7 +40,7 @@ namespace Sunny.UI
|
|||||||
/// 控件基类
|
/// 控件基类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ToolboxItem(false)]
|
[ToolboxItem(false)]
|
||||||
public class UIControl : Control, IStyleInterface, IZoomScale
|
public class UIControl : Control, IStyleInterface, IZoomScale, IFormTranslator
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造函数
|
/// 构造函数
|
||||||
@ -53,6 +53,14 @@ namespace Sunny.UI
|
|||||||
base.MinimumSize = new Size(1, 1);
|
base.MinimumSize = new Size(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
[Description("控件在界面显示时需要多语翻译的属性名称数组"), Category("SunnyUI")]
|
||||||
|
public virtual string[] FormTranslatorProperties { get; }
|
||||||
|
|
||||||
|
[DefaultValue(false)]
|
||||||
|
[Description("控件是否显示多语内置资源"), Category("SunnyUI")]
|
||||||
|
public bool ShowBuiltInResources { get; set; } = false;
|
||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public bool Disabled => !Enabled;
|
public bool Disabled => !Enabled;
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (!(value is DataTable || value is IList))
|
if (!(value is DataTable || value is IList))
|
||||||
{
|
{
|
||||||
throw new Exception(UIStyles.Localize.GridDataSourceException);
|
throw new Exception(UIStyles.CurrentResources.GridDataSourceException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,6 +375,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
bool isCancel = pages[0].OnPageDeselecting();
|
bool isCancel = pages[0].OnPageDeselecting();
|
||||||
if (isCancel) return false;
|
if (isCancel) return false;
|
||||||
|
pages[0].Translate();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var item in PageItems)
|
foreach (var item in PageItems)
|
||||||
@ -405,6 +406,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
bool isCancel = pages[0].OnPageDeselecting();
|
bool isCancel = pages[0].OnPageDeselecting();
|
||||||
if (isCancel) return false;
|
if (isCancel) return false;
|
||||||
|
pages[0].Translate();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var item in PageItems)
|
foreach (var item in PageItems)
|
||||||
|
@ -114,6 +114,7 @@ namespace Sunny.UI
|
|||||||
buttons[i].MouseEnter += UIDataGridPage_MouseEnter;
|
buttons[i].MouseEnter += UIDataGridPage_MouseEnter;
|
||||||
buttons[i].MouseLeave += UIDataGridPage_MouseLeave;
|
buttons[i].MouseLeave += UIDataGridPage_MouseLeave;
|
||||||
buttons[i].Click += UIDataGridPage_Click;
|
buttons[i].Click += UIDataGridPage_Click;
|
||||||
|
buttons[i].ShowBuiltInResources = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonTags.TryAdd(b0, -1);
|
buttonTags.TryAdd(b0, -1);
|
||||||
@ -170,9 +171,9 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
b0.Text = UIStyles.Localize.Prev;
|
b0.Text = UIStyles.CurrentResources.Prev;
|
||||||
b16.Text = UIStyles.Localize.Next;
|
b16.Text = UIStyles.CurrentResources.Next;
|
||||||
btnSelect.Text = UIStyles.Localize.SelectTitle;
|
btnSelect.Text = UIStyles.CurrentResources.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 +183,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 = UIStyles.Localize.SelectPageLeft;
|
uiLabel1.Text = UIStyles.CurrentResources.SelectPageLeft;
|
||||||
uiLabel2.Text = UIStyles.Localize.SelectPageRight;
|
uiLabel2.Text = UIStyles.CurrentResources.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 +310,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (!(value is DataTable || value is IList))
|
if (!(value is DataTable || value is IList))
|
||||||
{
|
{
|
||||||
throw new Exception(UIStyles.Localize.GridDataSourceException);
|
throw new Exception(UIStyles.CurrentResources.GridDataSourceException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +391,7 @@ namespace Sunny.UI
|
|||||||
// b0
|
// b0
|
||||||
//
|
//
|
||||||
b0.Cursor = Cursors.Hand;
|
b0.Cursor = Cursors.Hand;
|
||||||
b0.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point);
|
b0.Font = new Font("宋体", 10.5F);
|
||||||
b0.ImageAlign = ContentAlignment.MiddleLeft;
|
b0.ImageAlign = ContentAlignment.MiddleLeft;
|
||||||
b0.Location = new Point(3, 3);
|
b0.Location = new Point(3, 3);
|
||||||
b0.MinimumSize = new Size(1, 1);
|
b0.MinimumSize = new Size(1, 1);
|
||||||
@ -403,11 +404,12 @@ namespace Sunny.UI
|
|||||||
b0.TagString = "<";
|
b0.TagString = "<";
|
||||||
b0.Text = "上一页";
|
b0.Text = "上一页";
|
||||||
b0.TextAlign = ContentAlignment.MiddleRight;
|
b0.TextAlign = ContentAlignment.MiddleRight;
|
||||||
|
b0.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b1
|
// b1
|
||||||
//
|
//
|
||||||
b1.Cursor = Cursors.Hand;
|
b1.Cursor = Cursors.Hand;
|
||||||
b1.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b1.Font = new Font("宋体", 12F);
|
||||||
b1.Location = new Point(81, 3);
|
b1.Location = new Point(81, 3);
|
||||||
b1.MinimumSize = new Size(1, 1);
|
b1.MinimumSize = new Size(1, 1);
|
||||||
b1.Name = "b1";
|
b1.Name = "b1";
|
||||||
@ -416,11 +418,12 @@ namespace Sunny.UI
|
|||||||
b1.Symbol = 0;
|
b1.Symbol = 0;
|
||||||
b1.TabIndex = 1;
|
b1.TabIndex = 1;
|
||||||
b1.Text = "0";
|
b1.Text = "0";
|
||||||
|
b1.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b3
|
// b3
|
||||||
//
|
//
|
||||||
b3.Cursor = Cursors.Hand;
|
b3.Cursor = Cursors.Hand;
|
||||||
b3.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b3.Font = new Font("宋体", 12F);
|
||||||
b3.Location = new Point(145, 3);
|
b3.Location = new Point(145, 3);
|
||||||
b3.MinimumSize = new Size(1, 1);
|
b3.MinimumSize = new Size(1, 1);
|
||||||
b3.Name = "b3";
|
b3.Name = "b3";
|
||||||
@ -429,11 +432,12 @@ namespace Sunny.UI
|
|||||||
b3.Symbol = 0;
|
b3.Symbol = 0;
|
||||||
b3.TabIndex = 3;
|
b3.TabIndex = 3;
|
||||||
b3.Text = "0";
|
b3.Text = "0";
|
||||||
|
b3.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b2
|
// b2
|
||||||
//
|
//
|
||||||
b2.Cursor = Cursors.Hand;
|
b2.Cursor = Cursors.Hand;
|
||||||
b2.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b2.Font = new Font("宋体", 12F);
|
||||||
b2.Location = new Point(113, 3);
|
b2.Location = new Point(113, 3);
|
||||||
b2.MinimumSize = new Size(1, 1);
|
b2.MinimumSize = new Size(1, 1);
|
||||||
b2.Name = "b2";
|
b2.Name = "b2";
|
||||||
@ -442,11 +446,12 @@ namespace Sunny.UI
|
|||||||
b2.Symbol = 0;
|
b2.Symbol = 0;
|
||||||
b2.TabIndex = 2;
|
b2.TabIndex = 2;
|
||||||
b2.Text = "0";
|
b2.Text = "0";
|
||||||
|
b2.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b7
|
// b7
|
||||||
//
|
//
|
||||||
b7.Cursor = Cursors.Hand;
|
b7.Cursor = Cursors.Hand;
|
||||||
b7.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b7.Font = new Font("宋体", 12F);
|
||||||
b7.Location = new Point(273, 3);
|
b7.Location = new Point(273, 3);
|
||||||
b7.MinimumSize = new Size(1, 1);
|
b7.MinimumSize = new Size(1, 1);
|
||||||
b7.Name = "b7";
|
b7.Name = "b7";
|
||||||
@ -455,11 +460,12 @@ namespace Sunny.UI
|
|||||||
b7.Symbol = 0;
|
b7.Symbol = 0;
|
||||||
b7.TabIndex = 7;
|
b7.TabIndex = 7;
|
||||||
b7.Text = "0";
|
b7.Text = "0";
|
||||||
|
b7.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b6
|
// b6
|
||||||
//
|
//
|
||||||
b6.Cursor = Cursors.Hand;
|
b6.Cursor = Cursors.Hand;
|
||||||
b6.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b6.Font = new Font("宋体", 12F);
|
||||||
b6.Location = new Point(241, 3);
|
b6.Location = new Point(241, 3);
|
||||||
b6.MinimumSize = new Size(1, 1);
|
b6.MinimumSize = new Size(1, 1);
|
||||||
b6.Name = "b6";
|
b6.Name = "b6";
|
||||||
@ -468,11 +474,12 @@ namespace Sunny.UI
|
|||||||
b6.Symbol = 0;
|
b6.Symbol = 0;
|
||||||
b6.TabIndex = 6;
|
b6.TabIndex = 6;
|
||||||
b6.Text = "0";
|
b6.Text = "0";
|
||||||
|
b6.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b5
|
// b5
|
||||||
//
|
//
|
||||||
b5.Cursor = Cursors.Hand;
|
b5.Cursor = Cursors.Hand;
|
||||||
b5.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b5.Font = new Font("宋体", 12F);
|
||||||
b5.Location = new Point(209, 3);
|
b5.Location = new Point(209, 3);
|
||||||
b5.MinimumSize = new Size(1, 1);
|
b5.MinimumSize = new Size(1, 1);
|
||||||
b5.Name = "b5";
|
b5.Name = "b5";
|
||||||
@ -481,11 +488,12 @@ namespace Sunny.UI
|
|||||||
b5.Symbol = 0;
|
b5.Symbol = 0;
|
||||||
b5.TabIndex = 5;
|
b5.TabIndex = 5;
|
||||||
b5.Text = "0";
|
b5.Text = "0";
|
||||||
|
b5.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b4
|
// b4
|
||||||
//
|
//
|
||||||
b4.Cursor = Cursors.Hand;
|
b4.Cursor = Cursors.Hand;
|
||||||
b4.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b4.Font = new Font("宋体", 12F);
|
||||||
b4.Location = new Point(177, 3);
|
b4.Location = new Point(177, 3);
|
||||||
b4.MinimumSize = new Size(1, 1);
|
b4.MinimumSize = new Size(1, 1);
|
||||||
b4.Name = "b4";
|
b4.Name = "b4";
|
||||||
@ -494,11 +502,12 @@ namespace Sunny.UI
|
|||||||
b4.Symbol = 0;
|
b4.Symbol = 0;
|
||||||
b4.TabIndex = 4;
|
b4.TabIndex = 4;
|
||||||
b4.Text = "0";
|
b4.Text = "0";
|
||||||
|
b4.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b15
|
// b15
|
||||||
//
|
//
|
||||||
b15.Cursor = Cursors.Hand;
|
b15.Cursor = Cursors.Hand;
|
||||||
b15.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b15.Font = new Font("宋体", 12F);
|
||||||
b15.Location = new Point(529, 3);
|
b15.Location = new Point(529, 3);
|
||||||
b15.MinimumSize = new Size(1, 1);
|
b15.MinimumSize = new Size(1, 1);
|
||||||
b15.Name = "b15";
|
b15.Name = "b15";
|
||||||
@ -507,11 +516,12 @@ namespace Sunny.UI
|
|||||||
b15.Symbol = 0;
|
b15.Symbol = 0;
|
||||||
b15.TabIndex = 15;
|
b15.TabIndex = 15;
|
||||||
b15.Text = "0";
|
b15.Text = "0";
|
||||||
|
b15.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b14
|
// b14
|
||||||
//
|
//
|
||||||
b14.Cursor = Cursors.Hand;
|
b14.Cursor = Cursors.Hand;
|
||||||
b14.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b14.Font = new Font("宋体", 12F);
|
||||||
b14.Location = new Point(497, 3);
|
b14.Location = new Point(497, 3);
|
||||||
b14.MinimumSize = new Size(1, 1);
|
b14.MinimumSize = new Size(1, 1);
|
||||||
b14.Name = "b14";
|
b14.Name = "b14";
|
||||||
@ -520,11 +530,12 @@ namespace Sunny.UI
|
|||||||
b14.Symbol = 0;
|
b14.Symbol = 0;
|
||||||
b14.TabIndex = 14;
|
b14.TabIndex = 14;
|
||||||
b14.Text = "0";
|
b14.Text = "0";
|
||||||
|
b14.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b13
|
// b13
|
||||||
//
|
//
|
||||||
b13.Cursor = Cursors.Hand;
|
b13.Cursor = Cursors.Hand;
|
||||||
b13.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b13.Font = new Font("宋体", 12F);
|
||||||
b13.Location = new Point(465, 3);
|
b13.Location = new Point(465, 3);
|
||||||
b13.MinimumSize = new Size(1, 1);
|
b13.MinimumSize = new Size(1, 1);
|
||||||
b13.Name = "b13";
|
b13.Name = "b13";
|
||||||
@ -533,11 +544,12 @@ namespace Sunny.UI
|
|||||||
b13.Symbol = 0;
|
b13.Symbol = 0;
|
||||||
b13.TabIndex = 13;
|
b13.TabIndex = 13;
|
||||||
b13.Text = "0";
|
b13.Text = "0";
|
||||||
|
b13.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b12
|
// b12
|
||||||
//
|
//
|
||||||
b12.Cursor = Cursors.Hand;
|
b12.Cursor = Cursors.Hand;
|
||||||
b12.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b12.Font = new Font("宋体", 12F);
|
||||||
b12.Location = new Point(433, 3);
|
b12.Location = new Point(433, 3);
|
||||||
b12.MinimumSize = new Size(1, 1);
|
b12.MinimumSize = new Size(1, 1);
|
||||||
b12.Name = "b12";
|
b12.Name = "b12";
|
||||||
@ -546,11 +558,12 @@ namespace Sunny.UI
|
|||||||
b12.Symbol = 0;
|
b12.Symbol = 0;
|
||||||
b12.TabIndex = 12;
|
b12.TabIndex = 12;
|
||||||
b12.Text = "0";
|
b12.Text = "0";
|
||||||
|
b12.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b11
|
// b11
|
||||||
//
|
//
|
||||||
b11.Cursor = Cursors.Hand;
|
b11.Cursor = Cursors.Hand;
|
||||||
b11.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b11.Font = new Font("宋体", 12F);
|
||||||
b11.Location = new Point(401, 3);
|
b11.Location = new Point(401, 3);
|
||||||
b11.MinimumSize = new Size(1, 1);
|
b11.MinimumSize = new Size(1, 1);
|
||||||
b11.Name = "b11";
|
b11.Name = "b11";
|
||||||
@ -559,11 +572,12 @@ namespace Sunny.UI
|
|||||||
b11.Symbol = 0;
|
b11.Symbol = 0;
|
||||||
b11.TabIndex = 11;
|
b11.TabIndex = 11;
|
||||||
b11.Text = "0";
|
b11.Text = "0";
|
||||||
|
b11.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b10
|
// b10
|
||||||
//
|
//
|
||||||
b10.Cursor = Cursors.Hand;
|
b10.Cursor = Cursors.Hand;
|
||||||
b10.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b10.Font = new Font("宋体", 12F);
|
||||||
b10.Location = new Point(369, 3);
|
b10.Location = new Point(369, 3);
|
||||||
b10.MinimumSize = new Size(1, 1);
|
b10.MinimumSize = new Size(1, 1);
|
||||||
b10.Name = "b10";
|
b10.Name = "b10";
|
||||||
@ -572,11 +586,12 @@ namespace Sunny.UI
|
|||||||
b10.Symbol = 0;
|
b10.Symbol = 0;
|
||||||
b10.TabIndex = 10;
|
b10.TabIndex = 10;
|
||||||
b10.Text = "0";
|
b10.Text = "0";
|
||||||
|
b10.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b9
|
// b9
|
||||||
//
|
//
|
||||||
b9.Cursor = Cursors.Hand;
|
b9.Cursor = Cursors.Hand;
|
||||||
b9.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b9.Font = new Font("宋体", 12F);
|
||||||
b9.Location = new Point(337, 3);
|
b9.Location = new Point(337, 3);
|
||||||
b9.MinimumSize = new Size(1, 1);
|
b9.MinimumSize = new Size(1, 1);
|
||||||
b9.Name = "b9";
|
b9.Name = "b9";
|
||||||
@ -585,11 +600,12 @@ namespace Sunny.UI
|
|||||||
b9.Symbol = 0;
|
b9.Symbol = 0;
|
||||||
b9.TabIndex = 9;
|
b9.TabIndex = 9;
|
||||||
b9.Text = "0";
|
b9.Text = "0";
|
||||||
|
b9.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b8
|
// b8
|
||||||
//
|
//
|
||||||
b8.Cursor = Cursors.Hand;
|
b8.Cursor = Cursors.Hand;
|
||||||
b8.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
b8.Font = new Font("宋体", 12F);
|
||||||
b8.Location = new Point(305, 3);
|
b8.Location = new Point(305, 3);
|
||||||
b8.MinimumSize = new Size(1, 1);
|
b8.MinimumSize = new Size(1, 1);
|
||||||
b8.Name = "b8";
|
b8.Name = "b8";
|
||||||
@ -598,11 +614,12 @@ namespace Sunny.UI
|
|||||||
b8.Symbol = 0;
|
b8.Symbol = 0;
|
||||||
b8.TabIndex = 8;
|
b8.TabIndex = 8;
|
||||||
b8.Text = "0";
|
b8.Text = "0";
|
||||||
|
b8.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
//
|
//
|
||||||
// b16
|
// b16
|
||||||
//
|
//
|
||||||
b16.Cursor = Cursors.Hand;
|
b16.Cursor = Cursors.Hand;
|
||||||
b16.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point);
|
b16.Font = new Font("宋体", 10.5F);
|
||||||
b16.ImageAlign = ContentAlignment.MiddleRight;
|
b16.ImageAlign = ContentAlignment.MiddleRight;
|
||||||
b16.Location = new Point(561, 3);
|
b16.Location = new Point(561, 3);
|
||||||
b16.MinimumSize = new Size(1, 1);
|
b16.MinimumSize = new Size(1, 1);
|
||||||
@ -615,13 +632,14 @@ namespace Sunny.UI
|
|||||||
b16.TagString = ">";
|
b16.TagString = ">";
|
||||||
b16.Text = "下一页";
|
b16.Text = "下一页";
|
||||||
b16.TextAlign = ContentAlignment.MiddleLeft;
|
b16.TextAlign = ContentAlignment.MiddleLeft;
|
||||||
|
b16.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
b16.LocationChanged += b16_LocationChanged;
|
b16.LocationChanged += b16_LocationChanged;
|
||||||
//
|
//
|
||||||
// edtPage
|
// edtPage
|
||||||
//
|
//
|
||||||
edtPage.Cursor = Cursors.IBeam;
|
edtPage.Cursor = Cursors.IBeam;
|
||||||
edtPage.DoubleValue = 10D;
|
edtPage.DoubleValue = 10D;
|
||||||
edtPage.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
edtPage.Font = new Font("宋体", 12F);
|
||||||
edtPage.IntValue = 10;
|
edtPage.IntValue = 10;
|
||||||
edtPage.Location = new Point(673, 3);
|
edtPage.Location = new Point(673, 3);
|
||||||
edtPage.Margin = new Padding(4, 5, 4, 5);
|
edtPage.Margin = new Padding(4, 5, 4, 5);
|
||||||
@ -640,21 +658,23 @@ namespace Sunny.UI
|
|||||||
// btnSelect
|
// btnSelect
|
||||||
//
|
//
|
||||||
btnSelect.Cursor = Cursors.Hand;
|
btnSelect.Cursor = Cursors.Hand;
|
||||||
btnSelect.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point);
|
btnSelect.Font = new Font("宋体", 10.5F);
|
||||||
btnSelect.Location = new Point(756, 3);
|
btnSelect.Location = new Point(756, 3);
|
||||||
btnSelect.MinimumSize = new Size(1, 1);
|
btnSelect.MinimumSize = new Size(1, 1);
|
||||||
btnSelect.Name = "btnSelect";
|
btnSelect.Name = "btnSelect";
|
||||||
|
btnSelect.ShowBuiltInResources = true;
|
||||||
btnSelect.Size = new Size(61, 29);
|
btnSelect.Size = new Size(61, 29);
|
||||||
btnSelect.Symbol = 0;
|
btnSelect.Symbol = 0;
|
||||||
btnSelect.TabIndex = 3;
|
btnSelect.TabIndex = 3;
|
||||||
btnSelect.Text = "确定";
|
btnSelect.Text = "确定";
|
||||||
|
btnSelect.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
btnSelect.Click += btnSelect_Click;
|
btnSelect.Click += btnSelect_Click;
|
||||||
//
|
//
|
||||||
// uiLabel2
|
// uiLabel2
|
||||||
//
|
//
|
||||||
uiLabel2.AutoSize = true;
|
uiLabel2.AutoSize = true;
|
||||||
uiLabel2.BackColor = Color.Transparent;
|
uiLabel2.BackColor = Color.Transparent;
|
||||||
uiLabel2.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point);
|
uiLabel2.Font = new Font("宋体", 10.5F);
|
||||||
uiLabel2.ForeColor = Color.FromArgb(48, 48, 48);
|
uiLabel2.ForeColor = Color.FromArgb(48, 48, 48);
|
||||||
uiLabel2.Location = new Point(726, 10);
|
uiLabel2.Location = new Point(726, 10);
|
||||||
uiLabel2.Name = "uiLabel2";
|
uiLabel2.Name = "uiLabel2";
|
||||||
@ -667,7 +687,7 @@ namespace Sunny.UI
|
|||||||
//
|
//
|
||||||
uiLabel1.AutoSize = true;
|
uiLabel1.AutoSize = true;
|
||||||
uiLabel1.BackColor = Color.Transparent;
|
uiLabel1.BackColor = Color.Transparent;
|
||||||
uiLabel1.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point);
|
uiLabel1.Font = new Font("宋体", 10.5F);
|
||||||
uiLabel1.ForeColor = Color.FromArgb(48, 48, 48);
|
uiLabel1.ForeColor = Color.FromArgb(48, 48, 48);
|
||||||
uiLabel1.Location = new Point(650, 10);
|
uiLabel1.Location = new Point(650, 10);
|
||||||
uiLabel1.Name = "uiLabel1";
|
uiLabel1.Name = "uiLabel1";
|
||||||
|
@ -696,18 +696,6 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Translate()
|
|
||||||
{
|
|
||||||
List<Control> controls = this.GetInterfaceControls("ITranslate");
|
|
||||||
foreach (var control in controls)
|
|
||||||
{
|
|
||||||
if (control is ITranslate item)
|
|
||||||
{
|
|
||||||
item.Translate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly Guid Guid = Guid.NewGuid();
|
public readonly Guid Guid = Guid.NewGuid();
|
||||||
|
|
||||||
protected FormWindowState lastWindowState = FormWindowState.Normal;
|
protected FormWindowState lastWindowState = FormWindowState.Normal;
|
||||||
@ -1071,5 +1059,23 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion IFrame实现
|
#endregion IFrame实现
|
||||||
|
|
||||||
|
public virtual void Translate()
|
||||||
|
{
|
||||||
|
var controls = this.GetInterfaceControls<ITranslate>(true);
|
||||||
|
foreach (var control in controls)
|
||||||
|
{
|
||||||
|
if (control is not UIPage)
|
||||||
|
control.Translate();
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedPage?.Translate();
|
||||||
|
this.TranslateOther();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CodeTranslator : BaseCodeTranslator
|
||||||
|
{
|
||||||
|
public string ButtonInfo { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
btnOK.Text = UIStyles.Localize.OK;
|
btnOK.Text = UIStyles.CurrentResources.OK;
|
||||||
btnCancel.Text = UIStyles.Localize.Cancel;
|
btnCancel.Text = UIStyles.CurrentResources.Cancel;
|
||||||
base.TopMost = true;
|
base.TopMost = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,8 +331,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
btnOK.Text = UIStyles.Localize.OK;
|
btnOK.Text = UIStyles.CurrentResources.OK;
|
||||||
btnCancel.Text = UIStyles.Localize.Cancel;
|
btnCancel.Text = UIStyles.CurrentResources.Cancel;
|
||||||
base.TopMost = true;
|
base.TopMost = true;
|
||||||
|
|
||||||
Option = option;
|
Option = option;
|
||||||
|
@ -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, UIStyles.Localize.InfoTitle, UIStyle.Blue, UIMessageBoxButtons.OK, showMask, delay);
|
Show(message, UIStyles.CurrentResources.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, UIStyles.Localize.InfoTitle, UIStyles.Style, UIMessageBoxButtons.OK, showMask, delay);
|
Show(message, UIStyles.CurrentResources.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, UIStyles.Localize.SuccessTitle, UIStyle.Green, UIMessageBoxButtons.OK, showMask, delay);
|
Show(message, UIStyles.CurrentResources.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, UIStyles.Localize.WarningTitle, UIStyle.Orange, UIMessageBoxButtons.OK, showMask, delay);
|
Show(message, UIStyles.CurrentResources.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, UIStyles.Localize.ErrorTitle, UIStyle.Red, UIMessageBoxButtons.OK, showMask, delay);
|
Show(message, UIStyles.CurrentResources.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, UIStyles.Localize.AskTitle, true, UIStyle.Blue, showMask, defaultButton);
|
return ShowMessageDialog(message, UIStyles.CurrentResources.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(UIStyles.Localize.InfoTitle, message, UINotifierType.INFO, showMask, UIMessageDialogButtons.Ok, delay);
|
ShowMessageDialog2(UIStyles.CurrentResources.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(UIStyles.Localize.SuccessTitle, message, UINotifierType.OK, showMask, UIMessageDialogButtons.Ok, delay);
|
ShowMessageDialog2(UIStyles.CurrentResources.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(UIStyles.Localize.WarningTitle, message, UINotifierType.WARNING, showMask, UIMessageDialogButtons.Ok, delay);
|
ShowMessageDialog2(UIStyles.CurrentResources.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(UIStyles.Localize.ErrorTitle, message, UINotifierType.ERROR, showMask, UIMessageDialogButtons.Ok, delay);
|
ShowMessageDialog2(UIStyles.CurrentResources.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(UIStyles.Localize.AskTitle, message, UINotifierType.Ask, showMask, defaultButton);
|
return ShowMessageDialog2(UIStyles.CurrentResources.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 = UIStyles.Localize.InputTitle;
|
frm.Text = UIStyles.CurrentResources.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, UIStyles.Localize.SelectTitle, "", style, showMask);
|
return owner.ShowSelectDialog(ref selectIndex, items, UIStyles.CurrentResources.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(UIStyles.Localize.SuccessTitle, message, UIStyle.Green, showMask, delay);
|
owner.ShowSuccessDialog(UIStyles.CurrentResources.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(UIStyles.Localize.InfoTitle, message, UIStyles.Style, showMask, delay);
|
owner.ShowInfoDialog(UIStyles.CurrentResources.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(UIStyles.Localize.WarningTitle, message, UIStyle.Orange, showMask, delay);
|
owner.ShowWarningDialog(UIStyles.CurrentResources.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(UIStyles.Localize.ErrorTitle, message, UIStyle.Red, showMask, delay);
|
owner.ShowErrorDialog(UIStyles.CurrentResources.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, UIStyles.Localize.AskTitle, true, UIStyles.Style, showMask, defaultButton);
|
return UIMessageBox.ShowMessageDialog(owner, message, UIStyles.CurrentResources.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(UIStyles.Localize.SuccessTitle, message, showMask, delay);
|
owner.ShowSuccessDialog2(UIStyles.CurrentResources.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(UIStyles.Localize.InfoTitle, message, showMask, delay);
|
owner.ShowInfoDialog2(UIStyles.CurrentResources.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(UIStyles.Localize.WarningTitle, message, showMask, delay);
|
owner.ShowWarningDialog2(UIStyles.CurrentResources.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(UIStyles.Localize.ErrorTitle, message, showMask, delay);
|
owner.ShowErrorDialog2(UIStyles.CurrentResources.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, UIStyles.Localize.AskTitle, message, UINotifierType.Ask, showMask, defaultButton);
|
return UIMessageBox.ShowMessageDialog2(owner, UIStyles.CurrentResources.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, UIStyles.Localize.InfoTitle, isDialog, timeout);
|
UINotifierHelper.ShowNotifier(desc, UINotifierType.INFO, UIStyles.CurrentResources.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, UIStyles.Localize.SuccessTitle, isDialog, timeout);
|
UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UIStyles.CurrentResources.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, UIStyles.Localize.WarningTitle, isDialog, timeout);
|
UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UIStyles.CurrentResources.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, UIStyles.Localize.ErrorTitle, isDialog, timeout);
|
UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UIStyles.CurrentResources.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, UIStyles.Localize.InfoTitle, timeout);
|
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.INFO, UIStyles.CurrentResources.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, UIStyles.Localize.SuccessTitle, timeout);
|
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.OK, UIStyles.CurrentResources.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, UIStyles.Localize.WarningTitle, timeout);
|
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.WARNING, UIStyles.CurrentResources.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, UIStyles.Localize.ErrorTitle, timeout);
|
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.ERROR, UIStyles.CurrentResources.ErrorTitle, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion 一些辅助窗口
|
#endregion 一些辅助窗口
|
||||||
|
@ -36,8 +36,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
btnOK.Text = UIStyles.Localize.OK;
|
btnOK.Text = UIStyles.CurrentResources.OK;
|
||||||
btnCancel.Text = UIStyles.Localize.Cancel;
|
btnCancel.Text = UIStyles.CurrentResources.Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -33,8 +33,8 @@ namespace Sunny.UI
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Text = title;
|
Text = title;
|
||||||
Message = message;
|
Message = message;
|
||||||
btnOK.Text = UIStyles.Localize.OK;
|
btnOK.Text = UIStyles.CurrentResources.OK;
|
||||||
btnCancel.Text = UIStyles.Localize.Cancel;
|
btnCancel.Text = UIStyles.CurrentResources.Cancel;
|
||||||
|
|
||||||
foreColor = Color.Black;
|
foreColor = Color.Black;
|
||||||
|
|
||||||
|
@ -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 = UIStyles.Localize.OK;
|
ok_button.Text = UIStyles.CurrentResources.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 = UIStyles.Localize.CloseAll;
|
closeAllToolStripMenuItem.Text = UIStyles.CurrentResources.CloseAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void noteContent_Click(object sender, EventArgs e)
|
private void noteContent_Click(object sender, EventArgs e)
|
||||||
|
@ -28,15 +28,15 @@ namespace Sunny.UI
|
|||||||
public UIStatusForm()
|
public UIStatusForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Text = UIStyles.Localize.InfoTitle;
|
Text = UIStyles.CurrentResources.InfoTitle;
|
||||||
Description = UIStyles.Localize.SystemProcessing;
|
Description = UIStyles.CurrentResources.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 = UIStyles.Localize.InfoTitle;
|
Text = UIStyles.CurrentResources.InfoTitle;
|
||||||
Maximum = max;
|
Maximum = max;
|
||||||
Description = desc;
|
Description = desc;
|
||||||
Value = 0;
|
Value = 0;
|
||||||
|
@ -26,14 +26,14 @@ namespace Sunny.UI
|
|||||||
public UIWaitForm()
|
public UIWaitForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
base.Text = UIStyles.Localize.InfoTitle;
|
base.Text = UIStyles.CurrentResources.InfoTitle;
|
||||||
SetDescription(UIStyles.Localize.SystemProcessing);
|
SetDescription(UIStyles.CurrentResources.SystemProcessing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UIWaitForm(string desc)
|
public UIWaitForm(string desc)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
base.Text = UIStyles.Localize.InfoTitle;
|
base.Text = UIStyles.CurrentResources.InfoTitle;
|
||||||
SetDescription(desc);
|
SetDescription(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,7 +1124,13 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public virtual void Translate()
|
public virtual void Translate()
|
||||||
{
|
{
|
||||||
|
var controls = this.GetInterfaceControls<ITranslate>(true);
|
||||||
|
foreach (var control in controls)
|
||||||
|
{
|
||||||
|
control.Translate();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.TranslateOther();
|
||||||
}
|
}
|
||||||
|
|
||||||
public event OnReceiveParams ReceiveParams;
|
public event OnReceiveParams ReceiveParams;
|
||||||
|
@ -500,25 +500,5 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Control> GetInterfaceControls(this Control ctrl, string interfaceName)
|
|
||||||
{
|
|
||||||
List<Control> values = new List<Control>();
|
|
||||||
|
|
||||||
foreach (Control obj in ctrl.Controls)
|
|
||||||
{
|
|
||||||
if (obj.GetType().GetInterface(interfaceName) != null)
|
|
||||||
{
|
|
||||||
values.Add(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj.Controls.Count > 0)
|
|
||||||
{
|
|
||||||
values.AddRange(obj.GetInterfaceControls(interfaceName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -46,6 +46,8 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public static bool GlobalRectangle { get; set; } = false;
|
public static bool GlobalRectangle { get; set; } = false;
|
||||||
|
|
||||||
|
public static bool MultiLanguageSupport { get; set; } = false;
|
||||||
|
|
||||||
public static bool DPIScale { get; set; }
|
public static bool DPIScale { get; set; }
|
||||||
|
|
||||||
public static bool ZoomScale { get; set; }
|
public static bool ZoomScale { get; set; }
|
||||||
@ -238,10 +240,10 @@ namespace Sunny.UI
|
|||||||
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();
|
UIBuiltInResources lcn = new zh_CN_Resources();
|
||||||
UILocalize len = new UILocalize_EN_US();
|
UIBuiltInResources len = new en_US_Resources();
|
||||||
Localizes.TryAdd(lch.CultureInfo.LCID, lch);
|
BuiltInResources.TryAdd(lcn.CultureInfo.LCID, lcn);
|
||||||
Localizes.TryAdd(len.CultureInfo.LCID, len);
|
BuiltInResources.TryAdd(len.CultureInfo.LCID, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -396,21 +398,23 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CultureInfo _CultureInfo = CultureInfos.SimplifiedChinese;
|
private static CultureInfo _cultureInfo = CultureInfos.zh_CN;
|
||||||
public static CultureInfo CultureInfo
|
public static CultureInfo CultureInfo
|
||||||
{
|
{
|
||||||
get => _CultureInfo;
|
get => _cultureInfo;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value.LCID != _CultureInfo.LCID)
|
if (value == null) return;
|
||||||
|
|
||||||
|
if (value.LCID != _cultureInfo.LCID)
|
||||||
{
|
{
|
||||||
if (Localizes.TryGetValue(value.LCID, out var cultureInfo))
|
if (BuiltInResources.TryGetValue(value.LCID, out var cultureInfo))
|
||||||
{
|
{
|
||||||
_CultureInfo = cultureInfo.CultureInfo;
|
_cultureInfo = cultureInfo.CultureInfo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_CultureInfo = CultureInfos.SimplifiedChinese;
|
_cultureInfo = CultureInfos.zh_CN;
|
||||||
}
|
}
|
||||||
|
|
||||||
UIStyles.Translate();
|
UIStyles.Translate();
|
||||||
@ -418,8 +422,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConcurrentDictionary<int, UILocalize> Localizes = new();
|
public static readonly ConcurrentDictionary<int, UIBuiltInResources> BuiltInResources = new();
|
||||||
public static UILocalize Localize => Localizes[CultureInfo.LCID];
|
public static UIBuiltInResources CurrentResources => BuiltInResources[CultureInfo.LCID];
|
||||||
public static int LCID => Localize.CultureInfo.LCID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,14 @@
|
|||||||
* 2021-07-23: V3.0.5 增加文件说明
|
* 2021-07-23: V3.0.5 增加文件说明
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 多语翻译接口
|
/// 内置资源多语翻译接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITranslate
|
public interface ITranslate
|
||||||
{
|
{
|
||||||
@ -31,4 +35,75 @@ namespace Sunny.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void Translate();
|
void Translate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 界面显示控件多语翻译接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IFormTranslator
|
||||||
|
{
|
||||||
|
string[] FormTranslatorProperties { get; }
|
||||||
|
|
||||||
|
bool ShowBuiltInResources { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ICodeTranslator
|
||||||
|
{
|
||||||
|
void Load(IniFile ini);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class BaseCodeTranslator : ICodeTranslator
|
||||||
|
{
|
||||||
|
public void Load(IniFile ini)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TranslateHelper
|
||||||
|
{
|
||||||
|
public static void TranslateOther(this Form form)
|
||||||
|
{
|
||||||
|
if (!UIStyles.MultiLanguageSupport) return;
|
||||||
|
if (!(form is UIBaseForm || form is UIPage)) return;
|
||||||
|
|
||||||
|
string thisFullName = form.GetType().FullName;
|
||||||
|
string section = "Info";
|
||||||
|
var formControls = form.GetInterfaceControls<IFormTranslator>(true, false).Where(p => p.FormTranslatorProperties != null);
|
||||||
|
IniFile ini = new IniFile(Dir.CurrentDir() + "Language\\" + thisFullName + ".ini", System.Text.Encoding.UTF8);
|
||||||
|
ini.Write(section, "Warning", "注意:请先关闭应用程序,然后再修改此文档。否则修改可能会应用程序生成代码覆盖。");
|
||||||
|
ini.Write(section, "Information", "提示:此节为代码自动生成,无需修改。");
|
||||||
|
ini.Write(section, UIStyles.CultureInfo.LCID.ToString() + ".DisplayName", UIStyles.CultureInfo.DisplayName);
|
||||||
|
ini.Write(section, UIStyles.CultureInfo.LCID.ToString() + ".EnglishName", UIStyles.CultureInfo.EnglishName);
|
||||||
|
|
||||||
|
section = UIStyles.CultureInfo.LCID + ".Form";
|
||||||
|
foreach (var control in formControls)
|
||||||
|
{
|
||||||
|
if (control.ShowBuiltInResources) continue;
|
||||||
|
|
||||||
|
foreach (var propertyName in control.FormTranslatorProperties)
|
||||||
|
{
|
||||||
|
Control ctrl = (Control)control;
|
||||||
|
if (ctrl.Name.IsNullOrEmpty()) continue;
|
||||||
|
PropertyInfo pt = ctrl.GetType().GetProperty(propertyName);
|
||||||
|
if (pt == null || !pt.CanWrite) continue;
|
||||||
|
|
||||||
|
string key = ctrl.Name + "." + propertyName;
|
||||||
|
|
||||||
|
string langStr = ini.Read(section, key, "");
|
||||||
|
string ctrlStr = pt.GetValue(ctrl, null).ToString();
|
||||||
|
|
||||||
|
if (langStr.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
if (ctrlStr.IsValid()) ini.Write(section, key, ctrlStr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pt.SetValue(ctrl, langStr, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ini.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user