增加颜色选择框UIColorPicker

This commit is contained in:
Sunny 2020-06-01 22:52:50 +08:00
parent 11dfc8c552
commit 695f3706e8
29 changed files with 4564 additions and 39 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -46,11 +46,15 @@
this.uiLine5 = new Sunny.UI.UILine(); this.uiLine5 = new Sunny.UI.UILine();
this.uiTimePicker1 = new Sunny.UI.UITimePicker(); this.uiTimePicker1 = new Sunny.UI.UITimePicker();
this.uiLine6 = new Sunny.UI.UILine(); this.uiLine6 = new Sunny.UI.UILine();
this.uiLine7 = new Sunny.UI.UILine();
this.uiColorPicker1 = new Sunny.UI.UIColorPicker();
this.PagePanel.SuspendLayout(); this.PagePanel.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// PagePanel // PagePanel
// //
this.PagePanel.Controls.Add(this.uiColorPicker1);
this.PagePanel.Controls.Add(this.uiLine7);
this.PagePanel.Controls.Add(this.uiLine6); this.PagePanel.Controls.Add(this.uiLine6);
this.PagePanel.Controls.Add(this.uiTimePicker1); this.PagePanel.Controls.Add(this.uiTimePicker1);
this.PagePanel.Controls.Add(this.uiLine5); this.PagePanel.Controls.Add(this.uiLine5);
@ -94,6 +98,7 @@
this.uiTextBox1.Name = "uiTextBox1"; this.uiTextBox1.Name = "uiTextBox1";
this.uiTextBox1.Padding = new System.Windows.Forms.Padding(5); this.uiTextBox1.Padding = new System.Windows.Forms.Padding(5);
this.uiTextBox1.Size = new System.Drawing.Size(221, 29); this.uiTextBox1.Size = new System.Drawing.Size(221, 29);
this.uiTextBox1.Style = Sunny.UI.UIStyle.Custom;
this.uiTextBox1.TabIndex = 3; this.uiTextBox1.TabIndex = 3;
this.uiTextBox1.Watermark = "水印文字"; this.uiTextBox1.Watermark = "水印文字";
// //
@ -291,6 +296,7 @@
// //
// uiTimePicker1 // uiTimePicker1
// //
this.uiTimePicker1.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
this.uiTimePicker1.FillColor = System.Drawing.Color.White; this.uiTimePicker1.FillColor = System.Drawing.Color.White;
this.uiTimePicker1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiTimePicker1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiTimePicker1.Location = new System.Drawing.Point(188, 294); this.uiTimePicker1.Location = new System.Drawing.Point(188, 294);
@ -302,7 +308,7 @@
this.uiTimePicker1.SymbolDropDown = 61555; this.uiTimePicker1.SymbolDropDown = 61555;
this.uiTimePicker1.SymbolNormal = 61555; this.uiTimePicker1.SymbolNormal = 61555;
this.uiTimePicker1.TabIndex = 25; this.uiTimePicker1.TabIndex = 25;
this.uiTimePicker1.Text = "uiTimePicker1"; this.uiTimePicker1.Text = "23:41:39";
this.uiTimePicker1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; this.uiTimePicker1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.uiTimePicker1.Value = new System.DateTime(2020, 5, 29, 23, 41, 39, 684); this.uiTimePicker1.Value = new System.DateTime(2020, 5, 29, 23, 41, 39, 684);
// //
@ -317,6 +323,33 @@
this.uiLine6.Text = "UITimePicker"; this.uiLine6.Text = "UITimePicker";
this.uiLine6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.uiLine6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
// //
// uiLine7
//
this.uiLine7.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiLine7.Location = new System.Drawing.Point(30, 342);
this.uiLine7.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine7.Name = "uiLine7";
this.uiLine7.Size = new System.Drawing.Size(150, 20);
this.uiLine7.TabIndex = 28;
this.uiLine7.Text = "UIColorPicker";
this.uiLine7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// uiColorPicker1
//
this.uiColorPicker1.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
this.uiColorPicker1.FillColor = System.Drawing.Color.White;
this.uiColorPicker1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiColorPicker1.Location = new System.Drawing.Point(30, 376);
this.uiColorPicker1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiColorPicker1.MinimumSize = new System.Drawing.Size(63, 0);
this.uiColorPicker1.Name = "uiColorPicker1";
this.uiColorPicker1.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0);
this.uiColorPicker1.Size = new System.Drawing.Size(150, 29);
this.uiColorPicker1.TabIndex = 29;
this.uiColorPicker1.Text = "uiColorPicker1";
this.uiColorPicker1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.uiColorPicker1.Value = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(159)))), ((int)(((byte)(254)))));
//
// FTextBox // FTextBox
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
@ -350,5 +383,7 @@
private UILine uiLine5; private UILine uiLine5;
private UITimePicker uiTimePicker1; private UITimePicker uiTimePicker1;
private UILine uiLine6; private UILine uiLine6;
private UILine uiLine7;
private UIColorPicker uiColorPicker1;
} }
} }

View File

