* 一些语法上的重构

This commit is contained in:
Sunny 2021-10-16 22:33:10 +08:00
parent 7c1ec6d352
commit 5ece1cc39a
30 changed files with 101 additions and 93 deletions

Binary file not shown.

View File

@ -45,8 +45,8 @@ namespace Sunny.UI
// //
this.DropDownStyle = UIDropDownStyle.DropDownList; this.DropDownStyle = UIDropDownStyle.DropDownList;
this.Name = "UIColorPicker"; this.Name = "UIColorPicker";
this.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0); this.Padding = new Padding(0, 0, 30, 0);
this.ButtonClick += new System.EventHandler(this.UIColorPicker_ButtonClick); this.ButtonClick += this.UIColorPicker_ButtonClick;
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }
@ -109,7 +109,7 @@ namespace Sunny.UI
protected override void OnPaintFore(Graphics g, System.Drawing.Drawing2D.GraphicsPath path) protected override void OnPaintFore(Graphics g, System.Drawing.Drawing2D.GraphicsPath path)
{ {
base.OnPaintFore(g, path); base.OnPaintFore(g, path);
var pathColor = g.CreateRoundedRectanglePath(new Rectangle(3, 3, Width - 32, Height - 7), 5, UICornerRadiusSides.All); var pathColor = g.CreateRoundedRectanglePath(new Rectangle(3, 3, Width - 32, Height - 7), 3, UICornerRadiusSides.All);
g.FillPath(Value, pathColor); g.FillPath(Value, pathColor);
} }

View File

@ -321,7 +321,7 @@ namespace Sunny.UI
private void UIComboBox_KeyDown(object sender, KeyEventArgs e) private void UIComboBox_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == System.Windows.Forms.Keys.Enter) if (e.KeyCode == Keys.Enter)
{ {
ShowDropDown(); ShowDropDown();
} }
@ -329,7 +329,7 @@ namespace Sunny.UI
private void edit_KeyDown(object sender, KeyEventArgs e) private void edit_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == System.Windows.Forms.Keys.Enter) if (e.KeyCode == Keys.Enter)
{ {
ShowDropDown(); ShowDropDown();
} }

View File

