* UIBaseForm: 增加属性IconImage,以改善Icon转Image显示不佳,状态栏显示仍然用Icon属性

This commit is contained in:
Sunny 2024-10-05 22:11:46 +08:00
parent e67f03d9da
commit a411027eb1
39 changed files with 65 additions and 99 deletions

View File

@ -98,7 +98,6 @@ namespace Sunny.UI
TopPanel.Name = "TopPanel";
TopPanel.RadiusSides = UICornerRadiusSides.None;
TopPanel.RectSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right;
TopPanel.ShowBuiltInResources = true;
TopPanel.Size = new Size(461, 31);
TopPanel.TabIndex = 0;
TopPanel.Text = "2020-05-05";
@ -117,7 +116,6 @@ namespace Sunny.UI
b4.Padding = new Padding(24, 0, 0, 0);
b4.RadiusSides = UICornerRadiusSides.None;
b4.RectSides = ToolStripStatusLabelBorderSides.None;
b4.ShowBuiltInResources = true;
b4.Size = new Size(30, 24);
b4.Style = UIStyle.Custom;
b4.Symbol = 61697;
@ -137,7 +135,6 @@ namespace Sunny.UI
b3.Padding = new Padding(24, 0, 0, 0);
b3.RadiusSides = UICornerRadiusSides.None;
b3.RectSides = ToolStripStatusLabelBorderSides.None;
b3.ShowBuiltInResources = true;
b3.Size = new Size(30, 24);
b3.Style = UIStyle.Custom;
b3.Symbol = 61701;
@ -156,7 +153,6 @@ namespace Sunny.UI
b2.Padding = new Padding(24, 0, 0, 0);
b2.RadiusSides = UICornerRadiusSides.None;
b2.RectSides = ToolStripStatusLabelBorderSides.None;
b2.ShowBuiltInResources = true;
b2.Size = new Size(30, 24);
b2.Style = UIStyle.Custom;
b2.Symbol = 61700;
@ -175,7 +171,6 @@ namespace Sunny.UI
b1.Padding = new Padding(24, 0, 0, 0);
b1.RadiusSides = UICornerRadiusSides.None;
b1.RectSides = ToolStripStatusLabelBorderSides.None;
b1.ShowBuiltInResources = true;
b1.Size = new Size(30, 24);
b1.Style = UIStyle.Custom;
b1.Symbol = 61696;
@ -223,7 +218,6 @@ namespace Sunny.UI
p1.MinimumSize = new Size(1, 1);
p1.Name = "p1";
p1.RadiusSides = UICornerRadiusSides.None;
p1.ShowBuiltInResources = true;
p1.Size = new Size(461, 277);
p1.TabIndex = 0;
p1.Text = null;
@ -253,7 +247,6 @@ namespace Sunny.UI
p2.MinimumSize = new Size(1, 1);
p2.Name = "p2";
p2.RadiusSides = UICornerRadiusSides.None;
p2.ShowBuiltInResources = true;
p2.Size = new Size(461, 277);
p2.TabIndex = 1;
p2.Text = null;
@ -283,7 +276,6 @@ namespace Sunny.UI
p3.MinimumSize = new Size(1, 1);
p3.Name = "p3";
p3.RadiusSides = UICornerRadiusSides.None;
p3.ShowBuiltInResources = true;
p3.Size = new Size(461, 277);
p3.TabIndex = 2;
p3.Text = null;
@ -299,7 +291,6 @@ namespace Sunny.UI
Controls.Add(TopPanel);
FillColor = Color.White;
Name = "UICalendar";
ShowBuiltInResources = true;
Size = new Size(461, 348);
TopPanel.ResumeLayout(false);
TabControl.ResumeLayout(false);

View File

@ -50,7 +50,6 @@ namespace Sunny.UI
//
DropDownStyle = UIDropDownStyle.DropDownList;
Name = "UIColorPicker";
ShowBuiltInResources = true;
ButtonClick += UIColorPicker_ButtonClick;
ResumeLayout(false);
PerformLayout();

