diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll index 31c0a496..107dd6ae 100644 Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ diff --git a/Bin/SunnyUI.pdb b/Bin/SunnyUI.pdb index 23f01bbe..1e27c3be 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 d805942e..ff2145d5 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 31c0a496..107dd6ae 100644 Binary files a/SunnyUI.Demo/Bin/SunnyUI.dll and b/SunnyUI.Demo/Bin/SunnyUI.dll differ diff --git a/SunnyUI/Controls/UIGlobal.cs b/SunnyUI/Controls/UIGlobal.cs index bd5d0542..73b2c83b 100644 --- a/SunnyUI/Controls/UIGlobal.cs +++ b/SunnyUI/Controls/UIGlobal.cs @@ -20,9 +20,6 @@ ******************************************************************************/ using Sunny.UI.Properties; -using System.Collections.Generic; -using System.Reflection; -using System.Windows.Forms; namespace Sunny.UI { @@ -35,88 +32,5 @@ namespace Sunny.UI /// 版本 /// public static string Version = Resources.Name + " " + Resources.Version; - - public static bool IsCustom(this UIStyle style) - { - return style.Equals(UIStyle.Custom); - } - - public static bool IsValid(this UIStyle style) - { - return !style.IsCustom(); - } - - public static bool IsCustom(this UIBaseStyle style) - { - return style.Name.IsCustom(); - } - - public static bool IsValid(this UIBaseStyle style) - { - return !style.IsCustom(); - } - - public static void SetChildUIStyle(Control ctrl, UIStyle style) - { - List controls = ctrl.GetUIStyleControls("IStyleInterface"); - foreach (var control in controls) - { - if (control is IStyleInterface item) - { - if (!item.StyleCustomMode) - { - item.Style = style; - } - } - } - - FieldInfo[] fieldInfo = ctrl.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance); - foreach (var info in fieldInfo) - { - if (info.FieldType.Name == "UIContextMenuStrip") - { - UIContextMenuStrip context = (UIContextMenuStrip)info.GetValue(ctrl); - if (context != null && !context.StyleCustomMode) - { - context.SetStyle(style); - } - } - } - } - - /// - /// 查找包含接口名称的控件列表 - /// - /// 容器 - /// 接口名称 - /// 控件列表 - private static List GetUIStyleControls(this Control ctrl, string interfaceName) - { - List values = new List(); - - foreach (Control obj in ctrl.Controls) - { - if (obj.GetType().GetInterface(interfaceName) != null) - { - values.Add(obj); - } - - if (obj is UIPage) continue; - if (obj is UIPanel) continue; - - if (obj.Controls.Count > 0) - { - values.AddRange(obj.GetUIStyleControls(interfaceName)); - } - } - - return values; - } - - public static void ReStart(this Timer timer) - { - timer.Stop(); - timer.Start(); - } } } \ No newline at end of file diff --git a/SunnyUI/Controls/UIPanel.cs b/SunnyUI/Controls/UIPanel.cs index 6d904c0f..c86466ce 100644 --- a/SunnyUI/Controls/UIPanel.cs +++ b/SunnyUI/Controls/UIPanel.cs @@ -442,7 +442,7 @@ namespace Sunny.UI public void SetStyle(UIStyle style) { - UIGlobal.SetChildUIStyle(this, style); + this.SetChildUIStyle(style); SetStyleColor(UIStyles.GetStyleColor(style)); _style = style; diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs index 5aee0f11..553566fb 100644 --- a/SunnyUI/Controls/UITextBox.cs +++ b/SunnyUI/Controls/UITextBox.cs @@ -56,21 +56,17 @@ namespace Sunny.UI edit.SelectAll(); } - protected override void OnTextChanged(EventArgs e) - { - base.OnTextChanged(e); - edit.Text = Text; - Invalidate(); - } - public void CheckMaxMin() { edit.CheckMaxMin(); } + [Browsable(true)] + public new event EventHandler TextChanged; + private void EditTextChanged(object s, EventArgs e) { - Text = edit.Text; + TextChanged?.Invoke(this, e); } protected override void OnFontChanged(EventArgs e) diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs index 3c6d76e5..4de452a4 100644 --- a/SunnyUI/Forms/UIForm.cs +++ b/SunnyUI/Forms/UIForm.cs @@ -613,7 +613,7 @@ namespace Sunny.UI public void SetStyle(UIStyle style) { - UIGlobal.SetChildUIStyle(this, style); + this.SetChildUIStyle(style); btn.SetStyle(style); SetStyleColor(UIStyles.GetStyleColor(style)); diff --git a/SunnyUI/Pages/UIPage.cs b/SunnyUI/Pages/UIPage.cs index d71c6fa6..8c8fa9b1 100644 --- a/SunnyUI/Pages/UIPage.cs +++ b/SunnyUI/Pages/UIPage.cs @@ -122,7 +122,7 @@ namespace Sunny.UI public void SetStyle(UIStyle style) { - UIGlobal.SetChildUIStyle(this, style); + this.SetChildUIStyle(style); SetStyleColor(UIStyles.GetStyleColor(style)); _style = style; diff --git a/SunnyUI/Static/UControl.cs b/SunnyUI/Static/UControl.cs index c743bac6..93beb7c6 100644 --- a/SunnyUI/Static/UControl.cs +++ b/SunnyUI/Static/UControl.cs @@ -37,6 +37,12 @@ namespace Sunny.UI /// public static class ControlEx { + public static void ReStart(this Timer timer) + { + timer.Stop(); + timer.Start(); + } + public static Form GetParentForm(this Control ctrl) { while (!IsForm(ctrl.Parent)) diff --git a/SunnyUI/Style/UIStyle.cs b/SunnyUI/Style/UIStyle.cs index b158ee30..73ada75c 100644 --- a/SunnyUI/Style/UIStyle.cs +++ b/SunnyUI/Style/UIStyle.cs @@ -21,7 +21,9 @@ using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Drawing; +using System.Reflection; using System.Windows.Forms; namespace Sunny.UI @@ -640,4 +642,99 @@ namespace Sunny.UI /// public static readonly Color Transparent = Color.Transparent; } + + public static class UIStyleHelper + { + public static bool IsCustom(this UIStyle style) + { + return style.Equals(UIStyle.Custom); + } + + public static bool IsValid(this UIStyle style) + { + return !style.IsCustom(); + } + + public static bool IsCustom(this UIBaseStyle style) + { + return style.Name.IsCustom(); + } + + public static bool IsValid(this UIBaseStyle style) + { + return !style.IsCustom(); + } + + public static void SetChildUIStyle(this UIPanel ctrl, UIStyle style) + { + SetControlChildUIStyle(ctrl, style); + } + + public static void SetChildUIStyle(this UIForm ctrl, UIStyle style) + { + SetControlChildUIStyle(ctrl, style); + } + + public static void SetChildUIStyle(this UIPage ctrl, UIStyle style) + { + SetControlChildUIStyle(ctrl, style); + } + + private static void SetControlChildUIStyle(Control ctrl, UIStyle style) + { + List controls = ctrl.GetUIStyleControls("IStyleInterface"); + foreach (var control in controls) + { + if (control is IStyleInterface item) + { + if (!item.StyleCustomMode) + { + item.Style = style; + } + } + } + + FieldInfo[] fieldInfo = ctrl.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance); + foreach (var info in fieldInfo) + { + if (info.FieldType.Name == "UIContextMenuStrip") + { + UIContextMenuStrip context = (UIContextMenuStrip)info.GetValue(ctrl); + if (context != null && !context.StyleCustomMode) + { + context.SetStyle(style); + } + } + } + } + + /// + /// 查找包含接口名称的控件列表 + /// + /// 容器 + /// 接口名称 + /// 控件列表 + private static List GetUIStyleControls(this Control ctrl, string interfaceName) + { + List values = new List(); + + foreach (Control obj in ctrl.Controls) + { + if (obj.GetType().GetInterface(interfaceName) != null) + { + values.Add(obj); + } + + if (obj is UIPage) continue; + if (obj is UIPanel) continue; + + if (obj.Controls.Count > 0) + { + values.AddRange(obj.GetUIStyleControls(interfaceName)); + } + } + + return values; + } + } } \ No newline at end of file