[TEECHART/WINFORM] TChart 클래스 : Import/Export 속성을 사용해 차트간 커스텀 팔레트 적용하기
TeeChart/WinForm 2022. 4. 6. 00:04728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Steema.TeeChart;
using Steema.TeeChart.Drawing;
using Steema.TeeChart.Styles;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 테마 디렉토리 경로
/// </summary>
private string themeDirectoryPath;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
Text = "TChart 클래스 : Import/Export 속성을 사용해 차트간 커스텀 팔레트 적용하기";
this.saveWithTemplateCheckBox.Checked = true;
this.tChart1.Panel.Pen = new ChartPen(Color.Black);
SetChartStyle(this.tChart1);
Points points = new Points(this.tChart1.Chart);
points.FillSampleValues();
this.tChart2.Panel.Pen = new ChartPen(Color.Black);
this.applyThemeButton.Click += applyThemeButton_Click;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 테마 적용 버튼 클릭시 처리하기 - applyThemeButton_Click(sender, e)
/// <summary>
/// 테마 적용 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void applyThemeButton_Click(object sender, EventArgs e)
{
SaveCustomTheme();
this.tChart2.Clear();
this.tChart2.Import.Theme.Load(Path.Combine(this.themeDirectoryPath, "CustomTheme.xml"));
}
#endregion
//////////////////////////////////////////////////////////////////////////////// Function
#region 차트 스타일 설정하기 - SetChartStyle(tChart)
/// <summary>
/// 차트 스타일 설정하기
/// </summary>
/// <param name="tChart">TChart</param>
private void SetChartStyle(TChart tChart)
{
tChart.Aspect.View3D = false;
tChart.Panel.Gradient.StartColor = Color.AliceBlue;
tChart.Panel.Gradient.MiddleColor = Color.SeaShell;
tChart.Panel.Gradient.EndColor = Color.Khaki;
tChart.Panel.Gradient.Visible = true;
tChart.Panel.Bevel.Inner = BevelStyles.Raised;
tChart.Panel.Bevel.Outer = BevelStyles.None;
tChart.Header.Font.Name = "Verdana";
tChart.Header.Font.Size = 9;
tChart.Legend.Font.Name = "Verdana";
tChart.Legend.Font.Size = 7;
for(int i = 0; i < tChart.Axes.Count; ++i)
{
Axis axis = tChart.Axes[i];
axis.Labels.Font.Name = "Verdana";
axis.Labels.Font.Size = 7;
}
}
#endregion
#region 커스텀 테마 저장하기 - SaveCustomTheme()
/// <summary>
/// 커스텀 테마 저장하기
/// </summary>
private void SaveCustomTheme()
{
this.themeDirectoryPath = Utils.ThemeFolder();
if(!Directory.Exists(this.themeDirectoryPath))
{
this.themeDirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
}
this.tChart1.Export.Theme.SaveWithBase64 = this.saveWithTemplateCheckBox.Checked;
if(!Directory.Exists(this.themeDirectoryPath))
{
Directory.CreateDirectory(this.themeDirectoryPath);
}
this.tChart1.Export.Theme.Save(Path.Combine(this.themeDirectoryPath, "CustomTheme.xml"));
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'TeeChart > WinForm' 카테고리의 다른 글
[TEECHART/WINFORM] Gradient 클래스 : 커스텀 그라디언트 사용하기 (0) | 2022.04.06 |
---|---|
[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] ColorPalettes 클래스 : ApplyPalette 정적 메소드를 사용해 팔레트 설정하기 (0) | 2022.04.05 |
[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 |
댓글을 달아 주세요