* IStyle:支持自定义主题

This commit is contained in:
Sunny 2021-07-15 21:46:56 +08:00
parent d040187d82
commit 5b7c07c51c
24 changed files with 311 additions and 119 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

131
SunnyUI/.editorconfig Normal file
View File

@ -0,0 +1,131 @@
# Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\Users\Administrator\source\repos\SunnyUI\SunnyUI\ codebase based on best match to current usage at 2021/7/15
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]
#Core editorconfig formatting - indentation
#use soft tabs (spaces) for indentation
indent_style = space
#Formatting - indentation options
#indent switch case contents.
csharp_indent_case_contents = true
#indent switch labels
csharp_indent_switch_labels = true
#Formatting - new line options
#place catch statements on a new line
csharp_new_line_before_catch = true
#place else statements on a new line
csharp_new_line_before_else = true
#require members of object initializers to be on the same line
csharp_new_line_before_members_in_object_initializers = false
#require braces to be on a new line for accessors, object_collection_array_initializers, methods, types, control_blocks, and properties (also known as "Allman" style)
csharp_new_line_before_open_brace = accessors, object_collection_array_initializers, methods, types, control_blocks, properties
#require elements of query expression clauses to be on the same line
csharp_new_line_between_query_expression_clauses = false
#Formatting - organize using options
#sort System.* using directives alphabetically, and place them before other usings
dotnet_sort_system_directives_first = true
#Formatting - spacing options
#require NO space between a cast and the value
csharp_space_after_cast = false
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_after_colon_in_inheritance_clause = true
#require a space after a keyword in a control flow statement such as a for loop
csharp_space_after_keywords_in_control_flow_statements = true
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_before_colon_in_inheritance_clause = true
#remove space within empty argument list parentheses
csharp_space_between_method_call_empty_parameter_list_parentheses = false
#remove space between method call name and opening parenthesis
csharp_space_between_method_call_name_and_opening_parenthesis = false
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
csharp_space_between_method_call_parameter_list_parentheses = false
#remove space within empty parameter list parentheses for a method declaration
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
csharp_space_between_method_declaration_parameter_list_parentheses = false
#Formatting - wrapping options
#leave code block on separate lines
csharp_preserve_single_line_blocks = false
#leave statements and member declarations on the same line
csharp_preserve_single_line_statements = true
#Style - Code block preferences
#prefer no curly braces if allowed
csharp_prefer_braces = false:suggestion
#Style - expression bodied member options
#prefer expression-bodied members for accessors
csharp_style_expression_bodied_accessors = true:suggestion
#prefer block bodies for constructors
csharp_style_expression_bodied_constructors = false:suggestion
#prefer block bodies for methods
csharp_style_expression_bodied_methods = false:suggestion
#prefer expression-bodied members for properties
csharp_style_expression_bodied_properties = true:suggestion
#Style - expression level options
#prefer out variables to be declared inline in the argument list of a method call when possible
csharp_style_inlined_variable_declaration = true:suggestion
#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_member_access = true:suggestion
#Style - Expression-level preferences
#prefer objects to not be initialized using object initializers
dotnet_style_object_initializer = false:suggestion
#Style - implicit and explicit types
#prefer explicit type over var in all cases, unless overridden by another code style rule
csharp_style_var_elsewhere = false:suggestion
#prefer explicit type over var to declare variables with built-in system types such as int
csharp_style_var_for_built_in_types = false:suggestion
#prefer explicit type over var when the type is already mentioned on the right-hand side of a declaration
csharp_style_var_when_type_is_apparent = false:suggestion
#Style - language keyword and framework type options
#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
#Style - modifier options
#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
#Style - Modifier preferences
#when this rule is set to a list of modifiers, prefer the specified ordering.
csharp_preferred_modifier_order = public,private,protected,internal,static,override,readonly,virtual,extern,new,sealed:suggestion
#Style - Pattern matching
#prefer pattern matching instead of is expression with type casts
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
#Style - qualification options
#prefer events not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_event = false:suggestion
#prefer fields not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_field = false:suggestion
#prefer methods not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_method = false:suggestion
#prefer properties not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_property = false:suggestion

View File

