[TEECHART/WINFORM] ColorPalettes 클래스 : ApplyPalette 정적 메소드를 사용해 팔레트 설정하기
TeeChart/WinForm 2022. 4. 5. 23:39728x90
728x170
▶ 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
그리드형(광고전용)
'TeeChart > WinForm' 카테고리의 다른 글
[TEECHART/WINFORM] TChart 클래스 : BeforeDraw/BeforeDrawAxes/BeforeDrawSeries/AfterDraw 이벤트 사용하기 (0) | 2022.04.06 |
---|---|
[TEECHART/WINFORM] FastLine 클래스 : LinePen 속성을 사용해 라인 스타일/두께 설정하기 (0) | 2022.04.06 |
[TEECHART/WINFORM] TChart 클래스 : Aspect 속성을 사용해 안티 알리아싱 설정하기 (0) | 2022.04.06 |
[TEECHART/WINFORM] TChart 클래스 : Aspect 속성을 사용해 차트 회전시키기 (0) | 2022.04.06 |
[TEECHART/WINFORM] TChart 클래스 : Import/Export 속성을 사용해 차트간 커스텀 팔레트 적용하기 (0) | 2022.04.06 |
[TEECHART/WINFORM] ThemeEditor 클래스 : 차트 테마 설정하기 (0) | 2022.04.05 |
[TEECHART/WINFORM] ChartPartAnimation 클래스 : 차트 애니메이션 사용하기 (0) | 2022.04.05 |
[TEECHART/WINFORM] MarkSymbolEditor 클래스 : 마커 기호 속성 편집하기 (0) | 2022.04.05 |
[TEECHART/WINFORM] TChart 클래스 : Export 속성을 사용해 클립보드 복사하기 (0) | 2022.04.05 |
[TEECHART/WINFORM] TChart 클래스 : Aspect 속성을 사용해 3D 차트 회전시키기 (0) | 2022.04.05 |