//============================================================================
//ZedGraph Class Library - A Flexible Line Graph/Bar Graph Library in C#
//Copyright ?2004  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
//=============================================================================
#region Using directives
using System;
using System.Text;
#endregion
namespace DrawGraph
{
	/// 
	/// A class that captures an  scale range.
	/// 
	/// This structure is used by the  class to store
	///  scale range settings in a collection for later retrieval.
	/// The class stores the , ,
	/// , and  properties, along with
	/// the corresponding auto-scale settings: ,
	/// , ,
	/// and .
	///  John Champion 
	///  $Revision: 3.2 $ $Date: 2007/02/19 08:05:24 $ 
	public class ScaleState : ICloneable
	{
		/// 
		/// The axis range data for , ,
		/// , and 
		/// 
		private double _min, _minorStep, _majorStep, _max;
		/// 
		/// The status of ,
		/// , ,
		/// and 
		/// 
		private bool _minAuto, _minorStepAuto,
							_majorStepAuto, _maxAuto,
							_formatAuto, _magAuto;
		/// 
		/// The status of  and 
		/// 
		private DateUnit _minorUnit, _majorUnit;
		private string _format;
		private int _mag;
		/// 
		/// Construct a  from the specified 
		/// 
		/// The  from which to collect the scale
		/// range settings.
		public ScaleState( Axis axis )
		{
			_min = axis._scale._min;
			_minorStep = axis._scale._minorStep;
			_majorStep = axis._scale._majorStep;
			_max = axis._scale._max;
			_majorUnit = axis._scale._majorUnit;
			_minorUnit = axis._scale._minorUnit;
			_format = axis._scale._format;
			_mag = axis._scale._mag;
			//this.numDec = axis.NumDec;
			_minAuto = axis._scale._minAuto;
			_majorStepAuto = axis._scale._majorStepAuto;
			_minorStepAuto = axis._scale._minorStepAuto;
			_maxAuto = axis._scale._maxAuto;
			_formatAuto = axis._scale._formatAuto;
			_magAuto = axis._scale._magAuto;
		}
		/// 
		/// The Copy Constructor
		/// 
		/// The  object from which to copy
		public ScaleState( ScaleState rhs )
		{
			_min = rhs._min;
			_majorStep = rhs._majorStep;
			_minorStep = rhs._minorStep;
			_max = rhs._max;
			_majorUnit = rhs._majorUnit;
			_minorUnit = rhs._minorUnit;
			_format = rhs._format;
			_mag = rhs._mag;
			_minAuto = rhs._minAuto;
			_majorStepAuto = rhs._majorStepAuto;
			_minorStepAuto = rhs._minorStepAuto;
			_maxAuto = rhs._maxAuto;
			_formatAuto = rhs._formatAuto;
			_magAuto = rhs._magAuto;
		}
		/// 
		/// 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 ScaleState Clone()
		{
			return new ScaleState( this );
		}
		/// 
		/// Copy the properties from this  out to the specified .
		/// 
		/// The  reference to which the properties should be
		/// copied
		public void ApplyScale( Axis axis )
		{
			axis._scale._min = _min;
			axis._scale._majorStep = _majorStep;
			axis._scale._minorStep = _minorStep;
			axis._scale._max = _max;
			axis._scale._majorUnit = _majorUnit;
			axis._scale._minorUnit = _minorUnit;
			axis._scale._format = _format;
			axis._scale._mag = _mag;
			// The auto settings must be made after the min/step/max settings, since setting those
			// properties actually affects the auto settings.
			axis._scale._minAuto = _minAuto;
			axis._scale._minorStepAuto = _minorStepAuto;
			axis._scale._majorStepAuto = _majorStepAuto;
			axis._scale._maxAuto = _maxAuto;
			axis._scale._formatAuto = _formatAuto;
			axis._scale._magAuto = _magAuto;
		}
		/// 
		/// Determine if the state contained in this  object is different from
		/// the state of the specified .
		/// 
		/// The  object with which to compare states.
		/// true if the states are different, false otherwise
		public bool IsChanged( Axis axis )
		{
			return axis._scale._min != _min ||
					axis._scale._majorStep != _majorStep ||
					axis._scale._minorStep != _minorStep ||
					axis._scale._max != _max ||
					axis._scale._minorUnit != _minorUnit ||
					axis._scale._majorUnit != _majorUnit ||
					axis._scale._minAuto != _minAuto ||
					axis._scale._minorStepAuto != _minorStepAuto ||
					axis._scale._majorStepAuto != _majorStepAuto ||
					axis._scale._maxAuto != _maxAuto;
		}
	}
}