Commit 166f7cde HZH

processwave

1 个父辈 5af0f5ab
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
// UCProcessWave // UCProcessWave
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.Transparent; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(229)))), ((int)(((byte)(250)))));
this.Controls.Add(this.ucWave1); this.Controls.Add(this.ucWave1);
this.Name = "UCProcessWave"; this.Name = "UCProcessWave";
this.Size = new System.Drawing.Size(150, 150); this.Size = new System.Drawing.Size(150, 150);
......
...@@ -52,30 +52,6 @@ namespace HZH_Controls.Controls ...@@ -52,30 +52,6 @@ namespace HZH_Controls.Controls
} }
#endregion #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("自定义")] [Description("值变更事件"), Category("自定义")]
public event EventHandler ValueChanged; public event EventHandler ValueChanged;
...@@ -142,6 +118,30 @@ namespace HZH_Controls.Controls ...@@ -142,6 +118,30 @@ namespace HZH_Controls.Controls
} }
} }
public Color ValueColor
{
get { return this.ucWave1.WaveColor; }
set
{
this.ucWave1.WaveColor = value;
}
}
public override int RectWidth
{
get
{
return base.RectWidth;
}
set
{
if (value < 4)
base.RectWidth = 4;
else
base.RectWidth = value;
}
}
public UCProcessWave() public UCProcessWave()
{ {
InitializeComponent(); InitializeComponent();
...@@ -153,6 +153,8 @@ namespace HZH_Controls.Controls ...@@ -153,6 +153,8 @@ namespace HZH_Controls.Controls
this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.UserPaint, true);
base.IsRadius = true; base.IsRadius = true;
base.IsShowRect = false; base.IsShowRect = false;
RectWidth = 4;
RectColor = Color.White;
ucWave1.Height = (int)((double)m_value / (double)m_maxValue * this.Height) + ucWave1.WaveHeight; ucWave1.Height = (int)((double)m_value / (double)m_maxValue * this.Height) + ucWave1.WaveHeight;
this.SizeChanged += UCProcessWave_SizeChanged; this.SizeChanged += UCProcessWave_SizeChanged;
this.ucWave1.OnPainted += ucWave1_Painted; this.ucWave1.OnPainted += ucWave1_Painted;
...@@ -161,13 +163,34 @@ namespace HZH_Controls.Controls ...@@ -161,13 +163,34 @@ namespace HZH_Controls.Controls
void ucWave1_Painted(object sender, PaintEventArgs e) void ucWave1_Painted(object sender, PaintEventArgs e)
{ {
e.Graphics.SetGDIHigh(); e.Graphics.SetGDIHigh();
if (IsShowRect)
{
if (m_isRectangle)
{
Color rectColor = RectColor;
Pen pen = new Pen(rectColor, (float)RectWidth);
Rectangle clientRectangle = new Rectangle(0, this.ucWave1.Height - this.Height, this.Width, this.Height);
GraphicsPath graphicsPath = new GraphicsPath();
graphicsPath.AddArc(clientRectangle.X, clientRectangle.Y, 10, 10, 180f, 90f);
graphicsPath.AddArc(clientRectangle.Width - 10 - 1, clientRectangle.Y, 10, 10, 270f, 90f);
graphicsPath.AddArc(clientRectangle.Width - 10 - 1, clientRectangle.Bottom - 10 - 1, 10, 10, 0f, 90f);
graphicsPath.AddArc(clientRectangle.X, clientRectangle.Bottom - 10 - 1, 10, 10, 90f, 90f);
graphicsPath.CloseFigure();
e.Graphics.DrawPath(pen, graphicsPath);
}
else
{
SolidBrush solidBrush = new SolidBrush(RectColor);
e.Graphics.DrawEllipse(new Pen(solidBrush, RectWidth), new Rectangle(0, this.ucWave1.Height - this.Height, this.Width, this.Height));
}
}
if (!m_isRectangle) if (!m_isRectangle)
{ {
//这里曲线救国,因为设置了控件区域导致的毛边,通过画一个没有毛边的圆遮挡 //这里曲线救国,因为设置了控件区域导致的毛边,通过画一个没有毛边的圆遮挡
SolidBrush solidBrush = new SolidBrush(Color.White); SolidBrush solidBrush1 = 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)); e.Graphics.DrawEllipse(new Pen(solidBrush1, 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.%"); string strValue = ((double)m_value / (double)m_maxValue).ToString("0.%");
System.Drawing.SizeF sizeF = e.Graphics.MeasureString(strValue, Font); System.Drawing.SizeF sizeF = e.Graphics.MeasureString(strValue, Font);
......
...@@ -34,7 +34,7 @@ namespace HZH_Controls.Controls ...@@ -34,7 +34,7 @@ namespace HZH_Controls.Controls
/// 是否圆角 /// 是否圆角
/// </summary> /// </summary>
[Description("是否圆角"), Category("自定义")] [Description("是否圆角"), Category("自定义")]
public bool IsRadius public virtual bool IsRadius
{ {
get get
{ {
...@@ -43,11 +43,12 @@ namespace HZH_Controls.Controls ...@@ -43,11 +43,12 @@ namespace HZH_Controls.Controls
set set
{ {
this._isRadius = value; this._isRadius = value;
Refresh();
} }
} }
//圆角角度 //圆角角度
[Description("圆角角度"), Category("自定义")] [Description("圆角角度"), Category("自定义")]
public int ConerRadius public virtual int ConerRadius
{ {
get get
{ {
...@@ -56,6 +57,7 @@ namespace HZH_Controls.Controls ...@@ -56,6 +57,7 @@ namespace HZH_Controls.Controls
set set
{ {
this._cornerRadius = value; this._cornerRadius = value;
Refresh();
} }
} }
...@@ -63,7 +65,7 @@ namespace HZH_Controls.Controls ...@@ -63,7 +65,7 @@ namespace HZH_Controls.Controls
/// 是否显示边框 /// 是否显示边框
/// </summary> /// </summary>
[Description("是否显示边框"), Category("自定义")] [Description("是否显示边框"), Category("自定义")]
public bool IsShowRect public virtual bool IsShowRect
{ {
get get
{ {
...@@ -72,13 +74,14 @@ namespace HZH_Controls.Controls ...@@ -72,13 +74,14 @@ namespace HZH_Controls.Controls
set set
{ {
this._isShowRect = value; this._isShowRect = value;
Refresh();
} }
} }
/// <summary> /// <summary>
/// 边框颜色 /// 边框颜色
/// </summary> /// </summary>
[Description("边框颜色"), Category("自定义")] [Description("边框颜色"), Category("自定义")]
public Color RectColor public virtual Color RectColor
{ {
get get
{ {
...@@ -94,7 +97,7 @@ namespace HZH_Controls.Controls ...@@ -94,7 +97,7 @@ namespace HZH_Controls.Controls
/// 边框宽度 /// 边框宽度
/// </summary> /// </summary>
[Description("边框宽度"), Category("自定义")] [Description("边框宽度"), Category("自定义")]
public int RectWidth public virtual int RectWidth
{ {
get get
{ {
...@@ -103,13 +106,14 @@ namespace HZH_Controls.Controls ...@@ -103,13 +106,14 @@ namespace HZH_Controls.Controls
set set
{ {
this._rectWidth = value; this._rectWidth = value;
Refresh();
} }
} }
/// <summary> /// <summary>
/// 当使用边框时填充颜色,当值为背景色或透明色或空值则不填充 /// 当使用边框时填充颜色,当值为背景色或透明色或空值则不填充
/// </summary> /// </summary>
[Description("当使用边框时填充颜色,当值为背景色或透明色或空值则不填充"), Category("自定义")] [Description("当使用边框时填充颜色,当值为背景色或透明色或空值则不填充"), Category("自定义")]
public Color FillColor public virtual Color FillColor
{ {
get get
{ {
...@@ -118,6 +122,7 @@ namespace HZH_Controls.Controls ...@@ -118,6 +122,7 @@ namespace HZH_Controls.Controls
set set
{ {
this._fillColor = value; this._fillColor = value;
Refresh();
} }
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.trackBar3 = new System.Windows.Forms.TrackBar(); this.trackBar3 = new System.Windows.Forms.TrackBar();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.ucProcessWave2 = new HZH_Controls.Controls.UCProcessWave();
this.ucProcessWave1 = new HZH_Controls.Controls.UCProcessWave(); this.ucProcessWave1 = new HZH_Controls.Controls.UCProcessWave();
this.ucWaveWithSource1 = new HZH_Controls.Controls.UCWaveWithSource(); this.ucWaveWithSource1 = new HZH_Controls.Controls.UCWaveWithSource();
this.ucWave1 = new HZH_Controls.Controls.UCWave(); this.ucWave1 = new HZH_Controls.Controls.UCWave();
...@@ -134,25 +135,47 @@ ...@@ -134,25 +135,47 @@
this.label3.TabIndex = 9; this.label3.TabIndex = 9;
this.label3.Text = "波宽"; this.label3.Text = "波宽";
// //
// ucProcessWave2
//
this.ucProcessWave2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(229)))), ((int)(((byte)(250)))));
this.ucProcessWave2.ConerRadius = 0;
this.ucProcessWave2.EnabledTheme = false;
this.ucProcessWave2.FillColor = System.Drawing.Color.Empty;
this.ucProcessWave2.Font = new System.Drawing.Font("微软雅黑", 30F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucProcessWave2.IsRadius = false;
this.ucProcessWave2.IsRectangle = false;
this.ucProcessWave2.IsShowRect = true;
this.ucProcessWave2.Location = new System.Drawing.Point(910, 261);
this.ucProcessWave2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucProcessWave2.MaxValue = 100;
this.ucProcessWave2.Name = "ucProcessWave2";
this.ucProcessWave2.RectColor = System.Drawing.Color.White;
this.ucProcessWave2.RectWidth = 4;
this.ucProcessWave2.Size = new System.Drawing.Size(150, 150);
this.ucProcessWave2.TabIndex = 11;
this.ucProcessWave2.Value = 40;
this.ucProcessWave2.ValueColor = System.Drawing.Color.FromArgb(((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
//
// ucProcessWave1 // ucProcessWave1
// //
this.ucProcessWave1.BackColor = System.Drawing.Color.Transparent; this.ucProcessWave1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(229)))), ((int)(((byte)(250)))));
this.ucProcessWave1.ConerRadius = 0; this.ucProcessWave1.ConerRadius = 0;
this.ucProcessWave1.EnabledTheme = false; this.ucProcessWave1.EnabledTheme = false;
this.ucProcessWave1.FillColor = System.Drawing.Color.Empty; 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.Font = new System.Drawing.Font("微软雅黑", 30F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucProcessWave1.IsRadius = false; this.ucProcessWave1.IsRadius = false;
this.ucProcessWave1.IsRectangle = true; this.ucProcessWave1.IsRectangle = true;
this.ucProcessWave1.IsShowRect = false; this.ucProcessWave1.IsShowRect = true;
this.ucProcessWave1.Location = new System.Drawing.Point(756, 221); this.ucProcessWave1.Location = new System.Drawing.Point(756, 221);
this.ucProcessWave1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.ucProcessWave1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucProcessWave1.MaxValue = 100; this.ucProcessWave1.MaxValue = 100;
this.ucProcessWave1.Name = "ucProcessWave1"; this.ucProcessWave1.Name = "ucProcessWave1";
this.ucProcessWave1.RectColor = System.Drawing.Color.Empty; this.ucProcessWave1.RectColor = System.Drawing.Color.White;
this.ucProcessWave1.RectWidth = 0; this.ucProcessWave1.RectWidth = 4;
this.ucProcessWave1.Size = new System.Drawing.Size(150, 150); this.ucProcessWave1.Size = new System.Drawing.Size(108, 236);
this.ucProcessWave1.TabIndex = 11; this.ucProcessWave1.TabIndex = 11;
this.ucProcessWave1.Value = 40; this.ucProcessWave1.Value = 40;
this.ucProcessWave1.ValueColor = System.Drawing.Color.FromArgb(((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
// //
// ucWaveWithSource1 // ucWaveWithSource1
// //
...@@ -474,6 +497,7 @@ ...@@ -474,6 +497,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1438, 594); this.ClientSize = new System.Drawing.Size(1438, 594);
this.Controls.Add(this.ucProcessWave2);
this.Controls.Add(this.ucProcessWave1); this.Controls.Add(this.ucProcessWave1);
this.Controls.Add(this.ucWaveWithSource1); this.Controls.Add(this.ucWaveWithSource1);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
...@@ -542,6 +566,7 @@ ...@@ -542,6 +566,7 @@
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private HZH_Controls.Controls.UCWaveWithSource ucWaveWithSource1; private HZH_Controls.Controls.UCWaveWithSource ucWaveWithSource1;
private HZH_Controls.Controls.UCProcessWave ucProcessWave1; private HZH_Controls.Controls.UCProcessWave ucProcessWave1;
private HZH_Controls.Controls.UCProcessWave ucProcessWave2;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -27,20 +27,22 @@ namespace Test ...@@ -27,20 +27,22 @@ namespace Test
this.ucProcessEllipse1.Value++; this.ucProcessEllipse1.Value++;
this.ucProcessEllipse2.Value++; this.ucProcessEllipse2.Value++;
this.ucProcessLine1.Value++; this.ucProcessLine1.Value++;
this.ucProcessWave1.Value++;
ucProcessLineExt1.Value++; ucProcessLineExt1.Value++;
this.ucProcessWave1.Value++;
this.ucProcessWave2.Value++;
if (this.ucProcessEllipse1.Value == 100) if (this.ucProcessEllipse1.Value == 100)
this.ucProcessEllipse1.Value = 0; this.ucProcessEllipse1.Value = 0;
if (this.ucProcessEllipse2.Value == 100) if (this.ucProcessEllipse2.Value == 100)
this.ucProcessEllipse2.Value = 0; this.ucProcessEllipse2.Value = 0;
if (this.ucProcessWave1.Value >= this.ucProcessWave1.MaxValue)
this.ucProcessWave1.Value = 0;
if (this.ucProcessLine1.Value >= this.ucProcessLine1.MaxValue) if (this.ucProcessLine1.Value >= this.ucProcessLine1.MaxValue)
this.ucProcessLine1.Value = 0; this.ucProcessLine1.Value = 0;
if (this.ucProcessLineExt1.Value >= this.ucProcessLineExt1.MaxValue) if (this.ucProcessLineExt1.Value >= this.ucProcessLineExt1.MaxValue)
this.ucProcessLineExt1.Value = 0; this.ucProcessLineExt1.Value = 0;
if (this.ucProcessWave1.Value >= this.ucProcessWave1.MaxValue)
this.ucProcessWave1.Value = 0;
if (this.ucProcessWave2.Value >= this.ucProcessWave1.MaxValue)
this.ucProcessWave2.Value = 0;
Random r = new Random(); Random r = new Random();
int i = r.Next(100, 1000); int i = r.Next(100, 1000);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!