一个代码示例
前面已经介绍了Marks,Labels和Range。
Foxtable提供了三种对象,GaugeMarks、GaugeLabels和GaugeRange,分别用于表示Marks,Labels和Range。
本节用一个示例演示如何通过代码增加和设置arks,Labels和Range,要生成的仪表如下:
首先在窗口中增加一个Gauges控件,并给其增加一个空白的径向仪表,然后增加一个按钮来运行下面的代码:
Dim
rg
As
RadialGauge = e.Form.Controls("Guages1").RadialGauge
'设置仪表布局
rg.PointerOriginY =
0.73
rg.Radius =
0.65
rg.StartAngle =
-90
rg.SweepAngle =
180
rg.Viewport.AspectRatio =
1.5
'增加一个Marks作为主刻度,刻度间隔为20
Dim
mks
As
New
GaugeMarks()
mks.Location =
90
mks.Alignment = C1.Win.C1Gauge.C1GaugeAlignment.In
mks.Interval =
20
mks.Length =
13
mks.Width =
1.5
mks.Border.LineStyle = C1.Win.C1Gauge.C1GaugeBorderStyle.None
mks.Filling.Color = Color.Black
rg.Decorators.Add(mks)
'增加一个Marks作为副刻度,刻度间隔为5
mks =
New
GaugeMarks()
mks.Location =
87
mks.Alignment = C1.Win.C1Gauge.C1GaugeAlignment.In
mks.Interval =
5
mks.Length =
9
mks.Width =
1
mks.Border.LineStyle = C1.Win.C1Gauge.C1GaugeBorderStyle.None
mks.Filling.Color = Color.Black
mks.Filling.Opacity =
0.5
'透明度50%
rg.Decorators.Add(mks)
'增加一个Labels
Dim
lbs
As
New
GaugeLabels()
lbs.Location =
61
lbs.Alignment = C1.Win.C1Gauge.C1GaugeAlignment.Out
lbs.Interval =
20
lbs.Color = Color.Black
lbs.FontSize =
10
lbs.IsRotated =
True
rg.Decorators.Add(lbs)
'增加一个Range
Dim
rng
As
New
GaugeRange()
rng.Location =
60
rng.Alignment = C1.Win.C1Gauge.C1GaugeAlignment.In
rng.From =
50
rng.To =
100
rng.Width =
0
rng.Width2 =
20
rng.Border.LineStyle = C1.Win.C1Gauge.C1GaugeBorderStyle.None
rng.Filling.BrushType = C1.Win.C1Gauge.C1GaugeBrushType.Gradient
rng.Filling.Color = Color.Transparent
rng.Filling.Color2 = Color.FromArgb(255,
128,
128)
rg.Decorators.Add(rng)
'增加一个Sector作为仪表轮廓
Dim
sc
As
New
GaugeSector()
sc.OuterRadius =
102
sc.CenterRadius =
12
sc.InnerRadius =
-25
sc.CornerRadius
= 5
sc.StartAngle =
-90
sc.SweepAngle =
180
sc.Border.Color = Color.Gray
sc.Filling.BrushType = C1.Win.C1Gauge.C1GaugeBrushType.Gradient
sc.Filling.Color = Color.LightGray
sc.Filling.Color2 = Color.White
rg.FaceShapes.Add(sc)
'设置指针
rg.Pointer.Value =
88
rg.Pointer.SweepTime =
2
rg.Pointer.Length =
80
rg.Pointer.Offset =
0
rg.Pointer.Shape = C1.Win.C1Gauge.C1GaugePointerShape.Triangle
rg.Pointer.Width =
12
rg.Pointer.Border.Color = Color.Coral
rg.Pointer.Filling.Color = Color.Coral
'设置指针帽
rg.Cap.Radius =
15
rg.Cap.Border.Color = Color.LightGray
rg.Cap.Filling.BrushType = C1.Win.C1Gauge.C1GaugeBrushType.Gradient
rg.Cap.Filling.Color = Color.WhiteSmoke
rg.Cap.Filling.Color2 = Color.DarkGray
rg.cap.Gradient.Direction = C1.Win.C1Gauge.C1GaugeGradientDirection.RadialInner