■ 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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
using System; using System.Drawing; using DevExpress.XtraEditors; using DevExpress.XtraGauges.Core.Base; using DevExpress.XtraGauges.Core.Model; using DevExpress.XtraGauges.Win.Gauges.Circular; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 아크 스케일 상태 지시자 컴포넌트 1 /// </summary> private ArcScaleStateIndicatorComponent arcScaleStateIndicatorComponent1; /// <summary> /// 아크 스케일 상태 지시자 컴포넌트 2 /// </summary> private ArcScaleStateIndicatorComponent arcScaleStateIndicatorComponent2; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); #region 아크 스케일 상태 지시자 컴포넌트 1을 설정한다. this.arcScaleStateIndicatorComponent1 = new ArcScaleStateIndicatorComponent(); this.arcScaleStateIndicatorComponent1.Name = "arcScaleStateIndicatorComponent1"; this.arcScaleStateIndicatorComponent1.IndicatorScale = this.arcScaleComponent1; this.arcScaleStateIndicatorComponent1.Center = new PointF2D(125f, 225f); this.arcScaleStateIndicatorComponent1.Size = new SizeF(25f, 25f); this.arcScaleStateIndicatorComponent1.ZOrder = -100; this.circularGauge.Indicators.Add(this.arcScaleStateIndicatorComponent1); #endregion #region 스케일 지시자 상태 1을 설정한다. ScaleIndicatorState scaleIndicatorState1 = new ScaleIndicatorState(); scaleIndicatorState1.Name = "scaleIndicatorState1"; scaleIndicatorState1.ShapeType = StateIndicatorShapeType.ElectricLight4; scaleIndicatorState1.StartValue = 0f; scaleIndicatorState1.IntervalLength = 50f; this.arcScaleStateIndicatorComponent1.States.Add(scaleIndicatorState1); #endregion #region 스케일 지시자 상태 2를 설정한다. ScaleIndicatorState scaleIndicatorState2 = new ScaleIndicatorState(); scaleIndicatorState2.Name = "scaleIndicatorState2"; scaleIndicatorState2.ShapeType = StateIndicatorShapeType.ElectricLight3; scaleIndicatorState2.StartValue = 50f; scaleIndicatorState2.IntervalLength = 30f; this.arcScaleStateIndicatorComponent1.States.Add(scaleIndicatorState2); #endregion #region 스케일 지시자 상태 3을 설정한다. ScaleIndicatorState scaleIndicatorState3 = new ScaleIndicatorState(); scaleIndicatorState3.Name = "scaleIndicatorState3"; scaleIndicatorState3.ShapeType = StateIndicatorShapeType.ElectricLight2; scaleIndicatorState3.StartValue = 80f; scaleIndicatorState3.IntervalLength = 20f; this.arcScaleStateIndicatorComponent1.States.Add(scaleIndicatorState3); #endregion #region 아크 스케일 상태 지시자 컴포넌트 2를 설정한다. this.arcScaleStateIndicatorComponent2 = new ArcScaleStateIndicatorComponent(); this.arcScaleStateIndicatorComponent2.Name = "arcScaleStateIndicatorComponent2"; this.arcScaleStateIndicatorComponent2.IndicatorScale = this.arcScaleComponent2; this.arcScaleStateIndicatorComponent2.Center = new PointF2D(125f, 190f); this.arcScaleStateIndicatorComponent2.Size = new SizeF(25f, 25f); this.arcScaleStateIndicatorComponent2.ZOrder = -100; this.circularGauge.Indicators.Add(this.arcScaleStateIndicatorComponent2); #endregion #region 스케일 지시자 상태 4를 설정한다. ScaleIndicatorState scaleIndicatorState4 = new ScaleIndicatorState(); scaleIndicatorState4.Name = "scaleIndicatorState4"; scaleIndicatorState4.ShapeType = StateIndicatorShapeType.ElectricLight4; scaleIndicatorState4.StartValue = 0f; scaleIndicatorState4.IntervalLength = 700F; this.arcScaleStateIndicatorComponent2.States.Add(scaleIndicatorState4); #endregion #region 스케일 지시자 상태 5를 설정한다. ScaleIndicatorState scaleIndicatorState5 = new ScaleIndicatorState(); scaleIndicatorState5.Name = "scaleIndicatorState5"; scaleIndicatorState5.ShapeType = StateIndicatorShapeType.ElectricLight3; scaleIndicatorState5.StartValue = 700f; scaleIndicatorState5.IntervalLength = 200f; this.arcScaleStateIndicatorComponent2.States.Add(scaleIndicatorState5); #endregion #region 스케일 지시자 상태 6을 설정한다. ScaleIndicatorState scaleIndicatorState6 = new ScaleIndicatorState(); scaleIndicatorState6.Name = "scaleIndicatorState6"; scaleIndicatorState6.ShapeType = StateIndicatorShapeType.ElectricLight2; scaleIndicatorState6.StartValue = 900f; scaleIndicatorState6.IntervalLength = 100f; this.arcScaleStateIndicatorComponent2.States.Add(scaleIndicatorState6); #endregion this.trackBarControl1.EditValueChanged += trackBarControl1_EditValueChanged; this.trackBarControl2.EditValueChanged += trackBarControl2_EditValueChanged; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 트랙바 컨트롤 1 편집 값 변경시 처리하기 - trackBarControl1_EditValueChanged(sender, e) /// <summary> /// 트랙바 컨트롤 1 편집 값 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void trackBarControl1_EditValueChanged(object sender, EventArgs e) { float value = Convert.ToSingle(this.trackBarControl1.EditValue); this.arcScaleComponent1.Value = value; this.arcScaleNeedleComponent1.Value = value; } #endregion #region 트랙바 컨트롤 2 편집 값 변경시 처리하기 - trackBarControl2_EditValueChanged(sender, e) /// <summary> /// 트랙바 컨트롤 2 편집 값 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void trackBarControl2_EditValueChanged(object sender, EventArgs e) { float value = Convert.ToSingle(this.trackBarControl2.EditValue); this.arcScaleComponent2.Value = value; this.arcScaleNeedleComponent2.Value = value; } #endregion } } |