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

TestProject.zip
0.01MB

▶ MainForm.cs

using System;
using System.Drawing;
using System.Windows.Forms;

using Steema.TeeChart.Drawing;
using Steema.TeeChart.Styles;
using Steema.TeeChart.Themes;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : Form
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 적색 팔레트 색상 배열
        /// </summary>
        private Color[] redPaletteColorArray;

        /// <summary>
        /// 녹색 팔레트 색상 배열
        /// </summary>
        private Color[] greenPaletteColorArray;

        /// <summary>
        /// 청색 팔레트 색상 배열
        /// </summary>
        private Color[] bluePaletteColorArray;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

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

            Text = "ColorPalettes 클래스 : ApplyPalette 정적 메소드를 사용해 팔레트 설정하기";

            this.redPaletteColorArray = new Color[15];

            for(int i = 0; i < 15; i++)
            {
                this.redPaletteColorArray[i] = Color.FromArgb(128 + Convert.ToInt32(Math.Round(i * (128.0 / 15.0))), 0, 0);
            }

            this.greenPaletteColorArray = new Color[15];

            for(int i = 0; i < 15; i++)
            {
                this.greenPaletteColorArray[i] = Color.FromArgb(0, 128 + Convert.ToInt32(Math.Round(i * (128.0 / 15.0))), 0);
            }

            this.bluePaletteColorArray = new Color[15];

            for(int i = 0; i < 15; i++)
            {
                this.bluePaletteColorArray[i] = Color.FromArgb(0, 0, 128 + Convert.ToInt32(Math.Round(i * (128.0 / 15.0))));
            }

            this.customPaletteComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

            this.customPaletteComboBox.Items.Add("디폴트 티차트");
            this.customPaletteComboBox.Items.Add("적색"         );
            this.customPaletteComboBox.Items.Add("녹색"         );
            this.customPaletteComboBox.Items.Add("청색"         );

            this.customPaletteComboBox.SelectedIndex = 0;

            this.defaultPaletteComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

            foreach(string paletteName in Theme.ColorPalettes) 
            {
                this.defaultPaletteComboBox.Items.Add(paletteName);
            }

            this.defaultPaletteComboBox.SelectedIndex = 0;

            this.tChart.Panel.Pen = new ChartPen(Color.Black);

            Bar bar = new Bar(this.tChart.Chart);

            bar.ColorEach = true;

            bar.FillSampleValues(15);

            this.customPaletteComboBox.SelectedIndexChanged  += customPaletteComboBox_SelectedIndexChanged;
            this.defaultPaletteComboBox.SelectedIndexChanged += defaultPaletteComboBox_SelectedIndexChanged;
            Leave                                            += Form_Leave;
        }

        #endregion

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

        #region 폼 이탈시 처리하기 - Form_Leave(sender, e)

        /// <summary>
        /// 폼 이탈시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Form_Leave(object sender, EventArgs e)
        {
            ColorPalettes.ApplyPalette(this.tChart.Chart, Theme.OperaPalette);
        }

        #endregion
        #region 커스텀 팔레트 콤보 박스 선택 인덱스 변경시 처리하기 - customPaletteComboBox_SelectedIndexChanged(sender, e)

        /// <summary>
        /// 커스텀 팔레트 콤보 박스 선택 인덱스 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void customPaletteComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch(this.customPaletteComboBox.SelectedIndex) 
            {
                case 0 :

                    ColorPalettes.ApplyPalette(this.tChart.Chart, Theme.OperaPalette);

                    this.tChart.Refresh();

                    break;

                case 1 :

                    ColorPalettes.ApplyPalette(this.tChart.Chart, this.redPaletteColorArray);

                    this.tChart.Refresh();

                    break;

                case 2 :

                    ColorPalettes.ApplyPalette(this.tChart.Chart, this.greenPaletteColorArray);

                    this.tChart.Refresh();

                    break;

                case 3 :

                    ColorPalettes.ApplyPalette(this.tChart.Chart, this.bluePaletteColorArray);

                    this.tChart.Refresh();

                    break;

            }
        }

        #endregion
        #region 디폴트 팔레트 콤보 박스 선택 인덱스 변경시 처리하기 - defaultPaletteComboBox_SelectedIndexChanged(sender, e)

        /// <summary>
        /// 디폴트 팔레트 콤보 박스 선택 인덱스 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void defaultPaletteComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ColorPalettes.ApplyPalette(this.tChart.Chart, this.defaultPaletteComboBox.SelectedIndex);
        }

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