@ -67,8 +67,8 @@ namespace Sunny.UI
ShowText = false; ShowText = false;
ShowRect = false; ShowRect = false;
fillColor = UIStyles.Blue.AvatarFillColor; fillColor = UIStyles.GetStyleColor(UIStyle.Blue).AvatarFillColor;
foreColor = UIStyles.Blue.AvatarForeColor; foreColor = UIStyles.GetStyleColor(UIStyle.Blue).AvatarForeColor;
} }
private int avatarSize = 60; private int avatarSize = 60;

View File

@ -46,17 +46,17 @@ namespace Sunny.UI
Height = 35; Height = 35;
Cursor = Cursors.Hand; Cursor = Cursors.Hand;
foreHoverColor = UIStyles.Blue.ButtonForeHoverColor; foreHoverColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForeHoverColor;
forePressColor = UIStyles.Blue.ButtonForePressColor; forePressColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForePressColor;
foreSelectedColor = UIStyles.Blue.ButtonForeSelectedColor; foreSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForeSelectedColor;
rectHoverColor = UIStyles.Blue.RectHoverColor; rectHoverColor = UIStyles.GetStyleColor(UIStyle.Blue).RectHoverColor;
rectPressColor = UIStyles.Blue.RectPressColor; rectPressColor = UIStyles.GetStyleColor(UIStyle.Blue).RectPressColor;
rectSelectedColor = UIStyles.Blue.RectSelectedColor; rectSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).RectSelectedColor;
fillHoverColor = UIStyles.Blue.ButtonFillHoverColor; fillHoverColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillHoverColor;
fillPressColor = UIStyles.Blue.ButtonFillPressColor; fillPressColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillPressColor;
fillSelectedColor = UIStyles.Blue.ButtonFillSelectedColor; fillSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillSelectedColor;
SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick); SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick);
} }

View File

@ -40,8 +40,8 @@ namespace Sunny.UI
base.Cursor = Cursors.Hand; base.Cursor = Cursors.Hand;
ShowRect = false; ShowRect = false;
Size = new Size(150, 29); Size = new Size(150, 29);
foreColor = UIStyles.Blue.CheckBoxForeColor; foreColor = UIStyles.GetStyleColor(UIStyle.Blue).CheckBoxForeColor;
fillColor = UIStyles.Blue.CheckBoxColor; fillColor = UIStyles.GetStyleColor(UIStyle.Blue).CheckBoxColor;
SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick); SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick);
} }

View File

@ -197,7 +197,7 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 边框颜色 /// 边框颜色
/// </summary> /// </summary>
protected Color rectColor = UIStyles.Blue.RectColor; protected Color rectColor = UIStyles.GetStyleColor(UIStyle.Blue).RectColor;
/// <summary> /// <summary>
/// 字体颜色 /// 字体颜色

View File