View File

@ -43,7 +43,6 @@
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
Name = "UIComboBox";
ShowBuiltInResources = true;
KeyDown += UIComboBox_KeyDown;
ButtonClick += UIComboBox_ButtonClick;
FontChanged += UIComboBox_FontChanged;

View File

@ -52,7 +52,6 @@ namespace Sunny.UI
//
DropDownStyle = UIDropDownStyle.DropDownList;
Name = "UIComboDataGridView";
ShowBuiltInResources = true;
ButtonClick += UIComboDataGridView_ButtonClick;
ResumeLayout(false);
PerformLayout();

View File

@ -59,7 +59,6 @@ namespace Sunny.UI
//
DropDownStyle = UIDropDownStyle.DropDownList;
Name = "UIComboTreeView";
ShowBuiltInResources = true;
ButtonClick += UIComboTreeView_ButtonClick;
ResumeLayout(false);
PerformLayout();

View File

@ -58,9 +58,9 @@ namespace Sunny.UI
[Description("控件在界面显示时需要多语翻译的属性名称数组"), Category("SunnyUI")]
public virtual string[] FormTranslatorProperties { get; }
[DefaultValue(false)]
[Description("控件是否显示多语内置资源"), Category("SunnyUI")]
public bool ShowBuiltInResources { get; set; } = false;
[DefaultValue(true)]
[Description("控件在界面显示时需要多语翻译"), Category("SunnyUI")]
public bool MultiLanguageSupport { get; set; } = true;
[Browsable(false)]
public bool Disabled => !Enabled;

View File

@ -36,7 +36,6 @@
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
Name = "UIDatePicker";
ShowBuiltInResources = true;
SymbolDropDown = 61555;
SymbolNormal = 61555;
ButtonClick += UIDatetimePicker_ButtonClick;

View File

@ -46,7 +46,6 @@ namespace Sunny.UI
// UIDatetimePicker
//
Name = "UIDatetimePicker";
ShowBuiltInResources = true;
SymbolDropDown = 61555;
SymbolNormal = 61555;
ButtonClick += UIDatetimePicker_ButtonClick;

View File

@ -45,7 +45,6 @@
btnDec.Name = "btnDec";
btnDec.Padding = new System.Windows.Forms.Padding(26, 4, 0, 0);
btnDec.RadiusSides = UICornerRadiusSides.LeftTop | UICornerRadiusSides.LeftBottom;
btnDec.ShowBuiltInResources = true;
btnDec.Size = new System.Drawing.Size(29, 29);
btnDec.Symbol = 61544;
btnDec.TabIndex = 0;
@ -65,7 +64,6 @@
btnAdd.Name = "btnAdd";
btnAdd.Padding = new System.Windows.Forms.Padding(26, 3, 0, 0);
btnAdd.RadiusSides = UICornerRadiusSides.RightTop | UICornerRadiusSides.RightBottom;
btnAdd.ShowBuiltInResources = true;
btnAdd.Size = new System.Drawing.Size(29, 29);
btnAdd.Symbol = 61543;
btnAdd.TabIndex = 1;
@ -83,7 +81,6 @@
pnlValue.Name = "pnlValue";
pnlValue.RadiusSides = UICornerRadiusSides.None;
pnlValue.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Top | System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom;
pnlValue.ShowBuiltInResources = true;
pnlValue.Size = new System.Drawing.Size(58, 29);
pnlValue.TabIndex = 2;
pnlValue.Text = "0";
@ -98,7 +95,6 @@
Controls.Add(btnDec);
MinimumSize = new System.Drawing.Size(100, 0);
Name = "UIDoubleUpDown";
ShowBuiltInResources = true;
Size = new System.Drawing.Size(116, 29);
ResumeLayout(false);
}

View File