@ -36,16 +36,16 @@ namespace Sunny.UI
// //
// UIComboTreeView // UIComboTreeView
// //
this.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList; this.DropDownStyle = UIDropDownStyle.DropDownList;
this.Name = "UIComboTreeView"; this.Name = "UIComboTreeView";
this.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0); this.Padding = new Padding(0, 0, 30, 0);
this.ButtonClick += UIComboDataGridView_ButtonClick; this.ButtonClick += UIComboDataGridView_ButtonClick;
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }
private void UIComboDataGridView_ButtonClick(object sender, System.EventArgs e) private void UIComboDataGridView_ButtonClick(object sender, EventArgs e)
{ {
ItemForm.Size = ItemSize; ItemForm.Size = ItemSize;
item.ShowButtons = true; item.ShowButtons = true;

View File

@ -45,10 +45,10 @@ namespace Sunny.UI
// //
// UIComboTreeView // UIComboTreeView
// //
this.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList; this.DropDownStyle = UIDropDownStyle.DropDownList;
this.Name = "UIComboTreeView"; this.Name = "UIComboTreeView";
this.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0); this.Padding = new Padding(0, 0, 30, 0);
this.ButtonClick += new System.EventHandler(this.UIComboTreeView_ButtonClick); this.ButtonClick += this.UIComboTreeView_ButtonClick;
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -172,7 +172,7 @@ namespace Sunny.UI
} }
} }
private void UIComboTreeView_ButtonClick(object sender, System.EventArgs e) private void UIComboTreeView_ButtonClick(object sender, EventArgs e)
{ {
ItemForm.Size = ItemSize; ItemForm.Size = ItemSize;
item.TreeView.ExpandAll(); item.TreeView.ExpandAll();

View File

@ -32,7 +32,7 @@ namespace Sunny.UI
[ToolboxItem(true)] [ToolboxItem(true)]
[DefaultProperty("Value")] [DefaultProperty("Value")]
[DefaultEvent("ValueChanged")] [DefaultEvent("ValueChanged")]
public sealed partial class UIDatetimePicker : UIDropControl,IToolTip public sealed class UIDatetimePicker : UIDropControl, IToolTip
{ {
private void InitializeComponent() private void InitializeComponent()
{ {
@ -41,10 +41,10 @@ namespace Sunny.UI
// UIDatetimePicker // UIDatetimePicker
// //
this.Name = "UIDatetimePicker"; this.Name = "UIDatetimePicker";
this.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0); this.Padding = new Padding(0, 0, 30, 0);
this.SymbolDropDown = 61555; this.SymbolDropDown = 61555;
this.SymbolNormal = 61555; this.SymbolNormal = 61555;
this.ButtonClick += new System.EventHandler(this.UIDatetimePicker_ButtonClick); this.ButtonClick += this.UIDatetimePicker_ButtonClick;
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -91,7 +91,7 @@ namespace Sunny.UI
timer?.Dispose(); timer?.Dispose();
} }
[DefaultValue(System.Windows.Forms.FlowDirection.LeftToRight)] [DefaultValue(FlowDirection.LeftToRight)]
[Localizable(true)] [Localizable(true)]
public FlowDirection FlowDirection public FlowDirection FlowDirection
{ {
@ -377,31 +377,31 @@ namespace Sunny.UI
private void InitializeComponent() private void InitializeComponent()
{ {
this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel = new FlowLayoutPanel();
this.VBar = new Sunny.UI.UIVerScrollBarEx(); this.VBar = new UIVerScrollBarEx();
this.HBar = new Sunny.UI.UIHorScrollBarEx(); this.HBar = new UIHorScrollBarEx();
this.SuspendLayout(); this.SuspendLayout();
// //
// flowLayoutPanel // flowLayoutPanel
// //
this.flowLayoutPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255))))); this.flowLayoutPanel.BackColor = Color.FromArgb(235, 243, 255);
this.flowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel.Dock = DockStyle.Fill;
this.flowLayoutPanel.Location = new System.Drawing.Point(2, 2); this.flowLayoutPanel.Location = new Point(2, 2);
this.flowLayoutPanel.Name = "flowLayoutPanel"; this.flowLayoutPanel.Name = "flowLayoutPanel";
this.flowLayoutPanel.Size = new System.Drawing.Size(429, 383); this.flowLayoutPanel.Size = new Size(429, 383);
this.flowLayoutPanel.TabIndex = 0; this.flowLayoutPanel.TabIndex = 0;
this.flowLayoutPanel.Tag = "69605093-6397-AD32-9F69-3C29F642F87E"; this.flowLayoutPanel.Tag = "69605093-6397-AD32-9F69-3C29F642F87E";
// //
// VBar // VBar
// //
this.VBar.BoundsHeight = 10; this.VBar.BoundsHeight = 10;
this.VBar.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.VBar.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.VBar.LargeChange = 10; this.VBar.LargeChange = 10;
this.VBar.Location = new System.Drawing.Point(410, 5); this.VBar.Location = new Point(410, 5);
this.VBar.Maximum = 100; this.VBar.Maximum = 100;
this.VBar.MinimumSize = new System.Drawing.Size(1, 1); this.VBar.MinimumSize = new Size(1, 1);
this.VBar.Name = "VBar"; this.VBar.Name = "VBar";
this.VBar.Size = new System.Drawing.Size(18, 377); this.VBar.Size = new Size(18, 377);
this.VBar.TabIndex = 1; this.VBar.TabIndex = 1;
this.VBar.TagString = "63FD1249-41D3-E08A-F8F5-CC41CC30FD03"; this.VBar.TagString = "63FD1249-41D3-E08A-F8F5-CC41CC30FD03";
this.VBar.Text = "uiVerScrollBarEx1"; this.VBar.Text = "uiVerScrollBarEx1";
@ -411,13 +411,13 @@ namespace Sunny.UI
// HBar // HBar
// //
this.HBar.BoundsWidth = 10; this.HBar.BoundsWidth = 10;
this.HBar.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.HBar.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.HBar.LargeChange = 10; this.HBar.LargeChange = 10;
this.HBar.Location = new System.Drawing.Point(5, 364); this.HBar.Location = new Point(5, 364);
this.HBar.Maximum = 100; this.HBar.Maximum = 100;
this.HBar.MinimumSize = new System.Drawing.Size(1, 1); this.HBar.MinimumSize = new Size(1, 1);
this.HBar.Name = "HBar"; this.HBar.Name = "HBar";
this.HBar.Size = new System.Drawing.Size(399, 18); this.HBar.Size = new Size(399, 18);
this.HBar.TabIndex = 2; this.HBar.TabIndex = 2;
this.HBar.TagString = "79E1E7DD-3E4D-916B-C8F1-F45B579C290C"; this.HBar.TagString = "79E1E7DD-3E4D-916B-C8F1-F45B579C290C";
this.HBar.Text = "uiHorScrollBarEx1"; this.HBar.Text = "uiHorScrollBarEx1";
@ -430,8 +430,8 @@ namespace Sunny.UI
this.Controls.Add(this.VBar); this.Controls.Add(this.VBar);
this.Controls.Add(this.flowLayoutPanel); this.Controls.Add(this.flowLayoutPanel);
this.Name = "UIFlowLayoutPanel"; this.Name = "UIFlowLayoutPanel";
this.Padding = new System.Windows.Forms.Padding(2); this.Padding = new Padding(2);
this.Size = new System.Drawing.Size(433, 387); this.Size = new Size(433, 387);
this.ResumeLayout(false); this.ResumeLayout(false);
} }

