diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll
index 9bedfb6d..afa12e23 100644
Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ
diff --git a/Bin/SunnyUI.pdb b/Bin/SunnyUI.pdb
index 6babf425..c7511278 100644
Binary files a/Bin/SunnyUI.pdb and b/Bin/SunnyUI.pdb differ
diff --git a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe
index 608cd633..7b99a8c1 100644
Binary files a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe and b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe differ
diff --git a/SunnyUI.Demo/Bin/SunnyUI.dll b/SunnyUI.Demo/Bin/SunnyUI.dll
index 9bedfb6d..afa12e23 100644
Binary files a/SunnyUI.Demo/Bin/SunnyUI.dll and b/SunnyUI.Demo/Bin/SunnyUI.dll differ
diff --git a/SunnyUI.Demo/Controls/FScrollBar.Designer.cs b/SunnyUI.Demo/Controls/FScrollBar.Designer.cs
index 3241635d..00258087 100644
--- a/SunnyUI.Demo/Controls/FScrollBar.Designer.cs
+++ b/SunnyUI.Demo/Controls/FScrollBar.Designer.cs
@@ -40,11 +40,13 @@
this.uiHorScrollBar3 = new Sunny.UI.UIHorScrollBar();
this.uiHorScrollBar4 = new Sunny.UI.UIHorScrollBar();
this.timer1 = new System.Windows.Forms.Timer(this.components);
+ this.uiVerScrollBarEx1 = new Sunny.UI.UIVerScrollBarEx();
this.PagePanel.SuspendLayout();
this.SuspendLayout();
//
// PagePanel
//
+ this.PagePanel.Controls.Add(this.uiVerScrollBarEx1);
this.PagePanel.Controls.Add(this.uiHorScrollBar4);
this.PagePanel.Controls.Add(this.uiHorScrollBar3);
this.PagePanel.Controls.Add(this.uiHorScrollBar2);
@@ -190,6 +192,19 @@
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
+ // uiVerScrollBarEx1
+ //
+ this.uiVerScrollBarEx1.BoundsHeight = 10;
+ this.uiVerScrollBarEx1.Font = new System.Drawing.Font("微软雅黑", 12F);
+ this.uiVerScrollBarEx1.LargeChange = 10;
+ this.uiVerScrollBarEx1.Location = new System.Drawing.Point(219, 61);
+ this.uiVerScrollBarEx1.Maximum = 100;
+ this.uiVerScrollBarEx1.Name = "uiVerScrollBarEx1";
+ this.uiVerScrollBarEx1.Size = new System.Drawing.Size(18, 147);
+ this.uiVerScrollBarEx1.TabIndex = 62;
+ this.uiVerScrollBarEx1.Text = "uiVerScrollBarEx1";
+ this.uiVerScrollBarEx1.Value = 0;
+ //
// FScrollBar
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
@@ -216,5 +231,6 @@
private UIHorScrollBar uiHorScrollBar3;
private UIHorScrollBar uiHorScrollBar2;
private System.Windows.Forms.Timer timer1;
+ private UIVerScrollBarEx uiVerScrollBarEx1;
}
}
\ No newline at end of file
diff --git a/SunnyUI/Controls/UIDataGridView.cs b/SunnyUI/Controls/UIDataGridView.cs
index 2e35d169..22f1e4f0 100644
--- a/SunnyUI/Controls/UIDataGridView.cs
+++ b/SunnyUI/Controls/UIDataGridView.cs
@@ -32,7 +32,7 @@ namespace Sunny.UI
public class UIDataGridView : DataGridView, IStyleInterface
{
private readonly UIScrollBar VBar = new UIScrollBar();
- private readonly UIHorScrollBar HBar = new UIHorScrollBar();
+ private readonly UIHorScrollBarEx HBar = new UIHorScrollBarEx();
public UIDataGridView()
{
@@ -43,14 +43,13 @@ namespace Sunny.UI
VBar.Parent = this;
VBar.Visible = false;
- VBar.FillColor = UIColor.LightBlue;
+ HBar.FillColor = VBar.FillColor = UIColor.LightBlue;
VBar.ForeColor = UIColor.Blue;
VBar.StyleCustomMode = true;
VBar.ValueChanged += VBarValueChanged;
HBar.Parent = this;
HBar.Visible = false;
- HBar.FillColor = UIColor.LightBlue;
HBar.ForeColor = UIColor.Blue;
HBar.StyleCustomMode = true;
HBar.ValueChanged += HBar_ValueChanged;
@@ -80,41 +79,7 @@ namespace Sunny.UI
StripeOddColor = UIColor.LightBlue;
VerticalScrollBar.ValueChanged += VerticalScrollBar_ValueChanged;
- HorizontalScrollBar.VisibleChanged += HorizontalScrollBar_VisibleChanged;
- }
-
- private void VerticalScrollBar_ValueChanged(object sender, EventArgs e)
- {
- VBar.Value = FirstDisplayedScrollingRowIndex;
- }
-
- private void VBarValueChanged(object sender, EventArgs e)
- {
- FirstDisplayedScrollingRowIndex = VBar.Value;
- }
-
- private void HorizontalScrollBar_VisibleChanged(object sender, EventArgs e)
- {
- HBar.Value = FirstDisplayedScrollingColumnIndex;
- }
-
- private void HBar_ValueChanged(object sender, EventArgs e)
- {
- FirstDisplayedScrollingColumnIndex = HBar.Value;
- // int idx = 0;
- // for (int i = 0; i < ColumnCount; i++)
- // {
- // if (Columns[i].Visible && idx == HBar.Value)
- // {
- // FirstDisplayedScrollingColumnIndex = i;
- // break;
- // }
- //
- // if (Columns[i].Visible)
- // {
- // idx++;
- // }
- // }
+ HorizontalScrollBar.ValueChanged += HorizontalScrollBar_ValueChanged;
}
public void Init()
@@ -151,19 +116,26 @@ namespace Sunny.UI
SelectionMode = DataGridViewSelectionMode.FullRowSelect;
}
- protected override void OnPaint(PaintEventArgs e)
+ private void VerticalScrollBar_ValueChanged(object sender, EventArgs e)
{
- base.OnPaint(e);
-
- if (ShowRect)
- {
- Color color = RectColor;
- color = Enabled ? color : UIDisableColor.Fill;
- e.Graphics.DrawRectangle(color, new Rectangle(0, 0, Width - 1, Height - 1));
- }
+ VBar.Value = FirstDisplayedScrollingRowIndex;
}
+ private void VBarValueChanged(object sender, EventArgs e)
+ {
+ FirstDisplayedScrollingRowIndex = VBar.Value;
+ }
+ private void HorizontalScrollBar_ValueChanged(object sender, EventArgs e)
+ {
+ HBar.Value = HorizontalScrollBar.Value;
+ }
+
+ private void HBar_ValueChanged(object sender, EventArgs e)
+ {
+ HorizontalScrollBar.Value = HBar.Value;
+ HorizontalScrollingOffset = HBar.Value;
+ }
public void SetScrollInfo()
{
@@ -183,16 +155,12 @@ namespace Sunny.UI
VBar.Visible = false;
}
- // if (HorizontalScrollBar.Visible)
- // {
- // HBar.Maximum = VisibleColumnCount();
- // HBar.Value = FirstDisplayedScrollingColumnIndex;
- // HBar.Visible = true;
- // }
- if (ColumnCount > DisplayedColumnCount(false))
+ if (HorizontalScrollBar.Visible)
{
- HBar.Maximum = ColumnCount - DisplayedColumnCount(false);
- HBar.Value = FirstDisplayedScrollingColumnIndex;
+ HBar.Maximum = HorizontalScrollBar.Maximum;
+ HBar.Value = HorizontalScrollBar.Value;
+ HBar.BoundsWidth = HorizontalScrollBar.Bounds.Width;
+ HBar.LargeChange = HorizontalScrollBar.Maximum / VisibleColumnCount();
HBar.Visible = true;
}
else
@@ -214,6 +182,18 @@ namespace Sunny.UI
return cnt;
}
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ base.OnPaint(e);
+
+ if (ShowRect)
+ {
+ Color color = RectColor;
+ color = Enabled ? color : UIDisableColor.Fill;
+ e.Graphics.DrawRectangle(color, new Rectangle(0, 0, Width - 1, Height - 1));
+ }
+ }
+
protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);
@@ -550,10 +530,10 @@ namespace Sunny.UI
ClearColumns();
}
- public void AddRow(params object[] values)
- {
- Rows.Add(values);
- }
+ // public void AddRow(params object[] values)
+ // {
+ // Rows.Add(values);
+ // }
}
public static class UIDataGridViewHelper
diff --git a/SunnyUI/Controls/UIHorScrollBar.cs b/SunnyUI/Controls/UIHorScrollBar.cs
index 986e6d6d..654d5920 100644
--- a/SunnyUI/Controls/UIHorScrollBar.cs
+++ b/SunnyUI/Controls/UIHorScrollBar.cs
@@ -11,7 +11,7 @@
* If you use this code, please keep this note.
* 如果您使用此代码,请保留此说明。
******************************************************************************
- * 文件名称: UIScrollBar.cs
+ * 文件名称: UIHorScrollBar.cs
* 文件说明: 水平滚动条
* 当前版本: V2.2
* 创建日期: 2020-01-01
diff --git a/SunnyUI/Controls/UIHorScrollBarEx.cs b/SunnyUI/Controls/UIHorScrollBarEx.cs
new file mode 100644
index 00000000..e6f48bd5
--- /dev/null
+++ b/SunnyUI/Controls/UIHorScrollBarEx.cs
@@ -0,0 +1,277 @@
+/******************************************************************************
+ * SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。
+ * CopyRight (C) 2012-2020 ShenYongHua(沈永华).
+ * QQ群:56829229 QQ:17612584 EMail:SunnyUI@qq.com
+ *
+ * Blog: https://www.cnblogs.com/yhuse
+ * Gitee: https://gitee.com/yhuse/SunnyUI
+ * GitHub: https://github.com/yhuse/SunnyUI
+ *
+ * SunnyUI.dll can be used for free under the GPL-3.0 license.
+ * If you use this code, please keep this note.
+ * 如果您使用此代码,请保留此说明。
+ ******************************************************************************
+ * 文件名称: UIHorScrollBarEx.cs
+ * 文件说明: 水平滚动条
+ * 当前版本: V2.2
+ * 创建日期: 2020-08-29
+ *
+ * 2020-08-29: V2.2.7 新增水平滚动条
+******************************************************************************/
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+
+namespace Sunny.UI
+{
+ [ToolboxItem(true)]
+ public class UIHorScrollBarEx : UIControl
+ {
+ public UIHorScrollBarEx()
+ {
+ ShowText = false;
+ ShowRect = false;
+ Height = ScrollBarInfo.HorizontalScrollBarHeight() + 1;
+
+ fillColor = UIColor.LightBlue;
+ foreColor = UIColor.Blue;
+ fillHoverColor = Color.FromArgb(111, 168, 255);
+ fillPressColor = Color.FromArgb(74, 131, 229);
+ }
+
+ public int maximum = 100;
+ public int Maximum
+ {
+ get => maximum;
+ set
+ {
+ maximum = value.CheckLowerLimit(2);
+ Invalidate();
+ }
+ }
+
+ public int LargeChange { get; set; } = 10;
+
+ public int thisValue;
+ public event EventHandler ValueChanged;
+
+ public int Value
+ {
+ get => thisValue;
+ set
+ {
+ thisValue = value.CheckLowerLimit(0);
+ thisValue = value.CheckUpperLimit(Maximum - BoundsWidth);
+ Invalidate();
+ }
+ }
+
+ public int boundsWidth = 10;
+ public int BoundsWidth
+ {
+ get => boundsWidth;
+ set
+ {
+ boundsWidth = value.CheckLowerLimit(1);
+ Invalidate();
+ }
+ }
+
+ public int LeftButtonPos => 16;
+
+ public int RightButtonPos => Width - 16;
+
+ protected override void OnPaintFill(Graphics g, GraphicsPath path)
+ {
+ base.OnPaintFill(g, path);
+ g.Clear(fillColor);
+
+ DrawUpDownArrow(g, true);
+ DrawUpDownArrow(g, false);
+
+ DrawValueBar(g);
+ }
+
+ private void DrawValueBar(Graphics g)
+ {
+ Color clr = foreColor;
+ if (inCenterArea && IsPress)
+ {
+ clr = fillPressColor;
+ }
+
+ int left = 16 + Value * (Width - 32) / Maximum;
+ int width = BoundsWidth * (Width - 32) / Maximum;
+
+ g.SetHighQuality();
+ g.FillRoundRectangle(clr, new Rectangle(left, Height / 2 - 3, width, 6), 5);
+ g.SetDefaultQuality();
+ }
+
+ private Rectangle GetUpRect()
+ {
+ var rect = new Rectangle(1, 1, 16, Height - 2);
+ return rect;
+ }
+
+ private Rectangle GetDownRect()
+ {
+ return new Rectangle(Width - 17, 1, 16, Height - 2);
+ }
+
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+ IsPress = true;
+
+ if (inLeftArea)
+ {
+ int value = (Value - LargeChange).CheckRange(0, Maximum - BoundsWidth);
+ Value = value;
+ ValueChanged?.Invoke(this, null);
+ }
+
+ if (inRightArea)
+ {
+ int value = (Value + LargeChange).CheckRange(0, Maximum - BoundsWidth);
+ Value = value;
+ ValueChanged?.Invoke(this, null);
+ }
+
+ if (inCenterArea)
+ {
+ int x = BoundsWidth * (Width - 32) / Maximum;
+ int value = (e.Location.X - x / 2) * maximum / (Width - 32);
+ value = value.CheckRange(0, Maximum - BoundsWidth);
+ Value = value;
+ ValueChanged?.Invoke(this, null);
+ }
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+ IsPress = false;
+ Invalidate();
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+ IsPress = false;
+ Invalidate();
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ base.OnMouseEnter(e);
+ Invalidate();
+ }
+
+ private void DrawUpDownArrow(Graphics g, bool isUp)
+ {
+ Color clr_arrow = foreColor;
+ if ((inLeftArea || inRightArea) && IsPress)
+ {
+ clr_arrow = fillPressColor;
+ }
+
+ g.FillRectangle(fillColor, isUp ? GetUpRect() : GetDownRect());
+ g.SetHighQuality();
+ using (var pen = new Pen(clr_arrow, 2))
+ {
+ Point pt1, pt2, pt3;
+ if (!isUp)
+ {
+ pt1 = new Point(Width - 16 / 2 - 4, Height / 2 - 4);
+ pt2 = new Point(Width - 16 / 2, Height / 2);
+ pt3 = new Point(Width - 16 / 2 - 4, Height / 2 + 4);
+ }
+ else
+ {
+ pt1 = new Point(16 / 2 + 4 - 1, Height / 2 - 4);
+ pt2 = new Point(16 / 2 - 1, Height / 2);
+ pt3 = new Point(16 / 2 + 4 - 1, Height / 2 + 4);
+ }
+
+ g.DrawLines(pen, new[] { pt1, pt2, pt3 });
+ }
+
+ g.SetDefaultQuality();
+ }
+
+ private bool inLeftArea, inRightArea, inCenterArea;
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ inLeftArea = e.Location.X < LeftButtonPos;
+ inRightArea = e.Location.X > RightButtonPos;
+ inCenterArea = e.Location.X >= LeftButtonPos && e.Location.X <= RightButtonPos;
+
+ if (inCenterArea && IsPress)
+ {
+ int x = BoundsWidth * (Width - 32) / Maximum;
+ int value = (e.Location.X - x / 2) * maximum / (Width - 32);
+ value = value.CheckRange(0, Maximum - BoundsWidth);
+ Value = value;
+ ValueChanged?.Invoke(this, null);
+ }
+ }
+
+ public override void SetStyleColor(UIBaseStyle uiColor)
+ {
+ base.SetStyleColor(uiColor);
+ if (uiColor.IsCustom()) return;
+
+ fillColor = uiColor.PlainColor;
+ foreColor = uiColor.ScrollBarForeColor;
+ fillHoverColor = uiColor.ButtonFillHoverColor;
+ fillPressColor = uiColor.ButtonFillPressColor;
+ Invalidate();
+ }
+
+
+ ///
+ /// 字体颜色
+ ///
+ [Description("字体颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "80, 160, 255")]
+ public override Color ForeColor
+ {
+ get => foreColor;
+ set => SetForeColor(value);
+ }
+
+ ///
+ /// 填充颜色,当值为背景色或透明色或空值则不填充
+ ///
+ [Description("填充颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "235, 243, 255")]
+ public Color FillColor
+ {
+ get => fillColor;
+ set => SetFillColor(value);
+ }
+
+ [Description("鼠标移上颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "111, 168, 255")]
+ public Color HoverColor
+ {
+ get => fillHoverColor;
+ set => SetFillHoveColor(value);
+ }
+
+ [Description("鼠标按下颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "74, 131, 229")]
+ public Color PressColor
+ {
+ get => fillPressColor;
+ set => SetFillPressColor(value);
+ }
+ }
+}
diff --git a/SunnyUI/Controls/UIVerScrollBarEx.cs b/SunnyUI/Controls/UIVerScrollBarEx.cs
new file mode 100644
index 00000000..7c708e6d
--- /dev/null
+++ b/SunnyUI/Controls/UIVerScrollBarEx.cs
@@ -0,0 +1,276 @@
+/******************************************************************************
+ * SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。
+ * CopyRight (C) 2012-2020 ShenYongHua(沈永华).
+ * QQ群:56829229 QQ:17612584 EMail:SunnyUI@qq.com
+ *
+ * Blog: https://www.cnblogs.com/yhuse
+ * Gitee: https://gitee.com/yhuse/SunnyUI
+ * GitHub: https://github.com/yhuse/SunnyUI
+ *
+ * SunnyUI.dll can be used for free under the GPL-3.0 license.
+ * If you use this code, please keep this note.
+ * 如果您使用此代码,请保留此说明。
+ ******************************************************************************
+ * 文件名称: UIVerScrollBarEx.cs
+ * 文件说明: 垂直滚动条
+ * 当前版本: V2.2
+ * 创建日期: 2020-08-29
+ *
+ * 2020-08-29: V2.2.7 新增水平滚动条
+******************************************************************************/
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+
+namespace Sunny.UI
+{
+ [ToolboxItem(true)]
+ public class UIVerScrollBarEx : UIControl
+ {
+ public UIVerScrollBarEx()
+ {
+ ShowText = false;
+ ShowRect = false;
+ Width = ScrollBarInfo.VerticalScrollBarWidth() + 1;
+
+ fillColor = UIColor.LightBlue;
+ foreColor = UIColor.Blue;
+ fillHoverColor = Color.FromArgb(111, 168, 255);
+ fillPressColor = Color.FromArgb(74, 131, 229);
+ }
+
+ public int maximum = 100;
+ public int Maximum
+ {
+ get => maximum;
+ set
+ {
+ maximum = value.CheckLowerLimit(2);
+ Invalidate();
+ }
+ }
+
+ public int LargeChange { get; set; } = 10;
+
+ public int thisValue;
+ public event EventHandler ValueChanged;
+
+ public int Value
+ {
+ get => thisValue;
+ set
+ {
+ thisValue = value.CheckLowerLimit(0);
+ thisValue = value.CheckUpperLimit(Maximum - BoundsHeight);
+ Invalidate();
+ }
+ }
+
+ public int boundsHeight = 10;
+ public int BoundsHeight
+ {
+ get => boundsHeight;
+ set
+ {
+ boundsHeight = value.CheckLowerLimit(1);
+ Invalidate();
+ }
+ }
+
+ public int LeftButtonPos => 16;
+
+ public int RightButtonPos => Height - 16;
+
+ protected override void OnPaintFill(Graphics g, GraphicsPath path)
+ {
+ base.OnPaintFill(g, path);
+ g.Clear(fillColor);
+
+ DrawUpDownArrow(g, true);
+ DrawUpDownArrow(g, false);
+ DrawValueBar(g);
+ }
+
+ private void DrawValueBar(Graphics g)
+ {
+ Color clr = foreColor;
+ if (inCenterArea && IsPress)
+ {
+ clr = fillPressColor;
+ }
+
+ int top = 16 + Value * (Height - 32) / Maximum;
+ int height = BoundsHeight * (Height - 32) / Maximum;
+
+ g.SetHighQuality();
+ g.FillRoundRectangle(clr, new Rectangle(Width / 2 - 3, top, 6, height), 5);
+ g.SetDefaultQuality();
+ }
+
+ private Rectangle GetUpRect()
+ {
+ var rect = new Rectangle(1, 1, Width - 2, 16);
+ return rect;
+ }
+
+ private Rectangle GetDownRect()
+ {
+ var rect = new Rectangle(1, Height - 17, Width - 2, 16);
+ return rect;
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+ IsPress = true;
+
+ if (inLeftArea)
+ {
+ int value = (Value - LargeChange).CheckRange(0, Maximum - BoundsHeight);
+ Value = value;
+ ValueChanged?.Invoke(this, null);
+ }
+
+ if (inRightArea)
+ {
+ int value = (Value + LargeChange).CheckRange(0, Maximum - BoundsHeight);
+ Value = value;
+ ValueChanged?.Invoke(this, null);
+ }
+
+ if (inCenterArea)
+ {
+ int y = BoundsHeight * (Height - 32) / Maximum;
+ int value = (e.Location.Y - y / 2) * maximum / (Height - 32);
+ value = value.CheckRange(0, Maximum - BoundsHeight);
+ Value = value;
+ ValueChanged?.Invoke(this, null);
+ }
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+ IsPress = false;
+ Invalidate();
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+ IsPress = false;
+ Invalidate();
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ base.OnMouseEnter(e);
+ Invalidate();
+ }
+
+ private void DrawUpDownArrow(Graphics g, bool isUp)
+ {
+ Color clr_arrow = foreColor;
+ if ((inLeftArea || inRightArea) && IsPress)
+ {
+ clr_arrow = fillPressColor;
+ }
+
+ g.FillRectangle(fillColor, isUp ? GetUpRect() : GetDownRect());
+ g.SetHighQuality();
+ using (var pen = new Pen(clr_arrow, 2))
+ {
+ Point pt1, pt2, pt3;
+ if (!isUp)
+ {
+ pt1 = new Point(Width / 2 - 4, Height - 16 / 2 - 4);
+ pt2 = new Point(Width / 2, Height - 16 / 2);
+ pt3 = new Point(Width / 2 + 4, Height - 16 / 2 - 4);
+ }
+ else
+ {
+ pt1 = new Point(Width / 2 - 4, 16 / 2 + 4 - 1);
+ pt2 = new Point(Width / 2, 16 / 2 - 1);
+ pt3 = new Point(Width / 2 + 4, 16 / 2 + 4 - 1);
+ }
+
+ g.DrawLines(pen, new[] { pt1, pt2, pt3 });
+ }
+
+ g.SetDefaultQuality();
+ }
+
+ private bool inLeftArea, inRightArea, inCenterArea;
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ inLeftArea = e.Location.Y < LeftButtonPos;
+ inRightArea = e.Location.Y > RightButtonPos;
+ inCenterArea = e.Location.Y >= LeftButtonPos && e.Location.Y <= RightButtonPos;
+
+ if (inCenterArea && IsPress)
+ {
+ int y = BoundsHeight * (Height - 32) / Maximum;
+ int value = (e.Location.Y - y / 2) * maximum / (Height - 32);
+ value = value.CheckRange(0, Maximum - BoundsHeight);
+ Value = value;
+ ValueChanged?.Invoke(this, null);
+ }
+ }
+
+ public override void SetStyleColor(UIBaseStyle uiColor)
+ {
+ base.SetStyleColor(uiColor);
+ if (uiColor.IsCustom()) return;
+
+ fillColor = uiColor.PlainColor;
+ foreColor = uiColor.ScrollBarForeColor;
+ fillHoverColor = uiColor.ButtonFillHoverColor;
+ fillPressColor = uiColor.ButtonFillPressColor;
+ Invalidate();
+ }
+
+
+ ///
+ /// 字体颜色
+ ///
+ [Description("字体颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "80, 160, 255")]
+ public override Color ForeColor
+ {
+ get => foreColor;
+ set => SetForeColor(value);
+ }
+
+ ///
+ /// 填充颜色,当值为背景色或透明色或空值则不填充
+ ///
+ [Description("填充颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "235, 243, 255")]
+ public Color FillColor
+ {
+ get => fillColor;
+ set => SetFillColor(value);
+ }
+
+ [Description("鼠标移上颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "111, 168, 255")]
+ public Color HoverColor
+ {
+ get => fillHoverColor;
+ set => SetFillHoveColor(value);
+ }
+
+ [Description("鼠标按下颜色"), Category("SunnyUI")]
+ [DefaultValue(typeof(Color), "74, 131, 229")]
+ public Color PressColor
+ {
+ get => fillPressColor;
+ set => SetFillPressColor(value);
+ }
+ }
+}
diff --git a/SunnyUI/Static/UMath.cs b/SunnyUI/Static/UMath.cs
index e0ad3843..4ee4a4e7 100644
--- a/SunnyUI/Static/UMath.cs
+++ b/SunnyUI/Static/UMath.cs
@@ -166,7 +166,7 @@ namespace Sunny.UI
public static T CheckLowerLimit(this T obj, T lowerLimit) where T : IComparable
{
- return obj.CompareTo(lowerLimit) == -1 ? lowerLimit : obj;
+ return obj.CompareTo(lowerLimit) == -1 ? lowerLimit : obj;
}
public static T CheckUpperLimit(this T obj, T upperLimit) where T : IComparable
diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj
index 42b8556f..c49dbdcf 100644
--- a/SunnyUI/SunnyUI.csproj
+++ b/SunnyUI/SunnyUI.csproj
@@ -116,6 +116,12 @@
Component
+
+ Component
+
+
+ Component
+
UserControl
@@ -189,7 +195,7 @@
Component
- Component
+ UserControl
Form