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

TestProject.zip
0.01MB

▶ MainForm.cs

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

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

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

        #region Field

        /// <summary>
        /// 테마 에디터
        /// </summary>
        private ThemeEditor themeEditor;

        #endregion

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

        #region 생성자 - MainForm()

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

            Text = "ThemeEditor 클래스 : 차트 테마 설정하기";

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

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

            bar.ColorEach = true;

            bar.FillSampleValues();

            this.themeEditor = new ThemeEditor(this.tChart.Chart, null);

            object[] objectCollection;

            this.themeEditor.AddChartThemes(out objectCollection);

            this.themeListBox.DisplayMember = "Name";

            this.themeListBox.Items.Clear();

            foreach(object item in objectCollection)
            {
                this.themeListBox.Items.Add
                (
                    new ThemeItem
                    {
                        Name  = item.GetType().ToString().Replace("Steema.TeeChart.Themes.", string.Empty),
                        Theme = item as Theme
                    }
                );
            }

            this.themeListBox.SelectedIndexChanged += themeListBox_SelectedIndexChanged;
            this.themeEditorButton.Click           += themeEditorButton_Click;
            this.applyByCodeButton.Click           += applyByCodeButton_Click;

            this.themeListBox.SelectedIndex = 0;
        }

        #endregion

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

        #region 테마 리스트 박스 선택 인덱스 변경시 처리하기 - themeListBox_SelectedIndexChanged(sender, e)

        /// <summary>
        /// 테마 리스트 박스 선택 인덱스 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void themeListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(this.themeListBox.SelectedIndex != -1)
            {
                ThemeItem item = this.themeListBox.SelectedItem as ThemeItem;

                item.Theme.Apply();
            }
        }

        #endregion
        #region 테마 에디터 버튼 클릭시 처리하기 - themeEditorButton_Click(sender, e)

        /// <summary>
        /// 테마 에디터 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void themeEditorButton_Click(object sender, EventArgs e)
        {
            this.themeEditor.ShowDialog();

            this.themeListBox.SelectedIndex = 0;
        }

        #endregion
        #region 코드로 적용 버튼 클릭시 처리하기 - applyByCodeButton_Click(sender, e)

        /// <summary>
        /// 코드로 적용 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void applyByCodeButton_Click(object sender, EventArgs e)
        {
            XPTheme xpTheme = new XPTheme(this.tChart.Chart);

            xpTheme.Apply();
        }

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

댓글을 달아 주세요