Changed: modernise panelbook
This commit is contained in:
parent
53e4a1e84e
commit
3782bbfc44
3
2019/05/PanelBook.Designer.cs
generated
3
2019/05/PanelBook.Designer.cs
generated
@ -28,8 +28,7 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
components = new System.ComponentModel.Container();
|
components = new System.ComponentModel.Container();
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -1,12 +1,72 @@
|
|||||||
namespace RyzStudio.Windows.Forms
|
namespace RyzStudio.Windows.Forms
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
[ToolboxItem(true)]
|
[ToolboxItem(true)]
|
||||||
public partial class PanelBook : UserControl
|
public partial class PanelBook : UserControl
|
||||||
{
|
{
|
||||||
|
public class PanelCollection : CollectionBase
|
||||||
|
{
|
||||||
|
protected PanelBook panelBook = null;
|
||||||
|
|
||||||
|
public PanelCollection(PanelBook parentPanelBook) : base()
|
||||||
|
{
|
||||||
|
panelBook = parentPanelBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) => Array.ForEach(pages, x => this.Add(x));
|
||||||
|
|
||||||
|
public bool Contains(Panel value) => List.Contains(value);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected PanelCollection panelCollection = null;
|
protected PanelCollection panelCollection = null;
|
||||||
|
|
||||||
public PanelBook()
|
public PanelBook()
|
||||||
@ -14,51 +74,49 @@
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
panelCollection = new PanelCollection(this);
|
panelCollection = new PanelCollection(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Panel ActivePanel { get; set; } = null;
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public Panel ActivePanel { get; protected set; } = null;
|
||||||
|
|
||||||
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override bool AutoScroll { get => base.AutoScroll; set => base.AutoScroll = value; }
|
||||||
|
|
||||||
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public new Size AutoScrollMargin { get => base.AutoScrollMargin; set => base.AutoScrollMargin = value; }
|
||||||
|
|
||||||
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public new Size AutoScrollMinSize { get => base.AutoScrollMinSize; set => base.AutoScrollMinSize = value; }
|
||||||
|
|
||||||
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override Image BackgroundImage { get => base.BackgroundImage; set => base.BackgroundImage = value; }
|
||||||
|
|
||||||
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override ImageLayout BackgroundImageLayout { get => base.BackgroundImageLayout; set => base.BackgroundImageLayout = value; }
|
||||||
|
|
||||||
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public new ImeMode ImeMode { get => base.ImeMode; set => base.ImeMode = value; }
|
||||||
|
|
||||||
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override RightToLeft RightToLeft { get => base.RightToLeft; set => base.RightToLeft = value; }
|
||||||
|
|
||||||
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public new bool UseWaitCursor { get => base.UseWaitCursor; set => base.UseWaitCursor = value; }
|
||||||
|
|
||||||
[Category("Collection")]
|
[Category("Collection")]
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||||
public PanelCollection Pages
|
public PanelCollection Pages => panelCollection;
|
||||||
{
|
|
||||||
get { return panelCollection; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[Category("Collection")]
|
[Category("Collection")]
|
||||||
public int SelectedIndex
|
public int SelectedIndex
|
||||||
{
|
{
|
||||||
get
|
get => (panelCollection.Count <= 0) ? -1 : panelCollection.IndexOf(this.ActivePanel);
|
||||||
{
|
|
||||||
if (panelCollection.Count <= 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return panelCollection.IndexOf(this.ActivePanel);
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (panelCollection.Count <= 0)
|
if (panelCollection.Count <= 0) return;
|
||||||
{
|
if (value < 0) return;
|
||||||
return;
|
if (value > (panelCollection.Count - 1)) return;
|
||||||
}
|
if (value == this.SelectedIndex) return;
|
||||||
|
|
||||||
if (value < 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value > (panelCollection.Count - 1))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value == this.SelectedIndex)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActivatePanel(value);
|
ActivatePanel(value);
|
||||||
}
|
}
|
||||||
@ -66,10 +124,7 @@
|
|||||||
|
|
||||||
protected internal int PageIndex
|
protected internal int PageIndex
|
||||||
{
|
{
|
||||||
get
|
get => panelCollection.IndexOf(this.ActivePanel);
|
||||||
{
|
|
||||||
return panelCollection.IndexOf(this.ActivePanel);
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (panelCollection.Count <= 0)
|
if (panelCollection.Count <= 0)
|
||||||
@ -154,6 +209,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,80 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user