View File

@ -254,7 +254,7 @@ namespace Sunny.UI
} }
scrollValue = value; scrollValue = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
Invalidate(); Invalidate();
} }

View File

@ -133,14 +133,14 @@ namespace Sunny.UI
{ {
int value = (Value - LargeChange).CheckInRange(0, Maximum - BoundsWidth); int value = (Value - LargeChange).CheckInRange(0, Maximum - BoundsWidth);
Value = value; Value = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
} }
if (inRightArea) if (inRightArea)
{ {
int value = (Value + LargeChange).CheckInRange(0, Maximum - BoundsWidth); int value = (Value + LargeChange).CheckInRange(0, Maximum - BoundsWidth);
Value = value; Value = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
} }
if (inCenterArea) if (inCenterArea)
@ -149,7 +149,7 @@ namespace Sunny.UI
int value = (e.Location.X - x / 2) * maximum / (Width - 32); int value = (e.Location.X - x / 2) * maximum / (Width - 32);
value = value.CheckInRange(0, Maximum - BoundsWidth); value = value.CheckInRange(0, Maximum - BoundsWidth);
Value = value; Value = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
} }
} }
@ -220,7 +220,7 @@ namespace Sunny.UI
int value = (e.Location.X - x / 2) * maximum / (Width - 32); int value = (e.Location.X - x / 2) * maximum / (Width - 32);
value = value.CheckInRange(0, Maximum - BoundsWidth); value = value.CheckInRange(0, Maximum - BoundsWidth);
Value = value; Value = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
} }
} }

View File

@ -24,7 +24,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms; using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI

View File

@ -151,7 +151,7 @@ namespace Sunny.UI
// Draw the background ellipse // Draw the background ellipse
var rectangle = new Rectangle(Padding.Left, Padding.Top, diameter, diameter); var rectangle = new Rectangle(Padding.Left, Padding.Top, diameter, diameter);
g.FillEllipse(darkColor, rectangle, true); g.FillEllipse(darkColor, rectangle);
// Draw the glow gradient // Draw the glow gradient
var path = new GraphicsPath(); var path = new GraphicsPath();

View File

@ -223,7 +223,7 @@ namespace Sunny.UI
} }
} }
private bool showLightLine = false; private bool showLightLine;
[DefaultValue(false)] [DefaultValue(false)]
[Description("显示灯光亮线"), Category("SunnyUI")] [Description("显示灯光亮线"), Category("SunnyUI")]