@ -538,7 +538,6 @@ namespace Sunny.UI
VBar.Location = new Point(410, 5);
VBar.MinimumSize = new Size(1, 1);
VBar.Name = "VBar";
VBar.ShowBuiltInResources = true;
VBar.Size = new Size(18, 377);
VBar.TabIndex = 1;
VBar.TagString = "63FD1249-41D3-E08A-F8F5-CC41CC30FD03";
@ -551,7 +550,6 @@ namespace Sunny.UI
HBar.Location = new Point(5, 364);
HBar.MinimumSize = new Size(1, 1);
HBar.Name = "HBar";
HBar.ShowBuiltInResources = true;
HBar.Size = new Size(399, 18);
HBar.TabIndex = 2;
HBar.TagString = "79E1E7DD-3E4D-916B-C8F1-F45B579C290C";
@ -565,7 +563,6 @@ namespace Sunny.UI
Controls.Add(flowLayoutPanel);
Name = "UIFlowLayoutPanel";
Padding = new Padding(2);
ShowBuiltInResources = true;
Size = new Size(433, 387);
ResumeLayout(false);
}

View File

@ -422,7 +422,6 @@ namespace Sunny.UI
FillColor2 = Color.FromArgb(235, 243, 255);
Name = "UIIPTextBox";
Padding = new Padding(1);
ShowBuiltInResources = true;
Size = new Size(219, 29);
SizeChanged += UIIPTextBox_SizeChanged;
ResumeLayout(false);

View File

@ -52,9 +52,9 @@ namespace Sunny.UI
[Description("控件在界面显示时需要多语翻译的属性名称数组"), Category("SunnyUI")]
public string[] FormTranslatorProperties => ["Text"];
[DefaultValue(false)]
[Description("控件是否显示多语内置资源"), Category("SunnyUI")]
public bool ShowBuiltInResources { get; set; } = false;
[DefaultValue(true)]
[Description("控件在界面显示时需要多语翻译"), Category("SunnyUI")]
public bool MultiLanguageSupport { get; set; } = true;
/// <summary>

View File

@ -45,7 +45,6 @@
btnDec.Name = "btnDec";
btnDec.Padding = new System.Windows.Forms.Padding(26, 4, 0, 0);
btnDec.RadiusSides = UICornerRadiusSides.LeftTop | UICornerRadiusSides.LeftBottom;
btnDec.ShowBuiltInResources = true;
btnDec.Size = new System.Drawing.Size(29, 29);
btnDec.Symbol = 61544;
btnDec.TabIndex = 0;
@ -65,7 +64,6 @@
btnAdd.Name = "btnAdd";
btnAdd.Padding = new System.Windows.Forms.Padding(26, 3, 0, 0);
btnAdd.RadiusSides = UICornerRadiusSides.RightTop | UICornerRadiusSides.RightBottom;
btnAdd.ShowBuiltInResources = true;
btnAdd.Size = new System.Drawing.Size(29, 29);
btnAdd.Symbol = 61543;
btnAdd.TabIndex = 1;
@ -83,7 +81,6 @@
pnlValue.Name = "pnlValue";
pnlValue.RadiusSides = UICornerRadiusSides.None;
pnlValue.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Top | System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom;
pnlValue.ShowBuiltInResources = true;
pnlValue.Size = new System.Drawing.Size(58, 29);
pnlValue.TabIndex = 2;
pnlValue.Text = "0";
@ -98,7 +95,6 @@
Controls.Add(btnDec);
MinimumSize = new System.Drawing.Size(100, 0);
Name = "UIIntegerUpDown";
ShowBuiltInResources = true;
Size = new System.Drawing.Size(116, 29);
ResumeLayout(false);
}

View File

