Imports Infragistics.UltraGauge.Resources
This tutorial walks you through the process of creating a Digital gauge using code. At the end of this walkthrough, you will have created a Digital gauge that represents a digital radio.
To create a Digital gauge using code:
Before you start writing any code, you should place using/Imports directives in your code-behind so you don’t need to always type out a member’s fully qualified name.
In Visual Basic:
Imports Infragistics.UltraGauge.Resources
In C#:
using Infragistics.UltraGauge.Resources;
Create an instance of a Digital gauge and the brush element instances.
In Visual Basic:
Dim ultraGauge1 As New Infragistics.WebUI.UltraWebGauge.UltraGauge() Dim myDigitalGauge As New SegmentedDigitalGauge() Dim mySolidFillBrushElement As New SolidFillBrushElement() Dim mySolidFillBrushElement1 As New SolidFillBrushElement()
In C#:
Infragistics.Web.UltraWebGauge.UltraGauge ultraGauge1 = new Infragistics.WebUI.UltraWebGauge.UltraGauge(); SegmentedDigitalGauge myDigitalGauge = new SegmentedDigitalGauge(); SolidFillBrushElement mySolidFillBrushElement = new SolidFillBrushElement(); SolidFillBrushElement mySolidFillBrushElement1 = new SolidFillBrushElement();
Set the background color to Black.
In Visual Basic:
mySolidFillBrushElement.Color = System.Drawing.Color.Black myDigitalGauge.BrushElement = mySolidFillBrushElement
In C#:
mySolidFillBrushElement.Color = System.Drawing.Color.Black; myDigitalGauge.BrushElement = mySolidFillBrushElement;
Set the number of digits.
In Visual Basic:
myDigitalGauge.Digits = 8
In C#:
myDigitalGauge.Digits = 8;
Set the font color to Red.
In Visual Basic:
mySolidFillBrushElement1.Color = System.Drawing.Color.Red myDigitalGauge.FontBrushElement = mySolidFillBrushElement1
In C#:
mySolidFillBrushElement1.Color = System.Drawing.Color.Red; myDigitalGauge.FontBrushElement = mySolidFillBrushElement1;
Set the mode to 14-segment and the digit text to FM : 96.4.
In Visual Basic:
myDigitalGauge.Mode = SegmentMode.FourteenSegment myDigitalGauge.Text = "FM : 96.4"
In C#:
myDigitalGauge.Mode = SegmentMode.FourteenSegment; myDigitalGauge.Text = "FM : 96.4";
Add the Digital gauge to the Gauges collection. Set the following properties for your gauge:
Width = 200
Height = 200
In Visual Basic:
ultraGauge1.Gauges.Add(myDigitalGauge) ultraGauge1.Width = Unit.Pixel(200) ultraGauge1.Height = Unit.Pixel(200) Me.Controls.Add(ultraGauge1)
In C#:
ultraGauge1.Gauges.Add(myDigitalGauge); ultraGauge1.Width = Unit.Pixel(200); ultraGauge1.Height = Unit.Pixel(200); this.Controls.Add(ultraGauge1);
Save and your web page.