//============================================================================ //ZedGraph Class Library - A Flexible Line Graph/Bar Graph Library in C# //Copyright (C) 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.Collections; using System.Text; using System.Runtime.Serialization; using System.Security.Permissions; #endregion namespace DrawGraph { /// /// A collection base class containing basic extra functionality to be inherited /// by , , /// . /// /// The methods in this collection operate on basic /// types. Therefore, in order to make sure that /// the derived classes remain strongly-typed, there are no Add() or /// Insert() methods here, and no methods that return an object. /// Only Remove(), Move(), IndexOf(), etc. methods are included. /// /// John Champion /// $Revision: 3.8 $ $Date: 2006/06/24 20:26:43 $ [Serializable] public class CollectionPlus : CollectionBase { /// /// Default Constructor /// public CollectionPlus() : base() { } /// /// Return the zero-based position index of the specified object /// in the collection. /// /// A reference to the object that is to be found. /// /// The zero-based index of the specified object, or -1 if the /// object is not in the list /// public int IndexOf( object item ) { return List.IndexOf( item ); } /// /// Remove an object from the collection at the specified ordinal location. /// /// /// An ordinal position in the list at which the object to be removed /// is located. /// /// public void Remove( int index ) { if ( index >= 0 && index < List.Count ) List.RemoveAt( index ); } /// /// Remove an object from the collection based on an object reference. /// /// A reference to the object that is to be /// removed. /// public void Remove( object item ) { List.Remove( item ); } /// /// Move the position of the object at the specified index /// to the new relative position in the list. /// For Graphic type objects, this method controls the /// Z-Order of the items. Objects at the beginning of the list /// appear in front of objects at the end of the list. /// The zero-based index of the object /// to be moved. /// The relative number of positions to move /// the object. A value of -1 will move the /// object one position earlier in the list, a value /// of 1 will move it one position later. To move an item to the /// beginning of the list, use a large negative value (such as -999). /// To move it to the end of the list, use a large positive value. /// /// The new position for the object, or -1 if the object /// was not found. public int Move( int index, int relativePos ) { if ( index < 0 || index >= List.Count ) return -1; object obj = List[index]; List.RemoveAt( index ); index += relativePos; if ( index < 0 ) index = 0; if ( index > List.Count ) index = List.Count; List.Insert( index, obj ); return index; } /* #region Serialization /// /// Current schema value that defines the version of the serialized file /// public const int schema = 1; /// /// Constructor for deserializing objects /// /// A instance that defines the serialized data /// /// A instance that contains the serialized data /// protected CollectionPlus( 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 sch = info.GetInt32( "schema" ); } /// /// 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 ) { base.GetObjectData( info, context ); info.AddValue( "schema", schema ); } #endregion */ } }