첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainForm.cs

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.Base;
using DevExpress.XtraGauges.Win.Gauges.Circular;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : XtraForm
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            this.gaugeControl.BorderStyle = BorderStyles.NoBorder;
            this.gaugeControl.BackColor   = Color.Transparent;

            #region 환형 게이지를 설정한다.

            CircularGauge circularGauge = new CircularGauge();

            this.gaugeControl.Gauges.Add(circularGauge);

            #endregion
            #region SMALL 아크 스케일 컴포넌트를 설정한다.

            ArcScaleComponent smallArcScaleComponent = new ArcScaleComponent();

            smallArcScaleComponent.Name                             = "smallArcScaleComponent";
            smallArcScaleComponent.Center                           = new PointF2D(125, 125);
            smallArcScaleComponent.RadiusX                          = 30f;
            smallArcScaleComponent.RadiusY                          = 30f;
            smallArcScaleComponent.StartAngle                       = -240f;
            smallArcScaleComponent.EndAngle                         = 60f;
            smallArcScaleComponent.MaxValue                         = 40f;
            smallArcScaleComponent.MinValue                         = -40f;
            smallArcScaleComponent.Value                            = this.smallTrackBar.Value;
            smallArcScaleComponent.AppearanceTickmarkText.Font      = new Font("Tahoma", 8f);
            smallArcScaleComponent.AppearanceTickmarkText.TextBrush = new SolidBrushObject(Color.Gray);
            smallArcScaleComponent.MajorTickCount                   = 9;
            smallArcScaleComponent.MajorTickmark.FormatString       = "{0:F0}";
            smallArcScaleComponent.MajorTickmark.ShapeScale         = new FactorF2D(0.7f, 0.9f);
            smallArcScaleComponent.MajorTickmark.ShapeType          = TickmarkShapeType.Circular_Style10_4;
            smallArcScaleComponent.MajorTickmark.TextOffset         = 15F;
            smallArcScaleComponent.MajorTickmark.TextOrientation    = LabelOrientation.LeftToRight;
            smallArcScaleComponent.MinorTickCount                   = 4;
            smallArcScaleComponent.MinorTickmark.ShapeScale         = new FactorF2D(0.7f, 0.4f);
            smallArcScaleComponent.MinorTickmark.ShapeType          = TickmarkShapeType.Circular_Style10_2;

            circularGauge.Scales.Add(smallArcScaleComponent);

            #endregion
            #region 내부 BLUE 아크 스케일 범위를 설정한다.

            ArcScaleRange innerBlueArcScaleRange = new ArcScaleRange();

            innerBlueArcScaleRange.AppearanceRange.ContentBrush = new SolidBrushObject(Color.CornflowerBlue);
            innerBlueArcScaleRange.StartValue                   = -40f;
            innerBlueArcScaleRange.EndValue                     = 0f;
            innerBlueArcScaleRange.StartThickness               = 4f;
            innerBlueArcScaleRange.EndThickness                 = 4f;
            innerBlueArcScaleRange.ShapeOffset                  = 0f;

            smallArcScaleComponent.Ranges.Add(innerBlueArcScaleRange);

            #endregion
            #region 내부 YELLOW 아크 스케일 범위를 설정한다.

            ArcScaleRange innerYellowArcScaleRange = new ArcScaleRange();

            innerYellowArcScaleRange.AppearanceRange.ContentBrush = new SolidBrushObject(Color.Khaki);
            innerYellowArcScaleRange.StartValue                   = 0f;
            innerYellowArcScaleRange.EndValue                     = 40f;
            innerYellowArcScaleRange.StartThickness               = 4f;
            innerYellowArcScaleRange.EndThickness                 = 4f;
            innerYellowArcScaleRange.ShapeOffset                  = 0f;

            smallArcScaleComponent.Ranges.Add(innerYellowArcScaleRange);

            #endregion
            #region MEDIUM 아크 스케일 컴포넌트를 설정한다.

            ArcScaleComponent mediumArcScaleComponent = new ArcScaleComponent();

            mediumArcScaleComponent.Name                             = "mediumArcScaleComponent";
            mediumArcScaleComponent.Center                           = new PointF2D(125, 125);
            mediumArcScaleComponent.RadiusX                          = 80f;
            mediumArcScaleComponent.RadiusY                          = 80f;
            mediumArcScaleComponent.StartAngle                       = -240f;
            mediumArcScaleComponent.EndAngle                         = 60f;
            mediumArcScaleComponent.MinValue                         = 720f;
            mediumArcScaleComponent.MaxValue                         = 780f;
            mediumArcScaleComponent.AppearanceTickmarkText.Font      = new Font("Tahoma", 8F);
            mediumArcScaleComponent.AppearanceTickmarkText.TextBrush = new SolidBrushObject(Color.Gray);
            mediumArcScaleComponent.MajorTickCount                   = 7;
            mediumArcScaleComponent.MajorTickmark.FormatString       = "{0:F0}";
            mediumArcScaleComponent.MajorTickmark.ShapeScale         = new FactorF2D(0.7f, 1f);
            mediumArcScaleComponent.MajorTickmark.ShapeType          = TickmarkShapeType.Circular_Style10_4;
            mediumArcScaleComponent.MajorTickmark.TextOffset         = 15F;
            mediumArcScaleComponent.MajorTickmark.TextOrientation    = LabelOrientation.Tangent;
            mediumArcScaleComponent.MinorTickCount                   = 4;
            mediumArcScaleComponent.MinorTickmark.ShapeScale         = new FactorF2D(1.1F, 0.5F);
            mediumArcScaleComponent.MinorTickmark.ShapeType          = TickmarkShapeType.Circular_Style10_2;

            circularGauge.Scales.Add(mediumArcScaleComponent);

            #endregion
            #region LARGE 아크 스케일 컴포넌트를 설정한다.

            ArcScaleComponent largeArcScaleComponent = new ArcScaleComponent();

            largeArcScaleComponent.Name                             = "largeArcScaleComponent";
            largeArcScaleComponent.Center                           = new PointF2D(125, 125);
            largeArcScaleComponent.RadiusX                          = 110f;
            largeArcScaleComponent.RadiusY                          = 110f;
            largeArcScaleComponent.StartAngle                       = -240f;
            largeArcScaleComponent.EndAngle                         = 60f;
            largeArcScaleComponent.MinValue                         = 960f;
            largeArcScaleComponent.MaxValue                         = 1040f;
            largeArcScaleComponent.Value                            = this.largeTrackBar.Value;
            largeArcScaleComponent.AppearanceTickmarkText.Font      = new Font("Tahoma", 8F);
            largeArcScaleComponent.AppearanceTickmarkText.TextBrush = new SolidBrushObject(Color.Gray);
            largeArcScaleComponent.MajorTickCount                   = 9;
            largeArcScaleComponent.MajorTickmark.FormatString       = "{0:F0}";
            largeArcScaleComponent.MajorTickmark.ShapeScale         = new FactorF2D(0.7f, 1f);
            largeArcScaleComponent.MajorTickmark.ShapeType          = TickmarkShapeType.Circular_Style10_4;
            largeArcScaleComponent.MajorTickmark.TextOffset         = 15F;
            largeArcScaleComponent.MajorTickmark.TextOrientation    = LabelOrientation.Tangent;
            largeArcScaleComponent.MinorTickCount                   = 4;
            largeArcScaleComponent.MinorTickmark.ShapeScale         = new FactorF2D(1.1f, 0.5f);
            largeArcScaleComponent.MinorTickmark.ShapeType          = TickmarkShapeType.Circular_Style10_2;

            circularGauge.Scales.Add(largeArcScaleComponent);

            #endregion
            #region 외부 GREEN 아크 스케일 범위를 설정한다.

            ArcScaleRange outerGreenArcScaleRange = new ArcScaleRange();

            outerGreenArcScaleRange.AppearanceRange.ContentBrush = new SolidBrushObject(Color.SeaGreen);
            outerGreenArcScaleRange.StartValue                   = 970f;
            outerGreenArcScaleRange.EndValue                     = 991f;
            outerGreenArcScaleRange.StartThickness               = 4f;
            outerGreenArcScaleRange.EndThickness                 = 4f;
            outerGreenArcScaleRange.ShapeOffset                  = 33f;

            largeArcScaleComponent.Ranges.Add(outerGreenArcScaleRange);

            #endregion
            #region 외부 YELLOW 아크 스케일 범위를 설정한다.

            ArcScaleRange outerYellowArcScaleRange = new ArcScaleRange();

            outerYellowArcScaleRange.AppearanceRange.ContentBrush = new SolidBrushObject(Color.Khaki);
            outerYellowArcScaleRange.StartThickness               = 4f;
            outerYellowArcScaleRange.EndThickness                 = 4f;
            outerYellowArcScaleRange.StartValue                   = 991f;
            outerYellowArcScaleRange.EndValue                     = 1009f;
            outerYellowArcScaleRange.ShapeOffset                  = 33f;

            largeArcScaleComponent.Ranges.Add(outerYellowArcScaleRange);

            #endregion
            #region 외부 RED 아크 스케일 범위를 설정한다.

            ArcScaleRange outerRedArcScaleRange = new ArcScaleRange();

            outerRedArcScaleRange.AppearanceRange.ContentBrush = new SolidBrushObject(Color.LightCoral);
            outerRedArcScaleRange.StartValue                   = 1009f;
            outerRedArcScaleRange.EndValue                     = 1030f;
            outerRedArcScaleRange.StartThickness               = 4f;
            outerRedArcScaleRange.EndThickness                 = 4f;
            outerRedArcScaleRange.ShapeOffset                  = 33f;

            largeArcScaleComponent.Ranges.Add(outerRedArcScaleRange);

            #endregion
            #region 아크 스케일 바늘 컴포넌트를 설정한다.

            ArcScaleNeedleComponent arcScaleNeedleComponent = new ArcScaleNeedleComponent();

            arcScaleNeedleComponent.Name        = "arcScaleNeedleComponent";
            arcScaleNeedleComponent.ArcScale    = smallArcScaleComponent;
            arcScaleNeedleComponent.StartOffset = 18f;
            arcScaleNeedleComponent.EndOffset   = 5f;
            arcScaleNeedleComponent.ShapeType   = NeedleShapeType.CircularHalf_Style23;
            arcScaleNeedleComponent.ZOrder      = -50;

            circularGauge.Needles.Add(arcScaleNeedleComponent);

            #endregion
            #region 아크 스케일 마커 컴포넌트를 설정한다.

            ArcScaleMarkerComponent arcScaleMarkerComponent = new ArcScaleMarkerComponent();

            arcScaleMarkerComponent.Name        = "arcScaleMarkerComponent";
            arcScaleMarkerComponent.ArcScale    = largeArcScaleComponent;
            arcScaleMarkerComponent.ShapeOffset = 27f;
            arcScaleMarkerComponent.Shader      = new StyleShader() { StyleColor1 = Color.SlateBlue, StyleColor2 = Color.CornflowerBlue };
            arcScaleMarkerComponent.ShapeScale  = new FactorF2D(0.8F, 1F);
            arcScaleMarkerComponent.ZOrder      = -100;

            circularGauge.Markers.Add(arcScaleMarkerComponent);

            #endregion
            #region 아크 스케일 배경 레이어 컴포넌트를 설정한다.

            ArcScaleBackgroundLayerComponent arcScaleBackgroundLayerComponent = new ArcScaleBackgroundLayerComponent();

            arcScaleBackgroundLayerComponent.Name      = "arcScaleBackgroundLayerComponent";
            arcScaleBackgroundLayerComponent.ShapeType = BackgroundLayerShapeType.CircularFull_Style23;
            arcScaleBackgroundLayerComponent.ArcScale  = largeArcScaleComponent;
            arcScaleBackgroundLayerComponent.Size      = new SizeF(350f, 350f);
            arcScaleBackgroundLayerComponent.ZOrder    = 1000;

            circularGauge.BackgroundLayers.Add(arcScaleBackgroundLayerComponent);

            #endregion
            #region mm 레이블 컴포넌트를 설정한다.

            LabelComponent mmLabelComponent = new LabelComponent();

            mmLabelComponent.Name                     = "mmLabelComponent";
            mmLabelComponent.Text                     = "mm";
            mmLabelComponent.Position                 = new PointF2D(128, 210);
            mmLabelComponent.AppearanceText.TextBrush = new SolidBrushObject(Color.Gray);

            circularGauge.Labels.Add(mmLabelComponent);

            #endregion
            #region millibars 레이블 컴포넌트를 설정한다.

            LabelComponent millibarsLabelComponent = new LabelComponent();

            millibarsLabelComponent.Name                     = "millibarsLabelComponent";
            millibarsLabelComponent.Text                     = "millibars";
            millibarsLabelComponent.Position                 = new PointF2D(128, 238);
            millibarsLabelComponent.AppearanceText.TextBrush = new SolidBrushObject(Color.Gray);

            circularGauge.Labels.Add(millibarsLabelComponent);

            #endregion

            this.smallTrackBar.ValueChanged += (s, e) => smallArcScaleComponent.Value = this.smallTrackBar.Value;
            this.largeTrackBar.ValueChanged += (s, e) => largeArcScaleComponent.Value = this.largeTrackBar.Value;
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요