This commit is contained in:
Sunny 2024-10-06 21:31:18 +08:00
parent a411027eb1
commit e9ffd02edc
16 changed files with 290 additions and 132 deletions

View File

@ -196,7 +196,7 @@ namespace Sunny.UI.Demo
this.uiAvatar2.AvatarSize = 55;
this.uiAvatar2.Font = new System.Drawing.Font("宋体", 12F);
this.uiAvatar2.Icon = Sunny.UI.UIAvatar.UIIcon.Image;
this.uiAvatar2.Image = global::Sunny.UI.Demo.Properties.Resources.SunnyUISmall;
this.uiAvatar2.Image = global::Sunny.UI.Demo.Properties.Resources.SunnyUI72;
this.uiAvatar2.Location = new System.Drawing.Point(30, 85);
this.uiAvatar2.MinimumSize = new System.Drawing.Size(1, 1);
this.uiAvatar2.Name = "uiAvatar2";

View File

@ -31,8 +31,12 @@
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FMain));
this.uiContextMenuStrip1 = new Sunny.UI.UIContextMenuStrip();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.NHome = new System.Windows.Forms.ToolStripMenuItem();
this.NAbout = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.NZhCN = new System.Windows.Forms.ToolStripMenuItem();
this.NZhTW = new System.Windows.Forms.ToolStripMenuItem();
this.NEnUS = new System.Windows.Forms.ToolStripMenuItem();
this.StyleManager = new Sunny.UI.UIStyleManager(this.components);
this.uiNavBar1 = new Sunny.UI.UINavBar();
this.uiAvatar1 = new Sunny.UI.UIAvatar();
@ -52,32 +56,63 @@
// uiContextMenuStrip1
//
this.uiContextMenuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(249)))), ((int)(((byte)(255)))));
this.uiContextMenuStrip1.Font = new System.Drawing.Font("宋体", 12F);
this.uiContextMenuStrip1.Font = new System.Drawing.Font("Tahoma", 12F);
this.uiContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem1});
this.NHome,
this.NAbout,
this.toolStripMenuItem1,
this.NZhCN,
this.NZhTW,
this.NEnUS});
this.uiContextMenuStrip1.Name = "uiContextMenuStrip1";
this.uiContextMenuStrip1.Size = new System.Drawing.Size(107, 48);
this.uiContextMenuStrip1.Size = new System.Drawing.Size(143, 130);
//
// 关于ToolStripMenuItem
// NHome
//
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(106, 22);
this.ToolStripMenuItem.Text = "主页";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
this.NHome.Name = "NHome";
this.NHome.Size = new System.Drawing.Size(142, 24);
this.NHome.Text = "主页";
this.NHome.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 关于ToolStripMenuItem1
// NAbout
//
this.ToolStripMenuItem1.Name = "关于ToolStripMenuItem1";
this.ToolStripMenuItem1.Size = new System.Drawing.Size(106, 22);
this.ToolStripMenuItem1.Text = "关于";
this.ToolStripMenuItem1.Click += new System.EventHandler(this.ToolStripMenuItem1_Click);
this.NAbout.Name = "NAbout";
this.NAbout.Size = new System.Drawing.Size(142, 24);
this.NAbout.Text = "关于";
this.NAbout.Click += new System.EventHandler(this.ToolStripMenuItem1_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(139, 6);
//
// NZhCN
//
this.NZhCN.Name = "NZhCN";
this.NZhCN.Size = new System.Drawing.Size(142, 24);
this.NZhCN.Text = "简体中文";
this.NZhCN.Click += new System.EventHandler(this.NZhCN_Click);
//
// NZhTW
//
this.NZhTW.Name = "NZhTW";
this.NZhTW.Size = new System.Drawing.Size(142, 24);
this.NZhTW.Text = "繁体中文";
this.NZhTW.Click += new System.EventHandler(this.NZhTW_Click);
//
// NEnUS
//
this.NEnUS.Name = "NEnUS";
this.NEnUS.Size = new System.Drawing.Size(142, 24);
this.NEnUS.Text = "English";
this.NEnUS.Click += new System.EventHandler(this.NEnUS_Click);
//
// StyleManager
//
this.StyleManager.DPIScale = true;
this.StyleManager.GlobalFont = true;
this.StyleManager.GlobalFontName = "Tahoma";
this.StyleManager.MultiLanguageSupport = true;
//
// uiNavBar1
//
@ -160,6 +195,7 @@
this.uiPanel3.Location = new System.Drawing.Point(842, 0);
this.uiPanel3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiPanel3.MinimumSize = new System.Drawing.Size(1, 1);
this.uiPanel3.MultiLanguageSupport = false;
this.uiPanel3.Name = "uiPanel3";
this.uiPanel3.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.uiPanel3.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)));
@ -175,6 +211,7 @@
this.uiPanel2.Location = new System.Drawing.Point(0, 0);
this.uiPanel2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiPanel2.MinimumSize = new System.Drawing.Size(1, 1);
this.uiPanel2.MultiLanguageSupport = false;
this.uiPanel2.Name = "uiPanel2";
this.uiPanel2.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.uiPanel2.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Top | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
@ -190,11 +227,14 @@
this.uiNavMenu1.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll;
this.uiNavMenu1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiNavMenu1.FullRowSelect = true;
this.uiNavMenu1.HotTracking = true;
this.uiNavMenu1.ItemHeight = 35;
this.uiNavMenu1.Location = new System.Drawing.Point(2, 162);
this.uiNavMenu1.Name = "uiNavMenu1";
this.uiNavMenu1.ShowLines = false;
this.uiNavMenu1.ShowOneNode = true;
this.uiNavMenu1.ShowPlusMinus = false;
this.uiNavMenu1.ShowRootLines = false;
this.uiNavMenu1.Size = new System.Drawing.Size(286, 650);
this.uiNavMenu1.TabIndex = 4;
this.uiNavMenu1.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@ -224,6 +264,7 @@
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1132, 846);
this.CloseAskString = "您确认要退出程序吗?";
this.Controls.Add(this.uiTabControl1);
this.Controls.Add(this.uiNavMenu1);
this.Controls.Add(this.uiPanel1);
@ -231,11 +272,14 @@
this.ExtendBox = true;
this.ExtendMenu = this.uiContextMenuStrip1;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.IconImage = global::Sunny.UI.Demo.Properties.Resources.Sunny24;
this.MainTabControl = this.uiTabControl1;
this.Name = "FMain";
this.Padding = new System.Windows.Forms.Padding(2, 36, 2, 2);
this.Resizable = true;
this.ShowDragStretch = true;
this.Text = "Form1";
this.ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 1132, 846);
this.HotKeyEventHandler += new Sunny.UI.HotKeyEventHandler(this.Form1_HotKeyEventHandler);
this.PageSelected += new Sunny.UI.OnUIPageChanged(this.Form1_PageSelected);
this.ReceiveParams += new Sunny.UI.OnReceiveParams(this.Form1_ReceiveParams);
@ -249,8 +293,8 @@
#endregion
private UIContextMenuStrip uiContextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem NHome;
private System.Windows.Forms.ToolStripMenuItem NAbout;
private UIStyleManager StyleManager;
private UINavBar uiNavBar1;
private UIPanel uiPanel1;
@ -262,5 +306,9 @@
private UIPanel uiPanel3;
private System.Windows.Forms.Timer timer1;
private UIPanel uiPanel4;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem NZhCN;
private System.Windows.Forms.ToolStripMenuItem NZhTW;
private System.Windows.Forms.ToolStripMenuItem NEnUS;
}
}

