using System;
using System.Collections;
using System.Windows.Forms;
namespace Gui.Wizard
{
///
/// Summary description for PanelCollection.
///
public class PageCollection : CollectionBase
{
private Wizard vParent;
///
/// Constructor requires the wizard that owns this collection
///
/// Wizard
public PageCollection(Wizard parent):base()
{
vParent = parent;
}
///
/// Returns the wizard that owns this collection
///
public Wizard Parent
{
get
{
return vParent;
}
}
///
/// Finds the Page in the collection
///
public WizardPage this[ int index ]
{
get
{
return( (WizardPage) List[index] );
}
set
{
List[index] = value;
}
}
///
/// Adds a WizardPage into the Collection
///
/// The page to add
///
public int Add(WizardPage value )
{
int result = List.Add( value );
return result;
}
///
/// Adds an array of pages into the collection. Used by the Studio Designer generated coed
///
/// Array of pages to add
public void AddRange(WizardPage[] pages)
{
// Use external to validate and add each entry
foreach(WizardPage page in pages)
{
this.Add(page);
}
}
///
/// Finds the position of the page in the colleciton
///
/// Page to find position of
/// Index of Page in collection
public int IndexOf( WizardPage value )
{
return( List.IndexOf( value ) );
}
///
/// Adds a new page at a particular position in the Collection
///
/// Position
/// Page to be added
public void Insert( int index, WizardPage value )
{
List.Insert(index, value );
}
///
/// Removes the given page from the collection
///
/// Page to remove
public void Remove( WizardPage value )
{
//Remove the item
List.Remove( value );
}
///
/// Detects if a given Page is in the Collection
///
/// Page to find
///
public bool Contains( WizardPage value )
{
// If value is not of type Int16, this will return false.
return( List.Contains( value ) );
}
///
/// Propgate when a external designer modifies the pages
///
///
///
protected override void OnInsertComplete(int index, object value)
{
base.OnInsertComplete (index, value);
//Showthe page added
vParent.PageIndex = index;
}
///
/// Propogates when external designers remove items from page
///
///
///
protected override void OnRemoveComplete(int index, object value)
{
base.OnRemoveComplete (index, value);
//If the page that was added was the one that was visible
if (vParent.PageIndex == index)
{
//Can I show the one after
if (index < InnerList.Count)
{
vParent.PageIndex = index;
}
else
{
//Can I show the end one (if not -1 makes everythign disappear
vParent.PageIndex = InnerList.Count-1;
}
}
}
}
}