@ -97,7 +97,7 @@ namespace Sunny.UI
public class ContextMenuColorTable : ProfessionalColorTable public class ContextMenuColorTable : ProfessionalColorTable
{ {
private UIBaseStyle StyleColor = UIStyles.Blue; private UIBaseStyle StyleColor = UIStyles.GetStyleColor(UIStyle.Blue);
public void SetStyleColor(UIBaseStyle color) public void SetStyleColor(UIBaseStyle color)
{ {

View File

@ -549,22 +549,22 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 选中颜色 /// 选中颜色
/// </summary> /// </summary>
protected Color fillSelectedColor = UIStyles.Blue.ButtonFillSelectedColor; protected Color fillSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillSelectedColor;
/// <summary> /// <summary>
/// 边框颜色 /// 边框颜色
/// </summary> /// </summary>
protected Color rectColor = UIStyles.Blue.RectColor; protected Color rectColor = UIStyles.GetStyleColor(UIStyle.Blue).RectColor;
/// <summary> /// <summary>
/// 填充颜色 /// 填充颜色
/// </summary> /// </summary>
protected Color fillColor = UIStyles.Blue.ButtonFillColor; protected Color fillColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillColor;
/// <summary> /// <summary>
/// 字体颜色 /// 字体颜色
/// </summary> /// </summary>
protected Color foreColor = UIStyles.Blue.ButtonForeColor; protected Color foreColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForeColor;
/// <summary> /// <summary>
/// 字体鼠标移上颜色 /// 字体鼠标移上颜色
@ -579,7 +579,7 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 字体不可用颜色 /// 字体不可用颜色
/// </summary> /// </summary>
protected Color foreDisableColor = UIStyles.Blue.ForeDisableColor; protected Color foreDisableColor = UIStyles.GetStyleColor(UIStyle.Blue).ForeDisableColor;
/// <summary> /// <summary>
/// 边框鼠标移上颜色 /// 边框鼠标移上颜色
@ -594,7 +594,7 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 边框不可用颜色 /// 边框不可用颜色
/// </summary> /// </summary>
protected Color rectDisableColor = UIStyles.Blue.RectDisableColor; protected Color rectDisableColor = UIStyles.GetStyleColor(UIStyle.Blue).RectDisableColor;
/// <summary> /// <summary>
/// 填充鼠标移上颜色 /// 填充鼠标移上颜色
@ -609,7 +609,7 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 填充不可用颜色 /// 填充不可用颜色
/// </summary> /// </summary>
protected Color fillDisableColor = UIStyles.Blue.FillDisableColor; protected Color fillDisableColor = UIStyles.GetStyleColor(UIStyle.Blue).FillDisableColor;
/// <summary> /// <summary>
/// 设置选中颜色 /// 设置选中颜色

View File

@ -47,12 +47,12 @@ namespace Sunny.UI
RectSides = ToolStripStatusLabelBorderSides.None; RectSides = ToolStripStatusLabelBorderSides.None;
Padding = new Padding(0, 8, 0, 3); Padding = new Padding(0, 8, 0, 3);
foreHoverColor = UIStyles.Blue.ButtonForeHoverColor; foreHoverColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForeHoverColor;
forePressColor = UIStyles.Blue.ButtonForePressColor; forePressColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForePressColor;
foreSelectedColor = UIStyles.Blue.ButtonForeSelectedColor; foreSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonForeSelectedColor;
fillHoverColor = UIStyles.Blue.ButtonFillHoverColor; fillHoverColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillHoverColor;
fillPressColor = UIStyles.Blue.ButtonFillPressColor; fillPressColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillPressColor;
fillSelectedColor = UIStyles.Blue.ButtonFillSelectedColor; fillSelectedColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillSelectedColor;
SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick); SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick);
} }

View File

@ -47,7 +47,7 @@ namespace Sunny.UI
_style = UIStyle.Custom; _style = UIStyle.Custom;
} }
private Color foreColor = UIStyles.Blue.LabelForeColor; private Color foreColor = UIStyles.GetStyleColor(UIStyle.Blue).LabelForeColor;
/// <summary> /// <summary>
/// Tag字符串 /// Tag字符串

View File

@ -34,8 +34,8 @@ namespace Sunny.UI
SetStyleFlags(true, false); SetStyleFlags(true, false);
Size = new Size(360, 29); Size = new Size(360, 29);
MinimumSize = new Size(2, 2); MinimumSize = new Size(2, 2);
foreColor = UIStyles.Blue.LineForeColor; foreColor = UIStyles.GetStyleColor(UIStyle.Blue).LineForeColor;
fillColor = UIStyles.Blue.PlainColor; fillColor = UIStyles.GetStyleColor(UIStyle.Blue).PlainColor;
} }
public enum LineDirection public enum LineDirection

View File

