Commit 5af0f5ab HZH

Add ProcessWave

1 个父辈 a63c38ad
namespace HZH_Controls.Controls
{
partial class UCProcessWave
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ucWave1 = new HZH_Controls.Controls.UCWave();
this.SuspendLayout();
//
// ucWave1
//
this.ucWave1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.ucWave1.Location = new System.Drawing.Point(0, 140);
this.ucWave1.Name = "ucWave1";
this.ucWave1.Size = new System.Drawing.Size(150, 10);
this.ucWave1.TabIndex = 0;
this.ucWave1.Text = "ucWave1";
this.ucWave1.WaveColor = System.Drawing.Color.FromArgb(((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
this.ucWave1.WaveHeight = 15;
this.ucWave1.WaveSleep = 100;
this.ucWave1.WaveWidth = 100;
//
// UCProcessWave
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.ucWave1);
this.Name = "UCProcessWave";
this.Size = new System.Drawing.Size(150, 150);
this.ResumeLayout(false);
}
#endregion
private UCWave ucWave1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace HZH_Controls.Controls
{
public partial class UCProcessWave : UCControlBase
{
private bool m_isRectangle = false;
[Description("是否矩形"), Category("自定义")]
public bool IsRectangle
{
get { return m_isRectangle; }
set
{
m_isRectangle = value;
if (value)
{
base.ConerRadius = 10;
}
else
{
base.ConerRadius = Math.Min(this.Width, this.Height);
}
}
}
#region 不再使用的父类属性 English:Parent class attributes that are no longer used
[Browsable(false)]
public new int ConerRadius
{
get;
set;
}
[Browsable(false)]
public new bool IsRadius
{
get;
set;
}
[Browsable(false)]
public new Color FillColor
{
get;
set;
}
#endregion
[Description("是否显示边框"), Category("自定义")]
public new bool IsShowRect
{
get;
set;
}
/// <summary>
/// 边框颜色
/// </summary>
[Description("边框颜色"), Category("自定义")]
public new Color RectColor
{
get;
set;
}
/// <summary>
/// 边框宽度
/// </summary>
[Description("边框宽度"), Category("自定义")]
public new int RectWidth
{
get;
set;
}
[Description("值变更事件"), Category("自定义")]
public event EventHandler ValueChanged;
int m_value = 0;
[Description("当前属性"), Category("自定义")]
public int Value
{
set
{
if (value > m_maxValue)
m_value = m_maxValue;
else if (value < 0)
m_value = 0;
else
m_value = value;
if (ValueChanged != null)
ValueChanged(this, null);
ucWave1.Height = (int)((double)m_value / (double)m_maxValue * this.Height) + ucWave1.WaveHeight;
Refresh();
}
get
{
return m_value;
}
}
private int m_maxValue = 100;
[Description("最大值"), Category("自定义")]
public int MaxValue
{
get { return m_maxValue; }
set
{
if (value < m_value)
m_maxValue = m_value;
else
m_maxValue = value;
Refresh();
}
}
public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
}
}
public override Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
}
}
public UCProcessWave()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.Selectable, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.UserPaint, true);
base.IsRadius = true;
base.IsShowRect = false;
ucWave1.Height = (int)((double)m_value / (double)m_maxValue * this.Height) + ucWave1.WaveHeight;
this.SizeChanged += UCProcessWave_SizeChanged;
this.ucWave1.OnPainted += ucWave1_Painted;
base.ConerRadius = Math.Min(this.Width, this.Height);
}
void ucWave1_Painted(object sender, PaintEventArgs e)
{
e.Graphics.SetGDIHigh();
if (!m_isRectangle)
{
//这里曲线救国,因为设置了控件区域导致的毛边,通过画一个没有毛边的圆遮挡
SolidBrush solidBrush = new SolidBrush(Color.White);
e.Graphics.DrawEllipse(new Pen(solidBrush, 2), new Rectangle(-1, this.ucWave1.Height - this.Height - 1, this.Width + 2, this.Height + 2));
}
string strValue = ((double)m_value / (double)m_maxValue).ToString("0.%");
System.Drawing.SizeF sizeF = e.Graphics.MeasureString(strValue, Font);
e.Graphics.DrawString(strValue, Font, new SolidBrush(ForeColor), new PointF((this.Width - sizeF.Width) / 2, (this.ucWave1.Height - this.Height) + (this.Height - sizeF.Height) / 2));
}
void UCProcessWave_SizeChanged(object sender, EventArgs e)
{
if (!m_isRectangle)
{
base.ConerRadius = Math.Min(this.Width, this.Height);
if (this.Width != this.Height)
{
this.Size = new Size(Math.Min(this.Width, this.Height), Math.Min(this.Width, this.Height));
}
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.SetGDIHigh();
if (!m_isRectangle)
{
//这里曲线救国,因为设置了控件区域导致的毛边,通过画一个没有毛边的圆遮挡
SolidBrush solidBrush = new SolidBrush(Color.White);
e.Graphics.DrawEllipse(new Pen(solidBrush, 2), new Rectangle(-1, -1, this.Width + 2, this.Height + 2));
}
string strValue = ((double)m_value / (double)m_maxValue).ToString("0.%");
System.Drawing.SizeF sizeF = e.Graphics.MeasureString(strValue, Font);
e.Graphics.DrawString(strValue, Font, new SolidBrush(ForeColor), new PointF((this.Width - sizeF.Width) / 2, (this.Height - sizeF.Height) / 2 + 1));
}
}
}
<?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>
\ No newline at end of file
......@@ -124,9 +124,12 @@ namespace HZH_Controls.Controls
public UCControlBase()
{
this.InitializeComponent();
base.SetStyle(ControlStyles.UserPaint, true);
base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
base.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.Selectable, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
......@@ -148,7 +151,7 @@ namespace HZH_Controls.Controls
graphicsPath.AddArc(clientRectangle.Width - _cornerRadius - 1, clientRectangle.Height - _cornerRadius - 1, _cornerRadius, _cornerRadius, 0f, 90f);
graphicsPath.AddArc(0, clientRectangle.Height - _cornerRadius - 1, _cornerRadius, _cornerRadius, 90f, 90f);
graphicsPath.CloseFigure();
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.SetGDIHigh();
if (_fillColor != Color.Empty && _fillColor != Color.Transparent && _fillColor != this.BackColor)
e.Graphics.FillPath(new SolidBrush(this._fillColor), graphicsPath);
e.Graphics.DrawPath(pen, graphicsPath);
......
......@@ -11,6 +11,8 @@ namespace HZH_Controls.Controls
{
public class UCWave : Control
{
public event PaintEventHandler OnPainted;
private Color m_waveColor = Color.FromArgb(73, 119, 232);
[Description("波纹颜色"), Category("自定义")]
......@@ -131,6 +133,11 @@ namespace HZH_Controls.Controls
g.FillPath(new SolidBrush(Color.FromArgb(220, m_waveColor.R, m_waveColor.G, m_waveColor.B)), path1);
g.FillPath(new SolidBrush(Color.FromArgb(220, m_waveColor.R, m_waveColor.G, m_waveColor.B)), path2);
if (OnPainted != null)
{
OnPainted(this, e);
}
}
}
}
......@@ -157,8 +157,6 @@ namespace HZH_Controls.Controls
timer.Interval = m_sleepTime;
timer.Tick += timer_Tick;
this.VisibleChanged += UCWave_VisibleChanged;
}
......
......@@ -139,6 +139,12 @@
<Compile Include="Controls\Process\UCProcessLineExt.Designer.cs">
<DependentUpon>UCProcessLineExt.cs</DependentUpon>
</Compile>
<Compile Include="Controls\Process\UCProcessWave.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Process\UCProcessWave.Designer.cs">
<DependentUpon>UCProcessWave.cs</DependentUpon>
</Compile>
<Compile Include="Controls\Step\UCStep.cs">
<SubType>UserControl</SubType>
</Compile>
......@@ -483,6 +489,9 @@
<EmbeddedResource Include="Controls\Process\UCProcessLineExt.resx">
<DependentUpon>UCProcessLineExt.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\Process\UCProcessWave.resx">
<DependentUpon>UCProcessWave.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\RadioButton\UCRadioButton.resx">
<DependentUpon>UCRadioButton.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -37,6 +37,8 @@
this.label2 = new System.Windows.Forms.Label();
this.trackBar3 = new System.Windows.Forms.TrackBar();
this.label3 = new System.Windows.Forms.Label();
this.ucProcessWave1 = new HZH_Controls.Controls.UCProcessWave();
this.ucWaveWithSource1 = new HZH_Controls.Controls.UCWaveWithSource();
this.ucWave1 = new HZH_Controls.Controls.UCWave();
this.ucProcessLineExt1 = new HZH_Controls.Controls.UCProcessLineExt();
this.ucProcessLine1 = new HZH_Controls.Controls.UCProcessLine();
......@@ -56,7 +58,6 @@
this.ucPanelTitle1 = new HZH_Controls.Controls.UCPanelTitle();
this.ucStep2 = new HZH_Controls.Controls.UCStep();
this.ucStep1 = new HZH_Controls.Controls.UCStep();
this.ucWaveWithSource1 = new HZH_Controls.Controls.UCWaveWithSource();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit();
......@@ -133,6 +134,48 @@
this.label3.TabIndex = 9;
this.label3.Text = "波宽";
//
// ucProcessWave1
//
this.ucProcessWave1.BackColor = System.Drawing.Color.Transparent;
this.ucProcessWave1.ConerRadius = 0;
this.ucProcessWave1.EnabledTheme = false;
this.ucProcessWave1.FillColor = System.Drawing.Color.Empty;
this.ucProcessWave1.Font = new System.Drawing.Font("微软雅黑", 30F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucProcessWave1.IsRadius = false;
this.ucProcessWave1.IsRectangle = true;
this.ucProcessWave1.IsShowRect = false;
this.ucProcessWave1.Location = new System.Drawing.Point(756, 221);
this.ucProcessWave1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucProcessWave1.MaxValue = 100;
this.ucProcessWave1.Name = "ucProcessWave1";
this.ucProcessWave1.RectColor = System.Drawing.Color.Empty;
this.ucProcessWave1.RectWidth = 0;
this.ucProcessWave1.Size = new System.Drawing.Size(150, 150);
this.ucProcessWave1.TabIndex = 11;
this.ucProcessWave1.Value = 40;
//
// ucWaveWithSource1
//
this.ucWaveWithSource1.ConerRadius = 10;
this.ucWaveWithSource1.EnabledTheme = false;
this.ucWaveWithSource1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(229)))), ((int)(((byte)(250)))));
this.ucWaveWithSource1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucWaveWithSource1.GridLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
this.ucWaveWithSource1.GridLineTextColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
this.ucWaveWithSource1.IsRadius = true;
this.ucWaveWithSource1.IsShowRect = true;
this.ucWaveWithSource1.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
this.ucWaveWithSource1.LineTension = 0.5F;
this.ucWaveWithSource1.Location = new System.Drawing.Point(756, 14);
this.ucWaveWithSource1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucWaveWithSource1.Name = "ucWaveWithSource1";
this.ucWaveWithSource1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
this.ucWaveWithSource1.RectWidth = 1;
this.ucWaveWithSource1.Size = new System.Drawing.Size(586, 182);
this.ucWaveWithSource1.SleepTime = 1000;
this.ucWaveWithSource1.TabIndex = 10;
this.ucWaveWithSource1.WaveWidth = 50;
//
// ucWave1
//
this.ucWave1.Location = new System.Drawing.Point(249, 337);
......@@ -426,33 +469,12 @@
this.ucStep1.StepWidth = 35;
this.ucStep1.TabIndex = 0;
//
// ucWaveWithSource1
//
this.ucWaveWithSource1.ConerRadius = 10;
this.ucWaveWithSource1.EnabledTheme = false;
this.ucWaveWithSource1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(229)))), ((int)(((byte)(250)))));
this.ucWaveWithSource1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucWaveWithSource1.GridLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
this.ucWaveWithSource1.GridLineTextColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
this.ucWaveWithSource1.IsRadius = true;
this.ucWaveWithSource1.IsShowRect = true;
this.ucWaveWithSource1.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
this.ucWaveWithSource1.LineTension = 0.5F;
this.ucWaveWithSource1.Location = new System.Drawing.Point(756, 14);
this.ucWaveWithSource1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucWaveWithSource1.Name = "ucWaveWithSource1";
this.ucWaveWithSource1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
this.ucWaveWithSource1.RectWidth = 1;
this.ucWaveWithSource1.Size = new System.Drawing.Size(586, 182);
this.ucWaveWithSource1.TabIndex = 10;
this.ucWaveWithSource1.SleepTime = 1000;
this.ucWaveWithSource1.WaveWidth = 50;
//
// Form2
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1438, 594);
this.Controls.Add(this.ucProcessWave1);
this.Controls.Add(this.ucWaveWithSource1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
......@@ -519,5 +541,7 @@
private System.Windows.Forms.TrackBar trackBar3;
private System.Windows.Forms.Label label3;
private HZH_Controls.Controls.UCWaveWithSource ucWaveWithSource1;
private HZH_Controls.Controls.UCProcessWave ucProcessWave1;
}
}
\ No newline at end of file
......@@ -27,12 +27,15 @@ namespace Test
this.ucProcessEllipse1.Value++;
this.ucProcessEllipse2.Value++;
this.ucProcessLine1.Value++;
this.ucProcessWave1.Value++;
ucProcessLineExt1.Value++;
if (this.ucProcessEllipse1.Value == 100)
this.ucProcessEllipse1.Value = 0;
if (this.ucProcessEllipse2.Value == 100)
this.ucProcessEllipse2.Value = 0;
if (this.ucProcessWave1.Value >= this.ucProcessWave1.MaxValue)
this.ucProcessWave1.Value = 0;
if (this.ucProcessLine1.Value >= this.ucProcessLine1.MaxValue)
this.ucProcessLine1.Value = 0;
if (this.ucProcessLineExt1.Value >= this.ucProcessLineExt1.MaxValue)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!