//============================================================================ //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 all the scale range settings for a . /// /// /// This class is used to store scale ranges in order to allow zooming out to /// prior scale range states. objects are maintained in the /// collection. The object holds /// a object for each of the three axes; the , /// the , and the . /// /// John Champion /// $Revision: 3.15 $ $Date: 2007/04/16 00:03:07 $ public class ZoomState : ICloneable { /// /// An enumeration that describes whether a given state is the result of a Pan or Zoom /// operation. /// public enum StateType { /// /// Indicates the object is from a Zoom operation /// Zoom, /// /// Indicates the object is from a Wheel Zoom operation /// WheelZoom, /// /// Indicates the object is from a Pan operation /// Pan, /// /// Indicates the object is from a Scroll operation /// Scroll } /// /// objects to store the state data from the axes. /// private ScaleState _xAxis, _x2Axis; private ScaleStateList _yAxis, _y2Axis; /// /// An enum value indicating the type of adjustment being made to the /// scale range state. /// private StateType _type; /// /// Gets a value indicating the type of action (zoom or pan) /// saved by this . /// public StateType Type { get { return _type; } } /// /// Gets a string representing the type of adjustment that was made when this scale /// state was saved. /// /// A string representation for the state change type; typically /// "Pan", "Zoom", or "Scroll". public string TypeString { get { switch ( _type ) { case StateType.Pan: return "Pan"; case StateType.WheelZoom: return "WheelZoom"; case StateType.Zoom: default: return "Zoom"; case StateType.Scroll: return "Scroll"; } } } /// /// Construct a object from the scale ranges settings contained /// in the specified . /// /// The from which to obtain the scale /// range values. /// /// A enumeration that indicates whether /// this saved state is from a pan or zoom. public ZoomState( GraphPane pane, StateType type ) { _xAxis = new ScaleState( pane.XAxis ); _x2Axis = new ScaleState( pane.X2Axis ); _yAxis = new ScaleStateList( pane.YAxisList ); _y2Axis = new ScaleStateList( pane.Y2AxisList ); _type = type; } /// /// The Copy Constructor /// /// The object from which to copy public ZoomState( ZoomState rhs ) { _xAxis = new ScaleState( rhs._xAxis ); _x2Axis = new ScaleState( rhs._x2Axis ); _yAxis = new ScaleStateList( rhs._yAxis ); _y2Axis = new ScaleStateList( rhs._y2Axis ); } /// /// 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 ZoomState Clone() { return new ZoomState( this ); } /// /// Copy the properties from this out to the specified . /// /// The to which the scale range properties should be /// copied. public void ApplyState( GraphPane pane ) { _xAxis.ApplyScale( pane.XAxis ); _x2Axis.ApplyScale( pane.X2Axis ); _yAxis.ApplyScale( pane.YAxisList ); _y2Axis.ApplyScale( pane.Y2AxisList ); } /// /// 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( GraphPane pane ) { return _xAxis.IsChanged( pane.XAxis ) || _x2Axis.IsChanged( pane.X2Axis ) || _yAxis.IsChanged( pane.YAxisList ) || _y2Axis.IsChanged( pane.Y2AxisList ); } } }