//============================================================================ //ZedGraph Class Library - A Flexible Line Graph/Bar Graph Library in C# //Copyright ?2005 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.Collections.Generic; using System.Text; using System.Runtime.Serialization; using System.Security.Permissions; #endregion namespace DrawGraph { /// /// A collection class containing a list of objects. /// /// /// John Champion /// $Revision: 3.3 $ $Date: 2006/06/24 20:26:43 $ [Serializable] public class Y2AxisList : List, ICloneable { #region Constructors /// /// Default constructor for the collection class. /// public Y2AxisList() { } /// /// The Copy Constructor /// /// The object from which to copy public Y2AxisList( Y2AxisList rhs ) { foreach ( Y2Axis item in rhs ) { this.Add( item.Clone() ); } } /// /// 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 Y2AxisList Clone() { return new Y2AxisList( this ); } #endregion #region List Methods /// /// Indexer to access the specified object by /// its ordinal position in the list. /// /// The ordinal position (zero-based) of the /// object to be accessed. /// An object reference. public new Y2Axis this[int index] { get { return ( ( ( index < 0 || index >= this.Count ) ? null : base[index] ) ); } } /// /// Indexer to access the specified object by /// its string. /// /// The string title of the /// object to be accessed. /// A object reference. public Y2Axis this[string title] { get { int index = IndexOf( title ); if ( index >= 0 ) return this[index]; else return null; } } /// /// Return the zero-based position index of the /// with the specified . /// /// The comparison of titles is not case sensitive, but it must include /// all characters including punctuation, spaces, etc. /// The label that is in the /// attribute of the item to be found. /// /// The zero-based index of the specified , /// or -1 if the was not found in the list /// public int IndexOf( string title ) { int index = 0; foreach ( Y2Axis axis in this ) { if ( String.Compare( axis.Title._text, title, true ) == 0 ) return index; index++; } return -1; } /// /// Return the zero-based position index of the /// with the specified . /// /// In order for this method to work, the /// property must be of type . /// The tag that is in the /// attribute of the item to be found. /// /// The zero-based index of the specified , /// or -1 if the string is not in the list /// public int IndexOfTag( string tagStr ) { int index = 0; foreach ( Y2Axis axis in this ) { if ( axis.Tag is string && String.Compare( (string)axis.Tag, tagStr, true ) == 0 ) return index; index++; } return -1; } /// /// Create a new and add it to this list. /// /// The title string for the new axis /// An integer representing the ordinal position of the new in /// this . This is the value that you would set the /// property of a given to /// assign it to this new . Note that, for a , /// you would also need to set the property to true. public int Add( string title ) { Y2Axis axis = new Y2Axis( title ); Add( axis ); return Count - 1; } #endregion } }