* UIButton: 增加了AutoSize属性
This commit is contained in:
parent
ed17d205fe
commit
b9edbe0524
Binary file not shown.
Binary file not shown.
@ -23,6 +23,7 @@
|
||||
* 2020-09-14: V2.2.7 Tips颜色可设置
|
||||
* 2021-07-18: V3.0.5 增加ShowFocusColor,用来显示Focus状态
|
||||
* 2021-12-11: V3.0.9 增加了渐变色
|
||||
* 2022-02-26: V3.1.1 增加了AutoSize属性
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -62,6 +63,20 @@ namespace Sunny.UI
|
||||
SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick);
|
||||
}
|
||||
|
||||
private bool autoSize;
|
||||
|
||||
[Browsable(true), DefaultValue(false)]
|
||||
[Description("自动大小"), Category("SunnyUI")]
|
||||
public override bool AutoSize
|
||||
{
|
||||
get => autoSize;
|
||||
set
|
||||
{
|
||||
autoSize = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private bool isClick;
|
||||
|
||||
public void PerformClick()
|
||||
@ -227,6 +242,13 @@ namespace Sunny.UI
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
if (autoSize && Dock == DockStyle.None)
|
||||
{
|
||||
SizeF sf = e.Graphics.MeasureString(Text, Font);
|
||||
if (Width != (int)(sf.Width) + 6) Width = (int)(sf.Width) + 6;
|
||||
if (Height != (int)(sf.Height) + 6) Height = (int)(sf.Height) + 6;
|
||||
}
|
||||
|
||||
if (Enabled && ShowTips && !string.IsNullOrEmpty(TipsText))
|
||||
{
|
||||
e.Graphics.SetHighQuality();
|
||||
|
@ -49,7 +49,7 @@ namespace Sunny.UI
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
if (AutoSize)
|
||||
if (AutoSize && Dock == DockStyle.None)
|
||||
{
|
||||
SizeF sf = Text.MeasureString(Font);
|
||||
int w = (int)sf.Width + ImageSize + 3;
|
||||
|
@ -119,7 +119,7 @@ namespace Sunny.UI
|
||||
base.OnPaint(e);
|
||||
|
||||
SizeF TextSize = e.Graphics.MeasureString(Text, Font);
|
||||
if (autoSize)
|
||||
if (autoSize && Dock == DockStyle.None)
|
||||
{
|
||||
float width = (MarkPos == UIMarkPos.Left || MarkPos == UIMarkPos.Right) ?
|
||||
TextSize.Width + MarkSize + 2 : TextSize.Width;
|
||||
|
@ -55,7 +55,7 @@ namespace Sunny.UI
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
if (AutoSize)
|
||||
if (AutoSize && Dock == DockStyle.None)
|
||||
{
|
||||
SizeF sf = Text.MeasureString(Font);
|
||||
int w = (int)sf.Width + ImageSize + 3;
|
||||
|
@ -42,6 +42,16 @@ namespace Sunny.UI
|
||||
ShowText = false;
|
||||
}
|
||||
|
||||
private bool autoSize;
|
||||
|
||||
[Browsable(false)]
|
||||
[Description("自动大小"), Category("SunnyUI")]
|
||||
public override bool AutoSize
|
||||
{
|
||||
get => autoSize;
|
||||
set => autoSize = false;
|
||||
}
|
||||
|
||||
[DefaultValue(24)]
|
||||
[Description("字体图标大小"), Category("SunnyUI")]
|
||||
public int SymbolSize
|
||||
|
Loading…
x
Reference in New Issue
Block a user