//============================================================================ //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 the data associated with text title and its associated font /// properties. Inherits from , and adds /// and properties, which are specifically associated with /// the . /// /// /// John Champion /// $Revision: 3.1 $ $Date: 2006/06/24 20:26:44 $ [Serializable] public class AxisLabel : GapLabel, ICloneable, ISerializable { internal bool _isOmitMag, _isTitleAtCross; #region Constructors /// /// Constructor to build an from the text and the /// associated font properties. /// /// The representing the text to be /// displayed /// The font family name /// The size of the font in points and scaled according /// to the logic. /// The instance representing the color /// of the font /// true for a bold font face /// true for an italic font face /// true for an underline font face public AxisLabel( string text, string fontFamily, float fontSize, Color color, bool isBold, bool isItalic, bool isUnderline ) : base( text, fontFamily, fontSize, color, isBold, isItalic, isUnderline ) { _isOmitMag = false; _isTitleAtCross = true; } /// /// Copy constructor /// /// the instance to be copied. public AxisLabel( AxisLabel rhs ) : base( rhs ) { _isOmitMag = rhs._isOmitMag; _isTitleAtCross = rhs._isTitleAtCross; } /// /// 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 new AxisLabel Clone() { return new AxisLabel( this ); } #endregion #region Properties /// /// Gets or sets the property that controls whether or not the magnitude factor (power of 10) for /// this scale will be included in the label. /// /// /// For large scale values, a "magnitude" value (power of 10) is automatically /// used for scaling the graph. This magnitude value is automatically appended /// to the end of the Axis (e.g., "(10^4)") to indicate /// that a magnitude is in use. This property controls whether or not the /// magnitude is included in the title. Note that it only affects the axis /// title; a magnitude value may still be used even if it is not shown in the title. /// /// true to show the magnitude value, false to hide it /// /// /// public bool IsOmitMag { get { return _isOmitMag; } set { _isOmitMag = value; } } /// /// Gets or sets a value that determines whether the Axis title is located at the /// /// value or at the normal position (outside the ). /// /// /// This value only applies if is false. /// public bool IsTitleAtCross { get { return _isTitleAtCross; } set { _isTitleAtCross = value; } } #endregion #region Serialization /// /// Current schema value that defines the version of the serialized file /// public const int schema3 = 10; /// /// Constructor for deserializing objects /// /// A instance that defines the serialized data /// /// A instance that contains the serialized data /// protected AxisLabel( SerializationInfo info, StreamingContext context ) : base( info, 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 sch2 = info.GetInt32( "schema3" ); _isOmitMag = info.GetBoolean( "isOmitMag" ); _isTitleAtCross = info.GetBoolean( "isTitleAtCross" ); } /// /// 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 override void GetObjectData( SerializationInfo info, StreamingContext context ) { base.GetObjectData( info, context ); info.AddValue( "schema3", schema2 ); info.AddValue( "isOmitMag", _isVisible ); info.AddValue( "isTitleAtCross", _isTitleAtCross ); } #endregion } }