@ -37,9 +37,9 @@ namespace Sunny.UI
public partial class UIPanel : UserControl, IStyleInterface public partial class UIPanel : UserControl, IStyleInterface
{ {
private int radius = 5; private int radius = 5;
protected Color rectColor = UIStyles.Blue.RectColor; protected Color rectColor = UIStyles.GetStyleColor(UIStyle.Blue).RectColor;
protected Color fillColor = UIStyles.Blue.PlainColor; protected Color fillColor = UIStyles.GetStyleColor(UIStyle.Blue).PlainColor;
protected Color foreColor = UIStyles.Blue.PanelForeColor; protected Color foreColor = UIStyles.GetStyleColor(UIStyle.Blue).PanelForeColor;
public UIPanel() public UIPanel()
{ {

View File

@ -47,8 +47,8 @@ namespace Sunny.UI
Cursor = Cursors.Hand; Cursor = Cursors.Hand;
ShowRect = false; ShowRect = false;
Size = new Size(150, 29); Size = new Size(150, 29);
foreColor = UIStyles.Blue.CheckBoxForeColor; foreColor = UIStyles.GetStyleColor(UIStyle.Blue).CheckBoxForeColor;
fillColor = UIStyles.Blue.CheckBoxColor; fillColor = UIStyles.GetStyleColor(UIStyle.Blue).CheckBoxColor;
} }
protected override void OnPaint(PaintEventArgs e) protected override void OnPaint(PaintEventArgs e)

View File

@ -39,8 +39,8 @@ namespace Sunny.UI
public UIScrollingText() public UIScrollingText()
{ {
SetStyleFlags(true, false); SetStyleFlags(true, false);
fillColor = UIStyles.Blue.PlainColor; fillColor = UIStyles.GetStyleColor(UIStyle.Blue).PlainColor;
foreColor = UIStyles.Blue.RectColor; foreColor = UIStyles.GetStyleColor(UIStyle.Blue).RectColor;
Reset(); Reset();
timer.Interval = interval; timer.Interval = interval;

View File

@ -1730,22 +1730,22 @@ namespace Sunny.UI
public void ShowInfoNotifier(string desc, bool isDialog = false, int timeout = 2000) public void ShowInfoNotifier(string desc, bool isDialog = false, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, UINotifierType.INFO, UILocalize.InfoTitle, false, timeout); UINotifierHelper.ShowNotifier(desc, UINotifierType.INFO, UILocalize.InfoTitle, isDialog, timeout);
} }
public void ShowSuccessNotifier(string desc, bool isDialog = false, int timeout = 2000) public void ShowSuccessNotifier(string desc, bool isDialog = false, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, false, timeout); UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, isDialog, timeout);
} }
public void ShowWarningNotifier(string desc, bool isDialog = false, int timeout = 2000) public void ShowWarningNotifier(string desc, bool isDialog = false, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, false, timeout); UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, isDialog, timeout);
} }
public void ShowErrorNotifier(string desc, bool isDialog = false, int timeout = 2000) public void ShowErrorNotifier(string desc, bool isDialog = false, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, false, timeout); UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, isDialog, timeout);
} }
#endregion #endregion

View File

@ -165,30 +165,30 @@ namespace Sunny.UI
{ {
case UINotifierType.ERROR: case UINotifierType.ERROR:
icon.Symbol = 61527; icon.Symbol = 61527;
icon.SymbolColor = UIStyles.Red.ButtonFillColor; icon.SymbolColor = UIStyles.GetStyleColor(UIStyle.Red).ButtonFillColor;
LeaveColor = UIStyles.Red.ButtonFillColor; LeaveColor = UIStyles.GetStyleColor(UIStyle.Red).ButtonFillColor;
HoverColor = UIStyles.Red.ButtonFillHoverColor; HoverColor = UIStyles.GetStyleColor(UIStyle.Red).ButtonFillHoverColor;
break; break;
case UINotifierType.INFO: case UINotifierType.INFO:
icon.Symbol = 61530; icon.Symbol = 61530;
icon.SymbolColor = UIStyles.Blue.ButtonFillColor; icon.SymbolColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillColor;
LeaveColor = UIStyles.Blue.ButtonFillColor; LeaveColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillColor;
HoverColor = UIStyles.Blue.ButtonFillHoverColor; HoverColor = UIStyles.GetStyleColor(UIStyle.Blue).ButtonFillHoverColor;
break; break;
case UINotifierType.WARNING: case UINotifierType.WARNING:
icon.Symbol = 61553; icon.Symbol = 61553;
icon.SymbolColor = UIStyles.Orange.ButtonFillColor; icon.SymbolColor = UIStyles.GetStyleColor(UIStyle.Orange).ButtonFillColor;
LeaveColor = UIStyles.Orange.ButtonFillColor; LeaveColor = UIStyles.GetStyleColor(UIStyle.Orange).ButtonFillColor;
HoverColor = UIStyles.Orange.ButtonFillHoverColor; HoverColor = UIStyles.GetStyleColor(UIStyle.Orange).ButtonFillHoverColor;
break; break;
case UINotifierType.OK: case UINotifierType.OK:
icon.Symbol = 61528; icon.Symbol = 61528;
icon.SymbolColor = UIStyles.Green.ButtonFillColor; icon.SymbolColor = UIStyles.GetStyleColor(UIStyle.Green).ButtonFillColor;
LeaveColor = UIStyles.Green.ButtonFillColor; LeaveColor = UIStyles.GetStyleColor(UIStyle.Green).ButtonFillColor;
HoverColor = UIStyles.Green.ButtonFillHoverColor; HoverColor = UIStyles.GetStyleColor(UIStyle.Green).ButtonFillHoverColor;
break; break;
} }

