Example #1
0
        public void MoveTabsTo(DockedTabControl target)
        {
            var children = TabStrip.Children.ToArray(); // copy because collection will be modified

            foreach (ControlBase child in children)
            {
                TabButton button = child as TabButton;
                if (button == null)
                {
                    continue;
                }
                target.AddPage(button);
            }
            Invalidate();
        }
Example #2
0
        /// <summary>
        /// Handler for tab removing.
        /// </summary>
        /// <param name="button"></param>
        internal virtual void OnLoseTab(TabButton button)
        {
            if (m_CurrentButton == button)
            {
                m_CurrentButton = null;
            }

            //TODO: Select a tab if any exist.

            if (TabRemoved != null)
            {
                TabRemoved.Invoke(this);
            }

            Invalidate();
        }
Example #3
0
        /// <summary>
        /// Adds a new page/tab.
        /// </summary>
        /// <param name="label">Tab label.</param>
        /// <param name="page">Page contents.</param>
        /// <returns>Newly created control.</returns>
        public TabButton AddPage(String label, Base page = null)
        {
            if (null == page)
            {
                page = new Base(this);
            }
            else
            {
                page.Parent = this;
            }

            TabButton button = new TabButton(m_TabStrip);

            button.SetText(label);
            button.Page      = page;
            button.IsTabable = false;

            AddPage(button);
            return(button);
        }
Example #4
0
        /// <summary>
        /// Adds a new page/tab.
        /// </summary>
        /// <param name="label">Tab label.</param>
        /// <param name="page">Page contents.</param>
        /// <returns>Newly created control.</returns>
        public TabButton AddPage(string label, ControlBase page = null)
        {
            if (null == page)
            {
                page = new Layout.DockLayout(this);
            }
            else
            {
                page.Parent = this;
            }

            TabButton button = new TabButton(m_TabStrip);

            button.Text      = label;
            button.Page      = page;
            button.IsTabable = false;

            AddPage(button);
            return(button);
        }
Example #5
0
        /// <summary>
        /// Handler for tab selection.
        /// </summary>
        /// <param name="control">Event source (TabButton).</param>
        internal virtual void OnTabPressed(Base control)
        {
            TabButton button = control as TabButton;

            if (null == button)
            {
                return;
            }

            Base page = button.Page;

            if (null == page)
            {
                return;
            }

            if (m_CurrentButton == button)
            {
                return;
            }

            if (null != m_CurrentButton)
            {
                Base page2 = m_CurrentButton.Page;
                if (page2 != null)
                {
                    page2.IsHidden = true;
                }
                m_CurrentButton.Redraw();
                m_CurrentButton = null;
            }

            m_CurrentButton = button;

            page.IsHidden = false;

            m_TabStrip.Invalidate();
            Invalidate();
        }
Example #6
0
        /// <summary>
        /// Handler for tab selection.
        /// </summary>
        /// <param name="control">Event source (TabButton).</param>
        internal virtual void OnTabPressed(ControlBase control, EventArgs args)
        {
            TabButton button = control as TabButton;

            if (null == button)
            {
                return;
            }

            ControlBase page = button.Page;

            if (null == page)
            {
                return;
            }

            if (currentButton == button)
            {
                return;
            }

            if (null != currentButton)
            {
                ControlBase page2 = currentButton.Page;
                if (page2 != null)
                {
                    page2.IsHidden = true;
                }
                currentButton.Redraw();
                currentButton = null;
            }

            currentButton = button;

            page.IsHidden = false;

            tabStrip.Invalidate();
            Invalidate();
        }
Example #7
0
        /// <summary>
        /// Handler for tab removing.
        /// </summary>
        /// <param name="button"></param>
        internal virtual void OnLoseTab(TabButton button)
        {
            if (m_CurrentButton == button)
            {
                m_CurrentButton = null;
            }

            if (TabCount > 0)
            {
                button = m_TabStrip.Children[0] as TabButton;
                if (button != null)
                {
                    button.Page.Show();
                    m_CurrentButton = button;
                }
            }

            if (TabRemoved != null)
            {
                TabRemoved.Invoke(this, EventArgs.Empty);
            }

            Invalidate();
        }
Example #8
0
        /// <summary>
        /// Handler for tab selection.
        /// </summary>
        /// <param name="control">Event source (TabButton).</param>
        internal virtual void OnTabPressed(ControlBase control, EventArgs args)
        {
            TabButton button = control as TabButton;

            if (null == button)
            {
                return;
            }

            ControlBase page = button.Page;

            if (null == page)
            {
                return;
            }

            if (m_CurrentButton == button)
            {
                return;
            }

            if (null != m_CurrentButton)
            {
                ControlBase page2 = m_CurrentButton.Page;
                if (page2 != null)
                {
                    page2.IsHidden = true;
                }
                m_CurrentButton.Redraw();
                m_CurrentButton = null;
            }

            m_CurrentButton = button;

            page.IsHidden = false;
        }
Example #9
0
 private void UnsubscribeTabEvent(TabButton button)
 {
     button.Clicked -= OnTabPressed;
 }
