Example #1
0
        public void AddTab(object tabId = null, string tabText = null, Bitmap icon = null, object tag = null, bool?insertToTheLeft = null, bool select = true)
        {
            lock (_syncRoot)
            {
                tabText = tabText ?? GetDefaultText(Count);
                var tabIcon = icon ?? DefaultIcon;
                int width   = getTabWidth(tabText, tabIcon, CloseIcon);

                TabIds.Add(tabId);
                Texts.Add(tabText);
                Icons.Add(tabIcon);
                Widths.Add(width);
                Tags.Add(tag);
            }

            OnLayout(new LayoutEventArgs(this, null));
            Invalidate();

            int index = Count - 1;

            TabAdded?.Invoke(this, index);

            if (select)
            {
                SelectedIndex = index;
            }

            if ((insertToTheLeft ?? AddNewTabsToTheLeft) && index != 0)
            {
                RelocateTab(index, 0, selectRelocated: select);
            }
        }
Example #2
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();
        }
 protected void OnTabAdded(TabAddedEventArgs e)
 {
     if (!SupressTabEvents)
     {
         TabAdded?.Invoke(this, e);
     }
 }
Example #4
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>
        internal void AddPage(TabButton button)
        {
            ControlBase page = button.Page;

            page.Parent   = this;
            page.IsHidden = true;
            page.Dock     = Dock.Fill;
            page.Margin   = (Margin)this.Padding;

            button.Parent = m_TabStrip;
            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, EventArgs.Empty);
            }

            Invalidate();
        }
Example #5
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)
        {
            TabPage page = button.Page;

            page.Parent   = this;
            page.IsHidden = true;
            page.Margin   = new Margin(6, 6, 6, 6);
            page.Dock     = Dock.Fill;

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

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

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

            Invalidate();
        }
Example #6
0
        private void AddTab(float pos)
        {
            RectangleF rect = new RectangleF(pos, 10f, 8f, 8f);

            tabs.Add(rect);
            if (TabAdded != null)
            {
                TabAdded.Invoke(CreateTabArgs(pos));
            }
        }