View File

@ -460,14 +460,14 @@ namespace Sunny.UI
MenuHelper.SetPageIndex(node, pageIndex); MenuHelper.SetPageIndex(node, pageIndex);
} }
public void SetNodeTipsText(TreeNode node, string tipsText) public void SetNodeTipsText(TreeNode node, string nodeTipsText)
{ {
MenuHelper.SetTipsText(node, tipsText); MenuHelper.SetTipsText(node, nodeTipsText);
} }
public void SetNodeTipsText(TreeNode node, string tipsText, Color tipsBackColor, Color tipsForeColor) public void SetNodeTipsText(TreeNode node, string nodeTipsText, Color nodeTipsBackColor, Color nodeTipsForeColor)
{ {
MenuHelper.SetTipsText(node, tipsText, tipsBackColor, tipsForeColor); MenuHelper.SetTipsText(node, nodeTipsText, nodeTipsBackColor, nodeTipsForeColor);
} }
public void SetNodeSymbol(TreeNode node, int symbol, int symbolSize = 24) public void SetNodeSymbol(TreeNode node, int symbol, int symbolSize = 24)

View File

@ -399,7 +399,7 @@ namespace Sunny.UI
public Guid PageGuid { get; set; } = Guid.Empty; public Guid PageGuid { get; set; } = Guid.Empty;
public bool AlwaysOpen { get; set; } = false; public bool AlwaysOpen { get; set; }
public NavMenuItem() public NavMenuItem()

View File

@ -268,7 +268,7 @@ namespace Sunny.UI
dataSource = value; dataSource = value;
activePage = 1; activePage = 1;
TotalCount = dataManager?.List.Count ?? 0; TotalCount = dataManager?.List.Count ?? 0;
DataSourceChanged?.Invoke(this, null); DataSourceChanged?.Invoke(this, EventArgs.Empty);
} }
} }

View File

@ -561,7 +561,7 @@ namespace Sunny.UI
return result; return result;
} }
private int FlowPos = 0; private int FlowPos;
private void PaintFlow(Graphics g) private void PaintFlow(Graphics g)
{ {

View File

@ -259,7 +259,7 @@ namespace Sunny.UI
} }
scrollValue = value; scrollValue = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
Invalidate(); Invalidate();
} }

View File

@ -36,7 +36,7 @@ namespace Sunny.UI
private int _symbolSize = 24; private int _symbolSize = 24;
private int _imageInterval = 2; private int _imageInterval = 2;
private Color symbolColor = UIFontColor.Primary; private Color symbolColor;
public UISymbolLabel() public UISymbolLabel()
{ {

View File

@ -664,7 +664,7 @@ namespace Sunny.UI
} }
} }
private int LastIndex = 0; private int LastIndex;
public void Init() public void Init()
{ {

View File

@ -311,7 +311,7 @@ namespace Sunny.UI
private void Edit_MouseWheel(object sender, MouseEventArgs e) private void Edit_MouseWheel(object sender, MouseEventArgs e)
{ {
base.OnMouseWheel(e); OnMouseWheel(e);
if (bar != null && bar.Visible && edit != null) if (bar != null && bar.Visible && edit != null)
{ {
var si = ScrollBarInfo.GetInfo(edit.Handle); var si = ScrollBarInfo.GetInfo(edit.Handle);
@ -1074,7 +1074,7 @@ namespace Sunny.UI
} }
} }
private int _symbol = 0; private int _symbol;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Editor(typeof(UIImagePropertyEditor), typeof(UITypeEditor))] [Editor(typeof(UIImagePropertyEditor), typeof(UITypeEditor))]

View File

@ -30,7 +30,7 @@ namespace Sunny.UI
[ToolboxItem(true)] [ToolboxItem(true)]
[DefaultProperty("Value")] [DefaultProperty("Value")]
[DefaultEvent("ValueChanged")] [DefaultEvent("ValueChanged")]
public sealed partial class UITimePicker : UIDropControl,IToolTip public sealed class UITimePicker : UIDropControl, IToolTip
{ {
private void InitializeComponent() private void InitializeComponent()
{ {
@ -39,10 +39,10 @@ namespace Sunny.UI
// UITimePicker // UITimePicker
// //
this.Name = "UITimePicker"; this.Name = "UITimePicker";
this.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0); this.Padding = new Padding(0, 0, 30, 0);
this.SymbolDropDown = 61555; this.SymbolDropDown = 61555;
this.SymbolNormal = 61555; this.SymbolNormal = 61555;
this.ButtonClick += new System.EventHandler(this.UITimePicker_ButtonClick); this.ButtonClick += this.UITimePicker_ButtonClick;
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }

View File

@ -274,7 +274,7 @@ namespace Sunny.UI
public string Title { get; set; } public string Title { get; set; }
public string Description { get; set; } public string Description { get; set; }
public int Symbol { get; set; } = 0; public int Symbol { get; set; }
public int SymbolSize { get; set; } = 32; public int SymbolSize { get; set; } = 32;

View File

@ -128,7 +128,7 @@ namespace Sunny.UI
Invalidate(); Invalidate();
} }
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
} }
} }

