* UIBaseForm: IconImage增加IconImageSize属性,可调整大小

This commit is contained in:
Sunny 2024-10-29 22:55:52 +08:00
parent 88bce81140
commit ecc5d49b90
11 changed files with 47 additions and 13 deletions

View File

@ -3,7 +3,7 @@ using System.Drawing;
namespace Sunny.UI
{
public sealed class UIColorItem : UIDropDownItem, ITranslate
internal sealed class UIColorItem : UIDropDownItem, ITranslate
{
public UIColorItem()
{

View File

@ -27,7 +27,7 @@ namespace Sunny.UI
/// <summary>
/// 组合框弹出窗体
/// </summary>
public partial class UIComboBoxItem : UIDropDownItem
internal partial class UIComboBoxItem : UIDropDownItem
{
/// <summary>
/// 构造函数

View File

@ -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;

View File

@ -2,7 +2,7 @@
namespace Sunny.UI
{
public class UIComboTreeViewItem : UIDropDownItem, ITranslate
internal class UIComboTreeViewItem : UIDropDownItem, ITranslate
{
private UIPanel panel;
private UISymbolButton btnCancel;

View File

@ -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

View File

@ -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

View File

@ -3,7 +3,7 @@ using System.Drawing;
namespace Sunny.UI
{
public sealed class UINumPadItem : UIDropDownItem
internal sealed class UINumPadItem : UIDropDownItem
{
public UINumPadItem()
{

View File

@ -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

View File

@ -19,6 +19,7 @@
* 2024-04-29: V3.6.5
* 2024-04-29: V3.6.5 ShowTitleIcon使ShowIcon
* 2024-10-05: V3.7.0 IconImageIcon转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;

View File

@ -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)

View File

@ -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();