* UICombobox:增加TextChange事件

* 取消部分ResizeRedraw
This commit is contained in:
Sunny 2020-09-25 20:17:19 +08:00
parent 1fac28592f
commit f30ffa9f19
16 changed files with 59 additions and 31 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -105,6 +105,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1024, 720); this.ClientSize = new System.Drawing.Size(1024, 720);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(1024, 720);
this.Name = "FMain"; this.Name = "FMain";
this.Padding = new System.Windows.Forms.Padding(2, 35, 2, 2); this.Padding = new System.Windows.Forms.Padding(2, 35, 2, 2);
this.ShowDragStretch = true; this.ShowDragStretch = true;

View File

@ -81,6 +81,7 @@ namespace Sunny.UI
public new event KeyPressEventHandler KeyPress; public new event KeyPressEventHandler KeyPress;
[Browsable(true)]
public new event EventHandler TextChanged; public new event EventHandler TextChanged;
private void EditOnKeyPress(object sender, KeyPressEventArgs e) private void EditOnKeyPress(object sender, KeyPressEventArgs e)

View File

@ -92,7 +92,7 @@ namespace Sunny.UI
InitializeComponent(); InitializeComponent();
AutoSize = false; AutoSize = false;
DoubleBuffered = true; DoubleBuffered = true;
ResizeRedraw = true; //ResizeRedraw = true;
ToolStripControlHost _host = new ToolStripControlHost(item); ToolStripControlHost _host = new ToolStripControlHost(item);
Padding = Margin = _host.Padding = _host.Margin = Padding.Empty; Padding = Margin = _host.Padding = _host.Margin = Padding.Empty;
item.MinimumSize = item.Size; item.MinimumSize = item.Size;

View File

@ -115,7 +115,6 @@ namespace Sunny.UI
/// <param name="value">数值</param> /// <param name="value">数值</param>
protected override void InitValue(object value) protected override void InitValue(object value)
{ {
Console.WriteLine(value.ToString());
UICornerRadiusSides sides = (UICornerRadiusSides)value; UICornerRadiusSides sides = (UICornerRadiusSides)value;
ResetCheckBoxState(); ResetCheckBoxState();
if ((sides & UICornerRadiusSides.All) == UICornerRadiusSides.All) if ((sides & UICornerRadiusSides.All) == UICornerRadiusSides.All)

View File

@ -39,7 +39,12 @@ namespace Sunny.UI
/// </summary> /// </summary>
public UIControl() public UIControl()
{ {
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.Selectable, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
base.DoubleBuffered = true; base.DoubleBuffered = true;
UpdateStyles(); UpdateStyles();

View File

@ -41,11 +41,10 @@ namespace Sunny.UI
SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.Selectable, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.ResizeRedraw, true);
DoubleBuffered = true; DoubleBuffered = true;
UpdateStyles(); UpdateStyles();
Font = UIFontColor.Font; Font = UIFontColor.Font;
@ -57,6 +56,12 @@ namespace Sunny.UI
Version = UIGlobal.Version; Version = UIGlobal.Version;
} }
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
if (NavBarMenu != null) NavBarMenu.Font = Font;
}
[DefaultValue(null)] [DefaultValue(null)]
[Description("关联的TabControl"), Category("SunnyUI")] [Description("关联的TabControl"), Category("SunnyUI")]
public UITabControl TabControl { get; set; } public UITabControl TabControl { get; set; }

View File

@ -44,9 +44,9 @@ namespace Sunny.UI
public UIPanel() public UIPanel()
{ {
InitializeComponent(); InitializeComponent();
SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.Selectable, true); SetStyle(ControlStyles.Selectable, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.UserPaint, true);
@ -55,6 +55,7 @@ namespace Sunny.UI
UpdateStyles(); UpdateStyles();
Version = UIGlobal.Version; Version = UIGlobal.Version;
AutoScaleMode = AutoScaleMode.None;
base.Font = UIFontColor.Font; base.Font = UIFontColor.Font;
base.MinimumSize = new System.Drawing.Size(1, 1); base.MinimumSize = new System.Drawing.Size(1, 1);
} }

View File

@ -46,20 +46,13 @@ namespace Sunny.UI
edit.ScrollBars = RichTextBoxScrollBars.Vertical; edit.ScrollBars = RichTextBoxScrollBars.Vertical;
} }
private bool showScrollBar = true; protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
if (edit != null) edit.Font = Font;
}
// [DefaultValue(true)] private bool showScrollBar = true;
// public bool ShowScrollBar
// {
// get => showScrollBar;
// set
// {
// showScrollBar = value;
// bar.Visible = value;
// edit.ScrollBars = value ? RichTextBoxScrollBars.Vertical : RichTextBoxScrollBars.None;
// SetScrollInfo();
// }
// }
[DefaultValue(false)] [DefaultValue(false)]
[Description("是否只读"), Category("SunnyUI")] [Description("是否只读"), Category("SunnyUI")]

