Click here to Skip to main content
15,892,697 members
Articles / Programming Languages / C#

Cristi Potlog's Chart Control for .NET

Rate me:
Please Sign up or sign in to vote.
4.60/5 (27 votes)
24 Jul 2005MIT5 min read 223.6K   11.6K   114  
This article introduces a sample chart control for Windows Forms.
#region Copyright �2005, Cristi Potlog - All Rights Reserved
/* -------------------------------------------------------------- *
 *      Copyright �2005, Cristi Potlog - All Rights reserved      *
 *                                                                *
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY *
 * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT    *
 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR    *
 * FITNESS FOR A PARTICULAR PURPOSE.                              *
 *                                                                *
 * THIS COPYRIGHT NOTICE MAY NOT BE REMOVED FROM THIS FILE.       *
 * -------------------------------------------------------------- */
#endregion Copyright �2005, Cristi Potlog - All Rights Reserved

#region References
using System;
using System.ComponentModel;
using System.Windows.Forms;
#endregion

namespace CristiPotlog.ChartControl
{
	/// <summary>
	/// Represents the setting for the values axis scale of the chart control.
	/// </summary>
	[TypeConverter(typeof(ExpandableObjectConverter))]
	public class ChartValueScaleSettings
	{
		#region Consts
		private const int defaultMinimum = 0;
		private const int defaultMaximum = 100;
		private const int defaultMajorUnit = 20;
		private const int defaultMinorUnit = 5;
		private const bool defaultAutoScale = true;
		#endregion

		#region Fields
		private int minimum = ChartValueScaleSettings.defaultMinimum;
		private int maximum = ChartValueScaleSettings.defaultMaximum;
		private int majorUnit = ChartValueScaleSettings.defaultMajorUnit;
		private int minorUnit = ChartValueScaleSettings.defaultMinorUnit;
		private bool autoScale = ChartValueScaleSettings.defaultAutoScale;
		private Control owner = null;
		#endregion

		#region Constructor
		/// <summary>
		/// Creates a new instance of class ChartValueScaleSettings.
		/// </summary>
		/// <param name="owner">A Control object representing the owner chart.</param>
		internal ChartValueScaleSettings(Control owner)
		{
			this.owner = owner;
		}
		#endregion

		#region Properties
		/// <summary>
		/// Gets/sets a value representing the minimum value of the scale.
		/// </summary>
		[DefaultValue(ChartValueScaleSettings.defaultMinimum)]
		[Description("Gets/sets a value representing the minimum value of the scale.")]
		public int Minimum
		{
			get
			{
				return this.minimum;
			}
			set
			{
				if (this.minimum != value)
				{
					this.minimum = value;
					this.owner.Invalidate();
				}
			}
		}

		/// <summary>
		/// Gets/sets a value representing the maximun value of the scale.
		/// </summary>
		[DefaultValue(ChartValueScaleSettings.defaultMaximum)]
		[Description("Gets/sets a value representing the maximun value of the scale.")]
		public int Maximum
		{
			get
			{
				return this.maximum;
			}
			set
			{
				if (this.maximum != value)
				{
					this.maximum = value;
					this.owner.Invalidate();
				}
			}
		}

		/// <summary>
		/// Gets/sets a value representing the major unit value of the scale.
		/// </summary>
		[DefaultValue(ChartValueScaleSettings.defaultMajorUnit)]
		[Description("Gets/sets a value representing the major unit value of the scale.")]
		public int MajorUnit
		{
			get
			{
				return this.majorUnit;
			}
			set
			{
				if (this.majorUnit != value)
				{
					this.majorUnit = value;
					this.owner.Invalidate();
				}
			}
		}

		/// <summary>
		/// Gets/sets a value representing the minor unit value of the scale.
		/// </summary>
		[DefaultValue(ChartValueScaleSettings.defaultMinorUnit)]
		[Description("Gets/sets a value representing the minor unit value of the scale.")]
		public int MinorUnit
		{
			get
			{
				return this.minorUnit;
			}
			set
			{
				if (this.minorUnit != value)
				{
					this.minorUnit = value;
					this.owner.Invalidate();
				}
			}
		}

		/// <summary>
		/// Gets/sets a value representing whether scale parameters are determined automaticaly or not.
		/// </summary>
		[DefaultValue(ChartValueScaleSettings.defaultAutoScale)]
		[Description("Gets/sets a value representing whether scale parameters are determined automaticaly or not.")]
		public bool AutoScale
		{
			get
			{
				return this.autoScale;
			}
			set
			{
				if (this.autoScale != value)
				{
					this.autoScale = value;
					this.owner.Invalidate();
				}
			}
		}
		#endregion

		#region Methods
		/// <summary>
		/// Returns a string that represents the current object.  
		/// </summary>
		/// <returns>A string that represents the current object.</returns>
		public override string ToString()
		{
			return "(" + this.GetType().Name + ")";
		}
		#endregion
	}
}

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.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions