mirror of https://github.com/yhuse/SunnyUI.git

15 changed files with 873 additions and 89 deletions
-
BINBin/SunnyUI.dll
-
BINBin/SunnyUI.pdb
-
BINSunnyUI.Demo/Bin/SunnyUI.Demo.exe
-
BINSunnyUI.Demo/Bin/SunnyUI.dll
-
91SunnyUI.Demo/Controls/FOther.Designer.cs
-
1SunnyUI.Demo/Controls/FOther.cs
-
220SunnyUI.Demo/Controls/FScrollBar.Designer.cs
-
37SunnyUI.Demo/Controls/FScrollBar.cs
-
123SunnyUI.Demo/Controls/FScrollBar.resx
-
1SunnyUI.Demo/FMain.cs
-
9SunnyUI.Demo/SunnyUI.Demo.csproj
-
8SunnyUI/Charts/UIBarChart.cs
-
465SunnyUI/Controls/UIHorScrollBar.cs
-
4SunnyUI/Controls/UIScrollBar.cs
-
3SunnyUI/SunnyUI.csproj
@ -0,0 +1,220 @@ |
|||
namespace Sunny.UI.Demo |
|||
{ |
|||
partial class FScrollBar |
|||
{ |
|||
/// <summary>
|
|||
/// Required designer variable.
|
|||
/// </summary>
|
|||
private System.ComponentModel.IContainer components = null; |
|||
|
|||
/// <summary>
|
|||
/// Clean up any resources being used.
|
|||
/// </summary>
|
|||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|||
protected override void Dispose(bool disposing) |
|||
{ |
|||
if (disposing && (components != null)) |
|||
{ |
|||
components.Dispose(); |
|||
} |
|||
base.Dispose(disposing); |
|||
} |
|||
|
|||
#region Windows Form Designer generated code
|
|||
|
|||
/// <summary>
|
|||
/// Required method for Designer support - do not modify
|
|||
/// the contents of this method with the code editor.
|
|||
/// </summary>
|
|||
private void InitializeComponent() |
|||
{ |
|||
this.components = new System.ComponentModel.Container(); |
|||
this.uiLine7 = new Sunny.UI.UILine(); |
|||
this.uiHorScrollBar1 = new Sunny.UI.UIHorScrollBar(); |
|||
this.uiScrollBar4 = new Sunny.UI.UIScrollBar(); |
|||
this.uiScrollBar3 = new Sunny.UI.UIScrollBar(); |
|||
this.uiScrollBar2 = new Sunny.UI.UIScrollBar(); |
|||
this.uiLine1 = new Sunny.UI.UILine(); |
|||
this.uiScrollBar1 = new Sunny.UI.UIScrollBar(); |
|||
this.uiHorScrollBar2 = new Sunny.UI.UIHorScrollBar(); |
|||
this.uiHorScrollBar3 = new Sunny.UI.UIHorScrollBar(); |
|||
this.uiHorScrollBar4 = new Sunny.UI.UIHorScrollBar(); |
|||
this.timer1 = new System.Windows.Forms.Timer(this.components); |
|||
this.PagePanel.SuspendLayout(); |
|||
this.SuspendLayout(); |
|||
//
|
|||
// PagePanel
|
|||
//
|
|||
this.PagePanel.Controls.Add(this.uiHorScrollBar4); |
|||
this.PagePanel.Controls.Add(this.uiHorScrollBar3); |
|||
this.PagePanel.Controls.Add(this.uiHorScrollBar2); |
|||
this.PagePanel.Controls.Add(this.uiLine7); |
|||
this.PagePanel.Controls.Add(this.uiHorScrollBar1); |
|||
this.PagePanel.Controls.Add(this.uiScrollBar4); |
|||
this.PagePanel.Controls.Add(this.uiScrollBar3); |
|||
this.PagePanel.Controls.Add(this.uiScrollBar2); |
|||
this.PagePanel.Controls.Add(this.uiLine1); |
|||
this.PagePanel.Controls.Add(this.uiScrollBar1); |
|||
//
|
|||
// uiLine7
|
|||
//
|
|||
this.uiLine7.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiLine7.Location = new System.Drawing.Point(381, 20); |
|||
this.uiLine7.MinimumSize = new System.Drawing.Size(16, 16); |
|||
this.uiLine7.Name = "uiLine7"; |
|||
this.uiLine7.Size = new System.Drawing.Size(319, 20); |
|||
this.uiLine7.TabIndex = 58; |
|||
this.uiLine7.Text = "UIHorScrollBar"; |
|||
this.uiLine7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; |
|||
//
|
|||
// uiHorScrollBar1
|
|||
//
|
|||
this.uiHorScrollBar1.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiHorScrollBar1.Location = new System.Drawing.Point(381, 58); |
|||
this.uiHorScrollBar1.Name = "uiHorScrollBar1"; |
|||
this.uiHorScrollBar1.Size = new System.Drawing.Size(319, 23); |
|||
this.uiHorScrollBar1.TabIndex = 57; |
|||
this.uiHorScrollBar1.Text = "uiHorScrollBar1"; |
|||
//
|
|||
// uiScrollBar4
|
|||
//
|
|||
this.uiScrollBar4.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(251)))), ((int)(((byte)(238)))), ((int)(((byte)(238))))); |
|||
this.uiScrollBar4.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiScrollBar4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); |
|||
this.uiScrollBar4.HoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(127)))), ((int)(((byte)(128))))); |
|||
this.uiScrollBar4.Location = new System.Drawing.Point(156, 55); |
|||
this.uiScrollBar4.Name = "uiScrollBar4"; |
|||
this.uiScrollBar4.PressColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(87)))), ((int)(((byte)(89))))); |
|||
this.uiScrollBar4.Size = new System.Drawing.Size(23, 153); |
|||
this.uiScrollBar4.Style = Sunny.UI.UIStyle.Red; |
|||
this.uiScrollBar4.StyleCustomMode = true; |
|||
this.uiScrollBar4.TabIndex = 56; |
|||
this.uiScrollBar4.Text = "uiScrollBar4"; |
|||
//
|
|||
// uiScrollBar3
|
|||
//
|
|||
this.uiScrollBar3.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(251)))), ((int)(((byte)(245)))), ((int)(((byte)(233))))); |
|||
this.uiScrollBar3.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiScrollBar3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40))))); |
|||
this.uiScrollBar3.HoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(174)))), ((int)(((byte)(86))))); |
|||
this.uiScrollBar3.Location = new System.Drawing.Point(114, 55); |
|||
this.uiScrollBar3.Name = "uiScrollBar3"; |
|||
this.uiScrollBar3.PressColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(137)))), ((int)(((byte)(43))))); |
|||
this.uiScrollBar3.Size = new System.Drawing.Size(23, 153); |
|||
this.uiScrollBar3.Style = Sunny.UI.UIStyle.Orange; |
|||
this.uiScrollBar3.StyleCustomMode = true; |
|||
this.uiScrollBar3.TabIndex = 55; |
|||
this.uiScrollBar3.Text = "uiScrollBar3"; |
|||
//
|
|||
// uiScrollBar2
|
|||
//
|
|||
this.uiScrollBar2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(248)))), ((int)(((byte)(232))))); |
|||
this.uiScrollBar2.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiScrollBar2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(110)))), ((int)(((byte)(190)))), ((int)(((byte)(40))))); |
|||
this.uiScrollBar2.HoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(136)))), ((int)(((byte)(202)))), ((int)(((byte)(81))))); |
|||
this.uiScrollBar2.Location = new System.Drawing.Point(72, 55); |
|||
this.uiScrollBar2.Name = "uiScrollBar2"; |
|||
this.uiScrollBar2.PressColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(168)))), ((int)(((byte)(35))))); |
|||
this.uiScrollBar2.Size = new System.Drawing.Size(23, 153); |
|||
this.uiScrollBar2.Style = Sunny.UI.UIStyle.Green; |
|||
this.uiScrollBar2.StyleCustomMode = true; |
|||
this.uiScrollBar2.TabIndex = 54; |
|||
this.uiScrollBar2.Text = "uiScrollBar2"; |
|||
//
|
|||
// uiLine1
|
|||
//
|
|||
this.uiLine1.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiLine1.Location = new System.Drawing.Point(30, 20); |
|||
this.uiLine1.MinimumSize = new System.Drawing.Size(16, 16); |
|||
this.uiLine1.Name = "uiLine1"; |
|||
this.uiLine1.Size = new System.Drawing.Size(319, 20); |
|||
this.uiLine1.TabIndex = 53; |
|||
this.uiLine1.Text = "UIScrollBar"; |
|||
this.uiLine1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; |
|||
//
|
|||
// uiScrollBar1
|
|||
//
|
|||
this.uiScrollBar1.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiScrollBar1.Location = new System.Drawing.Point(30, 55); |
|||
this.uiScrollBar1.Name = "uiScrollBar1"; |
|||
this.uiScrollBar1.Size = new System.Drawing.Size(23, 153); |
|||
this.uiScrollBar1.TabIndex = 52; |
|||
this.uiScrollBar1.Text = "uiScrollBar1"; |
|||
//
|
|||
// uiHorScrollBar2
|
|||
//
|
|||
this.uiHorScrollBar2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(248)))), ((int)(((byte)(232))))); |
|||
this.uiHorScrollBar2.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiHorScrollBar2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(110)))), ((int)(((byte)(190)))), ((int)(((byte)(40))))); |
|||
this.uiHorScrollBar2.HoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(136)))), ((int)(((byte)(202)))), ((int)(((byte)(81))))); |
|||
this.uiHorScrollBar2.Location = new System.Drawing.Point(381, 100); |
|||
this.uiHorScrollBar2.Name = "uiHorScrollBar2"; |
|||
this.uiHorScrollBar2.PressColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(168)))), ((int)(((byte)(35))))); |
|||
this.uiHorScrollBar2.Size = new System.Drawing.Size(319, 23); |
|||
this.uiHorScrollBar2.Style = Sunny.UI.UIStyle.Green; |
|||
this.uiHorScrollBar2.StyleCustomMode = true; |
|||
this.uiHorScrollBar2.TabIndex = 59; |
|||
this.uiHorScrollBar2.Text = "uiHorScrollBar2"; |
|||
//
|
|||
// uiHorScrollBar3
|
|||
//
|
|||
this.uiHorScrollBar3.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(251)))), ((int)(((byte)(245)))), ((int)(((byte)(233))))); |
|||
this.uiHorScrollBar3.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiHorScrollBar3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40))))); |
|||
this.uiHorScrollBar3.HoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(174)))), ((int)(((byte)(86))))); |
|||
this.uiHorScrollBar3.Location = new System.Drawing.Point(381, 142); |
|||
this.uiHorScrollBar3.Name = "uiHorScrollBar3"; |
|||
this.uiHorScrollBar3.PressColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(137)))), ((int)(((byte)(43))))); |
|||
this.uiHorScrollBar3.Size = new System.Drawing.Size(319, 23); |
|||
this.uiHorScrollBar3.Style = Sunny.UI.UIStyle.Orange; |
|||
this.uiHorScrollBar3.StyleCustomMode = true; |
|||
this.uiHorScrollBar3.TabIndex = 60; |
|||
this.uiHorScrollBar3.Text = "uiHorScrollBar3"; |
|||
//
|
|||
// uiHorScrollBar4
|
|||
//
|
|||
this.uiHorScrollBar4.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(251)))), ((int)(((byte)(238)))), ((int)(((byte)(238))))); |
|||
this.uiHorScrollBar4.Font = new System.Drawing.Font("微软雅黑", 12F); |
|||
this.uiHorScrollBar4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); |
|||
this.uiHorScrollBar4.HoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(127)))), ((int)(((byte)(128))))); |
|||
this.uiHorScrollBar4.Location = new System.Drawing.Point(381, 184); |
|||
this.uiHorScrollBar4.Name = "uiHorScrollBar4"; |
|||
this.uiHorScrollBar4.PressColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(87)))), ((int)(((byte)(89))))); |
|||
this.uiHorScrollBar4.Size = new System.Drawing.Size(319, 23); |
|||
this.uiHorScrollBar4.Style = Sunny.UI.UIStyle.Red; |
|||
this.uiHorScrollBar4.StyleCustomMode = true; |
|||
this.uiHorScrollBar4.TabIndex = 61; |
|||
this.uiHorScrollBar4.Text = "uiHorScrollBar4"; |
|||
//
|
|||
// timer1
|
|||
//
|
|||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); |
|||
//
|
|||
// FScrollBar
|
|||
//
|
|||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); |
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
|||
this.ClientSize = new System.Drawing.Size(800, 450); |
|||
this.Name = "FScrollBar"; |
|||
this.Symbol = 57355; |
|||
this.Text = "ScrollBar"; |
|||
this.PagePanel.ResumeLayout(false); |
|||
this.ResumeLayout(false); |
|||
|
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
private UILine uiLine7; |
|||
private UIHorScrollBar uiHorScrollBar1; |
|||
private UIScrollBar uiScrollBar4; |
|||
private UIScrollBar uiScrollBar3; |
|||
private UIScrollBar uiScrollBar2; |
|||
private UILine uiLine1; |
|||
private UIScrollBar uiScrollBar1; |
|||
private UIHorScrollBar uiHorScrollBar4; |
|||
private UIHorScrollBar uiHorScrollBar3; |
|||
private UIHorScrollBar uiHorScrollBar2; |
|||
private System.Windows.Forms.Timer timer1; |
|||
} |
|||
} |
@ -0,0 +1,37 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel; |
|||
using System.Data; |
|||
using System.Drawing; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Windows.Forms; |
|||
|
|||
namespace Sunny.UI.Demo |
|||
{ |
|||
public partial class FScrollBar : UITitlePage |
|||
{ |
|||
public FScrollBar() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
public override void Init() |
|||
{ |
|||
value = 0; |
|||
timer1.ReStart(); |
|||
} |
|||
|
|||
private int value; |
|||
private void timer1_Tick(object sender, EventArgs e) |
|||
{ |
|||
value++; |
|||
uiScrollBar1.Value = value; |
|||
uiHorScrollBar1.Value = value; |
|||
uiScrollBar2.Value = value/3; |
|||
uiHorScrollBar2.Value = value/3; |
|||
uiScrollBar3.Value = value / 10; |
|||
uiHorScrollBar3.Value = value / 10; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,123 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<root> |
|||
<!-- |
|||
Microsoft ResX Schema |
|||
|
|||
Version 2.0 |
|||
|
|||
The primary goals of this format is to allow a simple XML format |
|||
that is mostly human readable. The generation and parsing of the |
|||
various data types are done through the TypeConverter classes |
|||
associated with the data types. |
|||
|
|||
Example: |
|||
|
|||
... ado.net/XML headers & schema ... |
|||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
|||
<resheader name="version">2.0</resheader> |
|||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
|||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
|||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
|||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
|||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
|||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
|||
</data> |
|||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
|||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
|||
<comment>This is a comment</comment> |
|||
</data> |
|||
|
|||
There are any number of "resheader" rows that contain simple |
|||
name/value pairs. |
|||
|
|||
Each data row contains a name, and value. The row also contains a |
|||
type or mimetype. Type corresponds to a .NET class that support |
|||
text/value conversion through the TypeConverter architecture. |
|||
Classes that don't support this are serialized and stored with the |
|||
mimetype set. |
|||
|
|||
The mimetype is used for serialized objects, and tells the |
|||
ResXResourceReader how to depersist the object. This is currently not |
|||
extensible. For a given mimetype the value must be set accordingly: |
|||
|
|||
Note - application/x-microsoft.net.object.binary.base64 is the format |
|||
that the ResXResourceWriter will generate, however the reader can |
|||
read any of the formats listed below. |
|||
|
|||
mimetype: application/x-microsoft.net.object.binary.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.soap.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
|||
value : The object must be serialized into a byte array |
|||
: using a System.ComponentModel.TypeConverter |
|||
: and then encoded with base64 encoding. |
|||
--> |
|||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
|||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
|||
<xsd:element name="root" msdata:IsDataSet="true"> |
|||
<xsd:complexType> |
|||
<xsd:choice maxOccurs="unbounded"> |
|||
<xsd:element name="metadata"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
|||
<xsd:attribute name="type" type="xsd:string" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" /> |
|||
<xsd:attribute ref="xml:space" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="assembly"> |
|||
<xsd:complexType> |
|||
<xsd:attribute name="alias" type="xsd:string" /> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="data"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
|||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
|||
<xsd:attribute ref="xml:space" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="resheader"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:choice> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:schema> |
|||
<resheader name="resmimetype"> |
|||
<value>text/microsoft-resx</value> |
|||
</resheader> |
|||
<resheader name="version"> |
|||
<value>2.0</value> |
|||
</resheader> |
|||
<resheader name="reader"> |
|||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
<resheader name="writer"> |
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
|||
<value>17, 17</value> |
|||
</metadata> |
|||
</root> |
@ -0,0 +1,465 @@ |
|||
/****************************************************************************** |
|||
* 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. |
|||
* 如果您使用此代码,请保留此说明。 |
|||
****************************************************************************** |
|||
* 文件名称: UIScrollBar.cs |
|||
* 文件说明: 水平滚动条 |
|||
* 当前版本: V2.2 |
|||
* 创建日期: 2020-01-01 |
|||
* |
|||
* 2020-07-18: V2.2.6 新增水平滚动条 |
|||
******************************************************************************/ |
|||
|
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.Drawing; |
|||
using System.Windows.Forms; |
|||
|
|||
namespace Sunny.UI |
|||
{ |
|||
[DefaultEvent("ValueChanged")] |
|||
[DefaultProperty("Value")] |
|||
[ToolboxItem(true)] |
|||
public sealed class UIHorScrollBar : UIControl |
|||
{ |
|||
public UIHorScrollBar() |
|||
{ |
|||
Maximum = 100; |
|||
left_state = value_state = right_state = DrawItemState.None; |
|||
timer.Interval = 150; |
|||
timer.Tick += TimerTick; |
|||
Width = 300; |
|||
Height = SystemInformation.HorizontalScrollBarHeight + 2; |
|||
ShowText = false; |
|||
|
|||
fillColor = UIColor.LightBlue; |
|||
foreColor = UIColor.Blue; |
|||
fillHoverColor = Color.FromArgb(111, 168, 255); |
|||
fillPressColor = Color.FromArgb(74, 131, 229); |
|||
} |
|||
|
|||
private int scrollValue; |
|||
private int SmallChange = 1; |
|||
private int LargeChange = 10; |
|||
private int maximum; |
|||
private DrawItemState left_state, value_state, right_state; |
|||
private DrawItemState left_state1, value_state1, right_state1; |
|||
private bool dragMove; |
|||
private int dragOffset; |
|||
private int barWidth; |
|||
private double percentValue; |
|||
private readonly Timer timer = new Timer(); |
|||
private bool isScrollUp = true; |
|||
private bool largeChange = true; |
|||
|
|||
public event EventHandler ValueChanged; |
|||
|
|||
[DefaultValue(0)] |
|||
public int Value |
|||
{ |
|||
get => scrollValue; |
|||
set |
|||
{ |
|||
scrollValue = Math.Min(maximum, value); |
|||
scrollValue = Math.Max(scrollValue, 0); |
|||
Invalidate(); |
|||
} |
|||
} |
|||
|
|||
[DefaultValue(100)] |
|||
public int Maximum |
|||
{ |
|||
get => maximum; |
|||
set |
|||
{ |
|||
maximum = Math.Max(value, 1); |
|||
SmallChange = value / 50; |
|||
SmallChange = Math.Max(1, SmallChange); |
|||
|
|||
LargeChange = value / 10; |
|||
LargeChange = Math.Max(1, LargeChange); |
|||
CalcValueArea(); |
|||
Invalidate(); |
|||
} |
|||
} |
|||
|
|||
protected override void OnSizeChanged(EventArgs e) |
|||
{ |
|||
base.OnSizeChanged(e); |
|||
CalcValueArea(); |
|||
} |
|||
|
|||
private void TimerTick(object sender, EventArgs e) |
|||
{ |
|||
if (isScrollUp) |
|||
ScrollLeft(largeChange); |
|||
else |
|||
ScrollRight(largeChange); |
|||
} |
|||
|
|||
private Rectangle GetUpRect() |
|||
{ |
|||
var rect = new Rectangle(1, 1, 16, Height - 2); |
|||
return rect; |
|||
} |
|||
|
|||
private void CalcValueArea() |
|||
{ |
|||
var centerWidth = GetValueClipRect().Width; |
|||
barWidth = centerWidth / (maximum + 1); |
|||
barWidth = Math.Max(30, barWidth); |
|||
percentValue = ((double)centerWidth - barWidth) / maximum; |
|||
} |
|||
|
|||
private Rectangle GetValueRect() |
|||
{ |
|||
return new Rectangle(ValueToPos(scrollValue), Height / 2 - 3, barWidth, 6); |
|||
} |
|||
|
|||
private int ValueToPos(int value) |
|||
{ |
|||
return (int)(value * percentValue) + 17; |
|||
} |
|||
|
|||
private int PosToValue(int pos) |
|||
{ |
|||
var value = (int)((pos - 17) / percentValue); |
|||
if (value < 0) |
|||
value = 0; |
|||
if (value > maximum) |
|||
value = maximum; |
|||
return value; |
|||
} |
|||
|
|||
private Rectangle GetDownRect() |
|||
{ |
|||
return new Rectangle(Width - 17, 1, 16, Height - 2); |
|||
} |
|||
|
|||
private Rectangle GetValueClipRect() |
|||
{ |
|||
return new Rectangle(17, 1, Width - 17 * 2, Height - 2); |
|||
} |
|||
|
|||
protected override void OnPaint(PaintEventArgs e) |
|||
{ |
|||
e.Graphics.Clear(fillColor); |
|||
DrawUpDownArrow(e.Graphics, left_state, GetUpRect(), true); |
|||
DrawUpDownArrow(e.Graphics, right_state, GetDownRect(), false); |
|||
DrawValueBar(e.Graphics, value_state); |
|||
} |
|||
|
|||
private void DrawValueBar(Graphics g, DrawItemState state) |
|||
{ |
|||
var rect = GetValueRect(); |
|||
|
|||
Color clr = foreColor; |
|||
if ((state & DrawItemState.HotLight) == DrawItemState.HotLight) |
|||
{ |
|||
clr = fillHoverColor; |
|||
} |
|||
|
|||
if ((state & DrawItemState.Selected) == DrawItemState.Selected) |
|||
{ |
|||
clr = fillPressColor; |
|||
} |
|||
|
|||
if (dragMove) |
|||
{ |
|||
rect = new Rectangle(MousePos - barWidth / 2, rect.Top, barWidth, rect.Height); |
|||
if (rect.Left < 17) |
|||
{ |
|||
rect = new Rectangle(17, rect.Top, barWidth, rect.Height); |
|||
} |
|||
|
|||
if (rect.Right > Width - 17) |
|||
{ |
|||
rect = new Rectangle(Width - 17 - barWidth, rect.Top, barWidth, rect.Height); |
|||
} |
|||
} |
|||
|
|||
g.SetHighQuality(); |
|||
g.FillRoundRectangle(clr, rect, 5); |
|||
g.SetDefaultQuality(); |
|||
} |
|||
|
|||
private void DrawUpDownArrow(Graphics g, DrawItemState state, Rectangle rect, bool isUp) |
|||
{ |
|||
Color clr_arrow = foreColor; |
|||
|
|||
if ((state & DrawItemState.HotLight) == DrawItemState.HotLight) |
|||
{ |
|||
clr_arrow = fillHoverColor; |
|||
} |
|||
|
|||
if ((state & DrawItemState.Selected) == DrawItemState.Selected) |
|||
{ |
|||
clr_arrow = fillPressColor; |
|||
} |
|||
|
|||
g.FillRectangle(fillColor, rect); |
|||
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(); |
|||
} |
|||
|
|||
public void SetValue(int value) |
|||
{ |
|||
if (value < 0) |
|||
{ |
|||
value = 0; |
|||
} |
|||
|
|||
if (value > maximum) |
|||
{ |
|||
value = maximum; |
|||
} |
|||
|
|||
scrollValue = value; |
|||
ValueChanged?.Invoke(this, null); |
|||
Invalidate(); |
|||
} |
|||
|
|||
public void ScrollLeft(bool large) |
|||
{ |
|||
SetValue(scrollValue - (large ? LargeChange : SmallChange)); |
|||
} |
|||
|
|||
public void ScrollRight(bool large) |
|||
{ |
|||
SetValue(scrollValue + (large ? LargeChange : SmallChange)); |
|||
} |
|||
|
|||
private void StartScroll(bool up, bool large) |
|||
{ |
|||
isScrollUp = up; |
|||
largeChange = large; |
|||
timer.Start(); |
|||
} |
|||
|
|||
private void StopScroll() |
|||
{ |
|||
timer.Stop(); |
|||
} |
|||
|
|||
protected override void OnMouseDown(MouseEventArgs e) |
|||
{ |
|||
if (e.Button != MouseButtons.Left) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
left_state = value_state = right_state = DrawItemState.None; |
|||
IsPress = true; |
|||
var hit = HitState(e.X, e.Y); |
|||
switch (hit) |
|||
{ |
|||
case 1: |
|||
if (Value > 0) |
|||
{ |
|||
left_state = DrawItemState.Selected; |
|||
ScrollLeft(false); |
|||
StartScroll(true, false); |
|||
} |
|||
break; |
|||
|
|||
case 2: |
|||
value_state = DrawItemState.Selected; |
|||
dragMove = true; |
|||
dragOffset = GetValueRect().Y - e.Y; |
|||
break; |
|||
|
|||
case 3: |
|||
if (Value < Maximum) |
|||
{ |
|||
right_state = DrawItemState.Selected; |
|||
ScrollRight(false); |
|||
StartScroll(false, false); |
|||
} |
|||
break; |
|||
|
|||
case 4: |
|||
if (Value > 0) |
|||
{ |
|||
ScrollLeft(true); |
|||
if (IsPress) |
|||
{ |
|||
StartScroll(true, true); |
|||
} |
|||
} |
|||
break; |
|||
|
|||
case 5: |
|||
if (Value < Maximum) |
|||
{ |
|||
ScrollRight(false); |
|||
if (IsPress) |
|||
{ |
|||
StartScroll(false, true); |
|||
} |
|||
} |
|||
break; |
|||
} |
|||
|
|||
if (StateChange()) |
|||
{ |
|||
Invalidate(); |
|||
} |
|||
} |
|||
|
|||
protected override void OnMouseUp(MouseEventArgs e) |
|||
{ |
|||
IsPress = false; |
|||
dragMove = false; |
|||
StopScroll(); |
|||
Invalidate(); |
|||
} |
|||
|
|||
private int MousePos; |
|||
|
|||
protected override void OnMouseMove(MouseEventArgs e) |
|||
{ |
|||
MousePos = e.X; |
|||
var hit = HitState(e.X, e.Y); |
|||
left_state = value_state = right_state = DrawItemState.None; |
|||
switch (hit) |
|||
{ |
|||
case 1: |
|||
left_state = IsPress ? DrawItemState.Selected : DrawItemState.HotLight; |
|||
break; |
|||
|
|||
case 2: |
|||
value_state = IsPress ? DrawItemState.Selected : DrawItemState.HotLight; |
|||
break; |
|||
|
|||
case 3: |
|||
right_state = IsPress ? DrawItemState.Selected : DrawItemState.HotLight; |
|||
break; |
|||
} |
|||
|
|||
if (dragMove) |
|||
{ |
|||
var value = PosToValue(e.X + dragOffset); |
|||
SetValue(value); |
|||
return; |
|||
} |
|||
|
|||
if (StateChange()) |
|||
{ |
|||
Invalidate(); |
|||
} |
|||
} |
|||
|
|||
protected override void OnMouseLeave(EventArgs e) |
|||
{ |
|||
base.OnMouseLeave(e); |
|||
left_state = right_state = value_state = DrawItemState.None; |
|||
Invalidate(); |
|||
} |
|||
|
|||
private bool StateChange() |
|||
{ |
|||
var change = left_state != left_state1 || right_state != right_state1 || value_state != value_state1; |
|||
left_state1 = left_state; |
|||
value_state1 = value_state; |
|||
right_state1 = right_state; |
|||
return change; |
|||
} |
|||
|
|||
private int HitState(int x, int y) |
|||
{ |
|||
var rect_left = GetUpRect(); |
|||
var rect_right = GetDownRect(); |
|||
var rect_value = GetValueRect(); |
|||
var rect_value_left = new Rectangle(rect_left.Right, 0, rect_value.Left - rect_left.Right, Height); |
|||
var rect_value_right= new Rectangle(rect_value.Left, 0, rect_right.Left - rect_value.Right, Height); |
|||
if (rect_left.Contains(x, y)) |
|||
return 1; |
|||
else if (rect_right.Contains(x, y)) |
|||
return 3; |
|||
else if (rect_value.Contains(x, y) || value_state == DrawItemState.Selected) |
|||
return 2; |
|||
else if (rect_value_left.Contains(x, y)) |
|||
return 4; |
|||
else if (rect_value_right.Contains(x, y)) |
|||
return 5; |
|||
else |
|||
return -1; |
|||
} |
|||
|
|||
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(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 字体颜色
|
|||
/// </summary>
|
|||
[Description("字体颜色"), Category("自定义")] |
|||
[DefaultValue(typeof(Color), "80, 160, 255")] |
|||
public override Color ForeColor |
|||
{ |
|||
get => foreColor; |
|||
set => SetForeColor(value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 填充颜色,当值为背景色或透明色或空值则不填充
|
|||
/// </summary>
|
|||
[Description("填充颜色"), Category("自定义")] |
|||
[DefaultValue(typeof(Color), "235, 243, 255")] |
|||
public Color FillColor |
|||
{ |
|||
get => fillColor; |
|||
set => SetFillColor(value); |
|||
} |
|||
|
|||
[DefaultValue(typeof(Color), "111, 168, 255")] |
|||
public Color HoverColor |
|||
{ |
|||
get => fillHoverColor; |
|||
set => SetFillHoveColor(value); |
|||
} |
|||
|
|||
[DefaultValue(typeof(Color), "74, 131, 229")] |
|||
public Color PressColor |
|||
{ |
|||
get => fillPressColor; |
|||
set => SetFillPressColor(value); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue