コード例 #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();
        }
コード例 #2
0
ファイル: TabControl.cs プロジェクト: jealouscloud/gwen-lra
        /// <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 TabPage AddPage(string label, ControlBase page = null)
        {
            TabButton button  = new TabButton(m_TabStrip);
            var       tabpage = new TabPage(this, button);

            tabpage.Name = label;
            button.SetText(label);
            button.Page      = tabpage;
            button.IsTabable = false;
            if (page != null)
            {
                tabpage.AddChild(page);
            }
            AddPage(button);
            return(tabpage);
        }
コード例 #3
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, EventArgs.Empty);
            }

            Invalidate();
        }
コード例 #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 ControlBase(this);
            }
            else
            {
                page.Parent = this;
            }

            TabButton button = new TabButton(m_TabStrip);

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

            AddPage(button);
            return(button);
        }
コード例 #5
0
ファイル: TabControl.cs プロジェクト: jealouscloud/gwen-lra
        /// <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;

            m_TabStrip.Invalidate();
            Invalidate();
        }
コード例 #6
0
ファイル: TabControl.cs プロジェクト: jealouscloud/gwen-lra
        public void RemoveTab(TabPage page)
        {
            var idx = -1;

            if (CurrentButton == page.TabButton)
            {
                idx = TabStrip.Children.IndexOf(page.TabButton);
                if (idx == TabStrip.Children.Count - 1)
                {
                    idx--;
                }
                m_CurrentButton = null;
            }
            TabStrip.RemoveChild(page.TabButton, true);
            RemoveChild(page, true);
            if (idx != -1)
            {
                GetPage(idx).FocusTab();
            }
            OnLoseTab(page.TabButton);
            Invalidate();
        }
コード例 #7
0
 public void UpdateFromTab(TabButton button)
 {
     Text = button.Text;
     SizeToChildren();
 }
コード例 #8
0
 public void UpdateFromTab(TabButton button)
 {
     Text = button.Text;
     SizeToContents();
 }
コード例 #9
0
ファイル: TabControl.cs プロジェクト: jealouscloud/gwen-lra
 private void UnsubscribeTabEvent(TabButton button)
 {
     button.Clicked -= OnTabPressed;
 }
コード例 #10
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.SkinBase 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);
        }
コード例 #11
0
 public void FocusTab()
 {
     TabButton.Press();
 }
コード例 #12
0
 public TabPage(ControlBase parent, TabButton button) : base(parent)
 {
     m_ParentButton = button;
 }