View File

@ -195,5 +195,56 @@ namespace Sunny.UI.Demo
{
uiPanel3.Text = DateTime.Now.DateTimeString();
}
private void NZhCN_Click(object sender, EventArgs e)
{
UIStyles.CultureInfo = CultureInfos.zh_CN;
}
private void NZhTW_Click(object sender, EventArgs e)
{
UIStyles.CultureInfo = CultureInfos.zh_TW;
}
private void NEnUS_Click(object sender, EventArgs e)
{
UIStyles.CultureInfo = CultureInfos.en_US;
}
/// <summary>
/// 重载多语翻译
/// </summary>
public override void Translate()
{
//必须保留
base.Translate();
//读取翻译代码中的多语资源
CodeTranslator.Load(this);
//设置多语资源
this.CloseAskString = CodeTranslator.Current.CloseAskString;
this.uiNavMenu1.Nodes[0].Text = this.uiNavBar1.Nodes[0].Text = CodeTranslator.Current.Controls;
this.uiNavMenu1.Nodes[1].Text = this.uiNavBar1.Nodes[1].Text = CodeTranslator.Current.Forms;
this.uiNavMenu1.Nodes[2].Text = this.uiNavBar1.Nodes[2].Text = CodeTranslator.Current.Charts;
this.uiNavMenu1.Nodes[3].Text = this.uiNavBar1.Nodes[3].Text = CodeTranslator.Current.Industrial;
this.uiNavBar1.Nodes[4].Text = CodeTranslator.Current.Theme;
this.uiNavMenu1.Nodes[4].Text = CodeTranslator.Current.Colorful;
this.uiNavMenu1.Nodes[5].Text = CodeTranslator.Current.Symbols;
this.uiNavBar1.Invalidate();
this.uiNavMenu1.Invalidate();
}
private class CodeTranslator : IniCodeTranslator<CodeTranslator>
{
public string CloseAskString { get; set; } = "您确认要退出程序吗?";
public string Controls { get; set; } = "控件";
public string Forms { get; set; } = "窗体";
public string Charts { get; set; } = "图表";
public string Industrial { get; set; } = "工控";
public string Theme { get; set; } = "主题";
public string Symbols { get; set; } = "字体图标";
public string Colorful { get; set; } = "多彩主题";
}
}
}
}

