Commit d864f644 HZH

修改滑块颜色

1 个父辈 e2d76073
...@@ -73,7 +73,7 @@ namespace HZH_Controls.Controls ...@@ -73,7 +73,7 @@ namespace HZH_Controls.Controls
if (value > maxValue || value < minValue) if (value > maxValue || value < minValue)
return; return;
var v = (float)Math.Round((double)value, dcimalDigits); var v = (float)Math.Round((double)value, dcimalDigits);
if (value == v) if (m_value == v)
return; return;
this.m_value = v; this.m_value = v;
this.Refresh(); this.Refresh();
...@@ -84,7 +84,7 @@ namespace HZH_Controls.Controls ...@@ -84,7 +84,7 @@ namespace HZH_Controls.Controls
} }
} }
private Color m_lineColor = Color.FromArgb(255, 77, 59); private Color m_lineColor = Color.FromArgb(228, 231, 237);
[Description("线颜色"), Category("自定义")] [Description("线颜色"), Category("自定义")]
public Color LineColor public Color LineColor
...@@ -96,6 +96,20 @@ namespace HZH_Controls.Controls ...@@ -96,6 +96,20 @@ namespace HZH_Controls.Controls
this.Refresh(); this.Refresh();
} }
} }
private Color m_valueColor = Color.FromArgb(255, 77, 59);
[Description("值颜色"), Category("自定义")]
public Color ValueColor
{
get { return m_valueColor; }
set
{
m_valueColor = value;
this.Refresh();
}
}
RectangleF m_lineRectangle; RectangleF m_lineRectangle;
RectangleF m_trackRectangle; RectangleF m_trackRectangle;
...@@ -143,8 +157,13 @@ namespace HZH_Controls.Controls ...@@ -143,8 +157,13 @@ namespace HZH_Controls.Controls
m_lineRectangle = new RectangleF(lineWidth, (this.Size.Height - lineWidth) / 2, this.Size.Width - lineWidth * 2, lineWidth); m_lineRectangle = new RectangleF(lineWidth, (this.Size.Height - lineWidth) / 2, this.Size.Width - lineWidth * 2, lineWidth);
GraphicsPath pathLine = ControlHelper.CreateRoundedRectanglePath(m_lineRectangle, 5); GraphicsPath pathLine = ControlHelper.CreateRoundedRectanglePath(m_lineRectangle, 5);
g.FillPath(new SolidBrush(m_lineColor), pathLine); g.FillPath(new SolidBrush(m_lineColor), pathLine);
GraphicsPath valueLine = ControlHelper.CreateRoundedRectanglePath(new RectangleF(lineWidth, (this.Size.Height - lineWidth) / 2, ((float)m_value / (float)(maxValue - minValue)) * m_lineRectangle.Width, lineWidth), 5);
g.FillPath(new SolidBrush(m_valueColor), valueLine);
m_trackRectangle = new RectangleF(m_lineRectangle.Left - lineWidth + (((float)m_value / (float)(maxValue - minValue)) * (this.Size.Width - lineWidth * 2)), (this.Size.Height - lineWidth * 2) / 2, lineWidth * 2, lineWidth * 2); m_trackRectangle = new RectangleF(m_lineRectangle.Left - lineWidth + (((float)m_value / (float)(maxValue - minValue)) * (this.Size.Width - lineWidth * 2)), (this.Size.Height - lineWidth * 2) / 2, lineWidth * 2, lineWidth * 2);
g.FillEllipse(new SolidBrush(m_lineColor), m_trackRectangle); g.FillEllipse(new SolidBrush(m_valueColor), m_trackRectangle);
g.FillEllipse(Brushes.White, new RectangleF(m_trackRectangle.X + m_trackRectangle.Width / 4, m_trackRectangle.Y + m_trackRectangle.Height / 4, m_trackRectangle.Width / 2, m_trackRectangle.Height / 2)); g.FillEllipse(Brushes.White, new RectangleF(m_trackRectangle.X + m_trackRectangle.Width / 4, m_trackRectangle.Y + m_trackRectangle.Height / 4, m_trackRectangle.Width / 2, m_trackRectangle.Height / 2));
} }
} }
......
...@@ -138,15 +138,18 @@ ...@@ -138,15 +138,18 @@
// //
// ucTrackBar1 // ucTrackBar1
// //
this.ucTrackBar1.LineWidth = 10; this.ucTrackBar1.DcimalDigits = 0;
this.ucTrackBar1.Location = new System.Drawing.Point(833, 403); this.ucTrackBar1.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(228)))), ((int)(((byte)(231)))), ((int)(((byte)(237)))));
this.ucTrackBar1.MaxValue = 100; this.ucTrackBar1.LineWidth = 10F;
this.ucTrackBar1.MinValue = 0; this.ucTrackBar1.Location = new System.Drawing.Point(999, 367);
this.ucTrackBar1.MaxValue = 100F;
this.ucTrackBar1.MinValue = 0F;
this.ucTrackBar1.Name = "ucTrackBar1"; this.ucTrackBar1.Name = "ucTrackBar1";
this.ucTrackBar1.Size = new System.Drawing.Size(212, 32); this.ucTrackBar1.Size = new System.Drawing.Size(250, 30);
this.ucTrackBar1.TabIndex = 12; this.ucTrackBar1.TabIndex = 12;
this.ucTrackBar1.Text = "ucTrackBar1"; this.ucTrackBar1.Text = "ucTrackBar1";
this.ucTrackBar1.Value = 100; this.ucTrackBar1.Value = 40F;
this.ucTrackBar1.ValueColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
// //
// ucProcessWave2 // ucProcessWave2
// //
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!