@ -47,9 +47,9 @@ namespace Sunny.UI
[Description("控件在界面显示时需要多语翻译的属性名称数组"), Category("SunnyUI")]
public string[] FormTranslatorProperties => ["Text"];
[DefaultValue(false)]
[Description("控件是否显示多语内置资源"), Category("SunnyUI")]
public bool ShowBuiltInResources { get; set; } = false;
[DefaultValue(true)]
[Description("控件在界面显示时需要多语翻译"), Category("SunnyUI")]
public bool MultiLanguageSupport { get; set; } = true;
/// <summary>
/// 禁止控件跟随窗体缩放
@ -186,9 +186,9 @@ namespace Sunny.UI
[Description("控件在界面显示时需要多语翻译的属性名称数组"), Category("SunnyUI")]
public string[] FormTranslatorProperties => ["Text"];
[DefaultValue(false)]
[Description("控件是否显示多语内置资源"), Category("SunnyUI")]
public bool ShowBuiltInResources { get; set; } = false;
[DefaultValue(true)]
[Description("控件在界面显示时需要多语翻译"), Category("SunnyUI")]
public bool MultiLanguageSupport { get; set; } = true;
/// <summary>
/// 禁止控件跟随窗体缩放

View File

@ -109,7 +109,6 @@ namespace Sunny.UI
buttons[i].MouseLeave += UIDataGridPage_MouseLeave;
buttons[i].Click += UIDataGridPage_Click;
buttons[i].Size = new System.Drawing.Size(32, 32);
buttons[i].ShowBuiltInResources = true;
}
buttonTags.TryAdd(b0, -1);
@ -600,7 +599,6 @@ namespace Sunny.UI
Name = "UIMiniPagination";
RadiusSides = UICornerRadiusSides.None;
RectSides = ToolStripStatusLabelBorderSides.None;
ShowBuiltInResources = true;
Size = new Size(641, 40);
ResumeLayout(false);
}

View File

@ -270,7 +270,6 @@ namespace Sunny.UI
// UINumPadTextBox
//
Name = "UINumPadTextBox";
ShowBuiltInResources = true;
ButtonClick += UIKeyBoardTextBox_ButtonClick;
ResumeLayout(false);
PerformLayout();

View File

@ -114,7 +114,6 @@ namespace Sunny.UI
buttons[i].MouseEnter += UIDataGridPage_MouseEnter;
buttons[i].MouseLeave += UIDataGridPage_MouseLeave;
buttons[i].Click += UIDataGridPage_Click;
buttons[i].ShowBuiltInResources = true;
}
buttonTags.TryAdd(b0, -1);
@ -647,7 +646,6 @@ namespace Sunny.UI
edtPage.MinimumSize = new Size(1, 1);
edtPage.Name = "edtPage";
edtPage.Padding = new Padding(5);
edtPage.ShowBuiltInResources = true;
edtPage.ShowText = false;
edtPage.Size = new Size(53, 29);
edtPage.TabIndex = 1;
@ -663,7 +661,6 @@ namespace Sunny.UI
btnSelect.Location = new Point(756, 3);
btnSelect.MinimumSize = new Size(1, 1);
btnSelect.Name = "btnSelect";
btnSelect.ShowBuiltInResources = true;
btnSelect.Size = new Size(61, 29);
btnSelect.Symbol = 0;
btnSelect.TabIndex = 3;
@ -679,7 +676,6 @@ namespace Sunny.UI
uiLabel2.ForeColor = Color.FromArgb(48, 48, 48);
uiLabel2.Location = new Point(726, 10);
uiLabel2.Name = "uiLabel2";
uiLabel2.ShowBuiltInResources = true;
uiLabel2.Size = new Size(21, 14);
uiLabel2.TabIndex = 2;
uiLabel2.Text = "页";
@ -693,7 +689,6 @@ namespace Sunny.UI
uiLabel1.ForeColor = Color.FromArgb(48, 48, 48);
uiLabel1.Location = new Point(650, 10);
uiLabel1.Name = "uiLabel1";
uiLabel1.ShowBuiltInResources = true;
uiLabel1.Size = new Size(21, 14);
uiLabel1.TabIndex = 0;
uiLabel1.Text = "第";
@ -724,7 +719,6 @@ namespace Sunny.UI
Controls.Add(b0);
Name = "UIPagination";
RectSides = ToolStripStatusLabelBorderSides.None;
ShowBuiltInResources = true;
Size = new Size(1139, 35);
ResumeLayout(false);
PerformLayout();

