■ 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 |
using System.Drawing; using DevExpress.XtraEditors; using DevExpress.XtraEditors.Controls; using DevExpress.XtraGauges.Core.Base; using DevExpress.XtraGauges.Core.Drawing; using DevExpress.XtraGauges.Core.Model; using DevExpress.XtraGauges.Win; using DevExpress.XtraGauges.Win.Gauges.Linear; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); #region 게이지 컨트롤을 설정한다. GaugeControl gaugeControl = new GaugeControl(); gaugeControl.Name = "gaugeControl"; gaugeControl.Parent = this; gaugeControl.Location = new Point(50, 50); gaugeControl.Size = new Size(260, 260); gaugeControl.BorderStyle = BorderStyles.NoBorder; gaugeControl.BackColor = Color.Transparent; #endregion #region 선형 게이지를 설정한다. LinearGauge linearGauge = new LinearGauge(); linearGauge.Name = "linearGauge"; linearGauge.Bounds = new Rectangle(5, 5, 255, 255); gaugeControl.Gauges.Add(linearGauge); #endregion #region 선형 스케일 컴포넌트를 설정한다. LinearScaleComponent linearScaleComponent = new LinearScaleComponent(); linearScaleComponent.Name = "linearScaleComponent"; linearScaleComponent.AppearanceTickmarkText.Font = new Font("Tahoma", 10f); linearScaleComponent.AppearanceTickmarkText.TextBrush = new SolidBrushObject("Color:White"); linearScaleComponent.MajorTickCount = 7; linearScaleComponent.MajorTickmark.FormatString = "{0:F0}"; linearScaleComponent.MajorTickmark.ShapeOffset = 6f; linearScaleComponent.MajorTickmark.ShapeType = TickmarkShapeType.Linear_Style7_3; linearScaleComponent.MajorTickmark.TextOffset = 35f; linearScaleComponent.MinorTickCount = 4; linearScaleComponent.MinorTickmark.ShapeOffset = 6f; linearScaleComponent.MinorTickmark.ShapeType = TickmarkShapeType.Linear_Style7_2; linearScaleComponent.EndPoint = new PointF2D(62.5f, 33f ); linearScaleComponent.StartPoint = new PointF2D(62.5f, 217f); linearScaleComponent.MaxValue = 60f; linearScaleComponent.MinValue = -60f; linearScaleComponent.Value = 10f; linearGauge.Scales.Add(linearScaleComponent); #endregion #region 선형 스케일 레벨 컴포넌트를 설정한다. LinearScaleLevelComponent linearScaleLevelComponent = new LinearScaleLevelComponent(); linearScaleLevelComponent.Name = "linearScaleLevelComponent"; linearScaleLevelComponent.LinearScale = linearScaleComponent; linearScaleLevelComponent.ShapeType = LevelShapeSetType.Style7; linearScaleLevelComponent.ZOrder = -50; linearGauge.Levels.Add(linearScaleLevelComponent); #endregion #region 선형 스케일 범위 1을 설정한다. LinearScaleRange linearScaleRange1 = new LinearScaleRange(); linearScaleRange1.Name = "linearScaleRange1"; linearScaleRange1.AppearanceRange.ContentBrush = new SolidBrushObject("Color:DeepSkyBlue"); linearScaleRange1.ShapeOffset = -20f; linearScaleRange1.StartValue = -60f; linearScaleRange1.EndValue = 0f; linearScaleComponent.Ranges.Add(linearScaleRange1); #endregion #region 선형 스케일 범위 2를 설정한다. LinearScaleRange linearScaleRange2 = new LinearScaleRange(); linearScaleRange2.Name = "Range1"; linearScaleRange2.AppearanceRange.ContentBrush = new SolidBrushObject("Color:DarkOrange"); linearScaleRange2.ShapeOffset = -20F; linearScaleRange2.StartValue = 0f; linearScaleRange2.EndValue = 60f; linearScaleComponent.Ranges.Add(linearScaleRange2); #endregion #region 선형 스케일 배경 레이어 컴포넌트를 설정한다. LinearScaleBackgroundLayerComponent linearScaleBackgroundLayerComponent = new LinearScaleBackgroundLayerComponent(); linearScaleBackgroundLayerComponent.Name = "linearScaleBackgroundLayerComponent"; linearScaleBackgroundLayerComponent.LinearScale = linearScaleComponent; linearScaleBackgroundLayerComponent.ScaleEndPos = new PointF2D(0.497f, 0.135f); linearScaleBackgroundLayerComponent.ScaleStartPos = new PointF2D(0.497f, 0.865f); linearScaleBackgroundLayerComponent.ShapeType = BackgroundLayerShapeType.Linear_Style7; linearScaleBackgroundLayerComponent.ZOrder = 1000; linearGauge.BackgroundLayers.Add(linearScaleBackgroundLayerComponent); #endregion } #endregion } } |