예제 #1
0
        private void PaintTabClose(Graphics g, int index)
        {
            PointPath path = GetTabClosePath(index);

            if (this.GetTabPath(index).MinimumBounds.Width < 2 * TAB_CLOSE_BUTTON_RADIUS)
            {
                return;
            }

            Color xColor = Color.FromArgb(90, 90, 90);

            if (path.HitTest(this.Owner.PointToClient(Control.MousePosition)))
            {
                xColor = Color.White;

                using (SolidBrush b = new SolidBrush(Color.FromArgb(219, 68, 55)))
                {
                    g.FillCircle(b, path.Bounds.X + TAB_CLOSE_BUTTON_RADIUS, path.Bounds.Y + TAB_CLOSE_BUTTON_RADIUS, TAB_CLOSE_BUTTON_RADIUS);
                }
            }

            using (Pen p = new Pen(xColor, 1.75f))
            {
                float left   = path.Bounds.Left + TAB_CLOSE_X_INSET;
                float right  = path.Bounds.Right - TAB_CLOSE_X_INSET;
                float top    = path.Bounds.Top + TAB_CLOSE_X_INSET;
                float bottom = path.Bounds.Bottom - TAB_CLOSE_X_INSET;
                g.DrawLine(p, left, top, right, bottom);
                g.DrawLine(p, right, top, left, bottom);
            }
        }
 public static void DrawPointPath(this Graphics graphics, Pen pen, PointPath pointPath, bool closed)
 {
     if (closed)
     {
         graphics.DrawPolygon(pen, pointPath.Points);
     }
     else
     {
         graphics.DrawLines(pen, pointPath.Points);
     }
 }
예제 #3
0
        public PointPath GetTabClosePath(int index)
        {
            PointPath tabPath = GetTabPath(index);

            int right  = tabPath.MinimumBounds.Right;
            int left   = right - 2 * TAB_CLOSE_BUTTON_RADIUS;
            int top    = tabPath.Bounds.Top + (tabPath.Bounds.Height / 2 - TAB_CLOSE_BUTTON_RADIUS);
            int bottom = top + 2 * TAB_CLOSE_BUTTON_RADIUS;

            return(new PointPath(new[]
            {
                new Point(left, top),
                new Point(right, top),
                new Point(right, bottom),
                new Point(left, bottom)
            }));
        }
예제 #4
0
        private void PaintNewTab(Graphics g)
        {
            PointPath newTabPath = GetNewTabPath();
            Rectangle bounds     = newTabPath.Bounds;

            Color newTabButtonColor = this.Owner.TabColor;

            if (this.Owner.Focused &&
                newTabPath.HitTest(this.Owner.PointToClient(Control.MousePosition)))
            {
                if (this.Owner.ShowHitTest)
                {
                    newTabButtonColor = Color.LightBlue;
                }
                else
                {
                    newTabButtonColor = ControlPaint.Light(newTabButtonColor, 0.5f);
                }
            }

            using (Brush b = new SolidBrush(newTabButtonColor))
            {
                g.FillPointPath(b, newTabPath);
            }
            using (Pen p = new Pen(this.Owner.TabBorderColor))
            {
                g.DrawPointPath(p, newTabPath, true);
            }

            using (Pen p = new Pen(Color.FromArgb(90, 90, 90), 1.6f))
            {
                float top    = bounds.Top + (bounds.Height - NEW_TAB_PLUS_SIZE) / 2.0f;
                float bottom = top + NEW_TAB_PLUS_SIZE;
                float midY   = top + (NEW_TAB_PLUS_SIZE / 2.0f);
                float left   = bounds.Left + ((float)bounds.Width - NEW_TAB_PLUS_SIZE) / 2.0f;
                float right  = left + NEW_TAB_PLUS_SIZE;
                float midX   = left + (NEW_TAB_PLUS_SIZE / 2.0f);
                g.DrawLine(p, left, midY, right, midY);
                g.DrawLine(p, midX, top, midX, bottom);
            }
        }
예제 #5
0
        private void PaintOptionsMenuButton(Graphics g)
        {
            PointPath path = GetOptionsPath();

            Color background = Color.Transparent;

            if (this.Owner.Focused &&
                path.HitTest(this.Owner.PointToClient(Control.MousePosition)))
            {
                if (this.Owner.ShowHitTest)
                {
                    background = Color.LightBlue;
                }
                else
                {
                    background = Color.FromArgb(222, 222, 222);
                }
            }

            using (SolidBrush b = new SolidBrush(background))
            {
                g.FillPointPath(b, path);
            }

            using (SolidBrush b = new SolidBrush(Color.FromArgb(60, 60, 60)))
            {
                float radius = 1.5f;
                float x      = path.Bounds.Left + path.Bounds.Width / 2.0f;
                float midY   = path.Bounds.Top + path.Bounds.Height / 2.0f;
                float topY   = midY - 2 * radius - 2;
                float botY   = midY + 2 * radius + 2;

                g.FillCircle(b, x, topY, radius);
                g.FillCircle(b, x, midY, radius);
                g.FillCircle(b, x, botY, radius);
            }
        }
