代码与指针

本节提供一个示例,目的是用代码实现下图中的三个指针:

你可以从仪表库中加载这个仪表,然后删除这三个指针,在运行本节的测试代码。

需要注意的是,由于Foxtable的代码编辑器能自动列出属性名和枚举值,所以这节的代码我是照着模板写的,完全没有伤一点脑细胞,例如Second指针的模板为:

<pointer name="seconds" value="17" offset="-25" length="115" shape="Round" width="2">
   <border lineStyle="None" />
   <filling color="DarkSeaGreen" />
   <shadow visible="True" />
</pointer>

直接照着模板写代码,就能写出:

Dim sp As New GaugePointer
sp.Name =
"seconds"
sp.Value = 17
sp.Offset = -25
sp.Length = 115
sp.Shape = C1.Win.C1Gauge.C1GaugePointerShape.Round
sp.Width = 2
sp.Border.LineStyle = C1.Win.C1Gauge.C1GaugeBorderStyle.None
sp.Filling.Color = Color.DarkSeaGreen
sp.Shadow.Visible =
True
rg.MorePointers.Add(sp)

完整的代码如下:

Dim rg As RadialGauge = e.Form.Controls("Guages1").RadialGauge
rg.Pointer.Visible =
False '隐藏主指针
'
增加Second指针
Dim
sp As New GaugePointer
sp.Name =
"seconds"
sp.Value = 17
sp.Offset = -25
sp.Length = 115
sp.Shape = C1.Win.C1Gauge.C1GaugePointerShape.Round
sp.Width = 2
sp.Border.LineStyle = C1.Win.C1Gauge.C1GaugeBorderStyle.None
sp.Filling.Color = Color.DarkSeaGreen
sp.Shadow.Visible =
True
rg.MorePointers.Add(sp)

'
增加Minute指针
Dim
MinutePointer As New GaugePointer
With
MinutePointer
    .Name =
"minutes"
    .Value = 22.3
    .Length = 94
    .Offset = -15
    .Shape = C1.Win.C1Gauge.C1GaugePointerShape.Custom
    .CustomShape.StartWidth = 9
    .CustomShape.EndWidth = 3.9
    .CustomShape.StartRadius = 2.6
    .CustomShape.EndRadius = 1.93
    .Border.Color = Color.DarkGray
    .Filling.BrushType = C1.Win.C1Gauge.C1GaugeBrushType.Gradient
    .Filling.Color = Color.MistyRose
    .Filling.Color2 = Color.DarkGray
    .Shadow.Visible =
True
End
With
rg.MorePointers.Add(MinutePointer)

'
增加Hour指针
Dim
hp As New GaugePointer()
hp.Name =
"hours"
hp.ValueOffset = 5
hp.Value = 0.42
hp.Length = 63
hp.Offset = -15
hp.Shape = C1.Win.C1Gauge.C1GaugePointerShape.Custom
hp.CustomShape.StartSwellWidth = 9
hp.CustomShape.EndWidth = 3.9
hp.CustomShape.StartRadius = 2.6
hp.CustomShape.EndRadius = 1.9
hp.Border.Color = Color.DarkGray
hp.Filling.BrushType = C1.Win.C1Gauge.C1GaugeBrushType.Gradient
hp.Filling.Color = Color.MistyRose
hp.Filling.Color2 = Color.DimGray
hp.Shadow.Visible =
True
rg.MorePointers.Add(hp)


本页地址:http://www.foxtable.com/webhelp/topics/3924.htm