* UIBaseForm: IconImage增加IconImageSize属性,可调整大小
This commit is contained in:
parent
88bce81140
commit
ecc5d49b90
@ -3,7 +3,7 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public sealed class UIColorItem : UIDropDownItem, ITranslate
|
internal sealed class UIColorItem : UIDropDownItem, ITranslate
|
||||||
{
|
{
|
||||||
public UIColorItem()
|
public UIColorItem()
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ namespace Sunny.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 组合框弹出窗体
|
/// 组合框弹出窗体
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class UIComboBoxItem : UIDropDownItem
|
internal partial class UIComboBoxItem : UIDropDownItem
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造函数
|
/// 构造函数
|
||||||
|
@ -30,7 +30,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public class UIComboDataGridViewItem : UIDropDownItem, ITranslate
|
internal class UIComboDataGridViewItem : UIDropDownItem, ITranslate
|
||||||
{
|
{
|
||||||
private UIPanel panel;
|
private UIPanel panel;
|
||||||
private UISymbolButton btnCancel;
|
private UISymbolButton btnCancel;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public class UIComboTreeViewItem : UIDropDownItem, ITranslate
|
internal class UIComboTreeViewItem : UIDropDownItem, ITranslate
|
||||||
{
|
{
|
||||||
private UIPanel panel;
|
private UIPanel panel;
|
||||||
private UISymbolButton btnCancel;
|
private UISymbolButton btnCancel;
|
||||||
|
@ -31,7 +31,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public sealed class UIDateItem : UIDropDownItem, ITranslate
|
internal sealed class UIDateItem : UIDropDownItem, ITranslate
|
||||||
{
|
{
|
||||||
#region InitializeComponent
|
#region InitializeComponent
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public sealed class UIDateTimeItem : UIDropDownItem, ITranslate
|
internal sealed class UIDateTimeItem : UIDropDownItem, ITranslate
|
||||||
{
|
{
|
||||||
#region InitializeComponent
|
#region InitializeComponent
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public sealed class UINumPadItem : UIDropDownItem
|
internal sealed class UINumPadItem : UIDropDownItem
|
||||||
{
|
{
|
||||||
public UINumPadItem()
|
public UINumPadItem()
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public sealed class UITimeItem : UIDropDownItem, ITranslate
|
internal sealed class UITimeItem : UIDropDownItem, ITranslate
|
||||||
{
|
{
|
||||||
|
|
||||||
#region InitializeComponent
|
#region InitializeComponent
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
* 2024-04-29: V3.6.5 增加文件说明
|
* 2024-04-29: V3.6.5 增加文件说明
|
||||||
* 2024-04-29: V3.6.5 删除ShowTitleIcon,默认使用ShowIcon
|
* 2024-04-29: V3.6.5 删除ShowTitleIcon,默认使用ShowIcon
|
||||||
* 2024-10-05: V3.7.0 增加属性IconImage,以改善Icon转Image显示不佳,状态栏显示仍然用Icon属性
|
* 2024-10-05: V3.7.0 增加属性IconImage,以改善Icon转Image显示不佳,状态栏显示仍然用Icon属性
|
||||||
|
* 2024-10-29: V3.7.2 IconImage增加IconImageSize属性,可调整大小
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -203,9 +204,34 @@ namespace Sunny.UI
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Image iconImage = null;
|
||||||
|
|
||||||
[Description("标题栏图标图片,状态栏显示仍然用Icon属性"), Category("SunnyUI")]
|
[Description("标题栏图标图片,状态栏显示仍然用Icon属性"), Category("SunnyUI")]
|
||||||
[DefaultValue(null)]
|
[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;
|
private StringAlignment textAlignment = StringAlignment.Near;
|
||||||
|
|
||||||
|
@ -558,13 +558,15 @@ namespace Sunny.UI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int titleLeft = 6;
|
||||||
if (ShowIcon && Icon != null)
|
if (ShowIcon && Icon != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (IconImage != null)
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -572,6 +574,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24);
|
e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
titleLeft = 6 + 24 + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@ -586,7 +590,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
else
|
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)
|
if (ControlBoxLeft != Width)
|
||||||
|
@ -161,13 +161,15 @@ namespace Sunny.UI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int titleLeft = 6;
|
||||||
if (ShowIcon && Icon != null)
|
if (ShowIcon && Icon != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (IconImage != null)
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -175,6 +177,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24);
|
e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2 + 1, 24, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
titleLeft = 6 + 24 + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@ -189,7 +193,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
else
|
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();
|
e.Graphics.SetHighQuality();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user