Exemple #1
0
        private Rectangle GetTabRectangle(int index)
        {
            Rectangle r = new Rectangle(new Point((index - 1) * TabSize.Width - ScrollLocation, 0), TabSize);

            r = Tab_Renderer.GetOffsetBounds(r, index);
            r = new Rectangle(1 + Tab_Renderer.Margins.Left + r.X, 1 + Tab_Renderer.Margins.Top + r.Y, r.Width, r.Height);
            return(r);
        }
Exemple #2
0
        private Rectangle GetTabRectangle(int index, bool raw)
        {
            if (!raw)
            {
                return(GetTabRectangle(index));
            }

            Rectangle r = new Rectangle(new Point((index - 1) * TabSize.Width, 0), TabSize);

            r = Tab_Renderer.GetOffsetBounds(r, index);
            r = new Rectangle(1 + Tab_Renderer.Margins.Left + r.X, 1 + Tab_Renderer.Margins.Top + r.Y, r.Width, r.Height);
            return(r);
        }
Exemple #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            RefreshTabSize(g);

            if (_Tabs.Count > 0)
            {
                _Draw_Tabs(g);
            }
            // Draw close button.
            if (Draw_Close)
            {
                System.Windows.Forms.VisualStyles.PushButtonState state = System.Windows.Forms.VisualStyles.PushButtonState.Normal;
                if (Tab_Renderer.HitsCloseButton(Mouse_Moving, TabBarBounds))
                {
                    state = System.Windows.Forms.VisualStyles.PushButtonState.Hot;
                }
                if (Tab_Renderer.HitsCloseButton(Mouse_Holding, TabBarBounds))
                {
                    state = System.Windows.Forms.VisualStyles.PushButtonState.Pressed;
                }
                if (!Can_Close)
                {
                    state = System.Windows.Forms.VisualStyles.PushButtonState.Disabled;
                }
                Tab_Renderer.DrawCloseButton(g, TabBarBounds, state);
            }

            Tab_Renderer.DrawScrollButtons(g, TabBarBounds, Mouse_Moving, Mouse_Holding, (Draw_Close), Overflow);

            // Top
            g.FillRectangle(SystemBrushes.Control, new Rectangle(0, 0, this.Size.Width, Padding.Top - TabBarBounds.Height));

            // Left
            g.FillRectangle(SystemBrushes.Control, new Rectangle(0, 0, Padding.Left, this.Size.Height));

            // Right
            g.FillRectangle(SystemBrushes.Control, new Rectangle(this.Size.Width - Padding.Right, 0, this.Size.Width, this.Size.Height));

            // Bottom
            g.FillRectangle(SystemBrushes.Control, new Rectangle(0, this.Size.Height - Padding.Bottom, this.Size.Width, this.Size.Height));
        }
Exemple #4
0
        private VisualTab_HitTest HitTest(Point p)
        {
            VisualTab_HitTest test = new VisualTab_HitTest();

            for (int i = 0; i < this.Tabs.Count; i++)
            {
                Rectangle tab_re = this.GetTabRectangle(i);

                if (tab_re.Contains(p))
                {
                    test.Tab      = i;
                    test.Location = VisualTab_HitLocation.Tab;
                    break;
                }
            }
            if (Tab_Renderer.ArrowLeft.Contains(p))
            {
                test.Location = VisualTab_HitLocation.Scroll_left;
            }
            if (Tab_Renderer.ArrowRight.Contains(p))
            {
                test.Location = VisualTab_HitLocation.Scroll_right;
            }
            if (Draw_Close)
            {
                if (Tab_Renderer.HitsCloseButton(p, TabBarBounds))
                {
                    test.Location = VisualTab_HitLocation.Close;
                }
            }
            if (WillDraw_Dropdown)
            {
            }

            return(test);
        }
