diff --git a/SunnyUI/Controls/Color/UIColorWheel.cs b/SunnyUI/Controls/Color/UIColorWheel.cs
index ec102e7a..aa43589e 100644
--- a/SunnyUI/Controls/Color/UIColorWheel.cs
+++ b/SunnyUI/Controls/Color/UIColorWheel.cs
@@ -329,7 +329,7 @@ namespace Sunny.UI
/// 设置主题样式
///
/// 主题样式
- public void SetStyle(UIStyle style)
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -337,7 +337,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
///
@@ -353,7 +359,7 @@ namespace Sunny.UI
///
/// 自定义主题风格
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("获取或设置可以自定义主题风格"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
diff --git a/SunnyUI/Controls/Color/UILabelRotate.cs b/SunnyUI/Controls/Color/UILabelRotate.cs
index 92aedf29..a2b47e02 100644
--- a/SunnyUI/Controls/Color/UILabelRotate.cs
+++ b/SunnyUI/Controls/Color/UILabelRotate.cs
@@ -236,7 +236,7 @@ namespace Sunny.UI
/// 设置主题样式
///
/// 主题样式
- public void SetStyle(UIStyle style)
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -244,7 +244,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
///
@@ -260,7 +266,7 @@ namespace Sunny.UI
///
/// 自定义主题风格
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("获取或设置可以自定义主题风格"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
diff --git a/SunnyUI/Controls/UIBreadcrumb.cs b/SunnyUI/Controls/UIBreadcrumb.cs
index 878336d4..47d829b6 100644
--- a/SunnyUI/Controls/UIBreadcrumb.cs
+++ b/SunnyUI/Controls/UIBreadcrumb.cs
@@ -315,7 +315,7 @@ namespace Sunny.UI
if (unSelectedForeColor != value)
{
unSelectedForeColor = value;
- SetStyleCustom();
+ Invalidate();
}
}
}
diff --git a/SunnyUI/Controls/UICheckBoxGroup.cs b/SunnyUI/Controls/UICheckBoxGroup.cs
index a1bff724..b515ca7d 100644
--- a/SunnyUI/Controls/UICheckBoxGroup.cs
+++ b/SunnyUI/Controls/UICheckBoxGroup.cs
@@ -62,15 +62,6 @@ namespace Sunny.UI
public UICheckBoxGroup()
{
items.CountChange += Items_CountChange;
- StyleCustomModeChanged += UICheckBoxGroup_StyleCustomModeChanged;
- }
-
- private void UICheckBoxGroup_StyleCustomModeChanged(object sender, EventArgs e)
- {
- foreach (var item in boxes)
- {
- item.StyleCustomMode = styleCustomMode;
- }
}
protected override void OnFontChanged(EventArgs e)
diff --git a/SunnyUI/Controls/UIContextMenuStrip.cs b/SunnyUI/Controls/UIContextMenuStrip.cs
index 08a08d84..5eb8ea31 100644
--- a/SunnyUI/Controls/UIContextMenuStrip.cs
+++ b/SunnyUI/Controls/UIContextMenuStrip.cs
@@ -83,7 +83,7 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
@@ -94,7 +94,11 @@ namespace Sunny.UI
[Description("鑾峰彇鎴栬缃寘鍚湁鍏虫帶浠剁殑鏁版嵁鐨勫璞″瓧绗︿覆"), Category("SunnyUI")]
public string TagString { get; set; }
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -102,7 +106,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UIControl.cs b/SunnyUI/Controls/UIControl.cs
index ec2c43c6..120d3a9b 100644
--- a/SunnyUI/Controls/UIControl.cs
+++ b/SunnyUI/Controls/UIControl.cs
@@ -281,16 +281,11 @@ namespace Sunny.UI
set => SetStyle(value);
}
- protected void SetStyleCustom(bool needRefresh = true)
- {
- if (needRefresh) Invalidate();
- }
-
///
/// 璁剧疆涓婚鏍峰紡
///
/// 涓婚鏍峰紡
- public void SetStyle(UIStyle style)
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -307,26 +302,12 @@ namespace Sunny.UI
_style = UIStyle.Inherited;
}
- protected bool styleCustomMode = false;
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
- public bool StyleCustomMode
- {
- get => styleCustomMode;
- set
- {
- if (styleCustomMode != value)
- {
- styleCustomMode = value;
- StyleCustomModeChanged?.Invoke(this, EventArgs.Empty);
- }
- }
- }
-
- public event EventHandler StyleCustomModeChanged;
+ public bool StyleCustomMode { get; set; }
///
/// 璁剧疆涓婚鏍峰紡棰滆壊
@@ -757,7 +738,7 @@ namespace Sunny.UI
if (fillSelectedColor != color)
{
fillSelectedColor = color;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -770,7 +751,7 @@ namespace Sunny.UI
if (foreSelectedColor != color)
{
foreSelectedColor = color;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -783,7 +764,7 @@ namespace Sunny.UI
if (rectSelectedColor != color)
{
rectSelectedColor = color;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -796,7 +777,7 @@ namespace Sunny.UI
if (fillHoverColor != color)
{
fillHoverColor = color;
- SetStyleCustom(false);
+ Invalidate();
}
}
@@ -809,7 +790,7 @@ namespace Sunny.UI
if (fillPressColor != color)
{
fillPressColor = color;
- SetStyleCustom(false);
+ Invalidate();
}
}
@@ -822,7 +803,7 @@ namespace Sunny.UI
if (fillDisableColor != color)
{
fillDisableColor = color;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -835,7 +816,7 @@ namespace Sunny.UI
if (fillReadOnlyColor != color)
{
fillReadOnlyColor = color;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -848,7 +829,7 @@ namespace Sunny.UI
if (rectHoverColor != color)
{
rectHoverColor = color;
- SetStyleCustom(false);
+ Invalidate();
}
}
@@ -861,7 +842,7 @@ namespace Sunny.UI
if (rectPressColor != color)
{
rectPressColor = color;
- SetStyleCustom(false);
+ Invalidate();
}
}
@@ -874,7 +855,7 @@ namespace Sunny.UI
if (rectDisableColor != color)
{
rectDisableColor = color;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -887,7 +868,7 @@ namespace Sunny.UI
if (rectReadOnlyColor != color)
{
rectReadOnlyColor = color;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -900,7 +881,7 @@ namespace Sunny.UI
if (foreHoverColor != color)
{
foreHoverColor = color;
- SetStyleCustom(false);
+ Invalidate();
}
}
@@ -913,7 +894,7 @@ namespace Sunny.UI
if (forePressColor != color)
{
forePressColor = color;
- SetStyleCustom(false);
+ Invalidate();
}
}
@@ -926,7 +907,7 @@ namespace Sunny.UI
if (foreDisableColor != color)
{
foreDisableColor = color;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -939,7 +920,7 @@ namespace Sunny.UI
if (foreReadOnlyColor != color)
{
foreReadOnlyColor = color;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -952,7 +933,7 @@ namespace Sunny.UI
if (rectColor != value)
{
rectColor = value;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -965,7 +946,7 @@ namespace Sunny.UI
if (fillColor != value)
{
fillColor = value;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -978,7 +959,7 @@ namespace Sunny.UI
if (fillColor2 != value)
{
fillColor2 = value;
- SetStyleCustom();
+ Invalidate();
}
}
@@ -991,7 +972,7 @@ namespace Sunny.UI
if (foreColor != value)
{
foreColor = value;
- SetStyleCustom();
+ Invalidate();
}
}
diff --git a/SunnyUI/Controls/UIDataGridView.cs b/SunnyUI/Controls/UIDataGridView.cs
index 00522104..75a8a2fd 100644
--- a/SunnyUI/Controls/UIDataGridView.cs
+++ b/SunnyUI/Controls/UIDataGridView.cs
@@ -649,7 +649,11 @@ namespace Sunny.UI
}
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -657,7 +661,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
@@ -720,7 +730,7 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
diff --git a/SunnyUI/Controls/UIGifAvatar.cs b/SunnyUI/Controls/UIGifAvatar.cs
index df0d0a93..6378a8b4 100644
--- a/SunnyUI/Controls/UIGifAvatar.cs
+++ b/SunnyUI/Controls/UIGifAvatar.cs
@@ -54,43 +54,23 @@ namespace Sunny.UI
///
/// 濉厖棰滆壊锛屽綋鍊间负鑳屾櫙鑹叉垨閫忔槑鑹叉垨绌哄煎垯涓嶅~鍏
///
- [Description("濉厖棰滆壊锛屽綋鍊间负鑳屾櫙鑹叉垨閫忔槑鑹叉垨绌哄煎垯涓嶅~鍏"), Category("SunnyUI")]
- [DefaultValue(typeof(Color), "243, 249, 255")]
+ [Description("濉厖棰滆壊"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "80, 160, 255")]
public Color FillColor
{
- get
- {
- return fillColor;
- }
- set
- {
- if (fillColor != value)
- {
- fillColor = value;
- SetStyleCustom();
- }
- }
+ get => fillColor;
+ set => SetFillColor(value);
}
///
/// 杈规棰滆壊
///
[Description("杈规棰滆壊"), Category("SunnyUI")]
- [DefaultValue(typeof(Color), "243, 249, 255")]
+ [DefaultValue(typeof(Color), "80, 160, 255")]
public Color RectColor
{
- get
- {
- return rectColor;
- }
- set
- {
- if (rectColor != value)
- {
- rectColor = value;
- SetStyleCustom();
- }
- }
+ get => rectColor;
+ set => SetRectColor(value);
}
public override void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UIImageButton.cs b/SunnyUI/Controls/UIImageButton.cs
index 05a18eda..a43b623d 100644
--- a/SunnyUI/Controls/UIImageButton.cs
+++ b/SunnyUI/Controls/UIImageButton.cs
@@ -105,7 +105,11 @@ namespace Sunny.UI
foreColor = uiColor.ImageButtonForeColor;
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -113,7 +117,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
private UIStyle _style = UIStyle.Blue;
@@ -213,7 +223,7 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
diff --git a/SunnyUI/Controls/UIImageListBox.cs b/SunnyUI/Controls/UIImageListBox.cs
index 50e327fa..9496c02b 100644
--- a/SunnyUI/Controls/UIImageListBox.cs
+++ b/SunnyUI/Controls/UIImageListBox.cs
@@ -570,7 +570,7 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
@@ -654,7 +654,11 @@ namespace Sunny.UI
set => SetStyle(value);
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -662,7 +666,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UIKnobControl.cs b/SunnyUI/Controls/UIKnobControl.cs
index 89b92806..b557b6da 100644
--- a/SunnyUI/Controls/UIKnobControl.cs
+++ b/SunnyUI/Controls/UIKnobControl.cs
@@ -1342,12 +1342,9 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
- public bool StyleCustomMode
- {
- get; set;
- }
+ public bool StyleCustomMode { get; set; }
protected UIStyle _style = UIStyle.Blue;
@@ -1361,19 +1358,25 @@ namespace Sunny.UI
set => SetStyle(value);
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
- this.SuspendLayout();
- UIStyleHelper.SetChildUIStyle(this, style);
-
if (!style.IsCustom())
{
SetStyleColor(style.Colors());
Invalidate();
}
- _style = style;
- this.ResumeLayout();
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public virtual void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UILabel.cs b/SunnyUI/Controls/UILabel.cs
index 9de73dd2..1949579c 100644
--- a/SunnyUI/Controls/UILabel.cs
+++ b/SunnyUI/Controls/UILabel.cs
@@ -119,7 +119,11 @@ namespace Sunny.UI
public string Version { get; }
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -127,13 +131,19 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
@@ -231,11 +241,15 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -243,7 +257,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UIListBoxEx.cs b/SunnyUI/Controls/UIListBoxEx.cs
index e9050a3c..5a916c6d 100644
--- a/SunnyUI/Controls/UIListBoxEx.cs
+++ b/SunnyUI/Controls/UIListBoxEx.cs
@@ -170,7 +170,7 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
@@ -233,7 +233,11 @@ namespace Sunny.UI
}
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -241,7 +245,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UINavBar.cs b/SunnyUI/Controls/UINavBar.cs
index 3e3cf4e9..f311463c 100644
--- a/SunnyUI/Controls/UINavBar.cs
+++ b/SunnyUI/Controls/UINavBar.cs
@@ -743,7 +743,11 @@ namespace Sunny.UI
}
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -751,7 +755,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
@@ -763,7 +773,7 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
diff --git a/SunnyUI/Controls/UINavMenu.cs b/SunnyUI/Controls/UINavMenu.cs
index 7f0d2cce..eed3348c 100644
--- a/SunnyUI/Controls/UINavMenu.cs
+++ b/SunnyUI/Controls/UINavMenu.cs
@@ -305,7 +305,7 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
@@ -459,7 +459,11 @@ namespace Sunny.UI
set => SetStyle(value);
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -467,7 +471,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UIRadioButtonGroup.cs b/SunnyUI/Controls/UIRadioButtonGroup.cs
index 4a82fee3..20e432e3 100644
--- a/SunnyUI/Controls/UIRadioButtonGroup.cs
+++ b/SunnyUI/Controls/UIRadioButtonGroup.cs
@@ -45,7 +45,6 @@ namespace Sunny.UI
public UIRadioButtonGroup()
{
items.CountChange += Items_CountChange;
- StyleCustomModeChanged += UICheckBoxGroup_StyleCustomModeChanged;
}
protected override void OnFontChanged(EventArgs e)
@@ -61,14 +60,6 @@ namespace Sunny.UI
}
}
- private void UICheckBoxGroup_StyleCustomModeChanged(object sender, EventArgs e)
- {
- foreach (var item in buttons)
- {
- item.StyleCustomMode = styleCustomMode;
- }
- }
-
private void Items_CountChange(object sender, EventArgs e)
{
Invalidate();
diff --git a/SunnyUI/Controls/UIRoundProcess.cs b/SunnyUI/Controls/UIRoundProcess.cs
index 550fd121..fbb013b7 100644
--- a/SunnyUI/Controls/UIRoundProcess.cs
+++ b/SunnyUI/Controls/UIRoundProcess.cs
@@ -216,7 +216,7 @@ namespace Sunny.UI
set
{
foreColor2 = value;
- SetStyleCustom();
+ Invalidate();
}
}
diff --git a/SunnyUI/Controls/UISmoothLabel.cs b/SunnyUI/Controls/UISmoothLabel.cs
index bf4ad335..0cc88be7 100644
--- a/SunnyUI/Controls/UISmoothLabel.cs
+++ b/SunnyUI/Controls/UISmoothLabel.cs
@@ -129,7 +129,11 @@ namespace Sunny.UI
public string Version { get; }
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -137,13 +141,19 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
diff --git a/SunnyUI/Controls/UISplitContainer.cs b/SunnyUI/Controls/UISplitContainer.cs
index 94f8b66a..b1586dfd 100644
--- a/SunnyUI/Controls/UISplitContainer.cs
+++ b/SunnyUI/Controls/UISplitContainer.cs
@@ -266,7 +266,7 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
@@ -641,7 +641,7 @@ namespace Sunny.UI
/// 璁剧疆涓婚鏍峰紡
///
/// 涓婚鏍峰紡
- public void SetStyle(UIStyle style)
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -649,7 +649,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetDPIScale()
diff --git a/SunnyUI/Controls/UISymbolButton.cs b/SunnyUI/Controls/UISymbolButton.cs
index 852b5c59..52bd78c0 100644
--- a/SunnyUI/Controls/UISymbolButton.cs
+++ b/SunnyUI/Controls/UISymbolButton.cs
@@ -106,7 +106,7 @@ namespace Sunny.UI
if (symbolColor != value)
{
symbolColor = value;
- SetStyleCustom();
+ Invalidate();
}
}
}
@@ -122,7 +122,7 @@ namespace Sunny.UI
if (symbolHoverColor != value)
{
symbolHoverColor = value;
- SetStyleCustom(false);
+ Invalidate();
}
}
}
@@ -138,7 +138,7 @@ namespace Sunny.UI
if (symbolPressColor != value)
{
symbolPressColor = value;
- SetStyleCustom(false);
+ Invalidate();
}
}
}
@@ -154,7 +154,7 @@ namespace Sunny.UI
if (symbolDisableColor != value)
{
symbolDisableColor = value;
- SetStyleCustom();
+ Invalidate();
}
}
}
@@ -170,7 +170,7 @@ namespace Sunny.UI
if (symbolSelectedColor != value)
{
symbolSelectedColor = value;
- SetStyleCustom();
+ Invalidate();
}
}
}
diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs
index 3b27503a..27cd7527 100644
--- a/SunnyUI/Controls/UITabControl.cs
+++ b/SunnyUI/Controls/UITabControl.cs
@@ -300,12 +300,9 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
- public bool StyleCustomMode
- {
- get; set;
- }
+ public bool StyleCustomMode { get; set; }
private HorizontalAlignment textAlignment = HorizontalAlignment.Center;
@@ -528,7 +525,11 @@ namespace Sunny.UI
}
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -536,7 +537,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UITabControlMenu.cs b/SunnyUI/Controls/UITabControlMenu.cs
index 8906bba6..3fb1eea7 100644
--- a/SunnyUI/Controls/UITabControlMenu.cs
+++ b/SunnyUI/Controls/UITabControlMenu.cs
@@ -97,7 +97,7 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
@@ -277,7 +277,11 @@ namespace Sunny.UI
}
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
@@ -285,7 +289,13 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UITableLayoutPanel.cs b/SunnyUI/Controls/UITableLayoutPanel.cs
index 5c214115..da36c85d 100644
--- a/SunnyUI/Controls/UITableLayoutPanel.cs
+++ b/SunnyUI/Controls/UITableLayoutPanel.cs
@@ -57,12 +57,9 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
- public bool StyleCustomMode
- {
- get; set;
- }
+ public bool StyleCustomMode { get; set; }
private UIStyle _style = UIStyle.Blue;
@@ -86,12 +83,25 @@ namespace Sunny.UI
get; set;
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
- this.SuspendLayout();
- UIStyleHelper.SetChildUIStyle(this, style);
- _style = style;
- this.ResumeLayout();
+ if (!style.IsCustom())
+ {
+ SetStyleColor(style.Colors());
+ Invalidate();
+ }
+
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs
index c59e771d..33aa14e6 100644
--- a/SunnyUI/Controls/UITextBox.cs
+++ b/SunnyUI/Controls/UITextBox.cs
@@ -1318,7 +1318,7 @@ namespace Sunny.UI
e.Graphics.DrawFontImage(Symbol, SymbolSize, SymbolColor, new Rectangle(4 + symbolOffset.X, (Height - SymbolSize) / 2 + 1 + symbolOffset.Y, SymbolSize, SymbolSize), SymbolOffset.X, SymbolOffset.Y, SymbolRotate);
}
- if (styleCustomMode && Text.IsValid() && NeedDrawDisabledText)
+ if (Text.IsValid() && NeedDrawDisabledText)
{
string text = Text;
if (PasswordChar > 0)
diff --git a/SunnyUI/Controls/UIUserControl.cs b/SunnyUI/Controls/UIUserControl.cs
index c6f73a28..3ad25afa 100644
--- a/SunnyUI/Controls/UIUserControl.cs
+++ b/SunnyUI/Controls/UIUserControl.cs
@@ -598,26 +598,13 @@ namespace Sunny.UI
{
}
- protected bool styleCustomMode = false;
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
- public bool StyleCustomMode
- {
- get => styleCustomMode;
- set
- {
- if (styleCustomMode != value)
- {
- styleCustomMode = value;
- StyleCustomModeChanged?.Invoke(this, EventArgs.Empty);
- }
- }
- }
+ public bool StyleCustomMode { get; set; }
- public event EventHandler StyleCustomModeChanged;
protected UIStyle _style = UIStyle.Blue;
@@ -631,19 +618,25 @@ namespace Sunny.UI
set => SetStyle(value);
}
- public void SetStyle(UIStyle style)
+ ///
+ /// 璁剧疆涓婚鏍峰紡
+ ///
+ /// 涓婚鏍峰紡
+ private void SetStyle(UIStyle style)
{
- this.SuspendLayout();
- UIStyleHelper.SetChildUIStyle(this, style);
-
if (!style.IsCustom())
{
SetStyleColor(style.Colors());
Invalidate();
}
- _style = style;
- this.ResumeLayout();
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
+ }
+
+ public void SetInheritedStyle(UIStyle style)
+ {
+ SetStyle(style);
+ _style = UIStyle.Inherited;
}
public virtual void SetStyleColor(UIBaseStyle uiColor)
diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs
index 603ef6f9..f67d5c80 100644
--- a/SunnyUI/Forms/UIForm.cs
+++ b/SunnyUI/Forms/UIForm.cs
@@ -310,6 +310,7 @@ namespace Sunny.UI
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
+
if (ShowTitle && !AllowAddControlOnTitle && e.Control.Top < TitleHeight)
{
e.Control.Top = Padding.Top;
@@ -1240,7 +1241,7 @@ namespace Sunny.UI
}
}
- public void SetStyle(UIStyle style)
+ private void SetStyle(UIStyle style)
{
this.SuspendLayout();
@@ -1255,12 +1256,12 @@ namespace Sunny.UI
this.ResumeLayout();
}
- [Description("鑷畾涔変富棰樻ā寮忥紙寮鍚悗鍏ㄥ眬涓婚鏇存敼灏嗗褰撳墠绐椾綋鏃犳晥锛"), Category("SunnyUI")]
- [DefaultValue(false)]
- public bool StyleCustomMode
- {
- get; set;
- }
+ ///
+ /// 鑷畾涔変富棰橀鏍
+ ///
+ [DefaultValue(false), Browsable(false)]
+ [Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
+ public bool StyleCustomMode { get; set; }
private Color controlBoxForeColor = Color.White;
///
diff --git a/SunnyUI/Frames/UIPage.cs b/SunnyUI/Frames/UIPage.cs
index dc4c6eb7..99cefd9d 100644
--- a/SunnyUI/Frames/UIPage.cs
+++ b/SunnyUI/Frames/UIPage.cs
@@ -465,12 +465,9 @@ namespace Sunny.UI
///
/// 鑷畾涔変富棰橀鏍
///
- [DefaultValue(false)]
+ [DefaultValue(false), Browsable(false)]
[Description("鑾峰彇鎴栬缃彲浠ヨ嚜瀹氫箟涓婚椋庢牸"), Category("SunnyUI")]
- public bool StyleCustomMode
- {
- get; set;
- }
+ public bool StyleCustomMode { get; set; }
public event EventHandler Initialize;
@@ -479,12 +476,6 @@ namespace Sunny.UI
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
- if (e.Control is IStyleInterface ctrl)
- {
- if (!ctrl.StyleCustomMode) ctrl.Style = Style;
- }
-
- UIStyleHelper.SetRawControlStyle(e, Style);
if (AllowShowTitle && !AllowAddControlOnTitle && e.Control.Top < TitleHeight)
{
@@ -562,10 +553,28 @@ namespace Sunny.UI
Finalize?.Invoke(this, new EventArgs());
}
- public void SetStyle(UIStyle style)
+ public void SetInheritedStyle(UIStyle style)
+ {
+ if (!DesignMode)
+ {
+ this.SuspendLayout();
+ UIStyleHelper.SetChildUIStyle(this, style);
+
+ if (_style == UIStyle.Inherited && style.IsValid())
+ {
+ SetStyleColor(style.Colors());
+ Invalidate();
+ _style = UIStyle.Inherited;
+ }
+
+ UIStyleChanged?.Invoke(this, new EventArgs());
+ this.ResumeLayout();
+ }
+ }
+
+ private void SetStyle(UIStyle style)
{
this.SuspendLayout();
- UIStyleHelper.SetChildUIStyle(this, style);
if (!style.IsCustom())
{
@@ -573,7 +582,7 @@ namespace Sunny.UI
Invalidate();
}
- _style = style;
+ _style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
UIStyleChanged?.Invoke(this, new EventArgs());
this.ResumeLayout();
}
diff --git a/SunnyUI/Style/UIStyle.cs b/SunnyUI/Style/UIStyle.cs
index 19bef74a..4d20b83f 100644
--- a/SunnyUI/Style/UIStyle.cs
+++ b/SunnyUI/Style/UIStyle.cs
@@ -43,7 +43,8 @@ namespace Sunny.UI
void SetStyleColor(UIBaseStyle uiColor);
- void SetStyle(UIStyle style);
+ //void SetStyle(UIStyle style);
+ void SetInheritedStyle(UIStyle style);
void SetDPIScale();
}
@@ -400,20 +401,9 @@ namespace Sunny.UI
List controls = ctrl.GetUIStyleControls("IStyleInterface");
foreach (var control in controls)
{
- if (control is IStyleInterface item)
+ if (control is IStyleInterface item && item.Style == UIStyle.Inherited)
{
- if (item.Style == UIStyle.Inherited)
- {
- if (item is UIButton ctrl1)
- {
- ctrl1.SetInheritedStyle(style);
- }
- else
- {
- item.Style = style;
- item.Style = UIStyle.Inherited;
- }
- }
+ item.SetInheritedStyle(style);
}
}
@@ -425,7 +415,7 @@ namespace Sunny.UI
UIContextMenuStrip context = (UIContextMenuStrip)info.GetValue(ctrl);
if (context != null && context.Style == UIStyle.Inherited)
{
- context.SetStyle(style);
+ context.SetInheritedStyle(style);
}
}
}
diff --git a/SunnyUI/Style/UIStyleManager.cs b/SunnyUI/Style/UIStyleManager.cs
index 1ddabfcd..d1ae017a 100644
--- a/SunnyUI/Style/UIStyleManager.cs
+++ b/SunnyUI/Style/UIStyleManager.cs
@@ -49,6 +49,17 @@ namespace Sunny.UI
Version = UIGlobal.Version;
}
+ ///
+ /// 涓婚鏍峰紡
+ ///
+ [DefaultValue(UIStyle.Blue), Description("涓婚鏍峰紡"), Category("SunnyUI")]
+ [Browsable(false)]
+ public UIStyle Style
+ {
+ get => UIStyles.Style;
+ set => UIStyles.SetStyle(value);
+ }
+
[DefaultValue(false), Description("DPI缂╂斁"), Category("SunnyUI")]
public bool DPIScale
{
diff --git a/SunnyUI/Style/UIStyles.cs b/SunnyUI/Style/UIStyles.cs
index e69cdc82..09f6cbf9 100644
--- a/SunnyUI/Style/UIStyles.cs
+++ b/SunnyUI/Style/UIStyles.cs
@@ -394,7 +394,9 @@ namespace Sunny.UI
/// 涓婚鏍峰紡
public static void SetStyle(UIStyle style)
{
+ if (Style == style) return;
Style = style;
+ if (!style.IsValid()) return;
foreach (var form in Forms.Values)
{