using System;
using System.Drawing;
using System.Windows.Forms;
using Steema.TeeChart.Drawing;
using Steema.TeeChart.Styles;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 수평 바
/// </summary>
private HorizBar horizBar;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
Text = "HorizBar 클래스 : MarksOnBar 속성을 사용해 막대 내 마크 표시하기";
#region 스타일 콤보 박스를 설정한다.
this.styleComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
this.styleComboBox.Items.Add("수평");
this.styleComboBox.Items.Add("수직");
this.styleComboBox.SelectedIndex = 0;
#endregion
#region 막대 내 표시 체크 박스를 설정한다.
this.showMarkInBarCheckBox.Checked = true;
#endregion
#region 위치 콤보 박스를 설정한다.
this.locationComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
this.locationComboBox.Items.Add(MarksLocation.Start );
this.locationComboBox.Items.Add(MarksLocation.Center);
this.locationComboBox.Items.Add(MarksLocation.End );
this.locationComboBox.SelectedIndex = 2;
#endregion
#region 각도 숫자 UP/DOWN을 설정한다.
this.angleNumericUpDown.TextAlign = HorizontalAlignment.Right;
this.angleNumericUpDown.Minimum = 0;
this.angleNumericUpDown.Value = 0;
this.angleNumericUpDown.Maximum = 360;
this.angleNumericUpDown.Increment = 90;
#endregion
#region 폰트 숫자 UP/DOWN을 설정한다.
this.fontSizeNumericUpDown.TextAlign = HorizontalAlignment.Right;
this.fontSizeNumericUpDown.Minimum = 1;
this.fontSizeNumericUpDown.Value = 16;
this.fontSizeNumericUpDown.Maximum = 100;
#endregion
#region 티차트를 설정한다.
this.tChart.Panel.Pen = new ChartPen(Color.Black);
#endregion
#region 수평 바를 설정한다.
this.horizBar = new HorizBar();
this.horizBar.BarStyle = BarStyles.RectGradient;
this.horizBar.Brush.Color = Color.Red;
this.horizBar.Brush.Solid = true;
this.horizBar.Brush.Gradient.EndColor = Color.FromArgb(230, 200, 90 );
this.horizBar.Brush.Gradient.MiddleColor = Color.FromArgb(226, 242, 170);
this.horizBar.Brush.Gradient.StartColor = Color.FromArgb(230, 200, 90 );
this.horizBar.Brush.Gradient.UseMiddle = true;
this.horizBar.Brush.Gradient.Visible = true;
this.horizBar.Brush.Visible = true;
this.horizBar.Marks.AutoPosition = false;
this.horizBar.MarksOnBar = true;
this.horizBar.Marks.Transparent = true;
this.horizBar.Marks.Font.Name = "Rage Italic";
this.horizBar.Marks.Font.Color = Color.Black;
this.horizBar.Marks.Font.Bold = true;
this.horizBar.Marks.Font.Size = 16;
this.horizBar.FillSampleValues(5);
this.tChart.Series.Add(this.horizBar);
#endregion
#region 이벤트를 설정한다.
this.styleComboBox.SelectedIndexChanged += styleComboBox_SelectedIndexChanged;
this.showMarkInBarCheckBox.CheckedChanged += showMarkInBarCheckBox_CheckedChanged;
this.locationComboBox.SelectedIndexChanged += locationComboBox_SelectedIndexChanged;
this.angleNumericUpDown.ValueChanged += angleNumericUpDown_ValueChanged;
this.fontSizeNumericUpDown.ValueChanged += fontSizeNumericUpDown_ValueChanged;
#endregion
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 스타일 콤보 박스 선택 인덱스 변경시 처리하기 - styleComboBox_SelectedIndexChanged(sender, e)
/// <summary>
/// 스타일 콤보 박스 선택 인덱스 변경시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void styleComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
Series series = this.tChart[0];
switch(this.styleComboBox.SelectedIndex)
{
case 0 : Series.ChangeType(ref series, typeof(HorizBar)); break;
case 1 : Series.ChangeType(ref series, typeof(Bar )); break;
}
UpdateMarkLocation();
}
#endregion
#region 막대 내 표시 체크 박스 체크 변경시 처리하기 - showMarkInBarCheckBox_CheckedChanged(sender, e)
/// <summary>
/// 막대 내 표시 체크 박스 체크 변경시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void showMarkInBarCheckBox_CheckedChanged(object sender, EventArgs e)
{
(this.tChart[0] as CustomBar).MarksOnBar = this.showMarkInBarCheckBox.Checked;
this.locationLabel.Enabled = this.showMarkInBarCheckBox.Enabled;
this.locationComboBox.Enabled = this.showMarkInBarCheckBox.Checked;
}
#endregion
#region 위치 콤보 박스 선택 인덱스 변경시 처리하기 - locationComboBox_SelectedIndexChanged(sender, e)
/// <summary>
/// 위치 콤보 박스 선택 인덱스 변경시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void locationComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
switch(this.locationComboBox.SelectedIndex)
{
case 0 : (this.tChart[0] as CustomBar).MarksLocation = MarksLocation.Start; break;
case 1 : (this.tChart[0] as CustomBar).MarksLocation = MarksLocation.Center; break;
case 2 : (this.tChart[0] as CustomBar).MarksLocation = MarksLocation.End; break;
}
}
#endregion
#region 각도 숫자 UP/DOWN 값 변경시 처리하기 - angleNumericUpDown_ValueChanged(sender, e)
/// <summary>
/// 각도 숫자 UP/DOWN 값 변경시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void angleNumericUpDown_ValueChanged(object sender, EventArgs e)
{
this.tChart[0].Marks.Angle = (int)this.angleNumericUpDown.Value;
}
#endregion
#region 폰트 크기 숫자 UP/DOWN 값 변경시 처리하기 - fontSizeNumericUpDown_ValueChanged(sender, e)
/// <summary>
/// 폰트 크기 숫자 UP/DOWN 값 변경시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void fontSizeNumericUpDown_ValueChanged(object sender, EventArgs e)
{
this.tChart[0].Marks.Font.Size = (int)this.fontSizeNumericUpDown.Value;
}
#endregion
//////////////////////////////////////////////////////////////////////////////// Function
#region 마크 위치 업데이트하기 - UpdateMarkLocation()
/// <summary>
/// 마크 위치 업데이트하기
/// </summary>
private void UpdateMarkLocation()
{
showMarkInBarCheckBox_CheckedChanged(null, null);
}
#endregion
}
}