Exemple #5
0
        private void _Draw_Tabs(Graphics g)
        {
            int       i             = 0;
            Rectangle bounds_intern = GetTabRectangle(0);

            switch (Tab_Renderer.Mode)
            {
            case VisualTabRenderer_Mode.NO_PREFERENCE:

                foreach (VisualTabPage p in this._Tabs)
                {
                    bounds_intern = GetTabRectangle(i);

                    if (bounds_intern.X > TabBarBoundsWithButtons.Width + TabBarBoundsWithButtons.X)
                    {
                        break;
                    }
                    System.Windows.Forms.VisualStyles.TabItemState state = System.Windows.Forms.VisualStyles.TabItemState.Normal;

                    if (IsSelected(p))
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Selected;
                    }
                    else if (bounds_intern.Contains(Mouse_Moving))
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Hot;
                    }
                    Tab_Renderer.DrawTabItem(g, bounds_intern, state);
                    g.DrawString(p.Text, this.Font, SystemBrushes.ControlText, Tab_Renderer.GetTextBounds(bounds_intern));


                    i++;
                }
                break;

            case VisualTabRenderer_Mode.SELECTED_LAST:
                foreach (VisualTabPage p in this._Tabs)
                {
                    if (IsSelected(p))
                    {
                        i++;
                        continue;
                    }
                    bounds_intern = GetTabRectangle(i);

                    if (bounds_intern.X > TabBarBounds.Width + TabBarBounds.X)
                    {
                        break;
                    }
                    System.Windows.Forms.VisualStyles.TabItemState state = System.Windows.Forms.VisualStyles.TabItemState.Normal;

                    if (bounds_intern.Contains(Mouse_Moving))
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Hot;
                    }


                    Tab_Renderer.DrawTabItem(g, bounds_intern, state);
                    g.DrawString(p.Text, this.Font, SystemBrushes.ControlText, Tab_Renderer.GetTextBounds(bounds_intern));

                    i++;
                }
                i = 0;

                foreach (VisualTabPage p in this._Tabs)
                {
                    if (!IsSelected(p))
                    {
                        i++;

                        continue;
                    }
                    bounds_intern = GetTabRectangle(i);
                    if (bounds_intern.X > TabBarBounds.Width + TabBarBounds.X)
                    {
                        break;
                    }
                    System.Windows.Forms.VisualStyles.TabItemState state = System.Windows.Forms.VisualStyles.TabItemState.Selected;


                    Tab_Renderer.DrawTabItem(g, bounds_intern, state);
                    g.DrawString(p.Text, this.Font, SystemBrushes.ControlText, Tab_Renderer.GetTextBounds(bounds_intern));

                    break;
                }
                //MessageBox.Show("Selected tab: " + i + " , " + this.SelectedTabIndex);
                break;

            case VisualTabRenderer_Mode.SELECTED_FIRST:

                foreach (VisualTabPage p in this._Tabs)
                {
                    bounds_intern = GetTabRectangle(i);
                    if (!IsSelected(p))
                    {
                        bounds_intern = Tab_Renderer.GetOffsetBounds(bounds_intern, i - 1);
                        i++;
                        continue;
                    }

                    System.Windows.Forms.VisualStyles.TabItemState state = System.Windows.Forms.VisualStyles.TabItemState.Selected;


                    Tab_Renderer.DrawTabItem(g, bounds_intern, state);

                    g.DrawString(p.Text, this.Font, SystemBrushes.ControlText, Tab_Renderer.GetTextBounds(bounds_intern));

                    i++;
                }
                i             = 0;
                bounds_intern = GetTabRectangle(0);
                foreach (VisualTabPage p in this._Tabs)
                {
                    if (IsSelected(p))
                    {
                        i++;
                        continue;
                    }
                    bounds_intern = GetTabRectangle(i);

                    System.Windows.Forms.VisualStyles.TabItemState state = System.Windows.Forms.VisualStyles.TabItemState.Normal;

                    if (bounds_intern.Contains(Mouse_Moving))
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Hot;
                    }

                    Tab_Renderer.DrawTabItem(g, bounds_intern, state);
                    g.DrawString(p.Text, this.Font, SystemBrushes.ControlText, Tab_Renderer.GetTextBounds(bounds_intern));

                    i++;
                }
                break;
            }
        }
Exemple #6
0
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     Tab_Renderer.DrawTabPage(e.Graphics, new Rectangle(new Point(0, -1), new Size(this.Size.Width + 2, this.Size.Height + 2)));
 }