diff --git a/SunnyUI/Controls/DropItem/UIColorItem.cs b/SunnyUI/Controls/DropItem/UIColorItem.cs index 36168ffa..2a558e8f 100644 --- a/SunnyUI/Controls/DropItem/UIColorItem.cs +++ b/SunnyUI/Controls/DropItem/UIColorItem.cs @@ -3,7 +3,7 @@ using System.Drawing; namespace Sunny.UI { - public sealed class UIColorItem : UIDropDownItem, ITranslate + internal sealed class UIColorItem : UIDropDownItem, ITranslate { public UIColorItem() { diff --git a/SunnyUI/Controls/DropItem/UIComboBoxItem.cs b/SunnyUI/Controls/DropItem/UIComboBoxItem.cs index 2ba484a1..bd511f21 100644 --- a/SunnyUI/Controls/DropItem/UIComboBoxItem.cs +++ b/SunnyUI/Controls/DropItem/UIComboBoxItem.cs @@ -27,7 +27,7 @@ namespace Sunny.UI /// /// 组合框弹出窗体 /// - public partial class UIComboBoxItem : UIDropDownItem + internal partial class UIComboBoxItem : UIDropDownItem { /// /// 构造函数 diff --git a/SunnyUI/Controls/DropItem/UIComboDataGridViewItem.cs b/SunnyUI/Controls/DropItem/UIComboDataGridViewItem.cs index 891a8949..dcf64b3f 100644 --- a/SunnyUI/Controls/DropItem/UIComboDataGridViewItem.cs +++ b/SunnyUI/Controls/DropItem/UIComboDataGridViewItem.cs @@ -30,7 +30,7 @@ using System.Windows.Forms; namespace Sunny.UI { - public class UIComboDataGridViewItem : UIDropDownItem, ITranslate + internal class UIComboDataGridViewItem : UIDropDownItem, ITranslate { private UIPanel panel; private UISymbolButton btnCancel; diff --git a/SunnyUI/Controls/DropItem/UIComboTreeViewItem.cs b/SunnyUI/Controls/DropItem/UIComboTreeViewItem.cs index 1155c142..be895396 100644 --- a/SunnyUI/Controls/DropItem/UIComboTreeViewItem.cs +++ b/SunnyUI/Controls/DropItem/UIComboTreeViewItem.cs @@ -2,7 +2,7 @@ namespace Sunny.UI { - public class UIComboTreeViewItem : UIDropDownItem, ITranslate + internal class UIComboTreeViewItem : UIDropDownItem, ITranslate { private UIPanel panel; private UISymbolButton btnCancel; diff --git a/SunnyUI/Controls/DropItem/UIDateItem.cs b/SunnyUI/Controls/DropItem/UIDateItem.cs index 3365ac96..3e631fec 100644 --- a/SunnyUI/Controls/DropItem/UIDateItem.cs +++ b/SunnyUI/Controls/DropItem/UIDateItem.cs @@ -31,7 +31,7 @@ using System.Windows.Forms; namespace Sunny.UI { - public sealed class UIDateItem : UIDropDownItem, ITranslate + internal sealed class UIDateItem : UIDropDownItem, ITranslate { #region InitializeComponent diff --git a/SunnyUI/Controls/DropItem/UIDateTimeItem.cs b/SunnyUI/Controls/DropItem/UIDateTimeItem.cs index 258565c1..05c4b648 100644 --- a/SunnyUI/Controls/DropItem/UIDateTimeItem.cs +++ b/SunnyUI/Controls/DropItem/UIDateTimeItem.cs @@ -31,7 +31,7 @@ using System.Windows.Forms; namespace Sunny.UI { - public sealed class UIDateTimeItem : UIDropDownItem, ITranslate + internal sealed class UIDateTimeItem : UIDropDownItem, ITranslate { #region InitializeComponent diff --git a/SunnyUI/Controls/DropItem/UINumPadItem.cs b/SunnyUI/Controls/DropItem/UINumPadItem.cs index afcd0a30..b0617ecc 100644 --- a/SunnyUI/Controls/DropItem/UINumPadItem.cs +++ b/SunnyUI/Controls/DropItem/UINumPadItem.cs @@ -3,7 +3,7 @@ using System.Drawing; namespace Sunny.UI { - public sealed class UINumPadItem : UIDropDownItem + internal sealed class UINumPadItem : UIDropDownItem { public UINumPadItem() { diff --git a/SunnyUI/Controls/DropItem/UITimeItem.cs b/SunnyUI/Controls/DropItem/UITimeItem.cs index 5c3ec328..97cba0e4 100644 --- a/SunnyUI/Controls/DropItem/UITimeItem.cs +++ b/SunnyUI/Controls/DropItem/UITimeItem.cs @@ -26,7 +26,7 @@ using System.Windows.Forms; namespace Sunny.UI { - public sealed class UITimeItem : UIDropDownItem, ITranslate + internal sealed class UITimeItem : UIDropDownItem, ITranslate { #region InitializeComponent diff --git a/SunnyUI/Forms/UIBaseForm.cs b/SunnyUI/Forms/UIBaseForm.cs index 1eb65603..c31cca03 100644 --- a/SunnyUI/Forms/UIBaseForm.cs +++ b/SunnyUI/Forms/UIBaseForm.cs @@ -19,6 +19,7 @@ * 2024-04-29: V3.6.5 增加文件说明 * 2024-04-29: V3.6.5 删除ShowTitleIcon,默认使用ShowIcon * 2024-10-05: V3.7.0 增加属性IconImage,以改善Icon转Image显示不佳,状态栏显示仍然用Icon属性 + * 2024-10-29: V3.7.2 IconImage增加IconImageSize属性,可调整大小 ******************************************************************************/ using System; @@ -203,9 +204,34 @@ namespace Sunny.UI return image; } + private Image iconImage = null; + [Description("标题栏图标图片,状态栏显示仍然用Icon属性"), Category("SunnyUI")] [DefaultValue(null)] - public Image IconImage { get; set; } + public Image IconImage + { + get => iconImage; + set + { + iconImage = value; + Invalidate(); + } + } + + private int iconImageSize = 24; + + [Description("标题栏图标图片大小"), Category("SunnyUI")] + [DefaultValue(24)] + public int IconImageSize + { + get => iconImageSize; + set + { + iconImageSize = Math.Max(16, value); + iconImageSize = Math.Min(titleHeight - 2, iconImageSize); + Invalidate(); + } + } private StringAlignment textAlignment = StringAlignment.Near; diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs index d642c780..0dea289e 100644 --- a/SunnyUI/Forms/UIForm.cs +++ b/SunnyUI/Forms/UIForm.cs @@ -558,13 +558,15 @@ namespace Sunny.UI return; } + int titleLeft = 6; if (ShowIcon && Icon != null) { try { if (IconImage != null) { - e.Graphics.DrawImage(IconImage, new Rectangle(6, (TitleHeight - 24) / 2 + 1, 24, 24), new Rectangle(0, 0, IconImage.Width, IconImage.Height), GraphicsUnit.Pixel); + e.Graphics.DrawImage(IconImage, new Rectangle(6, (TitleHeight - IconImageSize) / 2 + 1, IconImageSize, IconImageSize), new Rectangle(0, 0, IconImage.Width, IconImage.Height), GraphicsUnit.Pixel); + titleLeft = 6 + IconImageSize + 2; } else { @@ -572,6 +574,8 @@ namespace Sunny.UI { e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24); } + + titleLeft = 6 + 24 + 2; } } catch @@ -586,7 +590,7 @@ namespace Sunny.UI } else { - e.Graphics.DrawString(Text, TitleFont, titleForeColor, new Rectangle(6 + (ShowIcon && Icon != null ? 26 : 0), 0, Width, TitleHeight), ContentAlignment.MiddleLeft); + e.Graphics.DrawString(Text, TitleFont, titleForeColor, new Rectangle(titleLeft, 0, Width, TitleHeight), ContentAlignment.MiddleLeft); } if (ControlBoxLeft != Width) diff --git a/SunnyUI/Forms/UIForm2.cs b/SunnyUI/Forms/UIForm2.cs index 9a958d22..87f78ae4 100644 --- a/SunnyUI/Forms/UIForm2.cs +++ b/SunnyUI/Forms/UIForm2.cs @@ -161,13 +161,15 @@ namespace Sunny.UI return; } + int titleLeft = 6; if (ShowIcon && Icon != null) { try { if (IconImage != null) { - e.Graphics.DrawImage(IconImage, new Rectangle(6, (TitleHeight - 24) / 2 + 1, 24, 24), new Rectangle(0, 0, IconImage.Width, IconImage.Height), GraphicsUnit.Pixel); + e.Graphics.DrawImage(IconImage, new Rectangle(6, (TitleHeight - IconImageSize) / 2 + 1, IconImageSize, IconImageSize), new Rectangle(0, 0, IconImage.Width, IconImage.Height), GraphicsUnit.Pixel); + titleLeft = 6 + IconImageSize + 2; } else { @@ -175,6 +177,8 @@ namespace Sunny.UI { e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24); } + + titleLeft = 6 + 24 + 2; } } catch @@ -189,7 +193,7 @@ namespace Sunny.UI } else { - e.Graphics.DrawString(Text, TitleFont, titleForeColor, new Rectangle(6 + (ShowIcon && Icon != null ? 26 : 0), 0, Width, TitleHeight), ContentAlignment.MiddleLeft); + e.Graphics.DrawString(Text, TitleFont, titleForeColor, new Rectangle(titleLeft, 0, Width, TitleHeight), ContentAlignment.MiddleLeft); } e.Graphics.SetHighQuality();