View File

@ -530,7 +530,6 @@ namespace Sunny.UI
bar.Location = new Point(247, 4);
bar.MinimumSize = new Size(1, 1);
bar.Name = "bar";
bar.ShowBuiltInResources = true;
bar.Size = new Size(19, 173);
bar.TabIndex = 2;
bar.Text = "uiScrollBar1";
@ -542,7 +541,6 @@ namespace Sunny.UI
FillColor = Color.White;
Name = "UIRichTextBox";
Padding = new Padding(2);
ShowBuiltInResources = true;
FontChanged += UIRichTextBox_FontChanged;
SizeChanged += UIRichTextBox_SizeChanged;
ResumeLayout(false);

View File

@ -59,9 +59,9 @@ namespace Sunny.UI
[Description("控件在界面显示时需要多语翻译的属性名称数组"), Category("SunnyUI")]
public string[] FormTranslatorProperties => ["Text"];
[DefaultValue(false)]
[Description("控件是否显示多语内置资源"), Category("SunnyUI")]
public bool ShowBuiltInResources { get; set; } = false;
[DefaultValue(true)]
[Description("控件在界面显示时需要多语翻译"), Category("SunnyUI")]
public bool MultiLanguageSupport { get; set; } = true;
protected override void Dispose(bool disposing)
{

View File

@ -41,7 +41,6 @@
Cursor = System.Windows.Forms.Cursors.IBeam;
Name = "UITextBox";
Padding = new System.Windows.Forms.Padding(5);
ShowBuiltInResources = true;
Size = new System.Drawing.Size(250, 29);
ResumeLayout(false);
}

View File

@ -131,7 +131,6 @@ namespace Sunny.UI
btn.Click += Btn_Click;
btn.Radius = 3;
btn.SymbolOffset = new Point(-1, 1);
btn.ShowBuiltInResources = true;
edit.Invalidate();
Controls.Add(edit);
@ -142,7 +141,6 @@ namespace Sunny.UI
bar.Visible = false;
bar.ValueChanged += Bar_ValueChanged;
bar.MouseEnter += Bar_MouseEnter;
bar.ShowBuiltInResources = true;
TextAlignment = ContentAlignment.MiddleLeft;
lastEditHeight = edit.Height;

View File

@ -41,7 +41,6 @@ namespace Sunny.UI
// UITimePicker
//
Name = "UITimePicker";
ShowBuiltInResources = true;
SymbolDropDown = 61555;
SymbolNormal = 61555;
ButtonClick += UITimePicker_ButtonClick;

View File