@ -1,11 +1,4 @@
using System; 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 namespace Sunny.UI.Demo
{ {

View File

@ -0,0 +1,304 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Sunny.UI
{
internal class ColorSlider : LabelRotate
{
public event EventHandler SelectedValueChanged;
private Orientation m_orientation = Orientation.Vertical;
public Orientation Orientation
{
get { return m_orientation; }
set { m_orientation = value; }
}
public enum eNumberOfColors
{
Use2Colors,
Use3Colors,
}
private eNumberOfColors m_numberOfColors = eNumberOfColors.Use3Colors;
public eNumberOfColors NumberOfColors
{
get { return m_numberOfColors; }
set { m_numberOfColors = value; }
}
public enum eValueOrientation
{
MinToMax,
MaxToMin,
}
private eValueOrientation m_valueOrientation = eValueOrientation.MinToMax;
public eValueOrientation ValueOrientation
{
get { return m_valueOrientation; }
set { m_valueOrientation = value; }
}
private float m_percent = 0;
public float Percent
{
get { return m_percent; }
set
{
// ok so it is not really percent, but a value between 0 - 1.
if (value < 0) value = 0;
if (value > 1) value = 1;
if (value != m_percent)
{
m_percent = value;
if (SelectedValueChanged != null)
SelectedValueChanged(this, null);
Invalidate();
}
}
}
private Color m_color1 = Color.Black;
private Color m_color2 = Color.FromArgb(255, 127, 127, 127);
private Color m_color3 = Color.White;
public Color Color1
{
get { return m_color1; }
set { m_color1 = value; }
}
public Color Color2
{
get { return m_color2; }
set { m_color2 = value; }
}
public Color Color3
{
get { return m_color3; }
set { m_color3 = value; }
}
private Padding m_barPadding = new Padding(12, 5, 24, 10);
public Padding BarPadding
{
get { return m_barPadding; }
set
{
m_barPadding = value;
Invalidate();
}
}
public ColorSlider()
{
}
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
Invalidate();
}
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
DrawColorBar(e.Graphics);
if (Focused)
{
RectangleF lr = ClientRectangleF;
lr.Inflate(-2, -2);
ControlPaint.DrawFocusRectangle(e.Graphics, UIColorUtil.Rect(lr));
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
PointF mousepoint = new PointF(e.X, e.Y);
if (e.Button == MouseButtons.Left)
SetPercent(mousepoint);
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
Focus();
PointF mousepoint = new PointF(e.X, e.Y);
if (e.Button == MouseButtons.Left)
SetPercent(mousepoint);
}
protected override bool ProcessDialogKey(Keys keyData)
{
float percent = Percent * 100;
int step = 0;
if ((keyData & Keys.Up) == Keys.Up)
step = 1;
if ((keyData & Keys.Down) == Keys.Down)
step = -1;
if ((keyData & Keys.Control) == Keys.Control)
step *= 5;
if (step != 0)
{
SetPercent((float)Math.Round(percent + step));
return true;
}
return base.ProcessDialogKey(keyData);
}
protected virtual void SetPercent(float percent)
{
Percent = percent / 100;
}
protected virtual void SetPercent(PointF mousepoint)
{
RectangleF cr = ClientRectangleF;
RectangleF br = BarRectangle;
mousepoint.X += cr.X - br.X;
mousepoint.Y += cr.Y - br.Y;
Percent = GetPercentSet(BarRectangle, Orientation, mousepoint);
Refresh();
}
protected RectangleF BarRectangle
{
get
{
RectangleF r = ClientRectangle;
r.X += BarPadding.Left;
r.Width -= BarPadding.Right;
r.Y += BarPadding.Top;
r.Height -= BarPadding.Bottom;
return r;
}
}
protected float GetPercentSet(RectangleF r, Orientation orientation, PointF mousepoint)
{
float percentSet = 0;
if (orientation == Orientation.Vertical)
{
if (m_valueOrientation == eValueOrientation.MaxToMin)
percentSet = 1 - ((mousepoint.Y - r.Y / r.Height) / r.Height);
else
percentSet = mousepoint.Y / r.Height;
}
if (orientation == Orientation.Horizontal)
if (m_valueOrientation == eValueOrientation.MaxToMin)
percentSet = 1 - ((mousepoint.X - r.X / r.Width) / r.Width);
else
percentSet = (mousepoint.X / r.Width);
if (percentSet < 0)
percentSet = 0;
if (percentSet > 100)
percentSet = 100;
return percentSet;
}
protected void DrawSelector(Graphics dc, RectangleF r, Orientation orientation, float percentSet)
{
Pen pen = new Pen(Color.CadetBlue);
percentSet = Math.Max(0, percentSet);
percentSet = Math.Min(1, percentSet);
if (orientation == Orientation.Vertical)
{
float selectorY = (float)Math.Floor(r.Top + (r.Height - (r.Height * percentSet)));
if (m_valueOrientation == eValueOrientation.MaxToMin)
selectorY = (float)Math.Floor(r.Top + (r.Height - (r.Height * percentSet)));
else
selectorY = (float)Math.Floor(r.Top + (r.Height * percentSet));
dc.DrawLine(pen, r.X, selectorY, r.Right, selectorY);
Image image = SelectorImages.Image(SelectorImages.eIndexes.Right);
float xpos = r.Right;
float ypos = selectorY - image.Height / 2;
dc.DrawImageUnscaled(image, (int)xpos, (int)ypos);
image = SelectorImages.Image(SelectorImages.eIndexes.Left);
xpos = r.Left - image.Width;
dc.DrawImageUnscaled(image, (int)xpos, (int)ypos);
}
if (orientation == Orientation.Horizontal)
{
float selectorX = 0;
if (m_valueOrientation == eValueOrientation.MaxToMin)
selectorX = (float)Math.Floor(r.Left + (r.Width - (r.Width * percentSet)));
else
selectorX = (float)Math.Floor(r.Left + (r.Width * percentSet));
dc.DrawLine(pen, selectorX, r.Top, selectorX, r.Bottom);
Image image = SelectorImages.Image(SelectorImages.eIndexes.Up);
float xpos = selectorX - image.Width / 2;
float ypos = r.Bottom;
dc.DrawImageUnscaled(image, (int)xpos, (int)ypos);
image = SelectorImages.Image(SelectorImages.eIndexes.Down);
ypos = r.Top - image.Height;
dc.DrawImageUnscaled(image, (int)xpos, (int)ypos);
}
}
protected void DrawColorBar(Graphics dc)
{
RectangleF lr = BarRectangle;
if (m_numberOfColors == eNumberOfColors.Use2Colors)
UIColorUtil.Draw2ColorBar(dc, lr, Orientation, m_color1, m_color2);
else
UIColorUtil.Draw3ColorBar(dc, lr, Orientation, m_color1, m_color2, m_color3);
DrawSelector(dc, lr, Orientation, (float)Percent);
}
}
internal class HSLColorSlider : ColorSlider
{
private HSLColor m_selectedColor = new HSLColor();
public HSLColor SelectedHSLColor
{
get { return m_selectedColor; }
set
{
if (m_selectedColor.Equals(value))
return;
m_selectedColor = value;
value.Lightness = 0.5;
Color2 = Color.FromArgb(255, value.Color);
Percent = (float)m_selectedColor.Lightness;
Refresh();//Invalidate(UIColorUtil.Rect(BarRectangle));
}
}
protected override void SetPercent(PointF mousepoint)
{
base.SetPercent(mousepoint);
m_selectedColor.Lightness = Percent;
Refresh();
}
protected override void SetPercent(float percent)
{
base.SetPercent(percent);
m_selectedColor.Lightness = percent / 100;
SelectedHSLColor = m_selectedColor;
}
}
}

View File

@ -0,0 +1,386 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
namespace Sunny.UI
{
[ToolboxItem(false)]
public sealed class UIColorTable : LabelRotate
{
public event EventHandler SelectedIndexChanged;
public Color SelectedItem
{
get
{
if (m_selindex < 0 || m_selindex >= m_colors.Count)
return Color.White;
return m_colors[m_selindex];
}
set
{
if (m_selindex < m_colors.Count && value == m_colors[m_selindex])
return;
int index = m_colors.IndexOf(value);
if (index < 0)
return;
SetIndex(index);
}
}
public bool ColorExist(Color c)
{
int index = m_colors.IndexOf(c);
return index >= 0;
}
private int m_cols;
private int m_rows;
public int Cols
{
get { return m_cols; }
set
{
m_cols = value;
m_rows = m_colors.Count / m_cols;
if ((m_colors.Count % m_cols) != 0)
m_rows++;
}
}
private Size m_fieldSize = new Size(12, 12);
public Size FieldSize
{
get { return m_fieldSize; }
set { m_fieldSize = value; }
}
private int CompareColorByValue(Color c1, Color c2)
{
int color1 = c1.R << 16 | c1.G << 8 | c1.B;
int color2 = c2.R << 16 | c2.G << 8 | c2.B;
if (color1 > color2)
return -1;
if (color1 < color2)
return 1;
return 0;
}
private int CompareColorByHue(Color c1, Color c2)
{
float h1 = c1.GetHue();
float h2 = c2.GetHue();
if (h1 < h2)
return -1;
if (h1 > h2)
return 1;
return 0;
}
private int CompareColorByBrightness(Color c1, Color c2)
{
float h1 = c1.GetBrightness();
float h2 = c2.GetBrightness();
if (h1 < h2)
return -1;
if (h1 > h2)
return 1;
return 0;
}
public void SortColorByValue()
{
m_colors.Sort(CompareColorByValue);
Invalidate();
}
public void SortColorByHue()
{
m_colors.Sort(CompareColorByHue);
Invalidate();
}
public void SortColorByBrightness()
{
m_colors.Sort(CompareColorByBrightness);
Invalidate();
}
private List<Color> m_colors = new List<Color>();
public UIColorTable(Color[] colors)
{
this.DoubleBuffered = true;
if (colors != null)
m_colors = new List<Color>(colors);
Cols = 16;
m_initialColorCount = m_colors.Count;
Padding = new Padding(8, 8, 0, 0);
}
public UIColorTable()
{
this.DoubleBuffered = true;
PropertyInfo[] propinfos = typeof(Color).GetProperties(BindingFlags.Public | BindingFlags.Static);
foreach (PropertyInfo info in propinfos)
{
if (info.PropertyType == typeof(Color))
{
Color c = (Color)info.GetValue(typeof(Color), null);
if (c.A == 0) // transparent
continue;
m_colors.Add(c);
}
}
m_colors.Sort(CompareColorByBrightness);
m_initialColorCount = m_colors.Count;
Cols = 16;
Size = new Size(253, 148);
Padding = new Padding(8);
}
public void RemoveCustomColor()
{
if (m_colors.Count > m_initialColorCount)
m_colors.RemoveAt(m_colors.Count - 1);
}
public void SetCustomColor(Color col)
{
RemoveCustomColor();
if (m_colors.Contains(col) == false)
{
int rows = m_rows;
m_colors.Add(col);
Cols = Cols;
if (m_rows != rows)
Invalidate();
else
Invalidate(GetRectangle(m_colors.Count - 1));
}
}
public Color[] Colors
{
get { return m_colors.ToArray(); }
set
{
m_colors = new List<Color>(value);
Cols = 16;
m_initialColorCount = m_colors.Count;
}
}
private int m_spacing = 3;
private int m_selindex;
private int m_initialColorCount;
private Rectangle GetSelectedItemRect()
{
Rectangle rect = GetRectangle(m_selindex);
rect.Inflate(m_fieldSize.Width / 2, m_fieldSize.Height / 2);
return rect;
}
private Rectangle GetRectangle(int index)
{
GetRowCol(index, out int row, out int col);
return GetRectangle(row, col);
}
private void GetRowCol(int index, out int row, out int col)
{
row = index / m_cols;
col = index - (row * m_cols);
}
private Rectangle GetRectangle(int row, int col)
{
int x = Padding.Left + (col * (m_fieldSize.Width + m_spacing));
int y = Padding.Top + (row * (m_fieldSize.Height + m_spacing));
return new Rectangle(x, y, m_fieldSize.Width, m_fieldSize.Height);
}
private int GetIndexFromMousePos(int x, int y)
{
int col = (x - Padding.Left) / (m_fieldSize.Width + m_spacing);
int row = (y - Padding.Top) / (m_fieldSize.Height + m_spacing);
return GetIndex(row, col);
}
private int GetIndex(int row, int col)
{
if (col < 0 || col >= m_cols)
return -1;
if (row < 0 || row >= m_rows)
return -1;
return row * m_cols + col;
}
private void SetIndex(int index)
{
if (index == m_selindex)
return;
Invalidate(GetSelectedItemRect());
m_selindex = index;
if (SelectedIndexChanged != null)
SelectedIndexChanged(this, null);
Invalidate(GetSelectedItemRect());
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
Focus();
if (GetSelectedItemRect().Contains(new Point(e.X, e.Y)))
return;
int index = GetIndexFromMousePos(e.X, e.Y);
if (index != -1)
SetIndex(index);
}
protected override void OnPaint(PaintEventArgs e)
{
Size = new Size(253, 148);
base.OnPaint(e);
int index = 0;
int totalwidth = m_cols * (m_fieldSize.Width + m_spacing);
int totalheight = m_rows * (m_fieldSize.Height + m_spacing);
int offset = (m_spacing / 2 + 1);
Rectangle r = new Rectangle(0, 0, totalwidth, totalheight);
r.X += Padding.Left - offset;
r.Y += Padding.Top - offset;
e.Graphics.DrawRectangle(Pens.CadetBlue, r);
r.X++;
r.Y++;
r.Width--;
r.Height--;
e.Graphics.FillRectangle(Brushes.White, r);
for (int col = 1; col < m_cols; col++)
{
int x = Padding.Left - offset + (col * (m_fieldSize.Width + m_spacing));
e.Graphics.DrawLine(Pens.CadetBlue, x, r.Y, x, r.Bottom - 1);
}
for (int row = 1; row < m_rows; row++)
{
int y = Padding.Top - offset + (row * (m_fieldSize.Height + m_spacing));
e.Graphics.DrawLine(Pens.CadetBlue, r.X, y, r.Right - 1, y);
}
for (int row = 0; row < m_rows; row++)
{
for (int col = 0; col < m_cols; col++)
{
if (index >= m_colors.Count)
break;
Rectangle rect = GetRectangle(row, col);
using (SolidBrush brush = new SolidBrush(m_colors[index++]))
{
e.Graphics.FillRectangle(brush, rect);
}
}
}
if (m_selindex >= 0)
{
Rectangle rect = GetSelectedItemRect();
e.Graphics.FillRectangle(Brushes.White, rect);
rect.Inflate(-3, -3);
using (SolidBrush brush = new SolidBrush(SelectedItem))
{
e.Graphics.FillRectangle(brush, rect);
}
if (Focused)
{
rect.Inflate(2, 2);
ControlPaint.DrawFocusRectangle(e.Graphics, rect);
}
else
{
rect.X -= 2;
rect.Y -= 2;
rect.Width += 3;
rect.Height += 3;
e.Graphics.DrawRectangle(Pens.CadetBlue, rect);
}
}
}
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
Invalidate();
}
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
Invalidate();
}
protected override bool ProcessDialogKey(Keys keyData)
{
bool processed = false;
GetRowCol(m_selindex, out int row, out int col);
switch (keyData)
{
case Keys.Down:
row++;
processed = true;
break;
case Keys.Up:
row--;
processed = true;
break;
case Keys.Left:
col--;
if (col < 0)
{
col = m_cols - 1;
row--;
}
processed = true;
break;
case Keys.Right:
col++;
if (col >= m_cols)
{
col = 0;
row++;
}
processed = true;
break;
}
if (processed)
{
int index = GetIndex(row, col);
if (index != -1)
SetIndex(index);
return false;
}
return base.ProcessDialogKey(keyData);
}
private void InitializeComponent()
{
this.SuspendLayout();
//
// UIColorTable
//
this.Size = new System.Drawing.Size(253, 148);
this.ResumeLayout(false);
}
}
}

