From 878c93f509b0288f5a57d6c04234ab4c094fdb16 Mon Sep 17 00:00:00 2001 From: Sunny Date: Mon, 6 Nov 2023 23:18:13 +0800 Subject: [PATCH] =?UTF-8?q?*=20=E9=87=8D=E6=9E=84=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UITabControl.cs | 17 +++++------- SunnyUI/Frames/UIPage.cs | 45 +++++--------------------------- SunnyUI/Style/UIStyles.cs | 2 +- 3 files changed, 14 insertions(+), 50 deletions(-) diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 27cd7527..ac25aaea 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -31,6 +31,7 @@ * 2022-05-17: V3.1.9 修复了一个首页无法关闭的问题 * 2022-06-19: V3.2.0 多页面框架关闭页面时执行UIPage的FormClosed事件 * 2023-05-12: V3.3.6 重构DrawString函数 + * 2023-11-06: V3.5.2 重构主题 ******************************************************************************/ using Sunny.UI.Win32; @@ -356,16 +357,10 @@ namespace Sunny.UI { _fillColor = value; AfterSetFillColor(value); - SetStyleCustom(); + Invalidate(); } } - private void SetStyleCustom(bool needRefresh = true) - { - _style = UIStyle.Custom; - if (needRefresh) Invalidate(); - } - /// /// 边框颜色 /// @@ -421,7 +416,7 @@ namespace Sunny.UI if (tabSelectedForeColor != value) { tabSelectedForeColor = value; - SetStyleCustom(); + Invalidate(); } } } @@ -463,7 +458,7 @@ namespace Sunny.UI if (tabSelectedHighColor != value) { tabSelectedHighColor = value; - SetStyleCustom(); + Invalidate(); } } } @@ -488,12 +483,12 @@ namespace Sunny.UI } } - private UIStyle _style = UIStyle.Blue; + private UIStyle _style = UIStyle.Inherited; /// /// 主题样式 /// - [DefaultValue(UIStyle.Blue), Description("主题样式"), Category("SunnyUI")] + [DefaultValue(UIStyle.Inherited), Description("主题样式"), Category("SunnyUI")] public UIStyle Style { get => _style; diff --git a/SunnyUI/Frames/UIPage.cs b/SunnyUI/Frames/UIPage.cs index 99cefd9d..c643adc8 100644 --- a/SunnyUI/Frames/UIPage.cs +++ b/SunnyUI/Frames/UIPage.cs @@ -40,11 +40,11 @@ * 2023-07-27: V3.4.1 默认提示弹窗TopMost为true * 2023-10-09: V3.5.0 增加一个在窗体显示后延时执行的事件 * 2023-10-26: V3.5.1 字体图标增加旋转角度参数SymbolRotate + * 2023-11-06: V3.5.2 重构主题 ******************************************************************************/ using System; using System.ComponentModel; -using System.Diagnostics; using System.Drawing; using System.Drawing.Design; using System.Windows.Forms; @@ -59,7 +59,7 @@ namespace Sunny.UI private ToolStripStatusLabelBorderSides _rectSides = ToolStripStatusLabelBorderSides.None; - protected UIStyle _style = UIStyle.Blue; + protected UIStyle _style = UIStyle.Inherited; [Browsable(false)] public IFrame Frame @@ -290,7 +290,10 @@ namespace Sunny.UI public void Render() { - SetStyle(UIStyles.Style); + if (!DesignMode && UIStyles.Style.IsValid()) + { + Style = UIStyles.Style; + } } private int _symbolSize = 24; @@ -403,28 +406,10 @@ namespace Sunny.UI { _rectColor = value; AfterSetRectColor(value); - _style = UIStyle.Custom; Invalidate(); } } - protected bool IsDesignMode - { - get - { -#if NETFRAMEWORK - var ReturnFlag = false; - if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) - ReturnFlag = true; - else if (Process.GetCurrentProcess().ProcessName == "devenv") - ReturnFlag = true; - return ReturnFlag; -#else - return DesignMode || IsAncestorSiteInDesignMode; -#endif - } - } - [DefaultValue(ToolStripStatusLabelBorderSides.None)] [Description("边框显示位置"), Category("SunnyUI")] public ToolStripStatusLabelBorderSides RectSides @@ -455,7 +440,7 @@ namespace Sunny.UI /// /// 主题样式 /// - [DefaultValue(UIStyle.Blue), Description("主题样式"), Category("SunnyUI")] + [DefaultValue(UIStyle.Inherited), Description("主题样式"), Category("SunnyUI")] public UIStyle Style { get => _style; @@ -727,7 +712,6 @@ namespace Sunny.UI if (controlBoxForeColor != value) { controlBoxForeColor = value; - _style = UIStyle.Custom; Invalidate(); } } @@ -746,7 +730,6 @@ namespace Sunny.UI if (ControlBoxFillHoverColor != value) { controlBoxFillHoverColor = value; - _style = UIStyle.Custom; Invalidate(); } } @@ -905,20 +888,6 @@ namespace Sunny.UI } } - protected override void OnBackColorChanged(EventArgs e) - { - base.OnBackColorChanged(e); - AfterSetFillColor(BackColor); - _style = UIStyle.Custom; - } - - protected override void OnForeColorChanged(EventArgs e) - { - base.OnForeColorChanged(e); - AfterSetForeColor(ForeColor); - _style = UIStyle.Custom; - } - private int titleHeight = 35; [Description("面板高度"), Category("SunnyUI")] diff --git a/SunnyUI/Style/UIStyles.cs b/SunnyUI/Style/UIStyles.cs index 09f6cbf9..2ab118ea 100644 --- a/SunnyUI/Style/UIStyles.cs +++ b/SunnyUI/Style/UIStyles.cs @@ -405,7 +405,7 @@ namespace Sunny.UI foreach (var page in Pages.Values) { - page.Style = style; + page.SetInheritedStyle(style); } }