infra 仪表盘效果

private void Gauge2()
{
// Infragistics.WebUI.UltraWebGauge.UltraGauge ultraGauge2 =
//new Infragistics.WebUI.UltraWebGauge.UltraGauge();

RadialGauge myRadialGauge = new RadialGauge();
RadialGaugeScale myScale = new RadialGaugeScale();
NumericAxis numericAxis1 = new NumericAxis();
RadialGaugeNeedle myNeedle = new RadialGaugeNeedle();
SolidFillBrushElement mySolidFillBrushElement = new SolidFillBrushElement();
SolidFillBrushElement mySolidFillBrushElementMajor =
new SolidFillBrushElement();
SolidFillBrushElement mySolidFillBrushElementMinor =
new SolidFillBrushElement();
SolidFillBrushElement mySolidFillBrushElementMinorStroke =
new SolidFillBrushElement();
StrokeElement myStrokeElement = new StrokeElement();
SolidFillBrushElement mySolidFillBrushElement2 = new SolidFillBrushElement();
SimpleGradientBrushElement mySimpleGradientBrushElement =
new SimpleGradientBrushElement();
SolidFillBrushElement mySolidFillBrushElement1 = new SolidFillBrushElement();
mySolidFillBrushElement.Color = System.Drawing.Color.Black;
myRadialGauge.Dial.BrushElement = mySolidFillBrushElement;
myRadialGauge.Margin = new Margin(10, 10, 10, 10, Measure.Pixels);
//Set the following Axis properties and add the Axis to your scale:
numericAxis1.EndValue = 120; //仪盘表最大数值
myScale.Axes.Add(numericAxis1);
//Set the following Scale properties
myScale.EndAngle = 405;
myScale.StartAngle = 135;

mySolidFillBrushElement1.Color = System.Drawing.Color.White;
myScale.Labels.BrushElement = mySolidFillBrushElement1;

//Set the following Label properties
myScale.Labels.Extent = 65;
myScale.Labels.Font =
new System.Drawing.Font("Arial", 14F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
myScale.Labels.Frequency = 20;//大间隔显示数值:0 20 40 60
myScale.Labels.Orientation =
Infragistics.UltraGauge.Resources.RadialLabelOrientation.Horizontal;
myScale.Labels.SpanMaximum = 18;

//Set the following major Tickmark properties:
mySolidFillBrushElementMajor.Color =
System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))),
((int)(((byte)(189)))));
myScale.MajorTickmarks.BrushElement = mySolidFillBrushElementMajor;
myScale.MajorTickmarks.EndExtent = 95;
myScale.MajorTickmarks.EndWidth = 3;
myScale.MajorTickmarks.Frequency = 10; //大间隔显示频率
myScale.MajorTickmarks.StartExtent = 85;
myScale.MajorTickmarks.StartWidth = 3;

//Set the following minor Tickmark properties:
mySolidFillBrushElementMinor.Color =
System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))),
((int)(((byte)(240)))));
myScale.MinorTickmarks.BrushElement = mySolidFillBrushElementMinor;
myScale.MinorTickmarks.EndExtent = 90;
myScale.MinorTickmarks.EndWidth = 1;
myScale.MinorTickmarks.Frequency = 2;
//小间隔频率=myScale.MajorTickmarks.Frequency/myScale.MinorTickmarks.Frequency=10/2=5
myScale.MinorTickmarks.StartExtent = 85;
mySolidFillBrushElementMinorStroke.Color =
System.Drawing.Color.FromArgb(((int)(((byte)(135)))), ((int)(((byte)(135)))),
((int)(((byte)(135)))));
myStrokeElement.BrushElement = mySolidFillBrushElementMinorStroke;
myScale.MinorTickmarks.StrokeElement = myStrokeElement;

//Set the following Anchor properties:
myNeedle.Anchor.BrushElement = mySimpleGradientBrushElement;
mySimpleGradientBrushElement.EndColor = System.Drawing.Color.WhiteSmoke;
mySimpleGradientBrushElement.GradientStyle =
Infragistics.UltraGauge.Resources.Gradient.BackwardDiagonal;
mySimpleGradientBrushElement.StartColor = System.Drawing.Color.Gray;
myNeedle.Anchor.RadiusMeasure =
Infragistics.UltraGauge.Resources.Measure.Percent;

//设置指针属性
mySolidFillBrushElement2.Color = System.Drawing.Color.Red;
myNeedle.BrushElement = mySolidFillBrushElement2;
myNeedle.EndExtent = 65;
myNeedle.EndWidth = 1;
myNeedle.MidExtent = 0;
myNeedle.MidWidth = 3;
myNeedle.Precision = 1;
myNeedle.StartExtent = -20;
myNeedle.StartWidth = 3;
myNeedle.Value = int.Parse(TextBox2.Text.Trim());//指针显示值
myNeedle.WidthMeasure = Measure.Percent;
myScale.Markers.Add(myNeedle);


myRadialGauge.Scales.Add(myScale);
UltraGauge2.Gauges.Add(myRadialGauge);
//图形的大小
UltraGauge2.Height = Unit.Pixel(200);
UltraGauge2.Width = Unit.Pixel(200);

//显示文本框
BoxAnnotation boxAnnotation1 = new BoxAnnotation();
SolidFillBrushElement solidFillBrushElement1 = new SolidFillBrushElement();
SolidFillBrushElement solidFillBrushElement2 = new SolidFillBrushElement();
boxAnnotation1.Bounds = new System.Drawing.Rectangle(38, 70, 25, 10);
boxAnnotation1.BoundsMeasure = Infragistics.UltraGauge.Resources.Measure.Percent;
solidFillBrushElement2.Color = System.Drawing.Color.White;
boxAnnotation1.Label.BrushElement = solidFillBrushElement2;
boxAnnotation1.Label.FormatString = "Speed";
this.UltraGauge2.Annotations.Add(boxAnnotation1);


this.Controls.Add(UltraGauge2);

---------------------
作者:厦门德仔
来源:CSDN
原文:https://blog.csdn.net/david_520042/article/details/7394188
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自www.cnblogs.com/qiu18359243869/p/9859233.html