View File

@ -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="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@ -0,0 +1,308 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Sunny.UI
{
[ToolboxItem(false)]
public sealed class UIColorWheel : Control, IStyleInterface
{
public event EventHandler SelectedColorChanged;
private Color m_frameColor = UIColor.Blue;
private HSLColor m_selectedColor = new HSLColor(Color.BlanchedAlmond);
private PathGradientBrush m_brush;
private readonly List<PointF> m_path = new List<PointF>();
private readonly List<Color> m_colors = new List<Color>();
private double m_wheelLightness = 0.5;
public HSLColor SelectedHSLColor
{
get { return m_selectedColor; }
set
{
if (m_selectedColor.Equals(value))
return;
Invalidate(UIColorUtil.Rect(ColorSelectorRectangle));
m_selectedColor = value;
SelectedColorChanged?.Invoke(this, null);
Refresh();//Invalidate(UIColorUtil.Rect(ColorSelectorRectangle));
}
}
public void SetLightness(double lightness)
{
m_selectedColor.Lightness = lightness;
Invalidate(UIColorUtil.Rect(ColorSelectorRectangle));
SelectedColorChanged?.Invoke(this, null);
Refresh();//Invalidate(UIColorUtil.Rect(ColorSelectorRectangle));
}
public Color SelectedColor
{
get { return m_selectedColor.Color; }
set
{
if (m_selectedColor.Color != value)
SelectedHSLColor = new HSLColor(value);
}
}
public Color FrameColor
{
get => m_frameColor;
set
{
m_frameColor = value;
Invalidate();
}
}
public UIColorWheel()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
Width = Height = 148;
Version = UIGlobal.Version;
}
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
Invalidate();
}
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
if (Width != Height)
{
Height = Width;
}
using (SolidBrush b = new SolidBrush(BackColor))
{
e.Graphics.FillRectangle(b, ClientRectangle);
}
RectangleF wheelRectangle = WheelRectangle;
UIColorUtil.DrawFrame(e.Graphics, wheelRectangle, 6, m_frameColor);
wheelRectangle = ColorWheelRectangle;
PointF center = UIColorUtil.Center(wheelRectangle);
e.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
if (m_brush == null)
{
m_brush = new PathGradientBrush(m_path.ToArray(), WrapMode.Clamp);
m_brush.CenterPoint = center;
m_brush.CenterColor = Color.White;
m_brush.SurroundColors = m_colors.ToArray();
}
e.Graphics.FillPie(m_brush, UIColorUtil.Rect(wheelRectangle), 0, 360);
e.Graphics.DrawEllipse(BackColor, wheelRectangle);
DrawColorSelector(e.Graphics);
if (Focused)
{
RectangleF r = WheelRectangle;
r.Inflate(-2, -2);
ControlPaint.DrawFocusRectangle(e.Graphics, UIColorUtil.Rect(r));
}
e.Graphics.Smooth(false);
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
m_brush?.Dispose();
m_brush = null;
ReCalcWheelPoints();
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
PointF mousePoint = new PointF(e.X, e.Y);
if (e.Button == MouseButtons.Left)
SetColor(mousePoint);
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
Focus();
PointF mousePoint = new PointF(e.X, e.Y);
if (e.Button == MouseButtons.Left)
SetColor(mousePoint);
}
protected override bool ProcessDialogKey(Keys keyData)
{
HSLColor c = SelectedHSLColor;
double hue = c.Hue;
int step = 1;
if ((keyData & Keys.Control) == Keys.Control) step = 5;
if ((keyData & Keys.Up) == Keys.Up) hue += step;
if ((keyData & Keys.Down) == Keys.Down) hue -= step;
if (hue >= 360) hue = 0;
if (hue < 0) hue = 359;
if (hue != c.Hue)
{
c.Hue = hue;
SelectedHSLColor = c;
return true;
}
return base.ProcessDialogKey(keyData);
}
private RectangleF ColorSelectorRectangle
{
get
{
HSLColor color = m_selectedColor;
double angleR = color.Hue * Math.PI / 180;
PointF center = UIColorUtil.Center(ColorWheelRectangle);
double radius = Radius(ColorWheelRectangle);
radius *= color.Saturation;
double x = center.X + Math.Cos(angleR) * radius;
double y = center.Y - Math.Sin(angleR) * radius;
Rectangle selectorRectangle = new Rectangle(new Point((int)x, (int)y), new Size(0, 0));
selectorRectangle.Inflate(12, 12);
return selectorRectangle;
}
}
private void DrawColorSelector(Graphics dc)
{
Rectangle r = UIColorUtil.Rect(ColorSelectorRectangle);
PointF center = UIColorUtil.Center(r);
Image image = SelectorImages.Image(SelectorImages.eIndexes.Donut);
dc.DrawImageUnscaled(image, (int)(center.X - image.Width / 2.0), (int)(center.Y - image.Height / 2.0));
}
private RectangleF WheelRectangle
{
get
{
Rectangle r = ClientRectangle;
r.Width -= 1;
r.Height -= 1;
return r;
}
}
private RectangleF ColorWheelRectangle
{
get
{
RectangleF r = WheelRectangle;
r.Inflate(-5, -5);
return r;
}
}
private float Radius(RectangleF r)
{
return Math.Min((r.Width / 2), (r.Height / 2));
}
private void ReCalcWheelPoints()
{
m_path.Clear();
m_colors.Clear();
PointF center = UIColorUtil.Center(ColorWheelRectangle);
float radius = Radius(ColorWheelRectangle);
double angle = 0;
double fullCircle = 360;
double step = 5;
while (angle < fullCircle)
{
double angleR = angle * (Math.PI / 180);
double x = center.X + Math.Cos(angleR) * radius;
double y = center.Y - Math.Sin(angleR) * radius;
m_path.Add(new PointF((float)x, (float)y));
m_colors.Add(new HSLColor(angle, 1, m_wheelLightness).Color);
angle += step;
}
}
private void SetColor(PointF mousePoint)
{
if (WheelRectangle.Contains(mousePoint) == false)
return;
PointF center = UIColorUtil.Center(ColorWheelRectangle);
double radius = Radius(ColorWheelRectangle);
double dx = Math.Abs(mousePoint.X - center.X);
double dy = Math.Abs(mousePoint.Y - center.Y);
double angle = Math.Atan(dy / dx) / Math.PI * 180;
double dist = Math.Pow((Math.Pow(dx, 2) + (Math.Pow(dy, 2))), 0.5);
double saturation = dist / radius;
//if (dist > radius + 5) // give 5 pixels slack
// return;
if (dist < 6)
saturation = 0; // snap to center
if (mousePoint.X < center.X)
angle = 180 - angle;
if (mousePoint.Y > center.Y)
angle = 360 - angle;
SelectedHSLColor = new HSLColor(angle, saturation, SelectedHSLColor.Lightness);
}
private UIStyle _style = UIStyle.Blue;
/// <summary>
/// Ö÷ĚâŃůĘ˝
/// </summary>
[DefaultValue(UIStyle.Blue)]
public UIStyle Style
{
get => _style;
set => SetStyle(value);
}
/// <summary>
/// ÉčÖĂÖ÷ĚâŃůĘ˝
/// </summary>
/// <param name="style">Ö÷ĚâŃůĘ˝</param>
public void SetStyle(UIStyle style)
{
SetStyleColor(UIStyles.GetStyleColor(style));
_style = style;
}
/// <summary>
/// ÉčÖĂÖ÷ĚâŃůĘ˝ŃŐÉŤ
/// </summary>
/// <param name="uiColor"></param>
public void SetStyleColor(UIBaseStyle uiColor)
{
if (uiColor.IsCustom()) return;
FrameColor = uiColor.RectColor;
BackColor = uiColor.PlainColor;
Invalidate();
}
public bool StyleCustomMode { get; set; }
public string Version { get; }
public string TagString { get; set; }
}
}

View File

