//============================================================================
//PointPairList Class
//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.Collections.Generic;
namespace DrawGraph
{
///
/// A collection class containing a list of objects
/// that define the set of points to be displayed on the curve.
///
///
/// John Champion based on code by Jerry Vos
/// $Revision: 3.4 $ $Date: 2007/02/18 05:51:54 $
[Serializable]
public class StockPointList : List, IPointList, IPointListEdit
{
#region Properties
///
/// 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 new PointPair this[int index]
{
get { return base[index]; }
set { base[index] = new StockPt( value ); }
}
#endregion
#region Constructors
///
/// Default constructor for the collection class
///
public StockPointList()
{
}
///
/// The Copy Constructor
///
/// The StockPointList from which to copy
public StockPointList( StockPointList rhs )
{
for ( int i = 0; i < rhs.Count; i++ )
{
StockPt pt = new StockPt( rhs[i] );
this.Add( pt );
}
}
///
/// 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 StockPointList Clone()
{
return new StockPointList( this );
}
#endregion
#region Methods
///
/// Add a object to the collection at the end of the list.
///
/// The object to
/// be added
new public void Add( StockPt point )
{
base.Add( new StockPt( point ) );
}
///
/// Add a object to the collection at the end of the list.
///
/// The object to be added
public void Add( PointPair point )
{
// throw new ArgumentException( "Error: Only the StockPt type can be added to StockPointList" +
// ". An ordinary PointPair is not allowed" );
base.Add( new StockPt( point ) );
}
///
/// Add a object to the collection at the end of the list using
/// the specified values. The unspecified values (low, open, close) are all set to
/// .
///
/// An value
/// The high value for the day
/// The zero-based ordinal index where the point was added in the list.
public void Add( double date, double high )
{
Add( new StockPt( date, high, PointPair.Missing, PointPair.Missing,
PointPair.Missing, PointPair.Missing ) );
}
///
/// Add a single point to the from values of type double.
///
/// An value
/// The high value for the day
/// The low value for the day
/// The opening value for the day
/// The closing value for the day
/// The trading volume for the day
/// The zero-based ordinal index where the point was added in the list.
public void Add( double date, double high, double low, double open, double close, double vol )
{
StockPt point = new StockPt( date, high, low, open, close, vol );
Add( point );
}
///
/// Access the at the specified ordinal index.
///
///
/// To be compatible with the interface, the
/// must implement an index that returns a
/// rather than a . This method
/// will return the actual at the specified position.
///
/// The ordinal position (zero-based) in the list
/// The specified .
///
public StockPt GetAt( int index )
{
return base[index];
}
#endregion
}
}