View File

@ -27,7 +27,6 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Drawing.Design; using System.Drawing.Design;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
@ -862,7 +861,7 @@ namespace Sunny.UI
{ {
lineX -= Indent; lineX -= Indent;
if (pNode != null && Nodes.Count > 0) if (Nodes.Count > 0)
{ {
if (pNode.NextNode != null) if (pNode.NextNode != null)
e.Graphics.DrawLine(pn, lineX, lineY, lineX, e.Node.Bounds.Top); e.Graphics.DrawLine(pn, lineX, lineY, lineX, e.Node.Bounds.Top);
@ -912,7 +911,7 @@ namespace Sunny.UI
} }
} }
private bool TreeNodeSelected(DrawTreeNodeEventArgs e) public bool TreeNodeSelected(DrawTreeNodeEventArgs e)
{ {
return e.State == TreeNodeStates.Selected || e.State == TreeNodeStates.Focused || return e.State == TreeNodeStates.Selected || e.State == TreeNodeStates.Focused ||
e.State == (TreeNodeStates.Focused | TreeNodeStates.Selected); e.State == (TreeNodeStates.Focused | TreeNodeStates.Selected);
@ -984,7 +983,7 @@ namespace Sunny.UI
if (parentNode.Parent != null) //如果父节点之上还有父节点 if (parentNode.Parent != null) //如果父节点之上还有父节点
{ {
SetParentNodeCheckedState(parentNode, ByMouse); //递归调用 SetParentNodeCheckedState(parentNode, true); //递归调用
} }
} }

View File

@ -390,8 +390,6 @@ namespace Sunny.UI
pt4 = new Point(Width / 2 + 4, Height - pipeSize - 8 - 7); pt4 = new Point(Width / 2 + 4, Height - pipeSize - 8 - 7);
e.Graphics.FillPolygon(rectColor, new PointF[] { pt1, pt2, pt3, pt4, pt1 }); e.Graphics.FillPolygon(rectColor, new PointF[] { pt1, pt2, pt3, pt4, pt1 });
break; break;
default:
break;
} }
} }
} }

View File

@ -132,14 +132,14 @@ namespace Sunny.UI
{ {
int value = (Value - LargeChange).CheckInRange(0, Maximum - BoundsHeight); int value = (Value - LargeChange).CheckInRange(0, Maximum - BoundsHeight);
Value = value; Value = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
} }
if (inRightArea) if (inRightArea)
{ {
int value = (Value + LargeChange).CheckInRange(0, Maximum - BoundsHeight); int value = (Value + LargeChange).CheckInRange(0, Maximum - BoundsHeight);
Value = value; Value = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
} }
if (inCenterArea) if (inCenterArea)
@ -148,7 +148,7 @@ namespace Sunny.UI
int value = (e.Location.Y - y / 2) * maximum / (Height - 32); int value = (e.Location.Y - y / 2) * maximum / (Height - 32);
value = value.CheckInRange(0, Maximum - BoundsHeight); value = value.CheckInRange(0, Maximum - BoundsHeight);
Value = value; Value = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
} }
} }
@ -219,7 +219,7 @@ namespace Sunny.UI
int value = (e.Location.Y - y / 2) * maximum / (Height - 32); int value = (e.Location.Y - y / 2) * maximum / (Height - 32);
value = value.CheckInRange(0, Maximum - BoundsHeight); value = value.CheckInRange(0, Maximum - BoundsHeight);
Value = value; Value = value;
ValueChanged?.Invoke(this, null); ValueChanged?.Invoke(this, EventArgs.Empty);
} }
} }