예제 #6
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            if (_painter.GetNewTabPath().HitTest(e.Location))
            {
                if (e.Button == MouseButtons.Left)
                {
                    OnNewTabClick(EventArgs.Empty);
                    return;
                }
                else if (e.Button == MouseButtons.Right &&
                         NewTabContextMenu != null)
                {
                    NewTabContextMenu.Show(this, e.Location);
                    return;
                }
            }

            if (this.OptionsMenu != null &&
                e.Button == MouseButtons.Left)
            {
                PointPath optionsPath = _painter.GetOptionsPath();
                if (optionsPath.HitTest(e.Location))
                {
                    OptionsMenu.Show(this, _painter.OptionsMenuLocation);
                    return;
                }
            }

            if (e.Button == MouseButtons.Left)
            {
                Tab closeTab = this.GetTabCloseFromPoint(e.Location);
                if (closeTab != null)
                {
                    ClosingTab = true;
                    this.Tabs.Remove(closeTab);
                    OnTabClosed(new TabClosedEventArgs(closeTab));
                    ClosingTab = false;
                    return;
                }
            }

            if (e.Button != MouseButtons.Left)
            {
                Tab t = GetTabFromPoint(e.Location);
                if (t != null)
                {
                    if (e.Button == MouseButtons.Middle &&
                        this.CloseTabOnMiddleClick)
                    {
                        ClosingTab = true;
                        this.Tabs.Remove(t);
                        OnTabClosed(new TabClosedEventArgs(t));
                        ClosingTab = false;
                        return;
                    }
                    else if (e.Button == MouseButtons.Right &&
                             TabContextMenu != null)
                    {
                        SelectedIndex = Tabs.IndexOf(t);
                        TabContextMenu.Show(this, e.Location);
                        return;
                    }
                    else
                    {
                        SelectedIndex = Tabs.IndexOf(t);
                        OnTabClick(new TabClickEventArgs(t, e));
                        return;
                    }
                }
            }

            base.OnMouseClick(e);
        }
 public static void FillPointPath(this Graphics graphics, Brush brush, PointPath pointPath)
 {
     graphics.FillPolygon(brush, pointPath.Points);
 }
예제 #8
0
        private void PaintTab(Graphics g, Tab t, int index, bool selected)
        {
            PointPath path = GetTabPath(index);

            Color tabColor = selected ? this.Owner.SelectedTabColor : this.Owner.TabColor;

            if ((!selected || this.Owner.ShowHitTest) &&
                this.Owner.Focused &&
                path.HitTest(this.Owner.PointToClient(Control.MousePosition)))
            {
                if (this.Owner.ShowHitTest)
                {
                    tabColor = Color.LightBlue;
                }
                else
                {
                    tabColor = ControlPaint.Light(tabColor, 0.60f);
                }
            }

            using (Brush b = new SolidBrush(tabColor))
            {
                g.FillPointPath(b, path);
                using (Pen bp = new Pen(b))
                {
                    g.DrawPointPath(bp, path, true);
                }
            }

            using (Pen p = new Pen(this.Owner.TabBorderColor))
            {
                g.DrawPointPath(p, path, false);
            }

            int textAreaWidth = path.MinimumBounds.Width - 2 * TAB_CLOSE_BUTTON_RADIUS;
            int textAreaX     = path.MinimumBounds.X;

            if (t.Icon != null)
            {
                int x = path.MinimumBounds.Left + TAB_ICON_PADDING;
                int y = path.MinimumBounds.Top + (path.MinimumBounds.Height - TAB_ICON_SIZE) / 2;
                g.DrawImage(t.Icon, new Rectangle(x, y, TAB_ICON_SIZE, TAB_ICON_SIZE));
                textAreaWidth -= TAB_ICON_SIZE + 2 * TAB_ICON_PADDING;
                textAreaX     += TAB_ICON_SIZE + 2 * TAB_ICON_PADDING;
            }

            Rectangle       bounds = new Rectangle(textAreaX, path.MinimumBounds.Y, textAreaWidth, path.MinimumBounds.Height);
            TextFormatFlags flags  = TextFormatFlags.HorizontalCenter
                                     | TextFormatFlags.VerticalCenter
                                     | TextFormatFlags.SingleLine
                                     | TextFormatFlags.LeftAndRightPadding;

            if (t.Text.Contains(Path.DirectorySeparatorChar) ||
                t.Text.Contains(Path.AltDirectorySeparatorChar))
            {
                flags |= TextFormatFlags.PathEllipsis;
            }
            else
            {
                flags |= TextFormatFlags.WordEllipsis;
            }
            TextRenderer.DrawText(g, t.Text, t.Font, bounds, t.ForeColor, flags);

            PaintTabClose(g, index);
        }