View File

@ -64,7 +64,6 @@
this.uiSymbolButton13 = new Sunny.UI.UISymbolButton();
this.uiLine11 = new Sunny.UI.UILine();
this.uiSymbolButton12 = new Sunny.UI.UISymbolButton();
this.uiPagination1 = new Sunny.UI.UIPagination();
this.SuspendLayout();
//
// btnError
@ -89,7 +88,7 @@
this.btnError.StyleCustomMode = true;
this.btnError.Symbol = 61532;
this.btnError.TabIndex = 29;
this.btnError.Text = "Error";
this.btnError.Text = "错误";
this.btnError.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnError.Click += new System.EventHandler(this.btnError_Click);
//
@ -115,7 +114,7 @@
this.btnWarn.StyleCustomMode = true;
this.btnWarn.Symbol = 61553;
this.btnWarn.TabIndex = 28;
this.btnWarn.Text = "Warn";
this.btnWarn.Text = "警告";
this.btnWarn.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnWarn.Click += new System.EventHandler(this.btnWarn_Click);
//
@ -141,7 +140,7 @@
this.btnSuccess.StyleCustomMode = true;
this.btnSuccess.Symbol = 61528;
this.btnSuccess.TabIndex = 27;
this.btnSuccess.Text = "Success";
this.btnSuccess.Text = "成功";
this.btnSuccess.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSuccess.Click += new System.EventHandler(this.btnSuccess_Click);
//
@ -157,7 +156,7 @@
this.btnAsk.StyleCustomMode = true;
this.btnAsk.Symbol = 61529;
this.btnAsk.TabIndex = 26;
this.btnAsk.Text = "Query";
this.btnAsk.Text = "确认";
this.btnAsk.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAsk.Click += new System.EventHandler(this.btnAsk_Click);
//
@ -188,7 +187,7 @@
this.btnInfo.StyleCustomMode = true;
this.btnInfo.Symbol = 61530;
this.btnInfo.TabIndex = 37;
this.btnInfo.Text = "Info";
this.btnInfo.Text = "提示";
this.btnInfo.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnInfo.Click += new System.EventHandler(this.btnInfo_Click);
//
@ -345,7 +344,7 @@
this.uiSymbolButton2.StyleCustomMode = true;
this.uiSymbolButton2.Symbol = 61530;
this.uiSymbolButton2.TabIndex = 57;
this.uiSymbolButton2.Text = "Info";
this.uiSymbolButton2.Text = "提示";
this.uiSymbolButton2.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton2.Click += new System.EventHandler(this.uiSymbolButton2_Click);
//
@ -371,7 +370,7 @@
this.uiSymbolButton4.StyleCustomMode = true;
this.uiSymbolButton4.Symbol = 61532;
this.uiSymbolButton4.TabIndex = 55;
this.uiSymbolButton4.Text = "Error";
this.uiSymbolButton4.Text = "错误";
this.uiSymbolButton4.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton4.Click += new System.EventHandler(this.uiSymbolButton4_Click);
//
@ -397,7 +396,7 @@
this.uiSymbolButton5.StyleCustomMode = true;
this.uiSymbolButton5.Symbol = 61553;
this.uiSymbolButton5.TabIndex = 54;
this.uiSymbolButton5.Text = "Warn";
this.uiSymbolButton5.Text = "警告";
this.uiSymbolButton5.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton5.Click += new System.EventHandler(this.uiSymbolButton5_Click);
//
@ -423,7 +422,7 @@
this.uiSymbolButton6.StyleCustomMode = true;
this.uiSymbolButton6.Symbol = 61528;
this.uiSymbolButton6.TabIndex = 53;
this.uiSymbolButton6.Text = "Success";
this.uiSymbolButton6.Text = "成功";
this.uiSymbolButton6.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton6.Click += new System.EventHandler(this.uiSymbolButton6_Click);
//
@ -506,7 +505,7 @@
this.uiSymbolButton7.StyleCustomMode = true;
this.uiSymbolButton7.Symbol = 61532;
this.uiSymbolButton7.TabIndex = 64;
this.uiSymbolButton7.Text = "Error";
this.uiSymbolButton7.Text = "错误";
this.uiSymbolButton7.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton7.Click += new System.EventHandler(this.uiSymbolButton7_Click);
//
@ -532,7 +531,7 @@
this.uiSymbolButton8.StyleCustomMode = true;
this.uiSymbolButton8.Symbol = 61553;
this.uiSymbolButton8.TabIndex = 63;
this.uiSymbolButton8.Text = "Warn";
this.uiSymbolButton8.Text = "警告";
this.uiSymbolButton8.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton8.Click += new System.EventHandler(this.uiSymbolButton8_Click);
//
@ -558,7 +557,7 @@
this.uiSymbolButton9.StyleCustomMode = true;
this.uiSymbolButton9.Symbol = 61528;
this.uiSymbolButton9.TabIndex = 62;
this.uiSymbolButton9.Text = "Success";
this.uiSymbolButton9.Text = "成功";
this.uiSymbolButton9.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton9.Click += new System.EventHandler(this.uiSymbolButton9_Click);
//
@ -586,7 +585,7 @@
this.uiSymbolButton3.Size = new System.Drawing.Size(100, 35);
this.uiSymbolButton3.Symbol = 62144;
this.uiSymbolButton3.TabIndex = 68;
this.uiSymbolButton3.Text = "Login";
this.uiSymbolButton3.Text = "登录";
this.uiSymbolButton3.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton3.Click += new System.EventHandler(this.uiSymbolButton3_Click);
//
@ -601,7 +600,7 @@
this.uiSymbolButton10.Size = new System.Drawing.Size(100, 35);
this.uiSymbolButton10.Symbol = 61447;
this.uiSymbolButton10.TabIndex = 67;
this.uiSymbolButton10.Text = "Login";
this.uiSymbolButton10.Text = "登录";
this.uiSymbolButton10.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton10.Click += new System.EventHandler(this.uiSymbolButton10_Click);
//
@ -689,32 +688,11 @@
this.uiSymbolButton12.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton12.Click += new System.EventHandler(this.uiSymbolButton12_Click);
//
// uiPagination1
//
this.uiPagination1.ButtonFillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(128)))), ((int)(((byte)(204)))));
this.uiPagination1.ButtonStyleInherited = false;
this.uiPagination1.CausesValidation = false;
this.uiPagination1.Font = new System.Drawing.Font("宋体", 12F);
this.uiPagination1.Location = new System.Drawing.Point(258, 482);
this.uiPagination1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiPagination1.MinimumSize = new System.Drawing.Size(1, 1);
this.uiPagination1.Name = "uiPagination1";
this.uiPagination1.PagerCount = 11;
this.uiPagination1.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.uiPagination1.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
this.uiPagination1.ShowText = false;
this.uiPagination1.Size = new System.Drawing.Size(442, 35);
this.uiPagination1.TabIndex = 79;
this.uiPagination1.Text = "uiDataGridPage1";
this.uiPagination1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.uiPagination1.TotalCount = 40;
//
// FDialogs
//
this.AllowShowTitle = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(800, 590);
this.Controls.Add(this.uiPagination1);
this.Controls.Add(this.uiLine11);
this.Controls.Add(this.uiSymbolButton12);
this.Controls.Add(this.uiLine1);
@ -798,6 +776,5 @@
private UISymbolButton uiSymbolButton13;
private UILine uiLine11;
private UISymbolButton uiSymbolButton12;
private UIPagination uiPagination1;
}
}