@ -0,0 +1,328 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Sunny.UI
{
public struct HSLColor
{
private double m_hue;
private double m_saturation;
private double m_lightness;
// http://en.wikipedia.org/wiki/HSL_color_space
public double Hue
{
get { return m_hue; }
set { m_hue = value; }
}
public double Saturation
{
get { return m_saturation; }
set { m_saturation = value; }
}
public double Lightness
{
get { return m_lightness; }
set
{
m_lightness = value;
if (m_lightness < 0)
m_lightness = 0;
if (m_lightness > 1)
m_lightness = 1;
}
}
public HSLColor(double hue, double saturation, double lightness)
{
m_hue = Math.Min(360, hue);
m_saturation = Math.Min(1, saturation);
m_lightness = Math.Min(1, lightness);
}
public HSLColor(Color color)
{
m_hue = 0;
m_saturation = 1;
m_lightness = 1;
FromRGB(color);
}
public Color Color
{
get { return ToRGB(); }
set { FromRGB(value); }
}
private void FromRGB(Color cc)
{
double r = (double)cc.R / 255d;
double g = (double)cc.G / 255d;
double b = (double)cc.B / 255d;
double min = Math.Min(Math.Min(r, g), b);
double max = Math.Max(Math.Max(r, g), b);
// calulate hue according formula given in
// "Conversion from RGB to HSL or HSV"
m_hue = 0;
if (min != max)
{
if (r == max && g >= b)
{
m_hue = 60 * ((g - b) / (max - min)) + 0;
}
else
if (r == max && g < b)
{
m_hue = 60 * ((g - b) / (max - min)) + 360;
}
else
if (g == max)
{
m_hue = 60 * ((b - r) / (max - min)) + 120;
}
else
if (b == max)
{
m_hue = 60 * ((r - g) / (max - min)) + 240;
}
}
// find lightness
m_lightness = (min + max) / 2;
// find saturation
if (m_lightness == 0 || min == max)
m_saturation = 0;
else
if (m_lightness > 0 && m_lightness <= 0.5)
m_saturation = (max - min) / (2 * m_lightness);
else
if (m_lightness > 0.5)
m_saturation = (max - min) / (2 - 2 * m_lightness);
}
private Color ToRGB()
{
// convert to RGB according to
// "Conversion from HSL to RGB"
double r = m_lightness;
double g = m_lightness;
double b = m_lightness;
if (m_saturation == 0)
return Color.FromArgb(255, (int)(r * 255), (int)(g * 255), (int)(b * 255));
double q = 0;
if (m_lightness < 0.5)
q = m_lightness * (1 + m_saturation);
else
q = m_lightness + m_saturation - (m_lightness * m_saturation);
double p = 2 * m_lightness - q;
double hk = m_hue / 360;
// r,g,b colors
double[] tc = new double[3] { hk + (1d / 3d), hk, hk - (1d / 3d) };
double[] colors = new double[3] { 0, 0, 0 };
for (int color = 0; color < colors.Length; color++)
{
if (tc[color] < 0)
tc[color] += 1;
if (tc[color] > 1)
tc[color] -= 1;
if (tc[color] < (1d / 6d))
colors[color] = p + ((q - p) * 6 * tc[color]);
else
if (tc[color] >= (1d / 6d) && tc[color] < (1d / 2d))
colors[color] = q;
else
if (tc[color] >= (1d / 2d) && tc[color] < (2d / 3d))
colors[color] = p + ((q - p) * 6 * (2d / 3d - tc[color]));
else
colors[color] = p;
colors[color] *= 255; // convert to value expected by Color
}
return Color.FromArgb(255, (int)colors[0], (int)colors[1], (int)colors[2]);
}
public bool Equals(HSLColor color)
{
return Hue == color.Hue && Lightness == color.Lightness && Saturation == color.Saturation;
}
public override string ToString()
{
string s = string.Format("HSL({0:f2}, {1:f2}, {2:f2})", Hue, Saturation, Lightness);
return s;
}
}
public static class UIColorUtil
{
public static Rectangle Rect(RectangleF rf)
{
Rectangle r = new Rectangle();
r.X = (int)rf.X;
r.Y = (int)rf.Y;
r.Width = (int)rf.Width;
r.Height = (int)rf.Height;
return r;
}
public static RectangleF Rect(Rectangle r)
{
RectangleF rf = new RectangleF();
rf.X = r.X;
rf.Y = r.Y;
rf.Width = r.Width;
rf.Height = r.Height;
return rf;
}
public static Point Point(PointF pf)
{
return new Point((int)pf.X, (int)pf.Y);
}
public static PointF Center(RectangleF r)
{
PointF center = r.Location;
center.X += r.Width / 2;
center.Y += r.Height / 2;
return center;
}
public static void DrawFrame(Graphics dc, RectangleF r, float cornerRadius, Color color)
{
Pen pen = new Pen(color);
if (cornerRadius <= 0)
{
dc.DrawRectangle(pen, Rect(r));
return;
}
cornerRadius = (float)Math.Min(cornerRadius, Math.Floor(r.Width) - 2);
cornerRadius = (float)Math.Min(cornerRadius, Math.Floor(r.Height) - 2);
GraphicsPath path = new GraphicsPath();
path.AddArc(r.X, r.Y, cornerRadius, cornerRadius, 180, 90);
path.AddArc(r.Right - cornerRadius, r.Y, cornerRadius, cornerRadius, 270, 90);
path.AddArc(r.Right - cornerRadius, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 0, 90);
path.AddArc(r.X, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 90, 90);
path.CloseAllFigures();
dc.DrawPath(pen, path);
}
public static void Draw2ColorBar(Graphics dc, RectangleF r, Orientation orientation, Color c1, Color c2)
{
RectangleF lr1 = r;
float angle = 0;
if (orientation == Orientation.Vertical)
angle = 270;
if (orientation == Orientation.Horizontal)
angle = 0;
if (lr1.Height > 0 && lr1.Width > 0)
{
LinearGradientBrush lb1 = new LinearGradientBrush(lr1, c1, c2, angle, false);
dc.FillRectangle(lb1, lr1);
lb1.Dispose();
}
}
public static void Draw3ColorBar(Graphics dc, RectangleF r, Orientation orientation, Color c1, Color c2, Color c3)
{
// to draw a 3 color bar 2 gradient brushes are needed
// one from c1 - c2 and c2 - c3
RectangleF lr1 = r;
RectangleF lr2 = r;
float angle = 0;
if (orientation == Orientation.Vertical)
{
angle = 270;
lr1.Height = lr1.Height / 2;
lr2.Height = r.Height - lr1.Height;
lr2.Y += lr1.Height;
}
if (orientation == Orientation.Horizontal)
{
angle = 0;
lr1.Width = lr1.Width / 2;
lr2.Width = r.Width - lr1.Width;
lr1.X = lr2.Right;
}
if (lr1.Height > 0 && lr1.Width > 0)
{
LinearGradientBrush lb2 = new LinearGradientBrush(lr2, c1, c2, angle, false);
LinearGradientBrush lb1 = new LinearGradientBrush(lr1, c2, c3, angle, false);
dc.FillRectangle(lb1, lr1);
dc.FillRectangle(lb2, lr2);
lb1.Dispose();
lb2.Dispose();
}
// with some sizes the first pixel in the gradient rectangle shows the opposite color
// this is a workaround for that problem
if (orientation == Orientation.Vertical)
{
Pen pc2 = new Pen(c2, 1);
Pen pc3 = new Pen(c3, 1);
dc.DrawLine(pc3, lr1.Left, lr1.Top, lr1.Right - 1, lr1.Top);
dc.DrawLine(pc2, lr2.Left, lr2.Top, lr2.Right - 1, lr2.Top);
pc2.Dispose();
pc3.Dispose();
}
if (orientation == Orientation.Horizontal)
{
Pen pc1 = new Pen(c1, 1);
Pen pc2 = new Pen(c2, 1);
Pen pc3 = new Pen(c3, 1);
dc.DrawLine(pc1, lr2.Left, lr2.Top, lr2.Left, lr2.Bottom - 1);
dc.DrawLine(pc2, lr2.Right, lr2.Top, lr2.Right, lr2.Bottom - 1);
dc.DrawLine(pc3, lr1.Right, lr1.Top, lr1.Right, lr1.Bottom - 1);
pc1.Dispose();
pc2.Dispose();
pc3.Dispose();
}
}
}
internal class SelectorImages
{
public enum eIndexes
{
Right,
Left,
Up,
Down,
Donut,
}
private static ImageList m_imageList;
public static ImageList ImageList()
{
Type t = typeof(SelectorImages);
if (m_imageList == null)
m_imageList = ImageEx.GetToolbarImageList(t, Properties.Resources.colorbarIndicators, new Size(12, 12), Color.Magenta);
return m_imageList;
}
public static Image Image(eIndexes index)
{
return ImageList().Images[(int)index];
}
}
}

View File