@ -48,7 +48,6 @@ namespace Sunny.UI
b1.MinimumSize = new System.Drawing.Size(1, 1);
b1.Name = "b1";
b1.Padding = new Padding(28, 0, 0, 0);
b1.ShowBuiltInResources = true;
b1.Size = new System.Drawing.Size(44, 32);
b1.Symbol = 61697;
b1.TabIndex = 3;
@ -66,7 +65,6 @@ namespace Sunny.UI
b2.MinimumSize = new System.Drawing.Size(1, 1);
b2.Name = "b2";
b2.Padding = new Padding(28, 0, 0, 0);
b2.ShowBuiltInResources = true;
b2.Size = new System.Drawing.Size(44, 32);
b2.Symbol = 61701;
b2.TabIndex = 4;
@ -84,7 +82,6 @@ namespace Sunny.UI
b3.MinimumSize = new System.Drawing.Size(1, 1);
b3.Name = "b3";
b3.Padding = new Padding(28, 0, 0, 0);
b3.ShowBuiltInResources = true;
b3.Size = new System.Drawing.Size(44, 32);
b3.Symbol = 61700;
b3.TabIndex = 5;
@ -102,7 +99,6 @@ namespace Sunny.UI
b4.MinimumSize = new System.Drawing.Size(1, 1);
b4.Name = "b4";
b4.Padding = new Padding(28, 0, 0, 0);
b4.ShowBuiltInResources = true;
b4.Size = new System.Drawing.Size(44, 32);
b4.Symbol = 61696;
b4.TabIndex = 6;
@ -124,7 +120,6 @@ namespace Sunny.UI
l1.Name = "l1";
l1.Padding = new Padding(2);
l1.SelectionMode = SelectionMode.MultiExtended;
l1.ShowBuiltInResources = true;
l1.ShowText = false;
l1.Size = new System.Drawing.Size(210, 348);
l1.TabIndex = 7;
@ -146,7 +141,6 @@ namespace Sunny.UI
l2.Name = "l2";
l2.Padding = new Padding(2);
l2.SelectionMode = SelectionMode.MultiExtended;
l2.ShowBuiltInResources = true;
l2.ShowText = false;
l2.Size = new System.Drawing.Size(210, 348);
l2.TabIndex = 8;
@ -168,7 +162,6 @@ namespace Sunny.UI
Padding = new Padding(1);
RadiusSides = UICornerRadiusSides.None;
RectSides = ToolStripStatusLabelBorderSides.None;
ShowBuiltInResources = true;
Size = new System.Drawing.Size(500, 350);
ResumeLayout(false);
}

View File

@ -958,7 +958,6 @@ namespace Sunny.UI
Bar.Location = new Point(247, 3);
Bar.MinimumSize = new Size(1, 1);
Bar.Name = "Bar";
Bar.ShowBuiltInResources = true;
Bar.Size = new Size(19, 173);
Bar.Style = UIStyle.Custom;
Bar.StyleCustomMode = true;
@ -986,7 +985,6 @@ namespace Sunny.UI
Controls.Add(view);
FillColor = Color.White;
Name = "UITreeView";
ShowBuiltInResources = true;
ResumeLayout(false);
}

View File

@ -58,9 +58,9 @@ namespace Sunny.UI
[Description("控件在界面显示时需要多语翻译的属性名称数组"), Category("SunnyUI")]
public virtual string[] FormTranslatorProperties { get; }
[DefaultValue(false)]
[Description("控件是否显示多语内置资源"), Category("SunnyUI")]
public bool ShowBuiltInResources { get; set; } = false;
[DefaultValue(true)]
[Description("控件在界面显示时需要多语翻译"), Category("SunnyUI")]
public bool MultiLanguageSupport { get; set; } = true;
protected override void OnClick(EventArgs e)
{

View File

@ -18,6 +18,7 @@
*
* 2024-04-29: V3.6.5
* 2024-04-29: V3.6.5 ShowTitleIcon使ShowIcon
* 2024-10-05: V3.7.0 IconImageIcon转Image显示不佳Icon属性
******************************************************************************/
using System;
@ -152,7 +153,7 @@ namespace Sunny.UI
if (UIStyles.Style.IsValid())
SetInheritedStyle(UIStyles.Style);
if (!ShowBuiltInResources)
if (UIStyles.MultiLanguageSupport)
Translate();
}
@ -202,6 +203,10 @@ namespace Sunny.UI
return image;
}
[Description("标题栏图标图片状态栏显示仍然用Icon属性"), Category("SunnyUI")]
[DefaultValue(null)]
public Image IconImage { get; set; }
private StringAlignment textAlignment = StringAlignment.Near;
[Description("文字对齐方式"), Category("SunnyUI")]
@ -1066,9 +1071,9 @@ namespace Sunny.UI
#endregion IFrame实现
[DefaultValue(false)]
[Description("控件是否显示多语内置资源"), Category("SunnyUI")]
public bool ShowBuiltInResources { get; set; } = false;
[DefaultValue(true)]
[Description("控件在界面显示时需要多语翻译"), Category("SunnyUI")]
public bool MultiLanguageSupport { get; set; } = true;
public virtual void Translate()
{

View File

@ -62,7 +62,6 @@
btnCancel.MinimumSize = new System.Drawing.Size(1, 1);
btnCancel.Name = "btnCancel";
btnCancel.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
btnCancel.ShowBuiltInResources = true;
btnCancel.ShowFocusColor = true;
btnCancel.Size = new System.Drawing.Size(100, 35);
btnCancel.Symbol = 361453;
@ -82,7 +81,6 @@
btnOK.MinimumSize = new System.Drawing.Size(1, 1);
btnOK.Name = "btnOK";
btnOK.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
btnOK.ShowBuiltInResources = true;
btnOK.ShowFocusColor = true;
btnOK.Size = new System.Drawing.Size(100, 35);
btnOK.TabIndex = 0;

View File

@ -562,9 +562,16 @@ namespace Sunny.UI
{
try
{
using (Image image = IconToImage(Icon))
if (IconImage != null)
{
e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24);
e.Graphics.DrawImage(IconImage, new Rectangle(6, (TitleHeight - 24) / 2 + 1, 24, 24), new Rectangle(0, 0, IconImage.Width, IconImage.Height), GraphicsUnit.Pixel);
}
else
{
using (Image image = IconToImage(Icon))
{
e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24);
}
}
}
catch

