81 lines
2.0 KiB
C#
81 lines
2.0 KiB
C#
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace RyzStudio.Windows.Forms
|
|||
|
{
|
|||
|
[ToolboxItem(true)]
|
|||
|
public class PanelCollection : CollectionBase
|
|||
|
{
|
|||
|
protected PanelBook panelBook = null;
|
|||
|
|
|||
|
public PanelCollection()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public PanelCollection(PanelBook parent) : base()
|
|||
|
{
|
|||
|
panelBook = parent;
|
|||
|
}
|
|||
|
|
|||
|
public PanelBook Parent => panelBook;
|
|||
|
|
|||
|
public Panel this[int index] { get => (Panel)List[index]; set => List[index] = value; }
|
|||
|
|
|||
|
public int Add(Panel value) => List.Add(value);
|
|||
|
|
|||
|
public void AddRange(Panel[] pages)
|
|||
|
{
|
|||
|
foreach (Panel page in pages)
|
|||
|
{
|
|||
|
this.Add(page);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public int IndexOf(Panel value) => (List.IndexOf(value));
|
|||
|
|
|||
|
public void Insert(int index, Panel value) => List.Insert(index, value);
|
|||
|
|
|||
|
public void Remove(Panel value) => List.Remove(value);
|
|||
|
|
|||
|
public bool Contains(Panel value) => List.Contains(value);
|
|||
|
|
|||
|
protected override void OnInsertComplete(int index, object value)
|
|||
|
{
|
|||
|
base.OnInsertComplete(index, value);
|
|||
|
|
|||
|
if (panelBook != null)
|
|||
|
{
|
|||
|
panelBook.PageIndex = index;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnRemoveComplete(int index, object value)
|
|||
|
{
|
|||
|
base.OnRemoveComplete(index, value);
|
|||
|
|
|||
|
if (panelBook != null)
|
|||
|
{
|
|||
|
if (panelBook.PageIndex == index)
|
|||
|
{
|
|||
|
if (index < InnerList.Count)
|
|||
|
{
|
|||
|
panelBook.PageIndex = index;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
panelBook.PageIndex = InnerList.Count - 1;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|