@ -0,0 +1,231 @@
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Sunny.UI
{
[ToolboxItem(false)]
public class LabelRotate : Control, IStyleInterface
{
private float m_textAngle = 0;
private ContentAlignment m_rotatePointAlignment = ContentAlignment.MiddleCenter;
private ContentAlignment m_textAlignment = ContentAlignment.MiddleLeft;
public new string Text
{
get { return base.Text; }
set
{
base.Text = value;
Refresh();
}
}
public float TextAngle
{
get { return m_textAngle; }
set
{
m_textAngle = value;
Invalidate();
}
}
public ContentAlignment TextAlign
{
get { return m_textAlignment; }
set
{
m_textAlignment = value;
Invalidate();
}
}
public ContentAlignment RotatePointAlignment
{
get { return m_rotatePointAlignment; }
set
{
m_rotatePointAlignment = value;
Invalidate();
}
}
private Color m_frameColor = UIColor.Blue;
public Color FrameColor
{
get => m_frameColor;
set
{
m_frameColor = value;
Invalidate();
}
}
public LabelRotate()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.Text = string.Empty;
base.DoubleBuffered = true;
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
Version = UIGlobal.Version;
}
protected override void OnPaint(PaintEventArgs e)
{
using (SolidBrush b = new SolidBrush(BackColor))
{
e.Graphics.FillRectangle(b, ClientRectangle);
}
RectangleF lr = ClientRectangleF;
UIColorUtil.DrawFrame(e.Graphics, lr, 6, m_frameColor);
if (Text.Length > 0)
{
StringFormat format = new StringFormat();
string alignment = TextAlign.ToString();
if (((int)TextAlign & (int)(ContentAlignment.BottomLeft | ContentAlignment.MiddleLeft | ContentAlignment.TopLeft)) != 0)
format.Alignment = StringAlignment.Near;
if (((int)TextAlign & (int)(ContentAlignment.BottomCenter | ContentAlignment.MiddleCenter | ContentAlignment.TopCenter)) != 0)
format.Alignment = StringAlignment.Center;
if (((int)TextAlign & (int)(ContentAlignment.BottomRight | ContentAlignment.MiddleRight | ContentAlignment.TopRight)) != 0)
format.Alignment = StringAlignment.Far;
if (((int)TextAlign & (int)(ContentAlignment.BottomLeft | ContentAlignment.BottomCenter | ContentAlignment.BottomRight)) != 0)
format.LineAlignment = StringAlignment.Far;
if (((int)TextAlign & (int)(ContentAlignment.MiddleLeft | ContentAlignment.MiddleCenter | ContentAlignment.MiddleRight)) != 0)
format.LineAlignment = StringAlignment.Center;
if (((int)TextAlign & (int)(ContentAlignment.TopLeft | ContentAlignment.TopCenter | ContentAlignment.TopRight)) != 0)
format.LineAlignment = StringAlignment.Near;
Rectangle r = ClientRectangle;
r.X += Padding.Left;
r.Y += Padding.Top;
r.Width -= Padding.Right;
r.Height -= Padding.Bottom;
using (SolidBrush b = new SolidBrush(ForeColor))
{
if (TextAngle == 0)
{
e.Graphics.DrawString(Text, Font, b, r, format);
}
else
{
PointF center = UIColorUtil.Center(ClientRectangle);
switch (RotatePointAlignment)
{
case ContentAlignment.TopLeft:
center.X = r.Left;
center.Y = r.Top;
break;
case ContentAlignment.TopCenter:
center.Y = r.Top;
break;
case ContentAlignment.TopRight:
center.X = r.Right;
center.Y = r.Top;
break;
case ContentAlignment.MiddleLeft:
center.X = r.Left;
break;
case ContentAlignment.MiddleCenter:
break;
case ContentAlignment.MiddleRight:
center.X = r.Right;
break;
case ContentAlignment.BottomLeft:
center.X = r.Left;
center.Y = r.Bottom;
break;
case ContentAlignment.BottomCenter:
center.Y = r.Bottom;
break;
case ContentAlignment.BottomRight:
center.X = r.Right;
center.Y = r.Bottom;
break;
}
center.X += Padding.Left;
center.Y += Padding.Top;
center.X -= Padding.Right;
center.Y -= Padding.Bottom;
e.Graphics.TranslateTransform(center.X, center.Y);
e.Graphics.RotateTransform(TextAngle);
e.Graphics.DrawString(Text, Font, b, new PointF(0, 0), format);
e.Graphics.ResetTransform();
}
}
}
RaisePaintEvent(this, e);
}
protected RectangleF ClientRectangleF
{
get
{
RectangleF r = ClientRectangle;
r.Width -= 1;
r.Height -= 1;
return r;
}
}
private UIStyle _style = UIStyle.Blue;
/// <summary>
/// Ö÷ÌâÑùʽ
/// </summary>
[DefaultValue(UIStyle.Blue)]
public UIStyle Style
{
get => _style;
set => SetStyle(value);
}
/// <summary>
/// ÉèÖÃÖ÷ÌâÑùʽ
/// </summary>
/// <param name="style">Ö÷ÌâÑùʽ</param>
public void SetStyle(UIStyle style)
{
SetStyleColor(UIStyles.GetStyleColor(style));
_style = style;
}
/// <summary>
/// ÉèÖÃÖ÷ÌâÑùʽÑÕÉ«
/// </summary>
/// <param name="uiColor"></param>
public virtual void SetStyleColor(UIBaseStyle uiColor)
{
if (uiColor.IsCustom()) return;
FrameColor = uiColor.RectColor;
ForeColor = uiColor.PanelForeColor;
Invalidate();
}
public bool StyleCustomMode { get; set; }
public string Version { get; }
public string TagString { get; set; }
}
}

View File

@ -0,0 +1,599 @@
using System;
using System.Drawing;
namespace Sunny.UI
{
public sealed class UIColorItem : UIDropDownItem
{
public UIColorItem()
{
InitializeComponent();
}
private LabelRotate m_colorSample;
private UITextBox edtA;
private UITextBox edtR;
private UITextBox edtG;
private UITextBox edtB;
private UILabel lblA;
private UILabel lblR;
private UILabel lblG;
private UILabel lblB;
private UIColorWheel m_colorWheel;
private HSLColorSlider m_colorBar;
private ColorSlider m_opacitySlider;
private UISymbolButton btnOK;
private UISymbolButton btnCancel;
private UIColorTable m_colorTable;
private void InitializeComponent()
{
this.m_colorTable = new Sunny.UI.UIColorTable();
this.m_colorSample = new Sunny.UI.LabelRotate();
this.edtA = new Sunny.UI.UITextBox();
this.edtR = new Sunny.UI.UITextBox();
this.edtG = new Sunny.UI.UITextBox();
this.edtB = new Sunny.UI.UITextBox();
this.lblA = new Sunny.UI.UILabel();
this.lblR = new Sunny.UI.UILabel();
this.lblG = new Sunny.UI.UILabel();
this.lblB = new Sunny.UI.UILabel();
this.m_colorWheel = new Sunny.UI.UIColorWheel();
this.m_colorBar = new Sunny.UI.HSLColorSlider();
this.m_opacitySlider = new Sunny.UI.ColorSlider();
this.btnOK = new Sunny.UI.UISymbolButton();
this.btnCancel = new Sunny.UI.UISymbolButton();
this.SuspendLayout();
//
// m_colorTable
//
this.m_colorTable.BackColor = System.Drawing.Color.Transparent;
this.m_colorTable.Colors = new System.Drawing.Color[] {
System.Drawing.Color.Black,
System.Drawing.Color.DarkGreen,
System.Drawing.Color.DarkSlateGray,
System.Drawing.Color.Purple,
System.Drawing.Color.Maroon,
System.Drawing.Color.Teal,
System.Drawing.Color.Green,
System.Drawing.Color.Olive,
System.Drawing.Color.Navy,
System.Drawing.Color.Indigo,
System.Drawing.Color.MidnightBlue,
System.Drawing.Color.DarkRed,
System.Drawing.Color.DarkMagenta,
System.Drawing.Color.DarkBlue,
System.Drawing.Color.DarkCyan,
System.Drawing.Color.DarkOliveGreen,
System.Drawing.Color.SaddleBrown,
System.Drawing.Color.ForestGreen,
System.Drawing.Color.OliveDrab,
System.Drawing.Color.SeaGreen,
System.Drawing.Color.DarkGoldenrod,
System.Drawing.Color.DarkSlateBlue,
System.Drawing.Color.MediumBlue,
System.Drawing.Color.Sienna,
System.Drawing.Color.Brown,
System.Drawing.Color.DarkTurquoise,
System.Drawing.Color.DimGray,
System.Drawing.Color.LightSeaGreen,
System.Drawing.Color.DarkViolet,
System.Drawing.Color.Firebrick,
System.Drawing.Color.MediumVioletRed,
System.Drawing.Color.MediumSeaGreen,
System.Drawing.Color.Crimson,
System.Drawing.Color.Chocolate,
System.Drawing.Color.MediumSpringGreen,
System.Drawing.Color.Goldenrod,
System.Drawing.Color.SteelBlue,
System.Drawing.Color.LawnGreen,
System.Drawing.Color.DarkOrchid,
System.Drawing.Color.Orange,
System.Drawing.Color.LimeGreen,
System.Drawing.Color.Yellow,
System.Drawing.Color.Gold,
System.Drawing.Color.Red,
System.Drawing.Color.Magenta,
System.Drawing.Color.Lime,
System.Drawing.Color.SpringGreen,
System.Drawing.Color.YellowGreen,
System.Drawing.Color.Chartreuse,
System.Drawing.Color.DeepSkyBlue,
System.Drawing.Color.Aqua,
System.Drawing.Color.OrangeRed,
System.Drawing.Color.Blue,
System.Drawing.Color.DarkOrange,
System.Drawing.Color.CadetBlue,
System.Drawing.Color.Cyan,
System.Drawing.Color.Fuchsia,
System.Drawing.Color.Gray,
System.Drawing.Color.SlateGray,
System.Drawing.Color.Peru,
System.Drawing.Color.BlueViolet,
System.Drawing.Color.LightSlateGray,
System.Drawing.Color.DeepPink,
System.Drawing.Color.MediumTurquoise,
System.Drawing.Color.DodgerBlue,
System.Drawing.Color.Turquoise,
System.Drawing.Color.RoyalBlue,
System.Drawing.Color.SlateBlue,
System.Drawing.Color.MediumOrchid,
System.Drawing.Color.DarkKhaki,
System.Drawing.Color.IndianRed,
System.Drawing.Color.GreenYellow,
System.Drawing.Color.MediumAquamarine,
System.Drawing.Color.Tomato,
System.Drawing.Color.DarkSeaGreen,
System.Drawing.Color.Orchid,
System.Drawing.Color.RosyBrown,
System.Drawing.Color.PaleVioletRed,
System.Drawing.Color.MediumPurple,
System.Drawing.Color.Coral,
System.Drawing.Color.CornflowerBlue,
System.Drawing.Color.DarkGray,
System.Drawing.Color.SandyBrown,
System.Drawing.Color.MediumSlateBlue,
System.Drawing.Color.Tan,
System.Drawing.Color.DarkSalmon,
System.Drawing.Color.BurlyWood,
System.Drawing.Color.HotPink,
System.Drawing.Color.Salmon,
System.Drawing.Color.Violet,
System.Drawing.Color.LightCoral,
System.Drawing.Color.SkyBlue,
System.Drawing.Color.LightSalmon,
System.Drawing.Color.Khaki,
System.Drawing.Color.Plum,
System.Drawing.Color.LightGreen,
System.Drawing.Color.Aquamarine,
System.Drawing.Color.Silver,
System.Drawing.Color.LightSkyBlue,
System.Drawing.Color.LightSteelBlue,
System.Drawing.Color.LightBlue,
System.Drawing.Color.PaleGreen,
System.Drawing.Color.PowderBlue,
System.Drawing.Color.Thistle,
System.Drawing.Color.PaleGoldenrod,
System.Drawing.Color.PaleTurquoise,
System.Drawing.Color.LightGray,
System.Drawing.Color.Wheat,
System.Drawing.Color.NavajoWhite,
System.Drawing.Color.Moccasin,
System.Drawing.Color.LightPink,
System.Drawing.Color.PeachPuff,
System.Drawing.Color.Gainsboro,
System.Drawing.Color.Pink,
System.Drawing.Color.Bisque,
System.Drawing.Color.LightGoldenrodYellow,
System.Drawing.Color.LemonChiffon,
System.Drawing.Color.BlanchedAlmond,
System.Drawing.Color.Beige,
System.Drawing.Color.AntiqueWhite,
System.Drawing.Color.PapayaWhip,
System.Drawing.Color.Cornsilk,
System.Drawing.Color.LightYellow,
System.Drawing.Color.LightCyan,
System.Drawing.Color.Lavender,
System.Drawing.Color.Linen,
System.Drawing.Color.MistyRose,
System.Drawing.Color.OldLace,
System.Drawing.Color.WhiteSmoke,
System.Drawing.Color.SeaShell,
System.Drawing.Color.Azure,
System.Drawing.Color.Honeydew,
System.Drawing.Color.Ivory,
System.Drawing.Color.LavenderBlush,
System.Drawing.Color.FloralWhite,
System.Drawing.Color.AliceBlue,
System.Drawing.Color.MintCream,
System.Drawing.Color.GhostWhite,
System.Drawing.Color.Snow,
System.Drawing.Color.White};
this.m_colorTable.Cols = 16;
this.m_colorTable.FieldSize = new System.Drawing.Size(12, 12);
this.m_colorTable.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_colorTable.Location = new System.Drawing.Point(10, 8);
this.m_colorTable.Name = "m_colorTable";
this.m_colorTable.Padding = new System.Windows.Forms.Padding(8);
this.m_colorTable.RotatePointAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.m_colorTable.SelectedItem = System.Drawing.Color.Black;
this.m_colorTable.Size = new System.Drawing.Size(253, 148);
this.m_colorTable.Style = Sunny.UI.UIStyle.Custom;
this.m_colorTable.StyleCustomMode = false;
this.m_colorTable.TabIndex = 0;
this.m_colorTable.TagString = null;
this.m_colorTable.Text = "colorTable1";
this.m_colorTable.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.m_colorTable.TextAngle = 0F;
this.m_colorTable.SelectedIndexChanged += new System.EventHandler(this.m_colorTable_SelectedIndexChanged);
//
// m_colorSample
//
this.m_colorSample.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_colorSample.Location = new System.Drawing.Point(10, 163);
this.m_colorSample.Name = "m_colorSample";
this.m_colorSample.RotatePointAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.m_colorSample.Size = new System.Drawing.Size(253, 26);
this.m_colorSample.Style = Sunny.UI.UIStyle.Custom;
this.m_colorSample.StyleCustomMode = false;
this.m_colorSample.TabIndex = 1;
this.m_colorSample.TabStop = false;
this.m_colorSample.TagString = null;
this.m_colorSample.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.m_colorSample.TextAngle = 0F;
this.m_colorSample.Paint += new System.Windows.Forms.PaintEventHandler(this.m_colorSample_Paint);
//
// edtA
//
this.edtA.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtA.FillColor = System.Drawing.Color.White;
this.edtA.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.edtA.HasMaximum = true;
this.edtA.HasMinimum = true;
this.edtA.Location = new System.Drawing.Point(29, 197);
this.edtA.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtA.Maximum = 255D;
this.edtA.Minimum = 0D;
this.edtA.Name = "edtA";
this.edtA.Padding = new System.Windows.Forms.Padding(5);
this.edtA.Size = new System.Drawing.Size(41, 26);
this.edtA.Style = Sunny.UI.UIStyle.Custom;
this.edtA.TabIndex = 2;
this.edtA.Text = "0";
this.edtA.Type = Sunny.UI.UITextBox.UIEditType.Integer;
//
// edtR
//
this.edtR.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtR.FillColor = System.Drawing.Color.White;
this.edtR.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.edtR.HasMaximum = true;
this.edtR.HasMinimum = true;
this.edtR.Location = new System.Drawing.Point(93, 197);
this.edtR.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtR.Maximum = 255D;
this.edtR.Minimum = 0D;
this.edtR.Name = "edtR";
this.edtR.Padding = new System.Windows.Forms.Padding(5);
this.edtR.Size = new System.Drawing.Size(41, 26);
this.edtR.Style = Sunny.UI.UIStyle.Custom;
this.edtR.TabIndex = 3;
this.edtR.Text = "0";
this.edtR.Type = Sunny.UI.UITextBox.UIEditType.Integer;
//
// edtG
//
this.edtG.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtG.FillColor = System.Drawing.Color.White;
this.edtG.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.edtG.HasMaximum = true;
this.edtG.HasMinimum = true;
this.edtG.Location = new System.Drawing.Point(158, 197);
this.edtG.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtG.Maximum = 255D;
this.edtG.Minimum = 0D;
this.edtG.Name = "edtG";
this.edtG.Padding = new System.Windows.Forms.Padding(5);
this.edtG.Size = new System.Drawing.Size(41, 26);
this.edtG.Style = Sunny.UI.UIStyle.Custom;
this.edtG.TabIndex = 4;
this.edtG.Text = "0";
this.edtG.Type = Sunny.UI.UITextBox.UIEditType.Integer;
//
// edtB
//
this.edtB.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtB.FillColor = System.Drawing.Color.White;
this.edtB.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.edtB.HasMaximum = true;
this.edtB.HasMinimum = true;
this.edtB.Location = new System.Drawing.Point(222, 197);
this.edtB.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtB.Maximum = 255D;
this.edtB.Minimum = 0D;
this.edtB.Name = "edtB";
this.edtB.Padding = new System.Windows.Forms.Padding(5);
this.edtB.Size = new System.Drawing.Size(41, 26);
this.edtB.Style = Sunny.UI.UIStyle.Custom;
this.edtB.TabIndex = 5;
this.edtB.Text = "0";
this.edtB.Type = Sunny.UI.UITextBox.UIEditType.Integer;
//
// lblA
//
this.lblA.AutoSize = true;
this.lblA.BackColor = System.Drawing.Color.Transparent;
this.lblA.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblA.Location = new System.Drawing.Point(9, 200);
this.lblA.Name = "lblA";
this.lblA.Size = new System.Drawing.Size(19, 20);
this.lblA.Style = Sunny.UI.UIStyle.Custom;
this.lblA.TabIndex = 6;
this.lblA.Text = "A";
this.lblA.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblR
//
this.lblR.AutoSize = true;
this.lblR.BackColor = System.Drawing.Color.Transparent;
this.lblR.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblR.Location = new System.Drawing.Point(74, 200);
this.lblR.Name = "lblR";
this.lblR.Size = new System.Drawing.Size(18, 20);
this.lblR.Style = Sunny.UI.UIStyle.Custom;
this.lblR.TabIndex = 7;
this.lblR.Text = "R";
this.lblR.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblG
//
this.lblG.AutoSize = true;
this.lblG.BackColor = System.Drawing.Color.Transparent;
this.lblG.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblG.Location = new System.Drawing.Point(138, 200);
this.lblG.Name = "lblG";
this.lblG.Size = new System.Drawing.Size(19, 20);
this.lblG.Style = Sunny.UI.UIStyle.Custom;
this.lblG.TabIndex = 8;
this.lblG.Text = "G";
this.lblG.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblB
//
this.lblB.AutoSize = true;
this.lblB.BackColor = System.Drawing.Color.Transparent;
this.lblB.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblB.Location = new System.Drawing.Point(203, 200);
this.lblB.Name = "lblB";
this.lblB.Size = new System.Drawing.Size(18, 20);
this.lblB.Style = Sunny.UI.UIStyle.Custom;
this.lblB.TabIndex = 9;
this.lblB.Text = "B";
this.lblB.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// m_colorWheel
//
this.m_colorWheel.BackColor = System.Drawing.Color.Transparent;
this.m_colorWheel.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_colorWheel.Location = new System.Drawing.Point(269, 8);
this.m_colorWheel.Name = "m_colorWheel";
this.m_colorWheel.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(254)))), ((int)(((byte)(235)))), ((int)(((byte)(205)))));
this.m_colorWheel.Size = new System.Drawing.Size(148, 148);
this.m_colorWheel.Style = Sunny.UI.UIStyle.Custom;
this.m_colorWheel.StyleCustomMode = false;
this.m_colorWheel.TabIndex = 10;
this.m_colorWheel.TagString = null;
this.m_colorWheel.Text = "colorWheel1";
this.m_colorWheel.SelectedColorChanged += new System.EventHandler(this.m_colorWheel_SelectedColorChanged);
//
// m_colorBar
//
this.m_colorBar.BackColor = System.Drawing.Color.Transparent;
this.m_colorBar.BarPadding = new System.Windows.Forms.Padding(12, 5, 32, 10);
this.m_colorBar.Color1 = System.Drawing.Color.Black;
this.m_colorBar.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(127)))), ((int)(((byte)(127)))));
this.m_colorBar.Color3 = System.Drawing.Color.White;
this.m_colorBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.m_colorBar.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_colorBar.Location = new System.Drawing.Point(422, 8);
this.m_colorBar.Name = "m_colorBar";
this.m_colorBar.NumberOfColors = Sunny.UI.ColorSlider.eNumberOfColors.Use3Colors;
this.m_colorBar.Orientation = System.Windows.Forms.Orientation.Vertical;
this.m_colorBar.Padding = new System.Windows.Forms.Padding(0, 0, 1, 0);
this.m_colorBar.Percent = 0F;
this.m_colorBar.RotatePointAlignment = System.Drawing.ContentAlignment.MiddleRight;
this.m_colorBar.Size = new System.Drawing.Size(45, 148);
this.m_colorBar.Style = Sunny.UI.UIStyle.Custom;
this.m_colorBar.StyleCustomMode = false;
this.m_colorBar.TabIndex = 11;
this.m_colorBar.TagString = null;
this.m_colorBar.Text = "Lightness";
this.m_colorBar.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.m_colorBar.TextAngle = 270F;
this.m_colorBar.ValueOrientation = Sunny.UI.ColorSlider.eValueOrientation.MaxToMin;
this.m_colorBar.SelectedValueChanged += new System.EventHandler(this.m_colorBar_SelectedValueChanged);
//
// m_opacitySlider
//
this.m_opacitySlider.BackColor = System.Drawing.Color.Transparent;
this.m_opacitySlider.BarPadding = new System.Windows.Forms.Padding(60, 12, 80, 25);
this.m_opacitySlider.Color1 = System.Drawing.Color.White;
this.m_opacitySlider.Color2 = System.Drawing.Color.Black;
this.m_opacitySlider.Color3 = System.Drawing.Color.Black;
this.m_opacitySlider.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.m_opacitySlider.ForeColor = System.Drawing.Color.Black;
this.m_opacitySlider.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_opacitySlider.Location = new System.Drawing.Point(269, 163);
this.m_opacitySlider.Name = "m_opacitySlider";
this.m_opacitySlider.NumberOfColors = Sunny.UI.ColorSlider.eNumberOfColors.Use2Colors;
this.m_opacitySlider.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.m_opacitySlider.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0);
this.m_opacitySlider.Percent = 1F;
this.m_opacitySlider.RotatePointAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.m_opacitySlider.Size = new System.Drawing.Size(198, 26);
this.m_opacitySlider.Style = Sunny.UI.UIStyle.Custom;
this.m_opacitySlider.StyleCustomMode = false;
this.m_opacitySlider.TabIndex = 1;
this.m_opacitySlider.TagString = null;
this.m_opacitySlider.Text = "Opacity";
this.m_opacitySlider.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.m_opacitySlider.TextAngle = 0F;
this.m_opacitySlider.ValueOrientation = Sunny.UI.ColorSlider.eValueOrientation.MinToMax;
this.m_opacitySlider.SelectedValueChanged += new System.EventHandler(this.m_opacitySlider_SelectedValueChanged);
//
// btnOK
//
this.btnOK.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnOK.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btnOK.Location = new System.Drawing.Point(269, 197);
this.btnOK.Name = "btnOK";
this.btnOK.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
this.btnOK.Size = new System.Drawing.Size(95, 26);
this.btnOK.Style = Sunny.UI.UIStyle.Custom;
this.btnOK.TabIndex = 12;
this.btnOK.Text = "确定";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnCancel.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btnCancel.Location = new System.Drawing.Point(372, 197);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
this.btnCancel.Size = new System.Drawing.Size(95, 26);
this.btnCancel.Style = Sunny.UI.UIStyle.Custom;
this.btnCancel.Symbol = 61453;
this.btnCancel.TabIndex = 13;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// UIColorItem
//
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.m_opacitySlider);
this.Controls.Add(this.m_colorBar);
this.Controls.Add(this.m_colorWheel);
this.Controls.Add(this.lblB);
this.Controls.Add(this.lblG);
this.Controls.Add(this.lblR);
this.Controls.Add(this.lblA);
this.Controls.Add(this.edtB);
this.Controls.Add(this.edtG);
this.Controls.Add(this.edtR);
this.Controls.Add(this.edtA);
this.Controls.Add(this.m_colorSample);
this.Controls.Add(this.m_colorTable);
this.FillColor = System.Drawing.Color.White;
this.Name = "UIColorItem";
this.Size = new System.Drawing.Size(476, 233);
this.Style = Sunny.UI.UIStyle.Custom;
this.ResumeLayout(false);
this.PerformLayout();
}
private void m_colorTable_SelectedIndexChanged(object sender, EventArgs e)
{
Color selcol = (Color)m_colorTable.SelectedItem;
if (selcol != m_selectedColor)
{
lockColorTable = true;
m_colorWheel.SelectedColor = selcol;
lockColorTable = false;
m_colorSample.Invalidate();
}
}
private Color m_selectedColor = Color.AntiqueWhite;
private float m_opacity = 1;
private bool lockColorTable = false;
public Color SelectedColor
{
get { return Color.FromArgb((int)Math.Floor(255f * m_opacity), m_selectedColor); }
set
{
m_opacity = (float)value.A / 255f;
value = Color.FromArgb(255, value);
m_colorWheel.SelectedColor = value;
if (m_colorTable.ColorExist(value) == false)
m_colorTable.SetCustomColor(value);
m_colorTable.SelectedItem = value;
m_opacitySlider.Percent = m_opacity;
}
}
private void m_colorBar_SelectedValueChanged(object sender, EventArgs e)
{
m_colorWheel.SetLightness(m_colorBar.SelectedHSLColor.Lightness);
}
private void m_opacitySlider_SelectedValueChanged(object sender, EventArgs e)
{
m_opacity = Math.Max(0, m_opacitySlider.Percent);
m_opacity = Math.Min(1, m_opacitySlider.Percent);
m_colorSample.Refresh();
UpdateInfo();
}
private void UpdateInfo()
{
Color c = Color.FromArgb((int)Math.Floor(255f * m_opacity), m_selectedColor);
string info = string.Format("{0} aRGB({1}, {2}, {3}, {4})", m_colorWheel.SelectedHSLColor.ToString(), c.A, c.R, c.G, c.B);
edtA.IntValue = c.A;
edtR.IntValue = c.R;
edtG.IntValue = c.G;
edtB.IntValue = c.B;
//m_infoLabel.Text = info;
}
private void m_colorWheel_SelectedColorChanged(object sender, EventArgs e)
{
Color selcol = m_colorWheel.SelectedColor;
if (selcol != m_selectedColor)
{
m_selectedColor = selcol;
m_colorSample.Refresh();
if (lockColorTable == false && selcol != m_colorTable.SelectedItem)
m_colorTable.SetCustomColor(selcol);
}
m_colorBar.SelectedHSLColor = m_colorWheel.SelectedHSLColor;
UpdateInfo();
}
private void btnCancel_Click(object sender, EventArgs e)
{
CloseParent();
}
private void btnOK_Click(object sender, EventArgs e)
{
DoValueChanged(this, SelectedColor);
CloseParent();
}
private void m_colorSample_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Rectangle r = m_colorSample.ClientRectangle;
r.Inflate(-4, -4);
int width = r.Width;
r.Width /= 2;
Color c = Color.FromArgb((int)Math.Floor(255f * m_opacity), m_selectedColor);
SolidBrush b = new SolidBrush(c);
e.Graphics.FillRectangle(b, r);
r.X += r.Width;
e.Graphics.FillRectangle(Brushes.White, r);
c = Color.FromArgb(255, m_selectedColor);
b = new SolidBrush(c);
e.Graphics.FillRectangle(b, r);
}
public override void SetStyle(UIBaseStyle uiColor)
{
base.SetStyleColor(uiColor);
RectColor = uiColor.RectColor;
BackColor = uiColor.PlainColor;
btnOK.SetStyleColor(uiColor);
btnCancel.SetStyleColor(uiColor);
m_colorTable.SetStyleColor(uiColor);
m_colorWheel.SetStyleColor(uiColor);
m_colorBar.SetStyleColor(uiColor);
m_colorSample.SetStyleColor(uiColor);
m_opacitySlider.SetStyleColor(uiColor);
edtA.SetStyleColor(uiColor);
edtR.SetStyleColor(uiColor);
edtG.SetStyleColor(uiColor);
edtB.SetStyleColor(uiColor);
lblA.ForeColor = lblR.ForeColor = lblG.ForeColor = lblB.ForeColor = uiColor.PanelForeColor;
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -297,7 +297,7 @@ namespace Sunny.UI
ItemForm.SetRectColor(rectColor); ItemForm.SetRectColor(rectColor);
ItemForm.SetFillColor(fillColor); ItemForm.SetFillColor(fillColor);
ItemForm.SetForeColor(foreColor); ItemForm.SetForeColor(foreColor);
ItemForm.SetStyle(UIStyles.GetStyleColor(UIStyles.Style)); ItemForm.SetStyle(UIStyles.ActiveStyleColor);
} }
ButtonClick?.Invoke(this, e); ButtonClick?.Invoke(this, e);