Example #10
0
        /// <summary>
        /// Handler for tab selection.
        /// </summary>
        /// <param name="control">Event source (TabButton).</param>
        internal virtual void OnTabPressed(Base control)
        {
            TabButton button = control as TabButton;
            if (null == button) return;

            Base page = button.Page;
            if (null == page) return;

            if (m_CurrentButton == button)
                return;

            if (null != m_CurrentButton)
            {
                Base page2 = m_CurrentButton.Page;
                if (page2 != null)
                {
                    page2.IsHidden = true;
                }
                m_CurrentButton.Redraw();
                m_CurrentButton = null;
            }

            m_CurrentButton = button;

            page.IsHidden = false;

            m_TabStrip.Invalidate();
            Invalidate();
        }
Example #11
0
        /// <summary>
        /// Handler for tab removing.
        /// </summary>
        /// <param name="button"></param>
        internal virtual void OnLoseTab(TabButton button)
        {
            if (m_CurrentButton == button)
                m_CurrentButton = null;

            //TODO: Select a tab if any exist.

            if (TabRemoved != null)
                TabRemoved.Invoke(this);

            Invalidate();
        }
Example #12
0
        /// <summary>
        /// Adds a page/tab.
        /// </summary>
        /// <param name="button">Page to add. (well, it's a TabButton which is a parent to the page).</param>
        public void AddPage(TabButton button)
        {
            Base page = button.Page;
            page.Parent = this;
            page.IsHidden = true;
            page.Margin = new Margin(6, 6, 6, 6);
            page.Dock = Pos.Fill;

            button.Parent = m_TabStrip;
            button.Dock = Pos.Left;
            button.SizeToContents();
            if (button.TabControl != null)
                button.TabControl.UnsubscribeTabEvent(button);
            button.TabControl = this;
            button.Clicked += OnTabPressed;

            if (null == m_CurrentButton)
            {
                button.Press();
            }

            if (TabAdded != null)
                TabAdded.Invoke(this);

            Invalidate();
        }
Example #13
0
        /// <summary>
        /// Adds a new page/tab.
        /// </summary>
        /// <param name="label">Tab label.</param>
        /// <param name="page">Page contents.</param>
        /// <returns>Newly created control.</returns>
        public TabButton AddPage(String label, Base page = null)
        {
            if (null == page)
            {
                page = new Base(this);
            }
            else
            {
                page.Parent = this;
            }

            TabButton button = new TabButton(m_TabStrip);
            button.SetText(label);
            button.Page = page;
            button.IsTabable = false;

            AddPage(button);
            return button;
        }
Example #14
0
        /// <summary>
        /// Lays out the control's interior according to alignment, padding, dock etc.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void Layout(Skin.Base skin)
        {
            Point largestTab = new Point(5, 5);

            int num = 0;

            foreach (var child in Children)
            {
                TabButton button = child as TabButton;
                if (null == button)
                {
                    continue;
                }

                button.SizeToContents();

                Margin m        = new Margin();
                int    notFirst = num > 0 ? -1 : 0;

                if (Dock == Pos.Top)
                {
                    m.Left      = notFirst;
                    button.Dock = Pos.Left;
                }

                if (Dock == Pos.Left)
                {
                    m.Top       = notFirst;
                    button.Dock = Pos.Top;
                }

                if (Dock == Pos.Right)
                {
                    m.Top       = notFirst;
                    button.Dock = Pos.Top;
                }

                if (Dock == Pos.Bottom)
                {
                    m.Left      = notFirst;
                    button.Dock = Pos.Left;
                }

                largestTab.X = Math.Max(largestTab.X, button.Width);
                largestTab.Y = Math.Max(largestTab.Y, button.Height);

                button.Margin = m;
                num++;
            }

            if (Dock == Pos.Top || Dock == Pos.Bottom)
            {
                SetSize(Width, largestTab.Y);
            }

            if (Dock == Pos.Left || Dock == Pos.Right)
            {
                SetSize(largestTab.X, Height);
            }

            base.Layout(skin);
        }
Example #15
0
 public void UpdateFromTab(TabButton button)
 {
     Text = button.Text;
     SizeToContents();
 }
Example #16
0
 private void UnsubscribeTabEvent(TabButton button)
 {
     button.Clicked -= OnTabPressed;
 }
Example #17
0
        /// <summary>
        /// Handler for tab removing.
        /// </summary>
        /// <param name="button"></param>
        internal virtual void OnLoseTab(TabButton button)
        {
            if (m_CurrentButton == button)
                m_CurrentButton = null;

            //TODO: Select a tab if any exist.

            TabRemoved?.Invoke(this, EventArgs.Empty);

            Invalidate();
        }
Example #18
0
 public void UpdateFromTab(TabButton button)
 {
     Text = button.Text;
     SizeToContents();
 }
Example #19
0
 public void RemovePage(TabButton button)
 {
     RemoveChild(button.Page, true);
     m_TabStrip.RemoveChild(button, true);
 }