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

TestProject.zip
다운로드

▶ MainForm.cs

using System;
using System.Drawing;

using DevExpress.XtraEditors;

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

        #region 생성자 - MainForm()

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

            this.temperatureTrackBarControl.EditValueChanged += temperatureTrackBarControl_EditValueChanged;
            this.humidityTrackBarControl.EditValueChanged    += humidityTrackBarControl_EditValueChanged;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 온도 트랙바 컨트롤 편집 값 변경시 처리하기 - temperatureTrackBarControl_EditValueChanged(sender, e)

        /// <summary>
        /// 온도 트랙바 컨트롤 편집 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void temperatureTrackBarControl_EditValueChanged(object sender, EventArgs e)
        {
            this.temperatureArcScaleComponent.Value = Convert.ToSingle(this.temperatureTrackBarControl.EditValue);

            this.weatherStateImageIndicatorComponent.StateIndex = GetWeatherType();

            string sign = string.Empty;

            if(this.temperatureArcScaleComponent.Value > 0)
            {
                sign = "+";

                this.gaugeControl.ColorScheme.Color = Color.Crimson;
            }
            else
            {
                this.gaugeControl.ColorScheme.Color = Color.RoyalBlue;
            }

            this.temperatureLabelComponent.Text = $"t : {sign}{this.temperatureArcScaleComponent.Value}C";
        }

        #endregion
        #region 습도 트랙바 컨트롤 편집 값 변경시 처리하기 - humidityTrackBarControl_EditValueChanged(sender, e)

        /// <summary>
        /// 습도 트랙바 컨트롤 편집 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void humidityTrackBarControl_EditValueChanged(object sender, EventArgs e)
        {
            this.humidityArcScaleComponent.Value = Convert.ToSingle(this.humidityTrackBarControl.EditValue);

            this.weatherStateImageIndicatorComponent.StateIndex = GetWeatherType();

            this.humidityLabelComponent.Text = $"h : {humidityArcScaleComponent.Value}%";
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 날씨 타입 구하기 - GetWeatherType()

        /// <summary>
        /// 날씨 타입 구하기
        /// </summary>
        /// <returns>날씨 타입</returns>
        private int GetWeatherType()
        {
            if(temperatureArcScaleComponent.Value > 0)
            {
                if(humidityArcScaleComponent.Value < 75)
                {
                    return 0; // SUNNY
                }
                else
                {
                    return 2; // RAINY
                }
            }
            else
            {
                if(this.humidityArcScaleComponent.Value < 75)
                {
                    return 1; // CLOWDY
                }
                else
                {
                    return 3; // SNOW
                }
            }
        }

        #endregion
    }
}

 

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

댓글을 달아 주세요