■ GaugeControl 클래스를 사용해 환형 게이지를 동적 생성하는 방법을 보여준다.
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
using System.Drawing; using DevExpress.XtraEditors; using DevExpress.XtraEditors.Controls; using DevExpress.XtraGauges.Win; using DevExpress.XtraGauges.Win.Gauges.Circular; using DevExpress.XtraGauges.Core.Model; using DevExpress.XtraGauges.Core.Drawing; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); #region 게이지 컨트롤을 설정한다. GaugeControl gaugeControl = new GaugeControl(); gaugeControl.Parent = this; gaugeControl.Location = new Point(50, 50); gaugeControl.Size = new Size(400, 400); gaugeControl.BackColor = Color.Transparent; gaugeControl.BorderStyle = BorderStyles.NoBorder; #endregion #region 환형 게이지를 설정한다. CircularGauge circularGauge = gaugeControl.AddCircularGauge(); circularGauge.AddDefaultElements(); #endregion #region 아크 스케일 배경 레이어를 설정한다. ArcScaleBackgroundLayer arcScaleBackgroundLayer = circularGauge.BackgroundLayers[0]; arcScaleBackgroundLayer.ShapeType = BackgroundLayerShapeType.CircularFull_Style3; #endregion #region 아크 스케일 컴포넌트를 설정한다. ArcScaleComponent arcScaleComponent = circularGauge.Scales[0]; arcScaleComponent.MinValue = 0; arcScaleComponent.MaxValue = 100; arcScaleComponent.Value = 25; arcScaleComponent.AppearanceTickmarkText.Font = new Font("Tahoma", 10f); arcScaleComponent.AppearanceTickmarkText.TextBrush = new SolidBrushObject(Color.White); arcScaleComponent.MajorTickCount = 11; arcScaleComponent.MajorTickmark.FormatString = "{0:F0}"; arcScaleComponent.MajorTickmark.ShapeType = TickmarkShapeType.Circular_Style2_2; arcScaleComponent.MajorTickmark.ShapeOffset = -10; arcScaleComponent.MajorTickmark.TextOffset = -20; arcScaleComponent.MajorTickmark.AllowTickOverlap = true; arcScaleComponent.MinorTickCount = 3; arcScaleComponent.MinorTickmark.ShapeType = TickmarkShapeType.Circular_Style2_1; #endregion #region 아크 스케일 바늘 컴포넌트를 설정한다. ArcScaleNeedleComponent arcScaleNeedleComponent = circularGauge.Needles[0]; arcScaleNeedleComponent.ShapeType = NeedleShapeType.CircularFull_Style3; #endregion #region 아크 스케일 스핀들 캡 컴포넌트를 설정한다. ArcScaleSpindleCapComponent arcScaleSpindleCapComponent = arcScaleSpindleCapComponent = new ArcScaleSpindleCapComponent(); arcScaleSpindleCapComponent.Name = "arcScaleSpindleCapComponent"; arcScaleSpindleCapComponent.ArcScale = arcScaleComponent; arcScaleSpindleCapComponent.Size = new SizeF(42F, 42F); arcScaleSpindleCapComponent.ZOrder = -1000; arcScaleSpindleCapComponent.Shader = new OpacityShader(); circularGauge.SpindleCaps.Add(arcScaleSpindleCapComponent); #endregion } #endregion } } |