View File

@ -19,56 +19,56 @@ namespace Sunny.UI.Demo
private void btnInfo_Click(object sender, EventArgs e)
{
this.ShowInfoDialog2("默认信息提示框");
this.ShowInfoDialog("默认信息提示框");
this.ShowInfoDialog2(CodeTranslator.Current.Default);
this.ShowInfoDialog(CodeTranslator.Current.Default);
}
private void btnAsk_Click(object sender, EventArgs e)
{
if (this.ShowAskDialog2("确认信息提示框", true))
if (this.ShowAskDialog2(CodeTranslator.Current.Confirm, true))
{
this.ShowSuccessTip("您点击了确定按钮");
this.ShowSuccessTip(CodeTranslator.Current.PressedOK);
}
else
{
this.ShowErrorTip("您点击了取消按钮");
this.ShowErrorTip(CodeTranslator.Current.PressedCancel);
}
if (this.ShowAskDialog("确认信息提示框"))
if (this.ShowAskDialog(CodeTranslator.Current.Confirm))
{
this.ShowSuccessTip("您点击了确定按钮");
this.ShowSuccessTip(CodeTranslator.Current.PressedOK);
}
else
{
this.ShowErrorTip("您点击了取消按钮");
this.ShowErrorTip(CodeTranslator.Current.PressedCancel);
}
}
private void btnSuccess_Click(object sender, EventArgs e)
{
this.ShowSuccessDialog2("正确信息提示框", false, 3000);
this.ShowSuccessDialog("正确信息提示框", false, 3000);
this.ShowSuccessDialog2(CodeTranslator.Current.Success, false, 3000);
this.ShowSuccessDialog(CodeTranslator.Current.Success, false, 3000);
}
private void btnWarn_Click(object sender, EventArgs e)
{
this.ShowWarningDialog2("警告信息提示框");
this.ShowWarningDialog("警告信息提示框");
this.ShowWarningDialog2(CodeTranslator.Current.Warning);
this.ShowWarningDialog(CodeTranslator.Current.Warning);
}
private void btnError_Click(object sender, EventArgs e)
{
this.ShowErrorDialog2("错误信息提示框");
this.ShowErrorDialog("错误信息提示框");
this.ShowErrorDialog2(CodeTranslator.Current.Error);
this.ShowErrorDialog(CodeTranslator.Current.Error);
}
private void btnStatus2_Click(object sender, EventArgs e)
{
this.ShowStatusForm(100, "数据加载中......", 0);
this.ShowStatusForm(100, CodeTranslator.Current.Loading + "......", 0);
for (int i = 0; i < 88; i++)
{
SystemEx.Delay(50);
this.SetStatusFormDescription("数据加载中(" + i + "%)......");
this.SetStatusFormDescription(CodeTranslator.Current.Loading + "(" + i + "%)......");
this.SetStatusFormStepIt();
}
@ -77,8 +77,8 @@ namespace Sunny.UI.Demo
private void btnStringInput_Click(object sender, EventArgs e)
{
string value = "请输入字符串";
if (this.ShowInputStringDialog(ref value, true, "请输入字符串:", true))
string value = CodeTranslator.Current.InputString;
if (this.ShowInputStringDialog(ref value, true, CodeTranslator.Current.InputString, true))
{
this.ShowInfoDialog(value);
}
@ -128,7 +128,7 @@ namespace Sunny.UI.Demo
private void InfoNotifierClick(object sender, EventArgs e)
{
this.ShowInfoTip("嗨,你点击了右下角的弹窗消息");
this.ShowInfoTip(CodeTranslator.Current.PressedNotifier);
}
private void uiSymbolButton6_Click(object sender, EventArgs e)
@ -148,17 +148,17 @@ namespace Sunny.UI.Demo
private void uiSymbolButton9_Click(object sender, EventArgs e)
{
this.ShowSuccessTip("轻便消息提示框 - 成功");
this.ShowSuccessTip(CodeTranslator.Current.Success);
}
private void uiSymbolButton8_Click(object sender, EventArgs e)
{
this.ShowWarningTip("轻便消息提示框 - 警告");
this.ShowWarningTip(CodeTranslator.Current.Warning);
}
private void uiSymbolButton7_Click(object sender, EventArgs e)
{
this.ShowErrorTip("轻便消息提示框 - 错误");
this.ShowErrorTip(CodeTranslator.Current.Error);
}
private void uiSymbolButton10_Click(object sender, EventArgs e)
@ -167,7 +167,7 @@ namespace Sunny.UI.Demo
frm.ShowDialog();
if (frm.IsLogin)
{
UIMessageTip.ShowOk("登录成功");
UIMessageTip.ShowOk(CodeTranslator.Current.LoginSuccess);
}
frm.Dispose();
@ -188,7 +188,7 @@ namespace Sunny.UI.Demo
frm.ShowDialog();
if (frm.IsLogin)
{
UIMessageTip.ShowOk("登录成功");
UIMessageTip.ShowOk(CodeTranslator.Current.LoginSuccess);
}
frm.Dispose();
@ -201,24 +201,24 @@ namespace Sunny.UI.Demo
private void uiSymbolButton11_Click(object sender, EventArgs e)
{
this.ShowWaitForm("准备开始...");
this.ShowWaitForm(CodeTranslator.Current.Prepare);
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "20%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "20%");
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "40%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "40%");
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "60%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "60%");
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "80%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "80%");
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "100%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "100%");
this.HideWaitForm();
}
private void uiSymbolButton13_Click(object sender, EventArgs e)
{
string dir = "";
if (DirEx.SelectDirEx("扩展打开文件夹", ref dir))
if (DirEx.SelectDirEx(CodeTranslator.Current.OpenDir, ref dir))
{
UIMessageTip.ShowOk(dir);
}
@ -233,29 +233,40 @@ namespace Sunny.UI.Demo
private void btnCH_Click(object sender, EventArgs e)
{
UILocalizeHelper.SetCH();
LoginText = "登录";
UIStyles.Translate();
UIStyles.CultureInfo = CultureInfos.zh_CN;
}
private void btnEN_Click(object sender, EventArgs e)
{
UILocalizeHelper.SetEN();
LoginText = "Login";
UIStyles.Translate();
UIStyles.CultureInfo = CultureInfos.en_US;
}
private string LoginText = "登录";
public void Translate()
/// <summary>
/// 重载多语翻译
/// </summary>
public override void Translate()
{
uiSymbolButton6.Text = btnSuccess.Text = uiSymbolButton9.Text = UILocalize.SuccessTitle;
uiSymbolButton5.Text = btnWarn.Text = uiSymbolButton8.Text = UILocalize.WarningTitle;
uiSymbolButton4.Text = btnError.Text = uiSymbolButton7.Text = UILocalize.ErrorTitle;
uiSymbolButton2.Text = btnInfo.Text = UILocalize.InfoTitle;
btnAsk.Text = UILocalize.AskTitle;
//必须保留
base.Translate();
//读取翻译代码中的多语资源
CodeTranslator.Load(this);
}
uiSymbolButton3.Text = uiSymbolButton10.Text = LoginText;
private class CodeTranslator : IniCodeTranslator<CodeTranslator>
{
public string Default { get; set; } = "默认信息提示框";
public string Confirm { get; set; } = "确认信息提示框";
public string PressedOK { get; set; } = "您点击了确定按钮";
public string PressedCancel { get; set; } = "您点击了取消按钮";
public string Success { get; set; } = "正确信息提示框";
public string Warning { get; set; } = "警告信息提示框";
public string Error { get; set; } = "错误信息提示框";
public string Loading { get; set; } = "数据加载中";
public string InputString { get; set; } = "请输入字符串";
public string PressedNotifier { get; set; } = "嗨,你点击了右下角的弹窗消息";
public string LoginSuccess { get; set; } = "登录成功";
public string Prepare { get; set; } = "准备开始";
public string OpenDir { get; set; } = "打开文件夹";
}
}
}

View File

@ -13,6 +13,13 @@ namespace Sunny.UI.Demo
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//增加一个繁体中文的内置资源配置
UIStyles.BuiltInResources.TryAdd(CultureInfos.zh_TW.LCID, new zh_TW_Resources());
//从项目方案生成多语言配置文件生成文件在可执行文件夹的Language目录下
//生成后界面没有修改的情况下,可注释掉下一行,只运行一次即可
//TranslateHelper.LoadCsproj(@"D:\Source\SunnyUI\SunnyUI.Demo\SunnyUI.Demo.csproj");
Application.Run(new FMain());
}
}

