|
#region Revision History
//**********************************************************************//
// CtrlSoft, Copyright �2001-2007, All rights reserved.
//
// PerformanceChartStyle.cs
//
// Description:
// - [TODO: Write the purpose of PerformanceChartStyle.cs.]
//
// Created On: 8/03/2007 3:32:51 PM
// Created By: Igor V. Velikorossov <mailto:igor@ctrlsoft.net>
//**********************************************************************//
#endregion
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
namespace Ctrlsoft.Windows.Forms
{
/// <summary>
/// Represents a style object used by <see cref="PerformanceChart"/>.
/// </summary>
[TypeConverterAttribute(typeof(ExpandableObjectConverter))]
public class PerformanceChartStyle : PropertyChangeTrackingObject
{
private readonly PerformanceChartPen defaultHorizontalGridPen;
private readonly PerformanceChartPen defaultVerticalGridPen;
private readonly PerformanceChartPen defaultZeroLinePen;
private PerformanceChartPen horizontalGridPen;
private PerformanceChartPen verticalGridPen;
private PerformanceChartPen zeroLinePen;
private Color backgroundColorTop = Color.YellowGreen;
private Color backgroundColorBottom = Color.DarkOliveGreen;
private Color maxMinValueColor = Color.DarkGreen;
private bool showVerticalGridLines = true;
private bool showHorizontalGridLines = true;
private bool antiAliasing = true;
private bool showMaxMinValues = true;
private decimal maxValue = 100m;
private decimal minValue = 0m;
private string fmtMaxMinValues;
#region public PerformanceChartStyle()
/// <summary>
/// Initializes a new instance of the <see cref="PerformanceChartStyle"/> class.
/// </summary>
public PerformanceChartStyle()
{
this.defaultHorizontalGridPen = new PerformanceChartPen();
this.defaultHorizontalGridPen.Color = Color.DarkOliveGreen;
this.defaultHorizontalGridPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
this.defaultVerticalGridPen = new PerformanceChartPen();
this.defaultVerticalGridPen.Color = Color.DarkOliveGreen;
this.defaultVerticalGridPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
this.defaultZeroLinePen = new PerformanceChartPen();
this.defaultZeroLinePen.Color = Color.LightSteelBlue;
this.defaultZeroLinePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
this.horizontalGridPen = new PerformanceChartPen(this.defaultHorizontalGridPen);
this.verticalGridPen = new PerformanceChartPen(this.defaultVerticalGridPen);
this.zeroLinePen = new PerformanceChartPen(this.defaultZeroLinePen);
this.horizontalGridPen.PropertyChanged += new PropertyChangedEventHandler(chartPen_PropertyChanged);
this.verticalGridPen.PropertyChanged += new PropertyChangedEventHandler(chartPen_PropertyChanged);
this.zeroLinePen.PropertyChanged += new PropertyChangedEventHandler(chartPen_PropertyChanged);
}
#endregion // public ChartStyle
#region public bool AntiAliasing
/// <summary>
/// Gets or sets whether the anti-aliasing is enabled.
/// </summary>
[Category("Appearance")]
[DefaultValue(true)]
public bool AntiAliasing
{
get { return this.antiAliasing; }
set
{
if (this.antiAliasing != value)
{
this.antiAliasing = value;
this.OnPropertyChanged("AntiAliasing");
}
}
}
#endregion // public bool AntiAliasing
#region public bool ShowHorizontalGridLines
/// <summary>
/// Gets or sets whether the horizontal grid lines should be drawn.
/// </summary>
[Category("Appearance")]
[DefaultValue(true)]
public bool ShowHorizontalGridLines
{
get { return this.showHorizontalGridLines; }
set
{
if (this.showHorizontalGridLines != value)
{
this.showHorizontalGridLines = value;
this.OnPropertyChanged("ShowHorizontalGridLines");
}
}
}
#endregion // public bool ShowHorizontalGridLines
#region public bool ShowMaxMinValues
/// <summary>
/// Gets or sets whether the maximum/minimum values should be drawn.
/// </summary>
[Category("Appearance")]
[DefaultValue(true)]
public bool ShowMaxMinValues
{
get { return this.showMaxMinValues; }
set
{
if (this.showMaxMinValues != value)
{
this.showMaxMinValues = value;
this.OnPropertyChanged("ShowMaxMinValues");
}
}
}
#endregion // public bool ShowMaxMinValues
#region public bool ShowVerticalGridLines
/// <summary>
/// Gets or sets whether the vertical grid lines should be drawn.
/// </summary>
[Category("Appearance")]
[DefaultValue(true)]
public bool ShowVerticalGridLines
{
get { return this.showVerticalGridLines; }
set
{
if (this.showVerticalGridLines != value)
{
this.showVerticalGridLines = value;
this.OnPropertyChanged("ShowVerticalGridLines");
}
}
}
#endregion // public bool ShowVerticalGridLines
#region public ChartPen HorizontalGridPen
/// <summary>
/// Gets the pen used to draw the horizontal grid.
/// </summary>
[Category("Appearance")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PerformanceChartPen HorizontalGridPen
{
get { return horizontalGridPen; }
}
/// <summary>
/// Returns whether the <see cref="HorizontalGridPen"/> property must be serialized.
/// </summary>
/// <returns>
/// <see langword="true"/> to serialize the <see cref="HorizontalGridPen"/>; <see langword="false"/> otherwise.
/// </returns>
public bool ShouldSerializeHorizontalGridPen()
{
if (this.HorizontalGridPen == null)
return false;
return !this.HorizontalGridPen.Equals(this.defaultHorizontalGridPen);
}
/// <summary>
/// Resets the <see cref="HorizontalGridPen"/> property to its default vaule.
/// </summary>
public void ResetHorizontalGridPen()
{
this.horizontalGridPen = new PerformanceChartPen(this.defaultHorizontalGridPen);
}
#endregion // public ChartPen HorizontalGridPen
#region public ChartPen VerticalGridPen
/// <summary>
/// Gets the pen used to draw the vertical grid.
/// </summary>
[Category("Appearance")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PerformanceChartPen VerticalGridPen
{
get { return verticalGridPen; }
}
/// <summary>
/// Returns whether the <see cref="VerticalGridPen"/> property must be serialized.
/// </summary>
/// <returns>
/// <see langword="true"/> to serialize the <see cref="VerticalGridPen"/>; <see langword="false"/> otherwise.
/// </returns>
public bool ShouldSerializeVerticalGridPen()
{
if (this.VerticalGridPen == null)
return false;
return !this.VerticalGridPen.Equals(this.defaultVerticalGridPen);
}
/// <summary>
/// Resets the <see cref="VerticalGridPen"/> property to its default vaule.
/// </summary>
public void ResetVerticalGridPen()
{
this.verticalGridPen = new PerformanceChartPen(this.defaultVerticalGridPen);
}
#endregion // public ChartPen VerticalGridPen
#region public ChartPen ZeroLinePen
/*
/// <summary>
/// Gets the pen used to draw the 0-line.
/// </summary>
[Category("Appearance")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PerformanceChartPen ZeroLinePen
{
get { return zeroLinePen; }
}
/// <summary>
/// Returns whether the <see cref="ZeroLinePen"/> property must be serialized.
/// </summary>
/// <returns>
/// <see langword="true"/> to serialize the <see cref="ZeroLinePen"/>; <see langword="false"/> otherwise.
/// </returns>
public bool ShouldSerializeZeroLinePen()
{
if (this.ZeroLinePen == null)
return false;
return !this.ZeroLinePen.Equals(this.defaultZeroLinePen);
}
/// <summary>
/// Resets the <see cref="ZeroLinePen"/> property to its default vaule.
/// </summary>
public void ResetZeroLinePen()
{
this.zeroLinePen = new PerformanceChartPen(this.defaultZeroLinePen);
}
*/
#endregion // public ChartPen ZeroLinePen
#region public Color BackgroundColorTop
/// <summary>
/// Gets or sets the top gradient color of the chart background.
/// </summary>
[DefaultValue(typeof(Color), "YellowGreen")]
public Color BackgroundColorTop
{
get { return backgroundColorTop; }
set
{
if (this.backgroundColorTop != value)
{
this.backgroundColorTop = value;
this.OnPropertyChanged("BackgroundColorTop");
}
}
}
#endregion // public Color BackgroundColorTop
#region public Color BackgroundColorBottom
/// <summary>
/// Gets or sets the bottom gradient color of the chart background.
/// </summary>
[DefaultValue(typeof(Color), "DarkOliveGreen")]
public Color BackgroundColorBottom
{
get { return backgroundColorBottom; }
set
{
if (this.backgroundColorBottom != value)
{
this.backgroundColorBottom = value;
this.OnPropertyChanged("BackgroundColorBottom");
}
}
}
#endregion // public Color BackgroundColorBottom
#region public string FormatMaxMinValues
/// <summary>
/// Gets or sets format string to be applied to the
/// <see cref="MaximumValue"/> and <see cref="MinimumValue"/> values.
/// </summary>
[Category("Appearance")]
[DefaultValue("")]
[Description("Format string to be applied to the maximum and minimum chart values.")]
public string FormatMaxMinValues
{
get { return this.fmtMaxMinValues ?? string.Empty; }
set
{
if (string.Compare(this.fmtMaxMinValues, value, true, CultureInfo.InvariantCulture) != 0)
{
this.fmtMaxMinValues = value;
}
}
}
#endregion // public string FormatMaxMinValues
#region public Color MaxMinValueColor
/// <summary>
/// Gets or sets the color for the <see cref="MaximumValue"/>
/// and <see cref="MinimumValue"/> values.
/// </summary>
[DefaultValue(typeof(Color), "DarkGreen")]
public Color MaxMinValueColor
{
get { return this.maxMinValueColor; }
set
{
if (this.maxMinValueColor != value)
{
this.maxMinValueColor = value;
this.OnPropertyChanged("MaxMinValueColor");
}
}
}
#endregion // public Color BackgroundColorBottom
#region public decimal MaximumValue
/// <summary>
/// Gets or sets the maximum chart value.
/// </summary>
[Category("Appearance")]
[DefaultValue(typeof(decimal), "100")]
[Description("Maximum chart value")]
public decimal MaximumValue
{
get { return this.maxValue; }
set
{
if (value <= this.minValue)
value = this.minValue + 1;
if (this.maxValue != value)
{
this.maxValue = value;
this.OnPropertyChanged("MaximumValue");
}
}
}
#endregion // public decimal MaxValue
#region public decimal MinimumValue
/// <summary>
/// Gets or sets the maximum chart value.
/// </summary>
[Category("Appearance")]
[DefaultValue(typeof(decimal), "0")]
[Description("Minimum chart value")]
public decimal MinimumValue
{
get { return this.minValue; }
set
{
if (value >= this.maxValue)
value = this.maxValue - 1;
if (this.minValue != value)
{
this.minValue = value;
this.OnPropertyChanged("MinimumValue");
}
}
}
#endregion // public decimal MinimumValue
#region public override string ToString()
/// <summary>
/// Overrides <see cref="Object.ToString()"/>.
/// </summary>
/// <returns>Returns "PerformanceChartStyle" string.</returns>
public override string ToString()
{
return "PerformanceChartStyle";
}
#endregion // public override string ToString()
#region private void chartPen_PropertyChanged(object sender, PropertyChangedEventArgs e)
private void chartPen_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
PerformanceChartPen pen = sender as PerformanceChartPen;
if (pen == null)
return;
this.OnPropertyChanged("chartPen+" + e.PropertyName);
}
#endregion // private void chartPen_PropertyChanged(object sender, PropertyChangedEventArgs e)
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.