* UIHeaderButton: 增加Disabled颜色

This commit is contained in:
Sunny 2021-09-21 10:40:08 +08:00
parent cab9dfc02a
commit 8f3b1bccbb
5 changed files with 48 additions and 26 deletions

Binary file not shown.

Binary file not shown.

View File

@ -14,26 +14,26 @@ namespace Sunny.UI.Demo
Header.SetNodeSymbol(Header.Nodes[0], 61451); Header.SetNodeSymbol(Header.Nodes[0], 61451);
TreeNode parent = Aside.CreateNode("控件", 61451, 24, pageIndex); TreeNode parent = Aside.CreateNode("控件", 61451, 24, pageIndex);
//通过设置PageIndex关联节点文字、图标由相应的Page的Text、Symbol提供 //通过设置PageIndex关联节点文字、图标由相应的Page的Text、Symbol提供
Aside.CreateChildNode(parent, AddPage(new FAvatar(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FButton(), ++pageIndex)); Aside.CreateChildNode(parent, AddPage(new FButton(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FCheckBox(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FCombobox(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FContextMenuStrip(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FDataGridView(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FFlowLayoutPanel(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FHeaderButton(), ++pageIndex)); Aside.CreateChildNode(parent, AddPage(new FHeaderButton(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FLabel(), ++pageIndex)); Aside.CreateChildNode(parent, AddPage(new FLabel(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FCheckBox(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FRadioButton(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FTextBox(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FCombobox(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FDataGridView(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FListBox(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FTreeView(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FNavigation(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FTabControl(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FLine(), ++pageIndex)); Aside.CreateChildNode(parent, AddPage(new FLine(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FListBox(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FNavigation(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FPanel(), ++pageIndex)); Aside.CreateChildNode(parent, AddPage(new FPanel(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FFlowLayoutPanel(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FTransfer(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FAvatar(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FContextMenuStrip(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FProcess(), ++pageIndex)); Aside.CreateChildNode(parent, AddPage(new FProcess(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FRadioButton(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FScrollBar(), ++pageIndex)); Aside.CreateChildNode(parent, AddPage(new FScrollBar(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FTabControl(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FTextBox(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FTransfer(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FTreeView(), ++pageIndex));
Aside.CreateChildNode(parent, AddPage(new FOther(), ++pageIndex)); Aside.CreateChildNode(parent, AddPage(new FOther(), ++pageIndex));
//示例设置某个节点的小红点提示 //示例设置某个节点的小红点提示
Aside.ShowTips = true; Aside.ShowTips = true;
@ -81,7 +81,7 @@ namespace Sunny.UI.Demo
AddPage(new FColorful()); AddPage(new FColorful());
//选中第一个节点 //选中第一个节点
Aside.SelectFirst(); Aside.SelectPage(1002);
} }
private void Header_MenuItemClick(string text, int menuIndex, int pageIndex) private void Header_MenuItemClick(string text, int menuIndex, int pageIndex)

View File

@ -20,6 +20,7 @@
* 2021-03-27: V3.0.2 * 2021-03-27: V3.0.2
* 2021-06-01: V3.0.4 * 2021-06-01: V3.0.4
* 2021-06-22: V3.0.4 ShowSelected * 2021-06-22: V3.0.4 ShowSelected
* 2021-09-21: V3.0.7 Disabled颜色
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -51,10 +52,16 @@ namespace Sunny.UI
foreHoverColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForeHoverColor; foreHoverColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForeHoverColor;
forePressColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForePressColor; forePressColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForePressColor;
foreSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForeSelectedColor; foreSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForeSelectedColor;
fillHoverColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillHoverColor; fillHoverColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillHoverColor;
fillPressColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillPressColor; fillPressColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillPressColor;
fillSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillSelectedColor; fillSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillSelectedColor;
SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick); SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick);
fillDisableColor = fillColor;
foreDisableColor = foreColor;
rectDisableColor = UIStyles.GetStyleColor(UIStyle.Blue).RectDisableColor;
} }
private bool isClick; private bool isClick;
@ -141,9 +148,21 @@ namespace Sunny.UI
fillSelectedColor = uiColor.ButtonFillSelectedColor; fillSelectedColor = uiColor.ButtonFillSelectedColor;
foreSelectedColor = uiColor.ButtonForeSelectedColor; foreSelectedColor = uiColor.ButtonForeSelectedColor;
rectDisableColor = uiColor.RectDisableColor;
fillDisableColor = fillColor;
foreDisableColor = foreColor;
Invalidate(); Invalidate();
} }
[Description("不可用颜色"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "173, 178, 181")]
public Color CircleDisabledColor
{
get => rectDisableColor;
set => SetRectDisableColor(value);
}
/// <summary> /// <summary>
/// 填充颜色,当值为背景色或透明色或空值则不填充 /// 填充颜色,当值为背景色或透明色或空值则不填充
/// </summary> /// </summary>
@ -155,6 +174,14 @@ namespace Sunny.UI
set => SetFillColor(value); set => SetFillColor(value);
} }
[Description("填充颜色"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "80, 160, 255")]
public Color FillDisableColor
{
get => fillDisableColor;
set => SetFillDisableColor(value);
}
/// <summary> /// <summary>
/// 字体颜色 /// 字体颜色
/// </summary> /// </summary>
@ -166,15 +193,7 @@ namespace Sunny.UI
set => SetForeColor(value); set => SetForeColor(value);
} }
[DefaultValue(typeof(Color), "244, 244, 244"), Category("SunnyUI")] [DefaultValue(typeof(Color), "White"), Category("SunnyUI")]
[Description("不可用时填充颜色")]
public Color FillDisableColor
{
get => fillDisableColor;
set => SetFillDisableColor(value);
}
[DefaultValue(typeof(Color), "109, 109, 103"), Category("SunnyUI")]
[Description("不可用时字体颜色")] [Description("不可用时字体颜色")]
public Color ForeDisableColor public Color ForeDisableColor
{ {
@ -457,6 +476,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null) if (Symbol > 0 && Image == null)
{ {
Color bcColor = CircleColor; Color bcColor = CircleColor;
if (!Enabled) bcColor = CircleDisabledColor;
if (ShowCircleHoverColor && IsHover) if (ShowCircleHoverColor && IsHover)
{ {
bcColor = CircleHoverColor; bcColor = CircleHoverColor;
@ -484,6 +504,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null) if (Symbol > 0 && Image == null)
{ {
Color bcColor = CircleColor; Color bcColor = CircleColor;
if (!Enabled) bcColor = CircleDisabledColor;
if (ShowCircleHoverColor && IsHover) if (ShowCircleHoverColor && IsHover)
{ {
bcColor = CircleHoverColor; bcColor = CircleHoverColor;
@ -515,6 +536,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null) if (Symbol > 0 && Image == null)
{ {
Color bcColor = CircleColor; Color bcColor = CircleColor;
if (!Enabled) bcColor = CircleDisabledColor;
if (ShowCircleHoverColor && IsHover) if (ShowCircleHoverColor && IsHover)
{ {
bcColor = CircleHoverColor; bcColor = CircleHoverColor;
@ -542,6 +564,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null) if (Symbol > 0 && Image == null)
{ {
Color bcColor = CircleColor; Color bcColor = CircleColor;
if (!Enabled) bcColor = CircleDisabledColor;
if (ShowCircleHoverColor && IsHover) if (ShowCircleHoverColor && IsHover)
{ {
bcColor = CircleHoverColor; bcColor = CircleHoverColor;

View File

@ -196,11 +196,10 @@ namespace Sunny.UI
rectColor = uiColor.SwitchActiveColor; rectColor = uiColor.SwitchActiveColor;
fillColor = uiColor.SwitchFillColor; fillColor = uiColor.SwitchFillColor;
inActiveColor = uiColor.SwitchInActiveColor; inActiveColor = uiColor.SwitchInActiveColor;
disabledColor = uiColor.RectDisableColor; rectDisableColor = uiColor.RectDisableColor;
Invalidate(); Invalidate();
} }
private Color disabledColor;
[Description("不可用颜色"), Category("SunnyUI")] [Description("不可用颜色"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "173, 178, 181")] [DefaultValue(typeof(Color), "173, 178, 181")]
public Color DisabledColor public Color DisabledColor
@ -218,7 +217,7 @@ namespace Sunny.UI
protected override void OnPaintFill(Graphics g, GraphicsPath path) protected override void OnPaintFill(Graphics g, GraphicsPath path)
{ {
Color color = Active ? ActiveColor : InActiveColor; Color color = Active ? ActiveColor : InActiveColor;
if (!Enabled) color = disabledColor; if (!Enabled) color = rectDisableColor;
if (SwitchShape == UISwitchShape.Round) if (SwitchShape == UISwitchShape.Round)
{ {