Click here to Skip to main content
15,886,026 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.3K   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 display setting for a generic axis of the chart control.
	/// </summary>
	[TypeConverter(typeof(ExpandableObjectConverter))]
	public abstract class ChartAxisSettingsBase
	{
		#region Consts
		private const ChartTickMarkTypes defaultMinorTick = ChartTickMarkTypes.None;
		private const ChartTickMarkTypes defaultMajorTick = ChartTickMarkTypes.Outside;
		#endregion

		#region Fields
		private ChartTitleSettings title = null;
		private ChartLineSettings line = null;
		private ChartLabelsSettings labels = null;
		private ChartTickMarkTypes minorTick = ChartAxisSettingsBase.defaultMinorTick;
		private ChartTickMarkTypes majorTick = ChartAxisSettingsBase.defaultMajorTick;
		private Control owner = null;
		#endregion

		#region Constructor
		/// <summary>
		/// Creates a new instance of class ChartAxisSettingsBase.
		/// </summary>
		/// <param name="owner">A Control object representing the owner chart.</param>
		internal ChartAxisSettingsBase(Control owner)
		{
			this.owner = owner;
			// init fields
			this.line = new ChartLineSettings(owner);
			this.labels = new ChartLabelsSettings(owner);
			this.title = new ChartTitleSettings(owner);
		}

		#endregion

		#region Properties
		/// <summary>
		/// Determines the display settings for the title of the axis.
		/// </summary>
		[Description("Determines the display settings for the title of the axis.")]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
		public ChartTitleSettings Title
		{
			get
			{
				return this.title;
			}
		}

		/// <summary>
		/// Determines the display settings for the line of the axis.
		/// </summary>
		[Description("Determines the display settings for the line of the axis.")]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
		public ChartLineSettings Line
		{
			get
			{
				return this.line;
			}
		}

		/// <summary>
		/// Gets/sets a value representing the type of the minor tick of the the axis.
		/// </summary>
		[Description("Gets/sets a value representing the type of the minor tick of the the axis.")]
		[DefaultValue(ChartAxisSettingsBase.defaultMinorTick)]
		public ChartTickMarkTypes MinorTick
		{
			get
			{
				return this.minorTick;
			}
			set
			{
				if (this.minorTick != value)
				{
					this.minorTick = value;
					this.owner.Invalidate();
				}
			}
		}

		/// <summary>
		/// Gets/sets a value representing the type of the major tick of the the axis.
		/// </summary>
		[Description("Gets/sets a value representing the type of the major tick of the the axis.")]
		[DefaultValue(ChartAxisSettingsBase.defaultMajorTick)]
		public ChartTickMarkTypes MajorTick
		{
			get
			{
				return this.majorTick;
			}
			set
			{
				if (this.majorTick != value)
				{
					this.majorTick = value;
					this.owner.Invalidate();
				}
			}
		}

		/// <summary>
		/// Determines the display settings for the labels of the axis.
		/// </summary>
		[Description("Determines the display settings for the labels of the axis.")]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
		public ChartLabelsSettings Labels
		{
			get
			{
				return this.labels;
			}
		}

		#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