* UITitlePanel:增加可收缩选项

This commit is contained in:
Sunny 2020-07-30 20:20:50 +08:00
parent 1401d26d43
commit af641e9e8d
13 changed files with 271 additions and 5 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -68,7 +68,7 @@
this.PieChart.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244)))));
this.PieChart.Font = new System.Drawing.Font("微软雅黑", 12F);
this.PieChart.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(54)))), ((int)(((byte)(54)))));
this.PieChart.LegendFont = new System.Drawing.Font("微软雅黑", 12F);
this.PieChart.LegendFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.PieChart.Location = new System.Drawing.Point(30, 48);
this.PieChart.Name = "PieChart";
this.PieChart.Option = null;

View File

@ -31,11 +31,13 @@
this.uiTitlePanel1 = new Sunny.UI.UITitlePanel();
this.uiPanel1 = new Sunny.UI.UIPanel();
this.uiGroupBox1 = new Sunny.UI.UIGroupBox();
this.uiTitlePanel2 = new Sunny.UI.UITitlePanel();
this.PagePanel.SuspendLayout();
this.SuspendLayout();
//
// PagePanel
//
this.PagePanel.Controls.Add(this.uiTitlePanel2);
this.PagePanel.Controls.Add(this.uiGroupBox1);
this.PagePanel.Controls.Add(this.uiPanel1);
this.PagePanel.Controls.Add(this.uiTitlePanel1);
@ -74,6 +76,19 @@
this.uiGroupBox1.TabIndex = 4;
this.uiGroupBox1.Text = "uiGroupBox1";
//
// uiTitlePanel2
//
this.uiTitlePanel2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiTitlePanel2.ForeColor = System.Drawing.Color.White;
this.uiTitlePanel2.Location = new System.Drawing.Point(331, 230);
this.uiTitlePanel2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiTitlePanel2.Name = "uiTitlePanel2";
this.uiTitlePanel2.Padding = new System.Windows.Forms.Padding(0, 35, 0, 0);
this.uiTitlePanel2.ShowCollapse = true;
this.uiTitlePanel2.Size = new System.Drawing.Size(270, 180);
this.uiTitlePanel2.TabIndex = 5;
this.uiTitlePanel2.Text = "uiTitlePanel2";
//
// FPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
@ -91,5 +106,6 @@
private UITitlePanel uiTitlePanel1;
private UIPanel uiPanel1;
private UIGroupBox uiGroupBox1;
private UITitlePanel uiTitlePanel2;
}
}

View File

@ -201,5 +201,16 @@ namespace Sunny.UI
public delegate Color OnDataColorChangeEventHandler(double data);
public event OnDataColorChangeEventHandler DataColorChange;
public bool HaveCustomColor(int index)
{
return Colors.Count > 0 && index >= 0 && index < Colors.Count;
}
public void Clear()
{
Data.Clear();
Colors.Clear();
}
}
}

View File

@ -60,10 +60,22 @@ namespace Sunny.UI
Data.Add(data);
}
public void AddColor(Color color)
public void AddData(string data, Color color)
{
Data.Add(data);
Colors.Add(color);
}
public bool HaveCustomColor(int index)
{
return Colors.Count > 0 && index >= 0 && index < Colors.Count;
}
public void Clear()
{
Data.Clear();
Colors.Clear();
}
}
public class UIChartGrid

View File

