diff --git a/2019/05/PanelBook.Designer.cs b/2019/05/PanelBook.Designer.cs index 576b43a..7cb44d1 100644 --- a/2019/05/PanelBook.Designer.cs +++ b/2019/05/PanelBook.Designer.cs @@ -28,8 +28,7 @@ /// private void InitializeComponent() { - components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + components = new System.ComponentModel.Container(); } #endregion diff --git a/2019/05/PanelBook.cs b/2019/05/PanelBook.cs index 190ec28..8375433 100644 --- a/2019/05/PanelBook.cs +++ b/2019/05/PanelBook.cs @@ -1,12 +1,72 @@ namespace RyzStudio.Windows.Forms { using System; + using System.Collections; using System.ComponentModel; + using System.Drawing; using System.Windows.Forms; [ToolboxItem(true)] 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; public PanelBook() @@ -14,51 +74,49 @@ InitializeComponent(); 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")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - public PanelCollection Pages - { - get { return panelCollection; } - } + public PanelCollection Pages => panelCollection; [Category("Collection")] public int SelectedIndex { - get - { - if (panelCollection.Count <= 0) - { - return -1; - } - - return panelCollection.IndexOf(this.ActivePanel); - } + get => (panelCollection.Count <= 0) ? -1 : panelCollection.IndexOf(this.ActivePanel); set { - if (panelCollection.Count <= 0) - { - return; - } - - if (value < 0) - { - return; - } - - if (value > (panelCollection.Count - 1)) - { - return; - } - - if (value == this.SelectedIndex) - { - return; - } + if (panelCollection.Count <= 0) return; + if (value < 0) return; + if (value > (panelCollection.Count - 1)) return; + if (value == this.SelectedIndex) return; ActivatePanel(value); } @@ -66,10 +124,7 @@ protected internal int PageIndex { - get - { - return panelCollection.IndexOf(this.ActivePanel); - } + get => panelCollection.IndexOf(this.ActivePanel); set { if (panelCollection.Count <= 0) @@ -154,6 +209,5 @@ } } - } -} +} \ No newline at end of file diff --git a/2019/05/PanelCollection.cs b/2019/05/PanelCollection.cs deleted file mode 100644 index af9838b..0000000 --- a/2019/05/PanelCollection.cs +++ /dev/null @@ -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; - } - } - } - } - - } -}