View File

@ -165,9 +165,16 @@ namespace Sunny.UI
{
try
{
using (Image image = IconToImage(Icon))
if (IconImage != null)
{
e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24);
e.Graphics.DrawImage(IconImage, new Rectangle(6, (TitleHeight - 24) / 2 + 1, 24, 24), new Rectangle(0, 0, IconImage.Width, IconImage.Height), GraphicsUnit.Pixel);
}
else
{
using (Image image = IconToImage(Icon))
{
e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24);
}
}
}
catch

View File

@ -90,7 +90,6 @@
Controls.Add(label);
Name = "UIInputForm";
Padding = new System.Windows.Forms.Padding(0, 35, 0, 0);
ShowBuiltInResources = true;
Style = UIStyle.Custom;
Text = "输入";
ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 473, 182);

View File

@ -209,7 +209,6 @@
MinimumSize = new System.Drawing.Size(750, 450);
Name = "UILoginForm";
Padding = new System.Windows.Forms.Padding(0);
ShowBuiltInResources = true;
ShowIcon = false;
ShowInTaskbar = false;
ShowTitle = false;

View File

@ -104,7 +104,6 @@
MaximizeBox = false;
MinimizeBox = false;
Name = "UIMessageForm";
ShowBuiltInResources = true;
ShowIcon = false;
ShowInTaskbar = false;
Text = "UIMsgBox";

View File

@ -88,7 +88,6 @@
MaximizeBox = false;
MinimizeBox = false;
Name = "UIMessageForm2";
ShowBuiltInResources = true;
ShowIcon = false;
ShowInTaskbar = false;
StartPosition = System.Windows.Forms.FormStartPosition.Manual;

View File

@ -53,7 +53,6 @@
Controls.Add(uiProgressIndicator1);
Name = "UIProcessIndicatorForm";
Padding = new System.Windows.Forms.Padding(2, 0, 2, 2);
ShowBuiltInResources = true;
ShowTitle = false;
Text = "UIProcessIndicatorForm";
ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 800, 450);

View File

@ -87,7 +87,6 @@
Controls.Add(ComboBox);
Name = "UISelectForm";
Padding = new System.Windows.Forms.Padding(1, 35, 1, 1);
ShowBuiltInResources = true;
Text = "选择";
ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 473, 182);
Controls.SetChildIndex(ComboBox, 0);

