winform 仪表盘相关下载链接://download.csdn.net/download/floweroflvoe/10432601?utm_source=bbsseo
控件首次拖拽上来是这样的: Demo中美化之后是这样的: 这是修改demo后的成果:
其中颜色是一点一点配出来的,线条与色块是一个一个Range调整大小与位置得到的,最后的指针颜色本是没有和谐的颜色,通过修改源代码添加了合适的颜色。
样式是通过属性编辑器添加修改的,最后生成的设计器具体代码如下:
// // aGauge1 // this.aGauge1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(16)))), ((int)(((byte)(24)))), ((int)(((byte)(57))))); this.aGauge1.BaseArcColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(202)))), ((int)(((byte)(250))))); this.aGauge1.BaseArcRadius = 82; this.aGauge1.BaseArcStart = 155; this.aGauge1.BaseArcSweep = 230; this.aGauge1.BaseArcWidth = 2; this.aGauge1.Dock = System.Windows.Forms.DockStyle.Fill; this.aGauge1.GaugeAutoSize = true; aGaugeLabel1.Color = System.Drawing.Color.White; aGaugeLabel1.Font = new System.Drawing.Font("Verdana", 9.75F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); aGaugeLabel1.Name = "GaugeLabel1"; aGaugeLabel1.Position = new System.Drawing.Point(200, 260); aGaugeLabel1.Text = "0"; this.aGauge1.GaugeLabels.Add(aGaugeLabel1); aGaugeRange1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(129)))), ((int)(((byte)(133)))), ((int)(((byte)(204))))); aGaugeRange1.EndValue = 6.8F; aGaugeRange1.InnerRadius = 90; aGaugeRange1.InRange = false; aGaugeRange1.Name = "ShortRange"; aGaugeRange1.OuterRadius = 91; aGaugeRange1.StartValue = 1.8F; aGaugeRange2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(112)))), ((int)(((byte)(227))))); aGaugeRange2.EndValue = 1.7F; aGaugeRange2.InnerRadius = 70; aGaugeRange2.InRange = false; aGaugeRange2.Name = "GaugeRange3"; aGaugeRange2.OuterRadius = 77; aGaugeRange2.StartValue = 1.2F; aGaugeRange3.Color = System.Drawing.Color.FromArgb(((int)(((byte)(132)))), ((int)(((byte)(101)))), ((int)(((byte)(225))))); aGaugeRange3.EndValue = 1F; aGaugeRange3.InnerRadius = 70; aGaugeRange3.InRange = false; aGaugeRange3.Name = "GaugeRange2"; aGaugeRange3.OuterRadius = 77; aGaugeRange3.StartValue = 0.5F; aGaugeRange4.Color = System.Drawing.Color.FromArgb(((int)(((byte)(131)))), ((int)(((byte)(94)))), ((int)(((byte)(223))))); aGaugeRange4.EndValue = 0.3F; aGaugeRange4.InnerRadius = 70; aGaugeRange4.InRange = false; aGaugeRange4.Name = "GaugeRange1"; aGaugeRange4.OuterRadius = 77; aGaugeRange4.StartValue = -0.2F; aGaugeRange5.Color = System.Drawing.Color.FromArgb(((int)(((byte)(134)))), ((int)(((byte)(123)))), ((int)(((byte)(230))))); aGaugeRange5.EndValue = 2.4F; aGaugeRange5.InnerRadius = 70; aGaugeRange5.InRange = false; aGaugeRange5.Name = "GaugeRange4"; aGaugeRange5.OuterRadius = 77; aGaugeRange5.StartValue = 1.9F; aGaugeRange6.Color = System.Drawing.Color.FromArgb(((int)(((byte)(135)))), ((int)(((byte)(133)))), ((int)(((byte)(231))))); aGaugeRange6.EndValue = 3.1F; aGaugeRange6.InnerRadius = 70; aGaugeRange6.InRange = false; aGaugeRange6.Name = "GaugeRange5"; aGaugeRange6.OuterRadius = 77; aGaugeRange6.StartValue = 2.6F; aGaugeRange7.Color = System.Drawing.Color.FromArgb(((int)(((byte)(138)))), ((int)(((byte)(153)))), ((int)(((byte)(236))))); aGaugeRange7.EndValue = 3.8F; aGaugeRange7.InnerRadius = 70; aGaugeRange7.InRange = false; aGaugeRange7.Name = "GaugeRange6"; aGaugeRange7.OuterRadius = 77; aGaugeRange7.StartValue = 3.3F; aGaugeRange8.Color = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(177)))), ((int)(((byte)(239))))); aGaugeRange8.EndValue = 4.5F; aGaugeRange8.InnerRadius = 70; aGaugeRange8.InRange = false; aGaugeRange8.Name = "GaugeRange7"; aGaugeRange8.OuterRadius = 77; aGaugeRange8.StartValue = 4F; aGaugeRange9.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(194)))), ((int)(((byte)(244))))); aGaugeRange9.EndValue = 5.2F; aGaugeRange9.InnerRadius = 70; aGaugeRange9.InRange = false; aGaugeRange9.Name = "GaugeRange8"; aGaugeRange9.OuterRadius = 77; aGaugeRange9.StartValue = 4.7F; aGaugeRange10.Color = System.Drawing.Color.FromArgb(((int)(((byte)(143)))), ((int)(((byte)(204)))), ((int)(((byte)(246))))); aGaugeRange10.EndValue = 5.9F; aGaugeRange10.InnerRadius = 70; aGaugeRange10.InRange = false; aGaugeRange10.Name = "GaugeRange9"; aGaugeRange10.OuterRadius = 77; aGaugeRange10.StartValue = 5.4F; aGaugeRange11.Color = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(211)))), ((int)(((byte)(247))))); aGaugeRange11.EndValue = 6.6F; aGaugeRange11.InnerRadius = 70; aGaugeRange11.InRange = false; aGaugeRange11.Name = "GaugeRange10"; aGaugeRange11.OuterRadius = 77; aGaugeRange11.StartValue = 6.1F; aGaugeRange12.Color = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(214)))), ((int)(((byte)(248))))); aGaugeRange12.EndValue = 7.3F; aGaugeRange12.InnerRadius = 70; aGaugeRange12.InRange = false; aGaugeRange12.Name = "GaugeRange11"; aGaugeRange12.OuterRadius = 77; aGaugeRange12.StartValue = 6.8F; aGaugeRange13.Color = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(212)))), ((int)(((byte)(247))))); aGaugeRange13.EndValue = 8F; aGaugeRange13.InnerRadius = 70; aGaugeRange13.InRange = false; aGaugeRange13.Name = "GaugeRange12"; aGaugeRange13.OuterRadius = 77; aGaugeRange13.StartValue = 7.5F; aGaugeRange14.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(210)))), ((int)(((byte)(247))))); aGaugeRange14.EndValue = 8.7F; aGaugeRange14.InnerRadius = 70; aGaugeRange14.InRange = false; aGaugeRange14.Name = "GaugeRange13"; aGaugeRange14.OuterRadius = 77; aGaugeRange14.StartValue = 8.2F; aGaugeRange15.Color = System.Drawing.Color.FromArgb(((int)(((byte)(143)))), ((int)(((byte)(203)))), ((int)(((byte)(246))))); aGaugeRange15.EndValue = 9.4F; aGaugeRange15.InnerRadius = 70; aGaugeRange15.InRange = false; aGaugeRange15.Name = "GaugeRange14"; aGaugeRange15.OuterRadius = 77; aGaugeRange15.StartValue = 8.9F; aGaugeRange16.Color = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(190)))), ((int)(((byte)(243))))); aGaugeRange16.EndValue = 10.1F; aGaugeRange16.InnerRadius = 70; aGaugeRange16.InRange = false; aGaugeRange16.Name = "GaugeRange15"; aGaugeRange16.OuterRadius = 77; aGaugeRange16.StartValue = 9.6F; aGaugeRange17.Color = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(172)))), ((int)(((byte)(238))))); aGaugeRange17.EndValue = 10.8F; aGaugeRange17.InnerRadius = 70; aGaugeRange17.InRange = false; aGaugeRange17.Name = "GaugeRange16"; aGaugeRange17.OuterRadius = 77; aGaugeRange17.StartValue = 10.3F; aGaugeRange18.Color = System.Drawing.Color.FromArgb(((int)(((byte)(137)))), ((int)(((byte)(151)))), ((int)(((byte)(235))))); aGaugeRange18.EndValue = 11.5F; aGaugeRange18.InnerRadius = 70; aGaugeRange18.InRange = false; aGaugeRange18.Name = "GaugeRange17"; aGaugeRange18.OuterRadius = 77; aGaugeRange18.StartValue = 11F; aGaugeRange19.Color = System.Drawing.Color.FromArgb(((int)(((byte)(135)))), ((int)(((byte)(133)))), ((int)(((byte)(231))))); aGaugeRange19.EndValue = 12.2F; aGaugeRange19.InnerRadius = 70; aGaugeRange19.InRange = false; aGaugeRange19.Name = "GaugeRange18"; aGaugeRange19.OuterRadius = 77; aGaugeRange19.StartValue = 11.7F; aGaugeRange20.Color = System.Drawing.Color.FromArgb(((int)(((byte)(134)))), ((int)(((byte)(123)))), ((int)(((byte)(230))))); aGaugeRange20.EndValue = 12.9F; aGaugeRange20.InnerRadius = 70; aGaugeRange20.InRange = false; aGaugeRange20.Name = "GaugeRange19"; aGaugeRange20.OuterRadius = 77; aGaugeRange20.StartValue = 12.4F; aGaugeRange21.Color = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(111)))), ((int)(((byte)(227))))); aGaugeRange21.EndValue = 13.6F; aGaugeRange21.InnerRadius = 70; aGaugeRange21.InRange = false; aGaugeRange21.Name = "GaugeRange20"; aGaugeRange21.OuterRadius = 77; aGaugeRange21.StartValue = 13.1F; aGaugeRange22.Color = System.Drawing.Color.FromArgb(((int)(((byte)(132)))), ((int)(((byte)(102)))), ((int)(((byte)(225))))); aGaugeRange22.EndValue = 14.3F; aGaugeRange22.InnerRadius = 70; aGaugeRange22.InRange = false; aGaugeRange22.Name = "GaugeRange21"; aGaugeRange22.OuterRadius = 77; aGaugeRange22.StartValue = 13.8F; aGaugeRange23.Color = System.Drawing.Color.FromArgb(((int)(((byte)(131)))), ((int)(((byte)(93)))), ((int)(((byte)(223))))); aGaugeRange23.EndValue = 15F; aGaugeRange23.InnerRadius = 70; aGaugeRange23.InRange = false; aGaugeRange23.Name = "GaugeRange22"; aGaugeRange23.OuterRadius = 77; aGaugeRange23.StartValue = 14.5F; aGaugeRange24.Color = System.Drawing.Color.FromArgb(((int)(((byte)(78)))), ((int)(((byte)(115)))), ((int)(((byte)(153))))); aGaugeRange24.EndValue = 15.5F; aGaugeRange24.InnerRadius = 65; aGaugeRange24.InRange = false; aGaugeRange24.Name = "SingleGaugeRange"; aGaugeRange24.OuterRadius = 66; aGaugeRange24.StartValue = -0.5F; this.aGauge1.GaugeRanges.Add(aGaugeRange1); this.aGauge1.GaugeRanges.Add(aGaugeRange2); this.aGauge1.GaugeRanges.Add(aGaugeRange3); this.aGauge1.GaugeRanges.Add(aGaugeRange4); this.aGauge1.GaugeRanges.Add(aGaugeRange5); this.aGauge1.GaugeRanges.Add(aGaugeRange6); this.aGauge1.GaugeRanges.Add(aGaugeRange7); this.aGauge1.GaugeRanges.Add(aGaugeRange8); this.aGauge1.GaugeRanges.Add(aGaugeRange9); this.aGauge1.GaugeRanges.Add(aGaugeRange10); this.aGauge1.GaugeRanges.Add(aGaugeRange11); this.aGauge1.GaugeRanges.Add(aGaugeRange12); this.aGauge1.GaugeRanges.Add(aGaugeRange13); this.aGauge1.GaugeRanges.Add(aGaugeRange14); this.aGauge1.GaugeRanges.Add(aGaugeRange15); this.aGauge1.GaugeRanges.Add(aGaugeRange16); this.aGauge1.GaugeRanges.Add(aGaugeRange17); this.aGauge1.GaugeRanges.Add(aGaugeRange18); this.aGauge1.GaugeRanges.Add(aGaugeRange19); this.aGauge1.GaugeRanges.Add(aGaugeRange20); this.aGauge1.GaugeRanges.Add(aGaugeRange21); this.aGauge1.GaugeRanges.Add(aGaugeRange22); this.aGauge1.GaugeRanges.Add(aGaugeRange23); this.aGauge1.GaugeRanges.Add(aGaugeRange24); this.aGauge1.Location = new System.Drawing.Point(53, 3); this.aGauge1.MaxValue = 16F; this.aGauge1.MinValue = -1F; this.aGauge1.Name = "aGauge1"; this.aGauge1.NeedleColor1 = System.Windows.Forms.AGaugeNeedleColor.MyColor; this.aGauge1.NeedleColor2 = System.Drawing.Color.Lavender; this.aGauge1.NeedleRadius = 35; this.aGauge1.NeedleType = System.Windows.Forms.NeedleType.Advance; this.aGauge1.NeedleWidth = 2; this.aGauge1.ScaleLinesInterColor = System.Drawing.Color.Transparent; this.aGauge1.ScaleLinesInterInnerRadius = 61; this.aGauge1.ScaleLinesInterOuterRadius = 63; this.aGauge1.ScaleLinesInterWidth = 5; this.aGauge1.ScaleLinesMajorColor = System.Drawing.Color.FromArgb(((int)(((byte)(118)))), ((int)(((byte)(177)))), ((int)(((byte)(201))))); this.aGauge1.ScaleLinesMajorInnerRadius = 54; this.aGauge1.ScaleLinesMajorOuterRadius = 57; this.aGauge1.ScaleLinesMajorStepValue = 1F; this.aGauge1.ScaleLinesMajorWidth = 1; this.aGauge1.ScaleLinesMinorColor = System.Drawing.Color.FromArgb(((int)(((byte)(118)))), ((int)(((byte)(177)))), ((int)(((byte)(201))))); this.aGauge1.ScaleLinesMinorInnerRadius = 61; this.aGauge1.ScaleLinesMinorOuterRadius = 62; this.aGauge1.ScaleLinesMinorTicks = 2; this.aGauge1.ScaleLinesMinorWidth = 1; this.aGauge1.ScaleNumbersColor = System.Drawing.Color.FromArgb(((int)(((byte)(119)))), ((int)(((byte)(177)))), ((int)(((byte)(206))))); this.aGauge1.ScaleNumbersFormat = null; this.aGauge1.ScaleNumbersRadius = 48; this.aGauge1.ScaleNumbersRotation = 0; this.aGauge1.ScaleNumbersStartScaleLine = 1; this.aGauge1.ScaleNumbersStepScaleLines = 2; this.aGauge1.Size = new System.Drawing.Size(554, 338); this.aGauge1.TabIndex = 0; this.aGauge1.Text = "aGauge1"; this.aGauge1.Value = 0F; this.aGauge1.ValueChanged += new System.EventHandler(this.aGauge1_ValueChanged); this.aGauge1.ValueInRangeChanged += new System.EventHandler<System.Windows.Forms.ValueInRangeChangedEventArgs>(this.aGauge1_ValueInRangeChanged);
System.Windows.Forms.AGaugeLabel aGaugeLabel1 = new System.Windows.Forms.AGaugeLabel(); System.Windows.Forms.AGaugeRange aGaugeRange1 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange2 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange3 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange4 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange5 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange6 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange7 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange8 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange9 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange10 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange11 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange12 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange13 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange14 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange15 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange16 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange17 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange18 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange19 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange20 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange21 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange22 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange23 = new System.Windows.Forms.AGaugeRange(); System.Windows.Forms.AGaugeRange aGaugeRange24 = new System.Windows.Forms.AGaugeRange();
private System.Windows.Forms.AGauge aGauge1;
关于修改的指针颜色代码:AGauge.cs中修改AGaugeNeedleColor
public enum AGaugeNeedleColor { Gray = 0, Red = 1, Green = 2, Blue = 3, Yellow = 4, Violet = 5, Magenta = 6, MyColor=7 //新添加的颜色 };
switch (m_NeedleColor1) { case AGaugeNeedleColor.MyColor: // 新添加的颜色设置 clr1 = Color.FromArgb(114 + subcol, 76 + subcol, 130 + subcol); clr2 = Color.FromArgb(214 - subcol, 176 - subcol, 231 - subcol); clr3 = Color.FromArgb(114 + subcol2, 76 + subcol2, 130 + subcol2); clr4 = Color.FromArgb(214 - subcol2, 176 - subcol2, 231 - subcol2); e.Graphics.DrawEllipse(Pens.BlueViolet, center.X - needleWidth * 3, center.Y - needleWidth * 3, needleWidth * 6, needleWidth * 6); break; case AGaugeNeedleColor.Gray: clr1 = Color.FromArgb(80 + subcol, 80 + subcol, 80 + subcol); clr2 = Color.FromArgb(180 - subcol, 180 - subcol, 180 - subcol); clr3 = Color.FromArgb(80 + subcol2, 80 + subcol2, 80 + subcol2); clr4 = Color.FromArgb(180 - subcol2, 180 - subcol2, 180 - subcol2); e.Graphics.DrawEllipse(Pens.Gray, center.X - needleWidth * 3, center.Y - needleWidth * 3, needleWidth * 6, needleWidth * 6); break; }
重新加载之后属性中就会出现自己新加的颜色:
demo源码链接:https://pan.baidu.com/s/1Z_aMAzWmrdjQfY7RyyvJlA 提取码:kpvt