diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll
index b5c7601a..c73995ee 100644
Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ
diff --git a/Bin/SunnyUI.pdb b/Bin/SunnyUI.pdb
index 32c7120d..9ddd2b1a 100644
Binary files a/Bin/SunnyUI.pdb and b/Bin/SunnyUI.pdb differ
diff --git a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe
index 9c7e11d3..1a9cb239 100644
Binary files a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe and b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe differ
diff --git a/SunnyUI.Demo/Bin/SunnyUI.dll b/SunnyUI.Demo/Bin/SunnyUI.dll
index b5c7601a..c73995ee 100644
Binary files a/SunnyUI.Demo/Bin/SunnyUI.dll and b/SunnyUI.Demo/Bin/SunnyUI.dll differ
diff --git a/SunnyUI.Demo/Controls/FButton.Designer.cs b/SunnyUI.Demo/Controls/FButton.Designer.cs
index c974dd0a..c69808a2 100644
--- a/SunnyUI.Demo/Controls/FButton.Designer.cs
+++ b/SunnyUI.Demo/Controls/FButton.Designer.cs
@@ -160,6 +160,7 @@
this.uiButton1.Name = "uiButton1";
this.uiButton1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
this.uiButton1.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
+ this.uiButton1.ShowFocusLine = true;
this.uiButton1.Size = new System.Drawing.Size(100, 35);
this.uiButton1.Style = Sunny.UI.UIStyle.White;
this.uiButton1.StyleCustomMode = true;
@@ -172,6 +173,7 @@
this.uiButton2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiButton2.Location = new System.Drawing.Point(144, 50);
this.uiButton2.Name = "uiButton2";
+ this.uiButton2.ShowFocusLine = true;
this.uiButton2.Size = new System.Drawing.Size(100, 35);
this.uiButton2.StyleCustomMode = true;
this.uiButton2.TabIndex = 1;
@@ -189,6 +191,7 @@
this.uiButton3.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(110)))), ((int)(((byte)(190)))), ((int)(((byte)(40)))));
this.uiButton3.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(136)))), ((int)(((byte)(202)))), ((int)(((byte)(81)))));
this.uiButton3.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(168)))), ((int)(((byte)(35)))));
+ this.uiButton3.ShowFocusLine = true;
this.uiButton3.Size = new System.Drawing.Size(100, 35);
this.uiButton3.Style = Sunny.UI.UIStyle.Green;
this.uiButton3.StyleCustomMode = true;
@@ -207,6 +210,7 @@
this.uiButton4.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.uiButton4.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(127)))), ((int)(((byte)(128)))));
this.uiButton4.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(87)))), ((int)(((byte)(89)))));
+ this.uiButton4.ShowFocusLine = true;
this.uiButton4.Size = new System.Drawing.Size(100, 35);
this.uiButton4.Style = Sunny.UI.UIStyle.Red;
this.uiButton4.StyleCustomMode = true;
@@ -225,6 +229,7 @@
this.uiButton5.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40)))));
this.uiButton5.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(174)))), ((int)(((byte)(86)))));
this.uiButton5.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(137)))), ((int)(((byte)(43)))));
+ this.uiButton5.ShowFocusLine = true;
this.uiButton5.Size = new System.Drawing.Size(100, 35);
this.uiButton5.Style = Sunny.UI.UIStyle.Orange;
this.uiButton5.StyleCustomMode = true;
@@ -243,6 +248,7 @@
this.uiButton6.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
this.uiButton6.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(160)))), ((int)(((byte)(165)))));
this.uiButton6.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129)))));
+ this.uiButton6.ShowFocusLine = true;
this.uiButton6.Size = new System.Drawing.Size(100, 35);
this.uiButton6.Style = Sunny.UI.UIStyle.Gray;
this.uiButton6.StyleCustomMode = true;
diff --git a/SunnyUI/Controls/UIButton.cs b/SunnyUI/Controls/UIButton.cs
index 9711d99a..975bf584 100644
--- a/SunnyUI/Controls/UIButton.cs
+++ b/SunnyUI/Controls/UIButton.cs
@@ -23,6 +23,7 @@
using System;
using System.ComponentModel;
using System.Drawing;
+using System.Drawing.Drawing2D;
using System.Windows.Forms;
// ReSharper disable All
@@ -33,7 +34,7 @@ namespace Sunny.UI
[DefaultEvent("Click")]
[DefaultProperty("Text")]
[ToolboxItem(true)]
- public class UIButton : UIControl
+ public class UIButton : UIControl, IButtonControl
{
public UIButton()
{
@@ -65,6 +66,12 @@ namespace Sunny.UI
}
}
+ protected override void OnClick(EventArgs e)
+ {
+ Focus();
+ base.OnClick(e);
+ }
+
private bool showTips = false;
[Description("是否显示角标"), Category("自定义")]
@@ -136,6 +143,19 @@ namespace Sunny.UI
e.Graphics.FillEllipse(UIColor.Red, x, y, sfMax, sfMax);
e.Graphics.DrawString(TipsText, TipsFont, Color.White, x + sfMax / 2.0f - sf.Width / 2.0f, y + sfMax / 2.0f - sf.Height / 2.0f);
}
+
+ if (Focused && ShowFocusLine)
+ {
+ Rectangle rect = new Rectangle(2, 2, Width - 5, Height - 5);
+ var path = rect.CreateRoundedRectanglePath(Radius);
+ using (Pen pn = new Pen(ForeColor))
+ {
+ pn.DashStyle = DashStyle.Dot;
+ e.Graphics.DrawPath(pn, path);
+ }
+
+ path.Dispose();
+ }
}
private bool selected;
@@ -304,5 +324,25 @@ namespace Sunny.UI
IsHover = true;
Invalidate();
}
+
+ public void NotifyDefault(bool value)
+ {
+ }
+
+ [DefaultValue(DialogResult.None)]
+ public DialogResult DialogResult { get; set; } = DialogResult.None;
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ if (Focused && e.KeyCode == Keys.Space)
+ {
+ PerformClick();
+ }
+
+ base.OnKeyDown(e);
+ }
+
+ [DefaultValue(false)]
+ public bool ShowFocusLine { get; set; }
}
}
\ No newline at end of file
diff --git a/SunnyUI/Controls/UIControl.cs b/SunnyUI/Controls/UIControl.cs
index ffe9ccd0..ac53daee 100644
--- a/SunnyUI/Controls/UIControl.cs
+++ b/SunnyUI/Controls/UIControl.cs
@@ -694,5 +694,21 @@ namespace Sunny.UI
Invalidate();
}
}
+
+ /// 引发 事件。
+ /// 包含事件数据的 。
+ protected override void OnGotFocus(EventArgs e)
+ {
+ base.OnGotFocus(e);
+ this.Invalidate();
+ }
+
+ /// 引发 事件。
+ /// 包含事件数据的 。
+ protected override void OnLostFocus(EventArgs e)
+ {
+ base.OnLostFocus(e);
+ this.Invalidate();
+ }
}
}
\ No newline at end of file
diff --git a/Updates.txt b/Updates.txt
index 688b8148..1634c572 100644
--- a/Updates.txt
+++ b/Updates.txt
@@ -1,5 +1,8 @@
+ ӣ - ɾ *
+2020.06.23
+* UIButtonShowFocusLineɻý㲢ʾ
+
2020.06.22
* UIFormWindowStateChange¼жWindowState״̬ShowFullScreenȫʾ