View File

@ -75,7 +75,6 @@
MaximizeBox = false;
MinimizeBox = false;
Name = "UIStatusForm";
ShowBuiltInResources = true;
ShowIcon = false;
Text = "提示";
TopMost = true;

View File

@ -69,7 +69,6 @@
MaximizeBox = false;
MinimizeBox = false;
Name = "UIWaitForm";
ShowBuiltInResources = true;
ShowIcon = false;
Text = "提示";
TopMost = true;

View File

@ -305,7 +305,7 @@ namespace Sunny.UI
if (UIStyles.Style.IsValid())
SetInheritedStyle(UIStyles.Style);
if (!ShowBuiltInResources)
if (UIStyles.MultiLanguageSupport)
Translate();
}
@ -1152,8 +1152,8 @@ namespace Sunny.UI
this.TranslateOther();
}
[DefaultValue(false)]
[Description("控件是否显示多语内置资源"), Category("SunnyUI")]
public bool ShowBuiltInResources { get; set; } = false;
[DefaultValue(true)]
[Description("控件在界面显示时需要多语翻译"), Category("SunnyUI")]
public bool MultiLanguageSupport { get; set; } = true;
}
}

View File

@ -49,7 +49,7 @@ namespace Sunny.UI
{
string[] FormTranslatorProperties { get; }
bool ShowBuiltInResources { get; set; }
bool MultiLanguageSupport { get; set; }
}
public static class TranslateHelper
@ -77,10 +77,10 @@ namespace Sunny.UI
"UISymbolLabel",
"UITimePicker",
"UITurnSwitch",
"UITitlePanel"//,
"UITitlePanel",
//Native Controls
//"Button",
//"ToolStripMenuItem",
"ToolStripMenuItem"//,
//"CheckBox",
//"RadioButton",
//"GroupBox",
@ -184,8 +184,14 @@ namespace Sunny.UI
const string warning = "注意:请先关闭应用程序,然后再修改此文档。否则修改可能会应用程序生成代码覆盖。";
if (ini.Read(section, "Warning", "") != warning)
ini.Write(section, "Warning", warning);
ini.Write(section, "Controls", string.Join(";", names.ToArray()));
ini.UpdateFile();
ini.EraseSection("Controls");
ini.Write("Controls", "Count", names.Count);
for (int i = 0; i < names.Count; i++)
{
ini.Write("Controls", "Control" + i, names[i]);
}
}
}
}
@ -208,8 +214,8 @@ namespace Sunny.UI
string inifile = Dir.CurrentDir() + "Language\\" + thisFullName + ".ini";
if (!File.Exists(inifile)) return;
IniFile ini = new IniFile(Dir.CurrentDir() + "Language\\" + thisFullName + ".ini", System.Text.Encoding.UTF8);
string controls = ini.Read(section, "Controls", "");
if (controls.IsNullOrEmpty()) return;
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)
@ -220,8 +226,10 @@ namespace Sunny.UI
Dictionary<string, CtrlInfo> Ctrls2 = new Dictionary<string, CtrlInfo>();
Dictionary<string, CtrlInfo> Ctrls3 = new Dictionary<string, CtrlInfo>();
foreach (var item in controls.Split(';'))
for (int i = 0; i < count; i++)
{
string item = ini.Read("Controls", "Control" + i, "");
if (item.IsNullOrEmpty()) continue;
string[] strs = item.Split(",");
if (strs.Length == 0) continue;
@ -240,7 +248,7 @@ namespace Sunny.UI
section = UIStyles.CultureInfo.LCID + ".FormResources";
foreach (var control in formControls)
{
if (control.ShowBuiltInResources) continue;
if (!control.MultiLanguageSupport) continue;
Control ctrl = (Control)control;
if (ctrl.Name.IsNullOrEmpty()) continue;
if (Ctrls3.NotContainsKey(ctrl.Name)) continue;