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:
C# |
コードのコピー
|
---|---|
//C1Gauageを作成します。 C1Gauge gauge = new C1Gauge(); gauge.Dock = DockStyle.Fill; //フォームにコントロールを追加します。 Controls.Add(gauge); |
C# |
コードのコピー
|
---|---|
//放射状ゲージを作成します。 C1RadialGauge radialGauge = new C1RadialGauge(); //c1gaugeに放射状ゲージを追加します。 gauge.Gauges.Add(radialGauge); |
C# |
コードのコピー
|
---|---|
//フェイスの形状を追加します。 //楕円を追加してゲージの背景を作成します。 C1GaugeEllipse ellipse = new C1GaugeEllipse(); //枠線を設定します。 ellipse.Border.Thickness = 5; ellipse.Border.Color = Color.SkyBlue; //塗りつぶしを設定します。 ellipse.Filling.Color = Color.AliceBlue; |
C# |
コードのコピー
|
---|---|
//キャプションを追加します。 C1GaugeCaption caption = new C1GaugeCaption(); caption.Text = "C1Gauge Sample"; caption.Color = Color.Gray; caption.CenterPointY = 0.85; caption.FontSize = 10; |
C# |
コードのコピー
|
---|---|
radialGauge.FaceShapes.Add(ellipse); radialGauge.FaceShapes.Add(caption); |
C# |
コードのコピー
|
---|---|
//デコレータを追加します。 //範囲を作成してカスタマイズします。 C1GaugeRange range = new C1GaugeRange(); range.Width = 2; range.Location = 95; range.Alignment = C1GaugeAlignment.In; range.Border.Color = Color.Gray; range.Filling.Color = Color.Gray; //マークを作成してカスタマイズします。 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; //ラベルを作成してカスタマイズします。 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); |
C# |
コードのコピー
|
---|---|
//キャップとポインタをカスタマイズします。
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.