View File

@ -105,8 +105,8 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 紫 /// 紫
/// </summary> /// </summary>
//[DisplayText("Purple")] [DisplayText("Purple")]
//Purple = 9, Purple = 9,
/// <summary> /// <summary>
/// Office蓝 /// Office蓝
@ -154,7 +154,19 @@ namespace Sunny.UI
/// 浅灰 /// 浅灰
/// </summary> /// </summary>
[DisplayText("LightGray")] [DisplayText("LightGray")]
LightGray = 205 LightGray = 205,
/// <summary>
/// 浅紫
/// </summary>
[DisplayText("LightPurple")]
LightPurple = 209,
/// <summary>
/// 多彩的
/// </summary>
[DisplayText("Colorful")]
Colorful = 999
} }
/// <summary> /// <summary>
@ -179,89 +191,109 @@ namespace Sunny.UI
/// <summary> /// <summary>
/// 自定义 /// 自定义
/// </summary> /// </summary>
public static UIBaseStyle Custom = new UICustomStyle(); private readonly static UIBaseStyle Custom = new UICustomStyle();
/// <summary> /// <summary>
/// 白 /// 白
/// </summary> /// </summary>
public static UIBaseStyle White = new UIWhiteStyle(); private readonly static UIBaseStyle White = new UIWhiteStyle();
/// <summary> /// <summary>
/// 蓝 /// 蓝
/// </summary> /// </summary>
public static UIBaseStyle Blue = new UIBlueStyle(); private readonly static UIBaseStyle Blue = new UIBlueStyle();
/// <summary> /// <summary>
/// 浅蓝 /// 浅蓝
/// </summary> /// </summary>
public static UIBaseStyle LightBlue = new UILightBlueStyle(); private readonly static UIBaseStyle LightBlue = new UILightBlueStyle();
/// <summary> /// <summary>
/// 橙 /// 橙
/// </summary> /// </summary>
public static UIBaseStyle Orange = new UIOrangeStyle(); private readonly static UIBaseStyle Orange = new UIOrangeStyle();
/// <summary> /// <summary>
/// 浅橙 /// 浅橙
/// </summary> /// </summary>
public static UIBaseStyle LightOrange = new UILightOrangeStyle(); private readonly static UIBaseStyle LightOrange = new UILightOrangeStyle();
/// <summary> /// <summary>
/// 灰 /// 灰
/// </summary> /// </summary>
public static UIBaseStyle Gray = new UIGrayStyle(); private readonly static UIBaseStyle Gray = new UIGrayStyle();
/// <summary> /// <summary>
/// 浅灰 /// 浅灰
/// </summary> /// </summary>
public static UIBaseStyle LightGray = new UILightGrayStyle(); private readonly static UIBaseStyle LightGray = new UILightGrayStyle();
/// <summary> /// <summary>
/// 绿 /// 绿
/// </summary> /// </summary>
public static UIBaseStyle Green = new UIGreenStyle(); private readonly static UIBaseStyle Green = new UIGreenStyle();
/// <summary> /// <summary>
/// 浅绿 /// 浅绿
/// </summary> /// </summary>
public static UIBaseStyle LightGreen = new UILightGreenStyle(); private readonly static UIBaseStyle LightGreen = new UILightGreenStyle();
/// <summary> /// <summary>
/// 红 /// 红
/// </summary> /// </summary>
public static UIBaseStyle Red = new UIRedStyle(); private readonly static UIBaseStyle Red = new UIRedStyle();
/// <summary> /// <summary>
/// 浅红 /// 浅红
/// </summary> /// </summary>
public static UIBaseStyle LightRed = new UILightRedStyle(); private readonly static UIBaseStyle LightRed = new UILightRedStyle();
/// <summary> /// <summary>
/// 深蓝 /// 深蓝
/// </summary> /// </summary>
public static UIBaseStyle DarkBlue = new UIDarkBlueStyle(); private readonly static UIBaseStyle DarkBlue = new UIDarkBlueStyle();
/// <summary> /// <summary>
/// 黑 /// 黑
/// </summary> /// </summary>
public static UIBaseStyle Black = new UIBlackStyle(); private readonly static UIBaseStyle Black = new UIBlackStyle();
/// <summary> /// <summary>
/// Office蓝 /// Office蓝
/// </summary> /// </summary>
public static UIBaseStyle Office2010Blue = new UIOffice2010BlueStyle(); private readonly static UIBaseStyle Office2010Blue = new UIOffice2010BlueStyle();
/// <summary> /// <summary>
/// Office银 /// Office银
/// </summary> /// </summary>
public static UIBaseStyle Office2010Silver = new UIOffice2010SilverStyle(); private readonly static UIBaseStyle Office2010Silver = new UIOffice2010SilverStyle();
public static UIBaseStyle PurpleStyle = new UIPurpleStyle(); /// <summary>
/// 紫
/// </summary>
private readonly static UIBaseStyle Purple = new UIPurpleStyle();
/// <summary>
/// 浅紫
/// </summary>
private readonly static UIBaseStyle LightPurple = new UILightPurpleStyle();
/// <summary>
/// 多彩
/// </summary>
private readonly static UIColorfulStyle Colorful = new UIColorfulStyle();
/// <summary> /// <summary>
/// Office黑 /// Office黑
/// </summary> /// </summary>
public static UIBaseStyle Office2010Black = new UIOffice2010BlackStyle(); private readonly static UIBaseStyle Office2010Black = new UIOffice2010BlackStyle();
public static void InitColorful(Color styleColor, Color foreColor)
{
Colorful.Init(styleColor, foreColor);
Style = UIStyle.Colorful;
SetStyle(Style);
}
private static readonly ConcurrentDictionary<UIStyle, UIBaseStyle> Styles = new ConcurrentDictionary<UIStyle, UIBaseStyle>(); private static readonly ConcurrentDictionary<UIStyle, UIBaseStyle> Styles = new ConcurrentDictionary<UIStyle, UIBaseStyle>();
private static readonly ConcurrentDictionary<Guid, UIForm> Forms = new ConcurrentDictionary<Guid, UIForm>(); private static readonly ConcurrentDictionary<Guid, UIForm> Forms = new ConcurrentDictionary<Guid, UIForm>();
@ -288,10 +320,12 @@ namespace Sunny.UI
AddStyle(DarkBlue); AddStyle(DarkBlue);
AddStyle(Black); AddStyle(Black);
AddStyle(White); AddStyle(White);
//AddStyle(PurpleStyle); AddStyle(Purple);
AddStyle(LightPurple);
AddStyle(Office2010Blue); AddStyle(Office2010Blue);
AddStyle(Office2010Silver); AddStyle(Office2010Silver);
AddStyle(Office2010Black); AddStyle(Office2010Black);
AddStyle(Colorful);
MenuColors.TryAdd(UIMenuStyle.Custom, new UIMenuCustomColor()); MenuColors.TryAdd(UIMenuStyle.Custom, new UIMenuCustomColor());
MenuColors.TryAdd(UIMenuStyle.Black, new UIMenuBlackColor()); MenuColors.TryAdd(UIMenuStyle.Black, new UIMenuBlackColor());