View File

@ -600,6 +600,16 @@ namespace Sunny.UI.Demo.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap Sunny24 {
get {
object obj = ResourceManager.GetObject("Sunny24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -623,9 +633,9 @@ namespace Sunny.UI.Demo.Properties {
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap SunnyUISmall {
internal static System.Drawing.Bitmap SunnyUI72 {
get {
object obj = ResourceManager.GetObject("SunnyUISmall", resourceCulture);
object obj = ResourceManager.GetObject("SunnyUI72", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

View File

@ -253,14 +253,17 @@
<data name="sevilla" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\sevilla.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Sunny24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Sunny24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SunnyLogin" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SunnyLogin.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SunnyUI" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SunnyUI.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SunnyUISmall" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SunnyUISmall.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="SunnyUI72" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SunnyUI72.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Tom" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Tom.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -41,20 +41,20 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="SunnyUI, Version=3.7.0.0, Culture=neutral, PublicKeyToken=27d7d2e821d97aeb, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.3.7.0\lib\net472\SunnyUI.dll</HintPath>
<Reference Include="SunnyUI, Version=3.7.2.0, Culture=neutral, PublicKeyToken=27d7d2e821d97aeb, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.3.7.2\lib\net472\SunnyUI.dll</HintPath>
</Reference>
<Reference Include="SunnyUI.COM, Version=6.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.COM.6.3.3\lib\net472\SunnyUI.COM.dll</HintPath>
</Reference>
<Reference Include="SunnyUI.Common, Version=3.7.0.0, Culture=neutral, PublicKeyToken=5a271fb7ba597231, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.Common.3.7.0\lib\net472\SunnyUI.Common.dll</HintPath>
<Reference Include="SunnyUI.Common, Version=3.7.2.0, Culture=neutral, PublicKeyToken=5a271fb7ba597231, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.Common.3.7.2\lib\net472\SunnyUI.Common.dll</HintPath>
</Reference>
<Reference Include="SunnyUI.FrameDecoder, Version=7.1.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.FrameDecoder.7.1.6\lib\net472\SunnyUI.FrameDecoder.dll</HintPath>
</Reference>
<Reference Include="SunnyUI.Serialization, Version=6.3.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.Serialization.6.3.5\lib\net472\SunnyUI.Serialization.dll</HintPath>
<Reference Include="SunnyUI.Serialization, Version=6.3.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.Serialization.6.3.6\lib\net472\SunnyUI.Serialization.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@ -416,6 +416,7 @@
<DependentUpon>FCommon.cs</DependentUpon>
</Compile>
<Compile Include="Units\UMapperDemo.cs" />
<Compile Include="Units\UZhTW.cs" />
<EmbeddedResource Include="Charts\FDoughnutChart.resx">
<DependentUpon>FDoughnutChart.cs</DependentUpon>
</EmbeddedResource>
@ -772,6 +773,8 @@
<None Include="Resources\9.png" />
<None Include="Resources\Home_32x32.png" />
<None Include="Resources\Tom.gif" />
<None Include="Resources\Sunny24.png" />
<None Include="Resources\SunnyUI72.png" />
<Content Include="SunnyUI.ico" />
</ItemGroup>
<ItemGroup />

View File

@ -0,0 +1,55 @@
using System.Globalization;
namespace Sunny.UI.Demo
{
/// <summary>
/// 多語言字符串定義
/// </summary>
public class zh_TW_Resources : UIBuiltInResources
{
public override CultureInfo CultureInfo { get; } = CultureInfos.zh_TW;
public override string InfoTitle { get; set; } = "提示";
public override string SuccessTitle { get; set; } = "正確";
public override string WarningTitle { get; set; } = "警告";
public override string ErrorTitle { get; set; } = "錯誤";
public override string AskTitle { get; set; } = "提示";
public override string InputTitle { get; set; } = "輸入";
public override string SelectTitle { get; set; } = "選擇";
public override string CloseAll { get; set; } = "全部關閉";
public override string OK { get; set; } = "確定";
public override string Cancel { get; set; } = "取消";
public override string GridNoData { get; set; } = "[ 無資料 ]";
public override string GridDataLoading { get; set; } = "資料加載中,請稍候...";
public override string GridDataSourceException { get; set; } = "資料源必須為DataTable或者List";
public override string SystemProcessing { get; set; } = "系統正在處理中,請稍候...";
public override string Monday { get; set; } = "一";
public override string Tuesday { get; set; } = "二";
public override string Wednesday { get; set; } = "三";
public override string Thursday { get; set; } = "四";
public override string Friday { get; set; } = "五";
public override string Saturday { get; set; } = "六";
public override string Sunday { get; set; } = "日";
public override string Prev { get; set; } = "上一頁";
public override string Next { get; set; } = "下一頁";
public override string SelectPageLeft { get; set; } = "第";
public override string SelectPageRight { get; set; } = "頁";
public override string January { get; set; } = "一月";
public override string February { get; set; } = "二月";
public override string March { get; set; } = "三月";
public override string April { get; set; } = "四月";
public override string May { get; set; } = "五月";
public override string June { get; set; } = "六月";
public override string July { get; set; } = "七月";
public override string August { get; set; } = "八月";
public override string September { get; set; } = "九月";
public override string October { get; set; } = "十月";
public override string November { get; set; } = "十一月";
public override string December { get; set; } = "十二月";
public override string Today { get; set; } = "今天";
public override string Search { get; set; } = "搜尋";
public override string Clear { get; set; } = "清除";
public override string Open { get; set; } = "打開";
public override string Save { get; set; } = "保存";
public override string All { get; set; } = "全部";
}
}

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SunnyUI" version="3.7.0" targetFramework="net472" />
<package id="SunnyUI" version="3.7.2" targetFramework="net472" />
<package id="SunnyUI.COM" version="6.3.3" targetFramework="net472" />
<package id="SunnyUI.Common" version="3.7.0" targetFramework="net472" />
<package id="SunnyUI.Common" version="3.7.2" targetFramework="net472" />
<package id="SunnyUI.FrameDecoder" version="7.1.6" targetFramework="net472" />
<package id="SunnyUI.Serialization" version="6.3.5" targetFramework="net472" />
<package id="SunnyUI.Serialization" version="6.3.6" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />

View File

@ -6,6 +6,7 @@ namespace Sunny.UI
{
//语言文件对应ID网址
//https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms912047(v=winembedded.10)?redirectedfrom=MSDN
//https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c
//ID语言 ID语言
//1025 阿拉伯语
//1041 日语
@ -32,7 +33,6 @@ namespace Sunny.UI
//1038 匈牙利语
//2070 葡萄牙语
//1040 意大利语
//3076 汉语 - 香港
/// <summary>
/// 2052 简体中文

View File

@ -91,7 +91,6 @@ namespace Sunny.UI
private static Dictionary<string, string> NativeControlsProperty = new Dictionary<string, string>()
{
["Button"] = "Text",
["ToolStripMenuItem"] = "Text",
["CheckBox"] = "Text",
["RadioButton"] = "Text",
["GroupBox"] = "Text",
@ -217,12 +216,9 @@ namespace Sunny.UI
int count = ini.ReadInt("Controls", "Count", 0);
if (count == 0) return;
string key = UIStyles.CultureInfo.LCID.ToString() + ".DisplayName";
if (ini.Read(section, key, "") != UIStyles.CultureInfo.DisplayName)
ini.Write(section, key, UIStyles.CultureInfo.DisplayName);
key = UIStyles.CultureInfo.LCID.ToString() + ".EnglishName";
if (ini.Read(section, key, "") != UIStyles.CultureInfo.EnglishName)
ini.Write(section, key, UIStyles.CultureInfo.EnglishName);
string key = UIStyles.CultureInfo.LCID.ToString() + ".Name";
if (ini.Read(section, key, "") != UIStyles.CultureInfo.Name)
ini.Write(section, key, UIStyles.CultureInfo.Name);
Dictionary<string, CtrlInfo> Ctrls2 = new Dictionary<string, CtrlInfo>();
Dictionary<string, CtrlInfo> Ctrls3 = new Dictionary<string, CtrlInfo>();
@ -357,12 +353,9 @@ namespace Sunny.UI
ini.Write(section, "Warning", warning);
}
string key = UIStyles.CultureInfo.LCID.ToString() + ".DisplayName";
if (ini.Read(section, key, "") != UIStyles.CultureInfo.DisplayName)
ini.Write(section, key, UIStyles.CultureInfo.DisplayName);
key = UIStyles.CultureInfo.LCID.ToString() + ".EnglishName";
if (ini.Read(section, key, "") != UIStyles.CultureInfo.EnglishName)
ini.Write(section, key, UIStyles.CultureInfo.EnglishName);
string key = UIStyles.CultureInfo.LCID.ToString() + ".Name";
if (ini.Read(section, key, "") != UIStyles.CultureInfo.Name)
ini.Write(section, key, UIStyles.CultureInfo.Name);
ConcurrentDictionary<string, Ident> idents = InitIdents(current);

View File

@ -9,7 +9,7 @@
<Description>SunnyUI.Net 是基于.Net Framework4.0+、.Net6、.Net8 框架的 C# WinForm 开源控件库、工具类库、扩展类库、多页面开发框架。</Description>
<Copyright>CopyRight © SunnyUI.Net 2012-2024</Copyright>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
<Version>3.7.0.0</Version>
<Version>3.7.2.0</Version>
<Authors>ShenYonghua</Authors>
<Company>SunnyUI.Net</Company>
<PackageId>SunnyUI</PackageId>
@ -72,7 +72,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SunnyUI.Common" Version="3.7.0" />
<PackageReference Include="SunnyUI.Common" Version="3.7.2" />
</ItemGroup>
<ItemGroup>