View File

@ -136,7 +136,6 @@ namespace Sunny.UI
public static void DrawFontImage(this Graphics graphics, int symbol, int symbolSize, Color color, public static void DrawFontImage(this Graphics graphics, int symbol, int symbolSize, Color color,
RectangleF rect, int xOffset = 0, int yOffSet = 0) RectangleF rect, int xOffset = 0, int yOffSet = 0)
{ {
UISymbolType symbolType = (UISymbolType)symbol.Div(100000);
SizeF sf = graphics.GetFontImageSize(symbol, symbolSize); SizeF sf = graphics.GetFontImageSize(symbol, symbolSize);
graphics.DrawFontImage(symbol, symbolSize, color, rect.Left + ((rect.Width - sf.Width) / 2.0f).RoundEx(), graphics.DrawFontImage(symbol, symbolSize, color, rect.Left + ((rect.Width - sf.Width) / 2.0f).RoundEx(),
rect.Top + ((rect.Height - sf.Height) / 2.0f).RoundEx(), xOffset, yOffSet); rect.Top + ((rect.Height - sf.Height) / 2.0f).RoundEx(), xOffset, yOffSet);
@ -186,7 +185,7 @@ namespace Sunny.UI
using (Graphics g = image.Graphics()) using (Graphics g = image.Graphics())
{ {
SizeF sf = g.GetFontImageSize(symbol, size); SizeF sf = g.GetFontImageSize(symbol, size);
g.DrawFontImage(symbol, size, color, (image.Width - sf.Width) / 2.0f, (image.Height - sf.Height) / 2.0f, 0, 0); g.DrawFontImage(symbol, size, color, (image.Width - sf.Width) / 2.0f, (image.Height - sf.Height) / 2.0f);
} }
return image; return image;

View File

@ -291,51 +291,71 @@ namespace Sunny.UI
var t = typeof(FontAwesomeIcons); var t = typeof(FontAwesomeIcons);
foreach (var fieldInfo in t.GetFields()) foreach (var fieldInfo in t.GetFields())
{ {
int value = fieldInfo.GetRawConstantValue().ToString().ToInt(); object obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
FontAwesomeV4Labels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV4)); FontAwesomeV4Labels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV4));
} }
} }
}
private void bg2_DoWork(object sender, DoWorkEventArgs e) private void bg2_DoWork(object sender, DoWorkEventArgs e)
{ {
var t = typeof(FontElegantIcons); var t = typeof(FontElegantIcons);
foreach (var fieldInfo in t.GetFields()) foreach (var fieldInfo in t.GetFields())
{ {
int value = fieldInfo.GetRawConstantValue().ToString().ToInt(); object obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
ElegantIconsLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV4)); ElegantIconsLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV4));
} }
} }
}
private void bg3_DoWork(object sender, DoWorkEventArgs e) private void bg3_DoWork(object sender, DoWorkEventArgs e)
{ {
var t = typeof(FontAweSomeV5Brands); var t = typeof(FontAweSomeV5Brands);
foreach (var fieldInfo in t.GetFields()) foreach (var fieldInfo in t.GetFields())
{ {
int value = fieldInfo.GetRawConstantValue().ToString().ToInt(); object obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
FontAwesomeV5BrandsLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV5Brands)); FontAwesomeV5BrandsLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV5Brands));
} }
} }
}
private void bg4_DoWork(object sender, DoWorkEventArgs e) private void bg4_DoWork(object sender, DoWorkEventArgs e)
{ {
var t = typeof(FontAweSomeV5Regular); var t = typeof(FontAweSomeV5Regular);
foreach (var fieldInfo in t.GetFields()) foreach (var fieldInfo in t.GetFields())
{ {
int value = fieldInfo.GetRawConstantValue().ToString().ToInt(); object obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
FontAwesomeV5RegularLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV5Regular)); FontAwesomeV5RegularLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV5Regular));
} }
} }
}
private void bg5_DoWork(object sender, DoWorkEventArgs e) private void bg5_DoWork(object sender, DoWorkEventArgs e)
{ {
var t = typeof(FontAweSomeV5Solid); var t = typeof(FontAweSomeV5Solid);
foreach (var fieldInfo in t.GetFields()) foreach (var fieldInfo in t.GetFields())
{ {
int value = fieldInfo.GetRawConstantValue().ToString().ToInt(); object obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
FontAwesomeV5SolidLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV5Solid)); FontAwesomeV5SolidLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV5Solid));
} }
} }
} }
}
/// <summary> /// <summary>
/// 字体图标属性编辑器 /// 字体图标属性编辑器

