//============================================================================
//ZedGraph Class Library - A Flexible Line Graph/Bar Graph Library in C#
//Copyright ?2006  John Champion
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//=============================================================================
using System;
using System.Drawing;
using System.Text;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace DrawGraph
{
	/// 
	/// Class that handles that stores the margin properties for the GraphPane
	/// 
	/// 
	///  John Champion 
	///  $Revision: 3.1 $ $Date: 2006/06/24 20:26:44 $ 
	[Serializable]
	public class Margin : ICloneable, ISerializable
	{
		/// 
		/// Private fields that store the size of the margin around the edge of the pane which will be
		/// kept blank.  Use the public properties , ,
		/// ,  to access these values.
		/// 
		/// Units are points (1/72 inch)
		protected float	_left,
								_right,
								_top,
								_bottom;
	#region Constructors
		/// 
		/// Constructor to build a  from the default values.
		/// 
		public Margin()
		{
			_left = Default.Left;
			_right = Default.Right;
			_top = Default.Top;
			_bottom = Default.Bottom;
		}
		/// 
		/// Copy constructor
		/// 
		/// the  instance to be copied.
		public Margin( Margin rhs )
		{
			_left = rhs._left;
			_right = rhs._right;
			_top = rhs._top;
			_bottom = rhs._bottom;
		}
		/// 
		/// Implement the  interface in a typesafe manner by just
		/// calling the typed version of 
		/// 
		/// A deep copy of this object
		object ICloneable.Clone()
		{
			return this.Clone();
		}
		/// 
		/// Typesafe, deep-copy clone method.
		/// 
		/// A new, independent copy of this class
		public Margin Clone()
		{
			return new Margin( this );
		}
	#endregion
	#region Properties
		/// 
		/// Gets or sets a float value that determines the margin area between the left edge of the
		///  rectangle and the features of the graph.
		/// 
		/// This value is in units of points (1/72 inch), and is scaled
		/// linearly with the graph size.
		/// 
		/// 
		/// 
		/// 
		/// 
		public float Left
		{
			get { return _left; }
			set { _left = value; }
		}
		/// 
		/// Gets or sets a float value that determines the margin area between the right edge of the
		///  rectangle and the features of the graph.
		/// 
		/// This value is in units of points (1/72 inch), and is scaled
		/// linearly with the graph size.
		/// 
		/// 
		/// 
		/// 
		/// 
		public float Right
		{
			get { return _right; }
			set { _right = value; }
		}
		/// 
		/// Gets or sets a float value that determines the margin area between the top edge of the
		///  rectangle and the features of the graph.
		/// 
		/// This value is in units of points (1/72 inch), and is scaled
		/// linearly with the graph size.
		/// 
		/// 
		/// 
		/// 
		/// 
		public float Top
		{
			get { return _top; }
			set { _top = value; }
		}
		/// 
		/// Gets or sets a float value that determines the margin area between the bottom edge of the
		///  rectangle and the features of the graph.
		/// 
		/// This value is in units of points (1/72 inch), and is scaled
		/// linearly with the graph size.
		/// 
		/// 
		/// 
		/// 
		/// 
		public float Bottom
		{
			get { return _bottom; }
			set { _bottom = value; }
		}
		/// 
		/// Concurrently sets all outer margin values to a single value.
		/// 
		/// This value is in units of points (1/72 inch), and is scaled
		/// linearly with the graph size.
		/// 
		/// 
		/// 
		/// 
		/// 
		public float All
		{
			set
			{
				_bottom = value;
				_top = value;
				_left = value;
				_right = value;
			}
		}
	#endregion
	#region Serialization
		/// 
		/// Current schema value that defines the version of the serialized file
		/// 
		public const int schema = 10;
		/// 
		/// Constructor for deserializing objects
		/// 
		/// A  instance that defines the serialized data
		/// 
		/// A  instance that contains the serialized data
		/// 
		protected Margin( SerializationInfo info, StreamingContext context )
		{
			// The schema value is just a file version parameter.  You can use it to make future versions
			// backwards compatible as new member variables are added to classes
			int sch = info.GetInt32( "schema" );
			_left = info.GetSingle( "left" );
			_right = info.GetSingle( "right" );
			_top = info.GetSingle( "top" );
			_bottom = info.GetSingle( "bottom" );
		}
		/// 
		/// Populates a  instance with the data needed to serialize the target object
		/// 
		/// A  instance that defines the serialized data
		/// A  instance that contains the serialized data
		[SecurityPermissionAttribute( SecurityAction.Demand, SerializationFormatter = true )]
		public virtual void GetObjectData( SerializationInfo info, StreamingContext context )
		{
			info.AddValue( "schema", schema );
			info.AddValue( "left", _left );
			info.AddValue( "right", _right );
			info.AddValue( "top", _top );
			info.AddValue( "bottom", _bottom );
		}
	#endregion
	#region Defaults
		/// 
		/// A simple struct that defines the default property values for the  class.
		/// 
		public class Default
		{
			/// 
			/// The default value for the  property, which is
			/// the size of the space on the left side of the .
			/// 
			/// Units are points (1/72 inch)
			public static float Left = 10.0F;
			/// 
			/// The default value for the  property, which is
			/// the size of the space on the right side of the .
			/// 
			/// Units are points (1/72 inch)
			public static float Right = 10.0F;
			/// 
			/// The default value for the  property, which is
			/// the size of the space on the top side of the .
			/// 
			/// Units are points (1/72 inch)
			public static float Top = 10.0F;
			/// 
			/// The default value for the  property, which is
			/// the size of the space on the bottom side of the .
			/// 
			/// Units are points (1/72 inch)
			public static float Bottom = 10.0F;
		}
	#endregion
	}
}