View File

@ -34,6 +34,12 @@ namespace Sunny.UI
{ {
public delegate void OnValueChanged(object sender, bool value); public delegate void OnValueChanged(object sender, bool value);
public enum UISwitchShape
{
Round,
Square
}
public UISwitch() public UISwitch()
{ {
Height = 29; Height = 29;
@ -45,6 +51,20 @@ namespace Sunny.UI
fillColor = Color.White; fillColor = Color.White;
} }
public UISwitchShape switchShape = UISwitchShape.Round;
[Description("开关形状"), Category("SunnyUI")]
[DefaultValue(UISwitchShape.Round)]
public UISwitchShape SwitchShape
{
get => switchShape;
set
{
switchShape = value;
Invalidate();
}
}
public event OnValueChanged ValueChanged; public event OnValueChanged ValueChanged;
/// <summary> /// <summary>
@ -169,7 +189,7 @@ namespace Sunny.UI
protected override void OnPaintFill(Graphics g, GraphicsPath path) protected override void OnPaintFill(Graphics g, GraphicsPath path)
{ {
Width = (int)(Height * 2.6); //Width = (int)(Height * 2.6);
Rectangle rect = new Rectangle(0, 0, Width - 1, Height - 1); Rectangle rect = new Rectangle(0, 0, Width - 1, Height - 1);
g.FillRoundRectangle(Active ? ActiveColor : InActiveColor, rect, rect.Height); g.FillRoundRectangle(Active ? ActiveColor : InActiveColor, rect, rect.Height);

View File

@ -39,7 +39,7 @@ namespace Sunny.UI
public UITabControl() public UITabControl()
{ {
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
ItemSize = new Size(150, 40); ItemSize = new Size(150, 40);
DrawMode = TabDrawMode.OwnerDrawFixed; DrawMode = TabDrawMode.OwnerDrawFixed;

View File

@ -31,7 +31,7 @@ namespace Sunny.UI
{ {
public UITabControlMenu() public UITabControlMenu()
{ {
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
ItemSize = new Size(40, 200); ItemSize = new Size(40, 200);
DrawMode = TabDrawMode.OwnerDrawFixed; DrawMode = TabDrawMode.OwnerDrawFixed;

View File

@ -55,14 +55,12 @@ namespace Sunny.UI
ControlStyles.DoubleBuffer | ControlStyles.DoubleBuffer |
ControlStyles.OptimizedDoubleBuffer | ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint | ControlStyles.AllPaintingInWmPaint |
//ControlStyles.ResizeRedraw |
ControlStyles.SupportsTransparentBackColor, true); ControlStyles.SupportsTransparentBackColor, true);
UpdateStyles(); UpdateStyles();
Version = UIGlobal.Version; Version = UIGlobal.Version;
FormBorderStyle = FormBorderStyle.None; FormBorderStyle = FormBorderStyle.None;
m_aeroEnabled = false; m_aeroEnabled = false;
base.MaximumSize = ShowFullScreen ? Screen.PrimaryScreen.Bounds.Size : Screen.PrimaryScreen.WorkingArea.Size;
} }
//不显示FormBorderStyle属性 //不显示FormBorderStyle属性
@ -72,11 +70,7 @@ namespace Sunny.UI
public new FormBorderStyle FormBorderStyle public new FormBorderStyle FormBorderStyle
{ {
get { return base.FormBorderStyle; } get { return base.FormBorderStyle; }
set set { base.FormBorderStyle = FormBorderStyle.None; }
{
base.FormBorderStyle = FormBorderStyle.None;
Console.WriteLine(value);
}
} }
public void Render() public void Render()
@ -281,11 +275,21 @@ namespace Sunny.UI
{ {
} }
private bool showFullScreen;
/// <summary> /// <summary>
/// 是否以全屏模式进入最大化 /// 是否以全屏模式进入最大化
/// </summary> /// </summary>
[Description("是否以全屏模式进入最大化"), Category("WindowStyle"), DefaultValue(false)] [Description("是否以全屏模式进入最大化"), Category("WindowStyle"), DefaultValue(false)]
public bool ShowFullScreen { get; set; } public bool ShowFullScreen
{
get => showFullScreen;
set
{
showFullScreen = value;
base.MaximumSize = ShowFullScreen ? Screen.PrimaryScreen.Bounds.Size : Screen.PrimaryScreen.WorkingArea.Size;
}
}
/// <summary> /// <summary>
/// 标题栏高度 /// 标题栏高度
@ -1019,7 +1023,6 @@ namespace Sunny.UI
protected override void OnShown(EventArgs e) protected override void OnShown(EventArgs e)
{ {
base.OnShown(e); base.OnShown(e);
CalcSystemBoxPos(); CalcSystemBoxPos();
SetRadius(); SetRadius();
isShow = true; isShow = true;