View File

@ -24,30 +24,29 @@ using System.Drawing;
namespace Sunny.UI namespace Sunny.UI
{ {
public abstract class UIBaseStyle public class UIBaseStyle
{ {
public abstract UIStyle Name { get; } public virtual UIStyle Name { get; protected set; }
public virtual Color PrimaryColor { get; protected set; } public virtual Color PrimaryColor { get; protected set; }
public virtual Color RegularColor { get; protected set; } public virtual Color RegularColor { get; protected set; }
public virtual Color SecondaryColor { get; protected set; } public virtual Color SecondaryColor { get; protected set; }
public virtual Color PlainColor { get; protected set; } public virtual Color PlainColor { get; protected set; }
public abstract Color RectColor { get; } public virtual Color RectColor { get; protected set; }
public abstract Color RectHoverColor { get; } public virtual Color RectHoverColor { get; protected set; }
public abstract Color RectPressColor { get; } public virtual Color RectPressColor { get; protected set; }
public virtual Color RectSelectedColor { get; protected set; }
public abstract Color RectSelectedColor { get; }
public abstract Color ButtonForeSelectedColor { get; }
public abstract Color ButtonFillSelectedColor { get; }
public virtual Color ButtonFillColor { get; protected set; } public virtual Color ButtonFillColor { get; protected set; }
public virtual Color ButtonFillHoverColor { get; protected set; } public virtual Color ButtonFillHoverColor { get; protected set; }
public virtual Color ButtonFillPressColor { get; protected set; } public virtual Color ButtonFillPressColor { get; protected set; }
public virtual Color ButtonFillSelectedColor { get; protected set; }
public abstract Color ButtonForeColor { get; } public virtual Color ButtonForeColor { get; protected set; }
public abstract Color ButtonForeHoverColor { get; } public virtual Color ButtonForeHoverColor { get; protected set; }
public abstract Color ButtonForePressColor { get; } public virtual Color ButtonForePressColor { get; protected set; }
public virtual Color ButtonForeSelectedColor { get; protected set; }
public virtual Color FillDisableColor => Color.FromArgb(244, 244, 244); public virtual Color FillDisableColor => Color.FromArgb(244, 244, 244);
public virtual Color RectDisableColor => Color.FromArgb(173, 178, 181); public virtual Color RectDisableColor => Color.FromArgb(173, 178, 181);
@ -64,10 +63,10 @@ namespace Sunny.UI
public virtual Color DropDownControlColor => PanelForeColor; public virtual Color DropDownControlColor => PanelForeColor;
public abstract Color TitleColor { get; } public virtual Color TitleColor { get; protected set; }
public abstract Color TitleForeColor { get; } public virtual Color TitleForeColor { get; protected set; }
public virtual Color MenuSelectedColor => UIColor.Blue; public virtual Color MenuSelectedColor { get; protected set; } = UIColor.Blue;
public virtual Color GridSelectedColor { get; protected set; } = Color.FromArgb(155, 200, 255); public virtual Color GridSelectedColor { get; protected set; } = Color.FromArgb(155, 200, 255);
@ -124,13 +123,12 @@ namespace Sunny.UI
{ {
return Name.DisplayText(); return Name.DisplayText();
} }
}
public class UIPurpleStyle : UIBaseStyle protected virtual void Init(Color color, UIStyle style, Color foreColor)
{
public UIPurpleStyle()
{ {
PrimaryColor = UIColor.Purple; Name = style;
MenuSelectedColor = TitleColor = RectColor = PrimaryColor = color;
Color[] colors = GDIEx.GradientColors(Color.White, PrimaryColor, 16); Color[] colors = GDIEx.GradientColors(Color.White, PrimaryColor, 16);
Color[] colors1 = GDIEx.GradientColors(PrimaryColor, Color.Black, 16); Color[] colors1 = GDIEx.GradientColors(PrimaryColor, Color.Black, 16);
PlainColor = colors[1]; PlainColor = colors[1];
@ -138,35 +136,55 @@ namespace Sunny.UI
RegularColor = colors[10]; RegularColor = colors[10];
ButtonFillColor = PrimaryColor; ButtonFillColor = PrimaryColor;
ButtonFillHoverColor = colors[12]; RectHoverColor = ButtonFillHoverColor = colors[12];
ButtonFillPressColor = colors1[3]; RectSelectedColor = RectPressColor = ButtonFillSelectedColor = ButtonFillPressColor = colors1[3];
GridSelectedColor = colors[3]; GridSelectedColor = colors[3];
ButtonForeColor = ButtonForeHoverColor = ButtonForePressColor = ButtonForeSelectedColor = TitleForeColor = foreColor;
} }
public override UIStyle Name => UIStyle.Blue; protected virtual void InitPlain(Color color, UIStyle style, Color foreColor)
{
Name = style;
MenuSelectedColor = RectColor = RectHoverColor = TitleColor = ButtonForeColor = ButtonFillHoverColor = PrimaryColor = color;
Color[] colors = GDIEx.GradientColors(Color.White, PrimaryColor, 16);
Color[] colors1 = GDIEx.GradientColors(PrimaryColor, Color.Black, 16);
ButtonFillColor = PlainColor = colors[1];
SecondaryColor = colors[5];
RegularColor = colors[10];
ButtonFillSelectedColor = RectPressColor = RectSelectedColor = ButtonFillPressColor = colors1[3];
GridSelectedColor = colors[3];
ButtonForeHoverColor = ButtonForePressColor = ButtonForeSelectedColor = TitleForeColor = foreColor;
}
}
public override Color PrimaryColor { get; protected set; } public class UIPurpleStyle : UIBaseStyle
public override Color RegularColor { get; protected set; } {
public override Color SecondaryColor { get; protected set; } public UIPurpleStyle()
public override Color PlainColor { get; protected set; } {
Init(UIColor.Purple, UIStyle.Purple, Color.White);
}
}
public override Color ButtonFillColor { get; protected set; } public class UILightPurpleStyle : UIBaseStyle
public override Color ButtonFillHoverColor { get; protected set; } {
public override Color ButtonFillPressColor { get; protected set; } public UILightPurpleStyle()
{
InitPlain(UIColor.Purple, UIStyle.LightPurple, Color.White);
}
}
public override Color ButtonForeColor => Color.White; public class UIColorfulStyle : UIBaseStyle
public override Color ButtonForeHoverColor => Color.White; {
public override Color ButtonForePressColor => Color.White; public UIColorfulStyle()
public override Color RectSelectedColor => RectPressColor; {
public override Color ButtonForeSelectedColor => ButtonForePressColor; Init(Color.FromArgb(0, 190, 172), UIStyle.Colorful, Color.White);
public override Color ButtonFillSelectedColor => ButtonFillPressColor; }
public override Color RectColor => UIColor.Purple;
public override Color RectHoverColor => ButtonFillHoverColor; public void Init(Color styleColor, Color foreColor)
public override Color RectPressColor => ButtonFillPressColor; {
public override Color TitleColor => UIColor.Purple; Init(styleColor, UIStyle.Colorful, foreColor);
public override Color TitleForeColor => Color.White; }
public override Color MenuSelectedColor => UIColor.Purple;
public override Color GridSelectedColor { get; protected set; }
} }
public class UICustomStyle : UIBlueStyle public class UICustomStyle : UIBlueStyle

View File

@ -44,6 +44,14 @@ namespace Sunny.UI
} }
} }
public void Render()
{
if (Style != UIStyle.Custom)
{
UIStyles.SetStyle(Style);
}
}
/// <summary> /// <summary>
/// 构造函数 /// 构造函数
/// </summary> /// </summary>

View File

@ -44,6 +44,7 @@
<None Remove="Font\fa-solid-900.ttf" /> <None Remove="Font\fa-solid-900.ttf" />
<None Remove="Font\FontAwesome.ttf" /> <None Remove="Font\FontAwesome.ttf" />
<None Remove="Style\UIStyleColor.cs~RF1472b803.TMP" /> <None Remove="Style\UIStyleColor.cs~RF1472b803.TMP" />
<None Remove="Style\UIStyleColor.cs~RF22754f9d.TMP" />
<None Include="..\LICENSE"> <None Include="..\LICENSE">
<Pack>True</Pack> <Pack>True</Pack>
<PackagePath></PackagePath> <PackagePath></PackagePath>