@ -149,7 +149,7 @@ namespace Sunny.UI
public Color Color { get; set; }
public bool StyleCustomMode { get; set; }
public bool StyleCustomMode { get; private set; }
public UIPieSeriesData()
{
@ -159,6 +159,7 @@ namespace Sunny.UI
{
Name = name;
Value = value;
StyleCustomMode = false;
}
public UIPieSeriesData(string name, double value, Color color)

View File

@ -20,6 +20,7 @@
* 2020-04-25: V2.2.4
******************************************************************************/
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
@ -40,15 +41,27 @@ namespace Sunny.UI
{
_titleHeight = value;
Padding = new Padding(0, value, 0, 0);
CalcSystemBoxPos();
Invalidate();
}
}
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
if (e.Control.Top < TitleHeight)
{
e.Control.Top = TitleHeight + 1;
}
}
public UITitlePanel()
{
InitializeComponent();
ShowText = false;
foreColor = Color.White;
CalcSystemBoxPos();
}
public override void SetStyleColor(UIBaseStyle uiColor)
@ -119,6 +132,39 @@ namespace Sunny.UI
g.DrawString(Text, Font, color, Width - _titleInterval - sf.Width, (TitleHeight - sf.Height) / 2.0f);
break;
}
if (ShowCollapse)
{
if (InControlBox)
{
if (ShowRadius)
g.FillRoundRectangle(UIStyles.ActiveStyleColor.ButtonFillHoverColor, ControlBoxRect, 5);
else
g.FillRectangle(UIStyles.ActiveStyleColor.ButtonFillHoverColor, ControlBoxRect);
}
g.DrawFontImage(Collapsed ? 61703 : 61702, 24, color,
new Rectangle(ControlBoxRect.Left + 2, ControlBoxRect.Top, ControlBoxRect.Width, ControlBoxRect.Height));
}
}
private bool InControlBox;
protected override void OnMouseMove(MouseEventArgs e)
{
bool inControlBox = e.Location.InRect(ControlBoxRect);
if (inControlBox != InControlBox)
{
InControlBox = inControlBox;
if (ShowCollapse) Invalidate();
}
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
InControlBox = false;
Invalidate();
}
private int _titleInterval = 10;
@ -163,5 +209,59 @@ namespace Sunny.UI
return graphicsPath;
}
private Rectangle ControlBoxRect;
private void CalcSystemBoxPos()
{
ControlBoxRect = new Rectangle(Width - 6 - 28, TitleHeight / 2 - 14, 28, 28);
}
private bool showCollapse;
[Description("是否打开缩放按钮"), Category("SunnyUI"), DefaultValue(false)]
public bool ShowCollapse
{
get => showCollapse;
set
{
showCollapse = value;
Invalidate();
}
}
private bool collapsed;
private int rowHeight = 180;
[Description("是否缩放"), Category("SunnyUI"), DefaultValue(false)]
public bool Collapsed
{
get => collapsed;
set
{
if (value)
{
rowHeight = Height;
Height = TitleHeight;
}
else
{
Height = rowHeight;
}
collapsed = value;
Invalidate();
}
}
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
if (ShowCollapse && e.Location.InRect(ControlBoxRect))
{
Collapsed = !Collapsed;
}
}
}
}

View File

@ -110,6 +110,7 @@
this.btnCancel.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.btnCancel.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(127)))), ((int)(((byte)(128)))));
this.btnCancel.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(87)))), ((int)(((byte)(89)))));
this.btnCancel.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(87)))), ((int)(((byte)(89)))));
this.btnCancel.Font = new System.Drawing.Font("微软雅黑", 12F);
this.btnCancel.Location = new System.Drawing.Point(533, 326);
this.btnCancel.Name = "btnCancel";
@ -117,9 +118,11 @@
this.btnCancel.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.btnCancel.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(127)))), ((int)(((byte)(128)))));
this.btnCancel.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(87)))), ((int)(((byte)(89)))));
this.btnCancel.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(202)))), ((int)(((byte)(87)))), ((int)(((byte)(89)))));
this.btnCancel.Size = new System.Drawing.Size(86, 29);
this.btnCancel.Style = Sunny.UI.UIStyle.Red;
this.btnCancel.StyleCustomMode = true;
this.btnCancel.Symbol = 61453;
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);

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

@ -496,6 +496,9 @@
<EmbeddedResource Include="Forms\UIForm.resx">
<DependentUpon>UIForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\UILoginForm.resx">
<DependentUpon>UILoginForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\UINotifier.resx">
<DependentUpon>UINotifier.cs</DependentUpon>
</EmbeddedResource>