//============================================================================
//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.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.6 $ $Date: 2006/06/24 20:26:43 $
[Serializable]
public class PaneList : List, ICloneable
{
#region Constructors
///
/// Default constructor for the collection class.
///
public PaneList()
{
}
///
/// The Copy Constructor
///
/// The object from which to copy
public PaneList( PaneList rhs )
{
foreach ( GraphPane 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 PaneList Clone()
{
return new PaneList( this );
}
#endregion
#region Serialization
///
/// Current schema value that defines the version of the serialized file
///
public const int schema = 10;
///
/// Constructor for deserializing objects
///
/// A instance that defines the serialized data
///
/// A instance that contains the serialized data
///
protected PaneList( SerializationInfo info, StreamingContext 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 )
{
info.AddValue( "schema", schema );
}
#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.
/// A object reference.
public GraphPane this[ int index ]
{
get { return( (GraphPane) List[index] ); }
set { List[index] = value; }
}
*/
///
/// Indexer to access the specified object by
/// its string.
///
/// The string title of the
/// object to be accessed.
/// A object reference.
public GraphPane this[ string title ]
{
get
{
int index = IndexOf( title );
if ( index >= 0 )
return( (GraphPane) this[index] );
else
return null;
}
}
/*
///
/// Add a object to the collection at the end of the list.
///
/// A reference to the object to
/// be added
///
public void Add( GraphPane pane )
{
List.Add( pane );
}
///
/// Remove a object from the collection based on an object reference.
///
/// A reference to the object that is to be
/// removed.
///
public void Remove( GraphPane pane )
{
List.Remove( pane );
}
///
/// Insert a object into the collection at the specified
/// zero-based index location.
///
/// The zero-based index location for insertion.
/// A reference to the object that is to be
/// inserted.
///
public void Insert( int index, GraphPane pane )
{
List.Insert( index, pane );
}
*/
///
/// 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 ( GraphPane pane in this )
{
if ( String.Compare( pane.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 ( GraphPane pane in this )
{
if ( pane.Tag is string &&
String.Compare( (string) pane.Tag, tagStr, true ) == 0 )
return index;
index++;
}
return -1;
}
#endregion
}
}