View File

@ -31,10 +31,6 @@ namespace Sunny.UI
{ {
get; set; get; set;
} }
public Range BrightnessRange
{
get; set;
}
} }
private static readonly Dictionary<ColorScheme, DefinedColor> ColorDictionary = new Dictionary<ColorScheme, DefinedColor>(); private static readonly Dictionary<ColorScheme, DefinedColor> ColorDictionary = new Dictionary<ColorScheme, DefinedColor>();
@ -206,7 +202,7 @@ namespace Sunny.UI
var m = (v2 - v1) / (s2 - s1); var m = (v2 - v1) / (s2 - s1);
var b = v1 - m * s1; var b = v1 - m * s1;
return (int)(m * S + b); return m * S + b;
} }
} }
@ -270,15 +266,12 @@ namespace Sunny.UI
var sMin = jagged[0][0]; var sMin = jagged[0][0];
var sMax = jagged[jagged.Length - 1][0]; var sMax = jagged[jagged.Length - 1][0];
var bMin = jagged[jagged.Length - 1][1];
var bMax = jagged[0][1];
ColorDictionary[scheme] = new DefinedColor() ColorDictionary[scheme] = new DefinedColor()
{ {
HueRange = Range.ToRange(hueRange), HueRange = Range.ToRange(hueRange),
LowerBounds = jagged.Select(j => new Point(j[0], j[1])).ToArray(), LowerBounds = jagged.Select(j => new Point(j[0], j[1])).ToArray(),
SaturationRange = new Range(sMin, sMax), SaturationRange = new Range(sMin, sMax)
BrightnessRange = new Range(bMin, bMax)
}; };
} }
@ -345,7 +338,7 @@ namespace Sunny.UI
{ {
h = 1; h = 1;
} }
if (h == 360) if (h.EqualsDouble(360))
{ {
h = 359; h = 359;
} }

View File

@ -164,7 +164,7 @@ namespace Sunny.UI
{ {
public UIPurpleStyle() public UIPurpleStyle()
{ {
Init(UIColor.Purple, UIStyle.Purple, Color.White); base.Init(UIColor.Purple, UIStyle.Purple, Color.White);
} }
} }
@ -172,7 +172,7 @@ namespace Sunny.UI
{ {
public UILightPurpleStyle() public UILightPurpleStyle()
{ {
InitPlain(UIColor.Purple, UIStyle.LightPurple, Color.White); base.InitPlain(UIColor.Purple, UIStyle.LightPurple, Color.White);
} }
} }
@ -180,7 +180,7 @@ namespace Sunny.UI
{ {
public UIColorfulStyle() public UIColorfulStyle()
{ {
Init(Color.FromArgb(0, 190, 172), UIStyle.Colorful, Color.White); base.Init(Color.FromArgb(0, 190, 172), UIStyle.Colorful, Color.White);
} }
public void Init(Color styleColor, Color foreColor) public void Init(Color styleColor, Color foreColor)