View File

@ -52,6 +52,19 @@ namespace Sunny.UI
fillPressColor = UIStyles.Blue.ButtonFillPressColor; fillPressColor = UIStyles.Blue.ButtonFillPressColor;
} }
private bool isClick;
public void PerformClick()
{
if (isClick) return;
if (CanSelect && Enabled)
{
isClick = true;
OnClick(EventArgs.Empty);
isClick = false;
}
}
private bool showTips = false; private bool showTips = false;
[Description("是否显示角标"), Category("自定义")] [Description("是否显示角标"), Category("自定义")]

View File

@ -0,0 +1,106 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2020 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@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.
* 使
******************************************************************************
* : UIDatePicker.cs
* :
* : V2.2
* : 2020-05-29
*
* 2020-05-31: V2.2.5
******************************************************************************
* : Color picker with color wheel and eye dropper
* : Color picker with color wheel and eye dropper
* : jkristia
* : CPOL
* : https://www.codeproject.com/Articles/21965/Color-Picker-with-Color-Wheel-and-Eye-Dropper
******************************************************************************/
using System;
using System.ComponentModel;
using System.Drawing;
namespace Sunny.UI
{
[ToolboxItem(true)]
public sealed class UIColorPicker : UIDropControl
{
private void InitializeComponent()
{
this.SuspendLayout();
//
// UIColorPicker
//
this.DropDownStyle = UIDropDownStyle.DropDownList;
this.Name = "UIColorPicker";
this.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0);
this.ButtonClick += new System.EventHandler(this.UIColorPicker_ButtonClick);
this.PaintOther += new System.Windows.Forms.PaintEventHandler(this.UIColorPicker_PaintOther);
this.ResumeLayout(false);
this.PerformLayout();
}
public delegate void OnColorChanged(object sender, Color value);
public event OnColorChanged ValueChanged;
public UIColorPicker()
{
InitializeComponent();
ShowText = false;
Value = UIColor.Blue;
}
private void UIColorPicker_ButtonClick(object sender, EventArgs e)
{
item.SelectedColor = Value;
ItemForm.Show(this);
}
protected override void ItemForm_ValueChanged(object sender, object value)
{
Value = (Color)value;
Invalidate();
ValueChanged?.Invoke(this, Value);
}
private readonly UIColorItem item = new UIColorItem();
protected override void CreateInstance()
{
ItemForm = new UIDropDown(item);
}
private Color selectColor;
public Color Value
{
get => selectColor;
set
{
selectColor = value;
item.SelectedColor = value;
Invalidate();
}
}
private void UIColorPicker_PaintOther(object sender, System.Windows.Forms.PaintEventArgs e)
{
var pathColor = e.Graphics.CreateRoundedRectanglePath(new Rectangle(3, 3, Width - 32, Height - 7), 5,
UICornerRadiusSides.All);
e.Graphics.FillPath(Value, pathColor);
if (DropDownStyle != UIDropDownStyle.DropDownList)
DropDownStyle = UIDropDownStyle.DropDownList;
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -21,7 +21,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
@ -46,7 +45,7 @@ namespace Sunny.UI
ValueChanged?.Invoke(this, Value); ValueChanged?.Invoke(this, Value);
} }
private readonly UIDateTimeItem item = new UIDateTimeItem(); private readonly UIDateItem item = new UIDateItem();
protected override void CreateInstance() protected override void CreateInstance()
{ {

View File

@ -458,28 +458,8 @@ namespace Sunny.UI
/// </summary> /// </summary>
private Point location; private Point location;
/// <summary>
/// 获取当前鼠标活动区域所属的监视器
/// </summary>
/// <returns>Screen</returns>
private int GetMouseInScreen(Point mPnt)
{
int screenIndex = 0;
for (int i = 0; i < Screen.AllScreens.Length; i++)
{
if (mPnt.InRect(Screen.AllScreens[i].Bounds))
{
screenIndex = i;
break;
}
}
return screenIndex;
}
private void ShowMaximize(bool IsOnMoving = false) private void ShowMaximize(bool IsOnMoving = false)
{ {
//int screenIndex = GetMouseInScreen(MousePosition);
Screen screen = Screen.FromPoint(MousePosition); Screen screen = Screen.FromPoint(MousePosition);
if (windowState == FormWindowState.Normal) if (windowState == FormWindowState.Normal)
{ {
@ -613,9 +593,7 @@ namespace Sunny.UI
protected override void OnMouseMove(MouseEventArgs e) protected override void OnMouseMove(MouseEventArgs e)
{ {
Point pt = MousePosition; if (FormMoveMouseDown && !MousePosition.Equals(mouseOffset))
if (FormMoveMouseDown && !pt.Equals(mouseOffset))
{ {
if (this.windowState == FormWindowState.Maximized) if (this.windowState == FormWindowState.Maximized)
{ {
@ -627,8 +605,8 @@ namespace Sunny.UI
mouseOffset.X -= (int)((mouseOffset.X - LocationX) * offsetXRatio); mouseOffset.X -= (int)((mouseOffset.X - LocationX) * offsetXRatio);
} }
int offsetX = mouseOffset.X - pt.X; int offsetX = mouseOffset.X - MousePosition.X;
int offsetY = mouseOffset.Y - pt.Y; int offsetY = mouseOffset.Y - MousePosition.Y;
Rectangle WorkingArea = Screen.GetWorkingArea(this); Rectangle WorkingArea = Screen.GetWorkingArea(this);
// 若当前鼠标停留在容器上边缘将会触发一个时间为MaximumBorderInterval(ms)的边缘等待, // 若当前鼠标停留在容器上边缘将会触发一个时间为MaximumBorderInterval(ms)的边缘等待,
@ -731,7 +709,6 @@ namespace Sunny.UI
if (ShowRect) if (ShowRect)
{ {
Point[] points; Point[] points;
bool unShowRadius = !ShowRadius || windowState == FormWindowState.Maximized || bool unShowRadius = !ShowRadius || windowState == FormWindowState.Maximized ||
(Width == Screen.PrimaryScreen.WorkingArea.Width && (Width == Screen.PrimaryScreen.WorkingArea.Width &&
Height == Screen.PrimaryScreen.WorkingArea.Height); Height == Screen.PrimaryScreen.WorkingArea.Height);
@ -1033,7 +1010,7 @@ namespace Sunny.UI
{ {
if (ctrl != null && !ctrl.IsDisposed) if (ctrl != null && !ctrl.IsDisposed)
{ {
ctrl.MouseDown += ctrlMouseDown; ctrl.MouseDown += CtrlMouseDown;
} }
} }
} }
@ -1043,7 +1020,7 @@ namespace Sunny.UI
/// </summary> /// </summary>
/// <param name="sender">The source of the event.</param> /// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param> /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
private void ctrlMouseDown(object sender, MouseEventArgs e) private void CtrlMouseDown(object sender, MouseEventArgs e)
{ {
if (windowState == FormWindowState.Maximized) if (windowState == FormWindowState.Maximized)
{ {

View File

@ -70,6 +70,16 @@ namespace Sunny.UI.Properties {
} }
} }
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap colorbarIndicators {
get {
object obj = ResourceManager.GetObject("colorbarIndicators", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary> /// </summary>

View File

@ -121,6 +121,9 @@
<data name="close" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="close" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="colorbarIndicators" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\colorbarIndicators.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="gps1" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="gps1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\gps1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\gps1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -25,6 +25,7 @@ using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
@ -39,6 +40,16 @@ namespace Sunny.UI
/// </summary> /// </summary>
public static class ImageEx public static class ImageEx
{ {
public static ImageList GetToolbarImageList(Type type, Bitmap bitmap, Size imageSize, Color transparentColor)
{
ImageList imageList = new ImageList();
imageList.ImageSize = imageSize;
imageList.TransparentColor = transparentColor;
imageList.Images.AddStrip(bitmap);
imageList.ColorDepth = ColorDepth.Depth24Bit;
return imageList;
}
public static Bitmap Split(this Bitmap image, int size, UIShape shape) public static Bitmap Split(this Bitmap image, int size, UIShape shape)
{ {
//截图画板 //截图画板

View File

@ -413,6 +413,11 @@ namespace Sunny.UI
} }
} }
public static UIBaseStyle ActiveStyleColor
{
get => GetStyleColor(Style);
}
private static void AddStyle(UIBaseStyle uiColor) private static void AddStyle(UIBaseStyle uiColor)
{ {
if (Styles.ContainsKey(uiColor.Name)) if (Styles.ContainsKey(uiColor.Name))

View File

@ -51,12 +51,28 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Controls\Color\UIColorBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Color\UIColorTable.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Color\UIColorWheel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Color\UIHSLColor.cs" />
<Compile Include="Controls\Color\UILabelRotate.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\DropItem\UIComboBoxItem.cs"> <Compile Include="Controls\DropItem\UIComboBoxItem.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Controls\DropItem\UIComboBoxItem.Designer.cs"> <Compile Include="Controls\DropItem\UIComboBoxItem.Designer.cs">
<DependentUpon>UIComboBoxItem.cs</DependentUpon> <DependentUpon>UIComboBoxItem.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\DropItem\UIDateItem.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\DropItem\UIDateTimeItem.cs"> <Compile Include="Controls\DropItem\UIDateTimeItem.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
@ -72,6 +88,9 @@
<Compile Include="Controls\DropItem\UITimeItem.cs"> <Compile Include="Controls\DropItem\UITimeItem.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Controls\DropItem\UIColorItem.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\UITimePicker.cs"> <Compile Include="Controls\UITimePicker.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
@ -337,6 +356,9 @@
<Compile Include="Static\UDataReader.cs" /> <Compile Include="Static\UDataReader.cs" />
<Compile Include="Static\UAttribute.cs" /> <Compile Include="Static\UAttribute.cs" />
<Compile Include="Static\USyncTime.cs" /> <Compile Include="Static\USyncTime.cs" />
<Compile Include="Controls\UIColorPicker.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Units\UThunder.cs" /> <Compile Include="Units\UThunder.cs" />
<Compile Include="Controls\UILine.cs"> <Compile Include="Controls\UILine.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
@ -421,9 +443,18 @@
<Compile Include="Units\UXmlConfig.cs" /> <Compile Include="Units\UXmlConfig.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Controls\DropItem\UIColorItem.resx">
<DependentUpon>UIColorItem.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\Color\UIColorTable.resx">
<DependentUpon>UIColorTable.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\DropItem\UIComboBoxItem.resx"> <EmbeddedResource Include="Controls\DropItem\UIComboBoxItem.resx">
<DependentUpon>UIComboBoxItem.cs</DependentUpon> <DependentUpon>UIComboBoxItem.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Controls\DropItem\UIDateItem.resx">
<DependentUpon>UIDateItem.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\DropItem\UIDateTimeItem.resx"> <EmbeddedResource Include="Controls\DropItem\UIDateTimeItem.resx">
<DependentUpon>UIDateTimeItem.cs</DependentUpon> <DependentUpon>UIDateTimeItem.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
@ -522,6 +553,9 @@
<EmbeddedResource Include="Forms\UISelectForm.resx"> <EmbeddedResource Include="Forms\UISelectForm.resx">
<DependentUpon>UISelectForm.cs</DependentUpon> <DependentUpon>UISelectForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Controls\UIColorPicker.resx">
<DependentUpon>UIColorPicker.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Font\FontAwesome.ttf" /> <EmbeddedResource Include="Font\FontAwesome.ttf" />
@ -563,6 +597,9 @@
<ItemGroup> <ItemGroup>
<None Include="Resources\warning.png" /> <None Include="Resources\warning.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Resources\colorbarIndicators.bmp" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,5 +1,8 @@
+ 增加; - 删除; * 修改 + 增加; - 删除; * 修改
2020.05.31
+ UIColorPicker新增
2020.05.30 2020.05.30
* UIForm更新标题移动、双击最大化/正常、到顶最大化、最大化后拖拽正常 * UIForm更新标题移动、双击最大化/正常、到顶最大化、最大化后拖拽正常