[]
In this section you'll learn how to use the basic Gauges for WinForms functionality to create a simple application with a custom gauge control. This section is not intended to be a comprehensive tutorial of all features of Gauges for WinForms, but rather provide a quick introduction and highlight some general approaches to using the product.
In the following quick start guide, you'll create an application, add a gauge control to the application, and customize the appearance of the control.
Let's say the user wants to create a radial gauge for a car dashboard just like given in the snapshot below. The Gauge control provides various classes and properties to customize the control.
To create a WinForms application in .NET for Gauge control, complete the following steps:
Create a new Windows Forms application.
Switch to code view. Create a Gauge and add it to the form.
//create a C1 guage
C1Gauge gauge = new C1Gauge();
gauge.Dock = DockStyle.Fill;
// Add the control to form
Controls.Add(gauge);
Create a Radial Gauge and add it to the Gauge control using the Add method of GaugeCollection class.
//create a radial guage
C1RadialGauge radialGauge = new C1RadialGauge();
// Add the radial gauge to the c1gauge
gauge.Gauges.Add(radialGauge);
Add ellipse shape to create the background for Gauge. Set the border and fill color.
//add faceshapes
//add an ellipse to create the gauge background
C1GaugeEllipse ellipse = new C1GaugeEllipse();
//set border
ellipse.Border.Thickness = 5;
ellipse.Border.Color = Color.SkyBlue;
//set fill
ellipse.Filling.Color = Color.AliceBlue;
Add a caption for the Gauge.
//add a caption
C1GaugeCaption caption = new C1GaugeCaption();
caption.Text = "C1Gauge Sample";
caption.Color = Color.Gray;
caption.CenterPointY = 0.85;
caption.FontSize = 10;
Add the ellipse and caption using the FaceShapes property.
radialGauge.FaceShapes.Add(ellipse);
radialGauge.FaceShapes.Add(caption);
Add decorators, namely range, marks and labels, customize them and add them to the Radial Gauge using the Decorators property.
//add decorators
//create and customize Range
C1GaugeRange range = new C1GaugeRange();
range.Width = 2;
range.Location = 95;
range.Alignment = C1GaugeAlignment.In;
range.Border.Color = Color.Gray;
range.Filling.Color = Color.Gray;
//create and customize Marks
C1GaugeMarks marks = new C1GaugeMarks();
marks.Width = 4;
marks.Length = 9;
marks.Interval = 10;
marks.Location = 95;
marks.Alignment = C1GaugeAlignment.In;
marks.Border.Color = Color.Gray;
marks.Filling.Color = Color.Gray;
//create and customze labels
C1GaugeLabels labels = new C1GaugeLabels();
labels.Interval = 10;
labels.Location = 80;
labels.Color = Color.Gray;
radialGauge.Decorators.Add(labels);
radialGauge.Decorators.Add(marks);
radialGauge.Decorators.Add(range);
Fill color in Pointer and Cap.
//customize cap and pointer
radialGauge.Pointer.Filling.Color = Color.LightGoldenrodYellow;
radialGauge.Cap.Filling.Color = Color.Gray;
In this step you'll create a simple application using the C1Gauge control. You'll then customize the appearance of your application in Design view without adding any code to your project.
To begin, complete the following steps:
What You've Accomplished
In this step you created an application and added a C1Gauge control to the form. The gauge is currently displayed with default settings; in the next step you'll further customize the appearance of the control.
In the last step you created new application and added a C1Gauge control to the form. In this step you'll customize the gauge by using the Gauges for WinForms designers.
To customize the C1Gauge control, complete the following steps:
Adding Tick Marks
Adding Tick Labels
Customize the Pointer, Cap, Ellipse and Caption
What You've Accomplished
You've customized the appearance of the C1Gauge control. Next you will run the application.
In the previous steps you've created a new application, added a C1Gauge control to the form, and customized the control. All that's left is to run the application!
Select Debug | Start Debugging from the Visual Studio menu.
What You've Accomplished
Congratulations! You have successfully created a C1Gauge control. There are many templates you can apply to your gauge. See Gauges for WinForms Appearance for more information.
type=note
Note: The latest version of WinForms .NET Edition does not include rich design-time support yet. We will enhance it in the future releases.