* UICheckBox,UIRadioButton:增加AutoSize属性
* UIEditForm:确定、取消按钮可设置Enabled
This commit is contained in:
parent
9b55e4f60c
commit
4154b5c962
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
@ -237,6 +237,12 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(0), Description("水平偏移"), Category("SunnyUI")]
|
||||
public int OffsetX { get; set; } = 0;
|
||||
|
||||
[DefaultValue(0), Description("垂直偏移"), Category("SunnyUI")]
|
||||
public int OffsetY { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// OnPaint
|
||||
/// </summary>
|
||||
@ -288,13 +294,13 @@ namespace Sunny.UI
|
||||
|
||||
if (Icon == UIIcon.Symbol)
|
||||
{
|
||||
e.Graphics.DrawFontImage(symbol, symbolSize, ForeColor, new Rectangle((Width - avatarSize) / 2 + 1, (Height - avatarSize) / 2 + 1, avatarSize, avatarSize));
|
||||
e.Graphics.DrawFontImage(symbol, symbolSize, ForeColor, new Rectangle((Width - avatarSize) / 2 + 1 + OffsetX, (Height - avatarSize) / 2 + 1 + OffsetY, avatarSize, avatarSize));
|
||||
}
|
||||
|
||||
if (Icon == UIIcon.Text)
|
||||
{
|
||||
SizeF sf = e.Graphics.MeasureString(Text, Font);
|
||||
e.Graphics.DrawString(Text, Font, foreColor, 2 + (Width - sf.Width) / 2.0f, (Height - sf.Height) / 2.0f);
|
||||
e.Graphics.DrawString(Text, Font, foreColor, (Width - sf.Width) / 2.0f + OffsetX, (Height - sf.Height) / 2.0f + 1 + OffsetY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,33 @@ namespace Sunny.UI
|
||||
foreColor = UIStyles.Blue.CheckBoxForeColor;
|
||||
fillColor = UIStyles.Blue.CheckBoxColor;
|
||||
SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick);
|
||||
PaintOther += UICheckBox_PaintOther; ;
|
||||
}
|
||||
|
||||
private void UICheckBox_PaintOther(object sender, PaintEventArgs e)
|
||||
{
|
||||
if (AutoSize)
|
||||
{
|
||||
SizeF sf = Text.MeasureString(Font);
|
||||
int w = (int)sf.Width + ImageSize + 3;
|
||||
int h = Math.Max(ImageSize, (int)sf.Height) + 2;
|
||||
if (Width != w) Width = w;
|
||||
if (Height != h) Height = h;
|
||||
}
|
||||
}
|
||||
|
||||
private bool autoSize;
|
||||
|
||||
[Browsable(true)]
|
||||
[Description("自动大小"), Category("SunnyUI")]
|
||||
public override bool AutoSize
|
||||
{
|
||||
get => autoSize;
|
||||
set
|
||||
{
|
||||
autoSize = value;
|
||||
UICheckBox_PaintOther(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void OnValueChanged(object sender, bool value);
|
||||
|
@ -287,7 +287,7 @@ namespace Sunny.UI
|
||||
if (useDoubleClick != value)
|
||||
{
|
||||
useDoubleClick = value;
|
||||
//SetStyle(ControlStyles.StandardDoubleClick, useDoubleClick);
|
||||
SetStyle(ControlStyles.StandardDoubleClick, useDoubleClick);
|
||||
//Invalidate();
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,33 @@ namespace Sunny.UI
|
||||
Size = new Size(150, 29);
|
||||
foreColor = UIStyles.Blue.CheckBoxForeColor;
|
||||
fillColor = UIStyles.Blue.CheckBoxColor;
|
||||
PaintOther += UIRadioButton_PaintOther;
|
||||
}
|
||||
|
||||
private void UIRadioButton_PaintOther(object sender, PaintEventArgs e)
|
||||
{
|
||||
if (AutoSize)
|
||||
{
|
||||
SizeF sf = Text.MeasureString(Font);
|
||||
int w = (int)sf.Width + ImageSize + 3;
|
||||
int h = Math.Max(ImageSize, (int)sf.Height) + 2;
|
||||
if (Width != w) Width = w;
|
||||
if (Height != h) Height = h;
|
||||
}
|
||||
}
|
||||
|
||||
private bool autoSize;
|
||||
|
||||
[Browsable(true)]
|
||||
[Description("自动大小"), Category("SunnyUI")]
|
||||
public override bool AutoSize
|
||||
{
|
||||
get => autoSize;
|
||||
set
|
||||
{
|
||||
autoSize = value;
|
||||
UIRadioButton_PaintOther(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
|
@ -20,6 +20,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
@ -36,9 +37,28 @@ namespace Sunny.UI
|
||||
|
||||
public bool IsOK { get; private set; }
|
||||
|
||||
[Category("SunnyUI"), Description("确定按钮点击事件")]
|
||||
public event EventHandler ButtonOkClick;
|
||||
|
||||
[Category("SunnyUI"), Description("取消按钮点击事件")]
|
||||
public event EventHandler ButtonCancelClick;
|
||||
|
||||
[Description("确定按钮可用状态"), Category("SunnyUI")]
|
||||
[DefaultValue(true)]
|
||||
public bool ButtonOKEnabled
|
||||
{
|
||||
get => btnOK.Enabled;
|
||||
set => btnOK.Enabled = value;
|
||||
}
|
||||
|
||||
[Description("取消按钮可用状态"), Category("SunnyUI")]
|
||||
[DefaultValue(true)]
|
||||
public bool ButtonCancelEnabled
|
||||
{
|
||||
get => btnCancel.Enabled;
|
||||
set => btnCancel.Enabled = value;
|
||||
}
|
||||
|
||||
protected void btnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckData())
|
||||
@ -48,7 +68,7 @@ namespace Sunny.UI
|
||||
|
||||
if (ButtonOkClick != null)
|
||||
{
|
||||
ButtonOkClick.Invoke(sender,e);
|
||||
ButtonOkClick.Invoke(sender, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -62,7 +82,7 @@ namespace Sunny.UI
|
||||
{
|
||||
if (ButtonCancelClick != null)
|
||||
{
|
||||
ButtonCancelClick.Invoke(sender,e);
|
||||
ButtonCancelClick.Invoke(sender, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user