public void DrawPage(Graphics g, StiTabTitlePosition position, StiTabulatorPage page)
        {
            var rect     = new Rectangle(0, 0, page.Width - 1, page.Height - 1);
            var pageRect = ((StiTabulator)page.Parent).GetTitlePageRectangle(g, page);

            using (Pen penLight = new Pen(StiColorUtils.Light(SystemColors.Control, 30)),
                   penDark = new Pen(StiColorUtils.Dark(SystemColors.Control, 50)))
            {
                DrawDot(g, 0, 0);
                DrawDot(g, rect.Right, 0);
                DrawDot(g, rect.Right, rect.Bottom);
                DrawDot(g, 0, rect.Bottom);


                switch (position)
                {
                case StiTabTitlePosition.LeftHorizontal:
                    DrawPageLeftHorizontal(g, page, penLight, penDark, rect, pageRect);
                    break;

                case StiTabTitlePosition.TopHorizontal:
                    DrawPageTopHorizontal(g, page, penLight, penDark, rect, pageRect);
                    break;

                case StiTabTitlePosition.RightHorizontal:
                    DrawPageRightHorizontal(g, page, penLight, penDark, rect, pageRect);
                    break;
                }
            }
        }
        public void DrawPageTitle(Graphics g, StiTabTitlePosition position, StiTabulatorPage page)
        {
            var       rect = tabulator.GetTitlePageRectangle(g, page);
            Rectangle contentRect;

            if (rect.Width != 0 && rect.Height != 0)
            {
                using (Pen penLight = new Pen(StiColorUtils.Light(SystemColors.Control, 30)),
                       penDark = new Pen(StiColorUtils.Dark(SystemColors.Control, 50)))
                {
                    switch (position)
                    {
                    case StiTabTitlePosition.LeftHorizontal:
                        contentRect = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 1, rect.Height - 1);
                        DrawPageTitleLeftHorizontal(g, penLight, penDark, page, rect, contentRect);
                        break;

                    case StiTabTitlePosition.TopHorizontal:
                        contentRect = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 1, rect.Height - 1);
                        DrawPageTitleTopHorizontal(g, penLight, penDark, page, rect, contentRect);
                        break;

                    case StiTabTitlePosition.RightHorizontal:
                        contentRect = new Rectangle(rect.X, rect.Y + 3, rect.Width, rect.Height);
                        DrawPageTitleRightHorizontal(g, penLight, penDark, page, rect, contentRect);
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
        private void DrawMenuItemTitle(Graphics g, DrawItemEventArgs e, MenuItem menuItem, bool rightToLeft)
        {
            Rectangle rect = e.Bounds;

            rect.Location = new Point(0, 0);

            DrawMenuItemBar(g, e, menuItem, rightToLeft);

            if (!rightToLeft)
            {
                rect.X += MenuBarWidth;
            }
            rect.Width -= MenuBarWidth;

            rect.Width--;
            rect.Height--;

            using (var brush = new SolidBrush(StiColorUtils.Dark(SystemColors.Control, 20)))
            {
                g.FillRectangle(brush, rect);
            }

            var textRect = new Rectangle(rect.Left + 5, rect.Top, rect.Width - 5, rect.Height);

            using (var sf = new StringFormat())
            {
                if (rightToLeft)
                {
                    sf.Alignment = StringAlignment.Far;
                }
                else
                {
                    sf.Alignment = StringAlignment.Near;
                }
                sf.LineAlignment = StringAlignment.Center;
                sf.FormatFlags   = StringFormatFlags.NoWrap;
                sf.Trimming      = StringTrimming.EllipsisCharacter;

                sf.HotkeyPrefix = HotkeyPrefix.Hide;

                g.DrawString(menuItem.Text.Substring(2, menuItem.Text.Length - 4), Font, SystemBrushes.ControlText, textRect, sf);
            }

            using (var pen = new Pen(StiColors.Content))
            {
                if (rightToLeft)
                {
                    g.DrawLine(pen, rect.Right, rect.Y, rect.Right, rect.Bottom);
                }
                else
                {
                    g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);
                }
            }
        }
Esempio n. 4
0
        private void DrawMenuItemText(Graphics g, DrawItemEventArgs e, MenuItem item, bool rightToLeft)
        {
            Rectangle rect = e.Bounds;

            rect.Location = new Point(0, 0);
            if (!(item.Parent is MainMenu))
            {
                if (rightToLeft)
                {
                    rect = new Rectangle(rect.Left + 20, rect.Top, rect.Width - MenuBarWidth - 25, rect.Height);
                }
                else
                {
                    rect = new Rectangle(rect.Left + MenuBarWidth + 5, rect.Top, rect.Width, rect.Height);
                }

                using (var sf = new StringFormat())
                {
                    sf.Alignment = rightToLeft ? StringAlignment.Far : StringAlignment.Near;

                    sf.LineAlignment = StringAlignment.Center;
                    sf.FormatFlags  |= StringFormatFlags.NoWrap;
                    sf.HotkeyPrefix  = HotkeyPrefix.Show;

                    if (item.Enabled)
                    {
                        if (item.DefaultItem)
                        {
                            using (var defaultFont = new Font(Font, FontStyle.Bold))
                            {
                                g.DrawString(item.Text, defaultFont, SystemBrushes.ControlText, rect, sf);
                            }
                        }
                        else
                        {
                            g.DrawString(item.Text, Font, SystemBrushes.ControlText, rect, sf);
                        }
                    }
                    else
                    {
                        using (var brush = new SolidBrush(StiColorUtils.Light(SystemColors.ControlText, 150)))
                        {
                            g.DrawString(item.Text, Font, brush, rect, sf);
                        }
                    }
                }
            }
        }
        private void DrawPageTitleLeftHorizontal(Graphics g, Pen penLight, Pen penDark, StiTabulatorPage page,
                                                 Rectangle rect, Rectangle contentRect)
        {
            if (page != tabulator.SelectedTab)
            {
                int size = 4;
                rect.X            += size;
                rect.Width        -= size;
                contentRect.X     += size;
                contentRect.Width -= size;
            }

            g.DrawLine(penDark, rect.X + 1, rect.Y, rect.Right, rect.Y);
            g.DrawLine(penDark, rect.X, rect.Y + 1, rect.X, rect.Bottom - 1);
            g.DrawLine(penDark, rect.X + 1, rect.Bottom, rect.Right, rect.Bottom);

            if (page != tabulator.SelectedTab)
            {
                if (page.IsMouseOver)
                {
                    using (var br = new SolidBrush(StiColorUtils.Dark(StiColors.Content, 0)))
                    {
                        g.FillRectangle(br, contentRect);
                    }
                }
                else
                {
                    using (var br = new SolidBrush(StiColorUtils.Dark(StiColors.Content, 10)))
                    {
                        g.FillRectangle(br, contentRect);
                    }
                }
            }
            else
            {
                using (var br = new SolidBrush(tabulator.BackColor))
                {
                    g.FillRectangle(br, contentRect);
                }

                g.DrawLine(penLight, rect.X + 2, rect.Y + 1, rect.Right, rect.Y + 1);
                g.DrawLine(penLight, rect.X + 1, rect.Y + 1, rect.X + 1, rect.Bottom - 1);
            }

            tabulator.Mode.DrawTitleText(g, rect, page);
            tabulator.Mode.DrawTitleImage(g, rect, page);
        }
Esempio n. 6
0
        private void DrawPageTitleRightHorizontal(Graphics g, StiTabulatorPage page, Rectangle rect, Rectangle contentRect)
        {
            if (page != tabulator.SelectedTab)
            {
                if (page.IsMouseOver)
                {
                    using (var br = new SolidBrush(StiColorUtils.Dark(StiColors.Content, 0)))
                    {
                        g.FillRectangle(br, contentRect);
                    }
                }
            }
            else
            {
                using (var br = new SolidBrush(StiColorUtils.Dark(StiColors.Content, 0)))
                {
                    g.FillRectangle(br, contentRect);
                }
            }

            tabulator.Mode.DrawTitleText(g, rect, page);
            tabulator.Mode.DrawTitleImage(g, rect, page);
        }
Esempio n. 7
0
        private void DrawMenuItemShortcut(Graphics g, DrawItemEventArgs e, MenuItem item, bool rightToLeft)
        {
            var rect = e.Bounds;

            rect.Location = new Point(0, 0);
            rect.Width   -= 15;

            if (item.ShowShortcut && (!(item.Parent is MainMenu)))
            {
                using (var sf = new StringFormat())
                {
                    if (rightToLeft)
                    {
                        rect.X      += 10;
                        sf.Alignment = StringAlignment.Near;
                    }
                    else
                    {
                        sf.Alignment = StringAlignment.Far;
                    }
                    sf.LineAlignment = StringAlignment.Center;
                    string shortcutText = ConvertShortcut(item.Shortcut);

                    if (item.Enabled)
                    {
                        g.DrawString(shortcutText, Font, SystemBrushes.ControlText, rect, sf);
                    }
                    else
                    {
                        using (var brush = new SolidBrush(StiColorUtils.Light(SystemColors.ControlText, 150)))
                        {
                            g.DrawString(shortcutText, Font, brush, rect, sf);
                        }
                    }
                }
            }
        }
 protected override void OnSystemColorsChanged(EventArgs e)
 {
     base.OnSystemColorsChanged(e);
     StiColors.InitColors();
     BackColor = StiColorUtils.Light(SystemColors.Control, 10);
 }
        protected override void OnPaint(PaintEventArgs p)
        {
            var g    = p.Graphics;
            var rect = new Rectangle(0, 0, Width, Height);

            if (BackgroundImage == null)
            {
                if (ControlStyle == StiControlStyle.Office2013Blue)
                {
                    using (var brush = new SolidBrush(Color.White))
                    {
                        g.FillRectangle(brush, rect);
                    }
                }
                else if (ControlStyle == StiControlStyle.Office2010)
                {
                    using (var brush = new SolidBrush(Color.FromArgb(245, 245, 245)))
                    {
                        g.FillRectangle(brush, rect);
                    }
                }
                else
                {
                    using (var brush = StiBrushes.GetControlBrush(rect, 90))
                    {
                        g.FillRectangle(brush, rect);
                    }
                }
            }
            else
            {
                StiControlPaint.DrawImageBackground(g, BackgroundImage, rect);
            }

            using (var penDark = new Pen(StiColorUtils.Dark(SystemColors.Control, 30)))
            {
                if (ControlStyle == StiControlStyle.Office2013Blue || ControlStyle == StiControlStyle.Office2010)
                {
                    penDark.Color       = Color.FromArgb(198, 198, 198);
                    penDark.DashPattern = new float[] { 1f, 2f };

                    if (lineStyle == StiToolBarLineStyle.Bottom)
                    {
                        g.DrawLine(penDark, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
                    }
                    else if (lineStyle == StiToolBarLineStyle.All)
                    {
                        g.DrawRectangle(penDark, rect.X, rect.Y, rect.Right - 1, rect.Bottom - 1);
                    }
                    else
                    {
                        g.DrawLine(penDark, rect.X, rect.Top, rect.Right - 1, rect.Top);
                        g.DrawLine(penDark, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
                    }
                }
                else
                {
                    g.DrawLine(penDark, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
                    g.DrawLine(penDark, rect.Right - 1, rect.Bottom - 1, rect.Right - 1, rect.Y);
                }
            }

            if (ControlStyle == StiControlStyle.Flat)
            {
                int y = (Height - 16) / 2;
                int x = 4;
                if (this.RightToLeft == RightToLeft.Yes)
                {
                    x = this.Width - 6;
                }
                DrawDot(g, x, y);
                DrawDot(g, x, y + 4);
                DrawDot(g, x, y + 8);
                DrawDot(g, x, y + 12);
            }
        }
Esempio n. 10
0
        protected override void OnPaint(PaintEventArgs p)
        {
            const int startTextPosX = 5;
            var       g             = p.Graphics;

            var rect = this.ClientRectangle;

            using (var backBrush = new SolidBrush(this.BackColor))
            {
                g.FillRectangle(backBrush, rect);

                SizeF textSize = g.MeasureString(this.Text, this.Font);
                if (textSize.Width > rect.Width - 10 - startTextPosX)
                {
                    textSize.Width = rect.Width - 10 - startTextPosX;
                }

                int leftSpace  = rect.X + startTextPosX + 4;
                int rightSpace = rect.X + startTextPosX + (int)textSize.Width + 8;

                if (Text.Length == 0)
                {
                    leftSpace = rightSpace;
                }

                if (this.RightToLeft == RightToLeft.Yes)
                {
                    leftSpace  = rect.Right - startTextPosX - (int)textSize.Width - 8;
                    rightSpace = rect.Right - startTextPosX - 4;
                }

                int centerY = rect.Y + (int)(textSize.Height / 2);

                Color disabledColor = StiColorUtils.GetDisabledColor(this);

                using (var penLight = new Pen(ControlPaint.Light(disabledColor, 1f)))
                    using (var penDark = new Pen(ControlPaint.Dark(disabledColor, 0f)))
                    {
                        if (linePosition == StiLinePosition.Top)
                        {
                            if (this.lineStyle == StiLineStyle.Dot)
                            {
                                penDark.DashPattern = new float[] { 1f, 2f };

                                var p1 = new Point(rect.X, centerY);
                                var p2 = new Point(leftSpace, centerY);
                                var p3 = new Point(rightSpace, centerY);
                                var p4 = new Point(rect.Right, centerY);

                                if (string.IsNullOrEmpty(this.Text))
                                {
                                    g.DrawLine(penDark, p1, p4);
                                }
                                else
                                {
                                    g.DrawLine(penDark, p1, p2);
                                    g.DrawLine(penDark, p3, p4);
                                }
                            }
                            else
                            {
                                var p1 = new Point(rect.X, centerY);
                                var p2 = new Point(leftSpace, centerY);
                                var p3 = new Point(rightSpace, centerY);
                                var p4 = new Point(rect.Right, centerY);

                                g.DrawLine(penDark, p1, p2);
                                g.DrawLine(penDark, p3, p4);
                                p1.Y++;
                                p2.Y++;
                                p3.Y++;
                                p4.Y++;
                                g.DrawLine(penLight, p1, p2);
                                g.DrawLine(penLight, p3, p4);
                            }
                        }
                        else if (linePosition == StiLinePosition.Bottom)
                        {
                            if (this.lineStyle == StiLineStyle.Dot)
                            {
                                penDark.DashPattern = new float[] { 1f, 2f };

                                var p1 = new Point(rect.X, rect.Bottom - 1);
                                var p2 = new Point(rect.Right, rect.Bottom - 1);

                                g.DrawLine(penDark, p1, p2);
                            }
                        }
                        else if (linePosition == StiLinePosition.Right)
                        {
                            if (this.lineStyle == StiLineStyle.Dot)
                            {
                                penDark.DashPattern = new float[] { 1f, 2f };

                                var p1 = new Point(rect.Right - 1, rect.Y);
                                var p2 = new Point(rect.Right - 1, rect.Bottom - 1);

                                g.DrawLine(penDark, p1, p2);
                            }
                        }
                    }

                if (this.Text.Length > 0)
                {
                    var textRect = new Rectangle(leftSpace, 0, (int)textSize.Width + 5, 16);

                    #region Draw text
                    using (var sf = new StringFormat())
                    {
                        sf.FormatFlags  = StringFormatFlags.NoWrap;
                        sf.Trimming     = StringTrimming.EllipsisCharacter;
                        sf.Alignment    = StringAlignment.Center;
                        sf.HotkeyPrefix = HotkeyPrefix.Show;

                        if (RightToLeft == RightToLeft.Yes)
                        {
                            sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                        }

                        if (base.Enabled)
                        {
                            using (var foreBrush = new SolidBrush(ForeColor))
                                g.DrawString(Text, Font, foreBrush, textRect, sf);
                        }
                        else
                        {
                            ControlPaint.DrawStringDisabled(g, this.Text, this.Font, disabledColor, textRect, sf);
                        }
                    }
                    #endregion
                }
            }
        }
Esempio n. 11
0
        public static void DrawCheckBox(Graphics g, Rectangle rect, string text, Font font,
                                        Color foreColor, Color backColor,
                                        RightToLeft rightToLeft, bool isEnabled,
                                        bool isMouseOver, bool isFocused, bool drawLine, bool isChecked, CheckState checkState,
                                        Appearance appearance)
        {
            Rectangle checkRect = Rectangle.Empty;
            Rectangle textRect  = Rectangle.Empty;

            textRect = new Rectangle(rect.X + 4, rect.Y, rect.Width - 4, rect.Height);
            if (rightToLeft == RightToLeft.No)
            {
                checkRect = new Rectangle(rect.X, rect.Y + (rect.Height - 12) / 2 - 1, 12, 12);
            }
            else
            {
                checkRect = new Rectangle(rect.Right - 15, rect.Y + (rect.Height - 12) / 2 - 1, 12, 12);
            }

            if (appearance == Appearance.Normal)
            {
                if (rightToLeft == RightToLeft.No)
                {
                    textRect.X     += 10;
                    textRect.Width -= 10;
                }
                else
                {
                    textRect.Width -= 16;
                }

                #region PaintLine
                if (drawLine)
                {
                    using (Pen penLight = new Pen(StiColorUtils.Light(SystemColors.Control, 30)),
                           penDark = new Pen(StiColorUtils.Dark(SystemColors.Control, 50)))
                    {
                        int strWidth = (int)g.MeasureString(text, font).Width;

                        int posX = strWidth + 16 + rect.X;
                        int posY = rect.Y + rect.Height / 2;

                        if (posX < rect.Right)
                        {
                            g.DrawLine(penDark, posX, posY, rect.Right, posY);
                            g.DrawLine(penLight, posX, posY + 1, rect.Right, posY + 1);
                        }
                    }
                }
                #endregion

                if (isEnabled)
                {
                    using (var brush = new LinearGradientBrush(checkRect, StiColors.ContentDark, SystemColors.ControlLightLight, 45))
                    {
                        g.FillRectangle(brush, checkRect);
                    }
                }
                else
                {
                    g.FillRectangle(SystemBrushes.Control, checkRect);
                }

                if (isEnabled && (isMouseOver || isFocused))
                {
                    g.DrawRectangle(StiPens.SelectedText, checkRect);
                }
                else
                {
                    g.DrawRectangle(SystemPens.ControlDark, checkRect);
                }

                if (isChecked || checkState == CheckState.Indeterminate)
                {
                    StiControlPaint.DrawCheck(g, checkRect.X + 6, checkRect.Y + 6, isEnabled);
                }

                if (checkState == CheckState.Indeterminate)
                {
                    using (var brush = new SolidBrush(Color.FromArgb(200, SystemColors.Control)))
                    {
                        g.FillRectangle(brush,
                                        checkRect.X + 1, checkRect.Y + 1, checkRect.Width - 2, checkRect.Height - 2);
                    }
                }

                #region Paint focus
                if (isFocused)
                {
                    Rectangle focusRect = textRect;
                    SizeF     sizeText  = g.MeasureString(text, font);
                    focusRect.Width  = (int)sizeText.Width;
                    focusRect.Y      = (focusRect.Height - ((int)sizeText.Height + 2)) / 2;
                    focusRect.Height = (int)sizeText.Height + 2;

                    if (rightToLeft == RightToLeft.Yes)
                    {
                        focusRect.X = textRect.Right - focusRect.Width;
                    }

                    ControlPaint.DrawFocusRectangle(g, focusRect);
                }
                #endregion
            }
            else
            {
                StiButton.DrawButton(g, rect, text, font, foreColor, backColor, null, -1, null, rightToLeft,
                                     false, isEnabled, isMouseOver, isChecked, false, isFocused,
                                     ContentAlignment.BottomCenter, ContentAlignment.MiddleCenter);
            }

            #region Paint string
            if (appearance == Appearance.Normal)
            {
                using (var sf = new StringFormat())
                    using (var foreBrush = new SolidBrush(foreColor))
                    {
                        sf.FormatFlags   = StringFormatFlags.NoWrap;
                        sf.LineAlignment = StringAlignment.Center;
                        sf.Trimming      = StringTrimming.EllipsisCharacter;
                        sf.HotkeyPrefix  = HotkeyPrefix.Show;

                        if (rightToLeft == RightToLeft.Yes)
                        {
                            sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                        }

                        if (isEnabled)
                        {
                            g.DrawString(text, font, foreBrush, textRect, sf);
                        }
                        else
                        {
                            ControlPaint.DrawStringDisabled(g, text, font, backColor,
                                                            textRect, sf);
                        }
                    }
            }
            #endregion
        }
        public static void DrawButton(Graphics g, Rectangle rect, string text, Font font,
                                      Color foreColor, Color backColor,
                                      ImageList imageList, int imageIndex, Image image, RightToLeft rightToLeft, bool wordWrap,
                                      bool isEnabled, bool isMouseOver, bool isPressed,
                                      bool isDefault, bool isFocused, ContentAlignment imageAlign, ContentAlignment textAlign)
        {
            Rectangle btRect = new Rectangle(rect.X, rect.Y, rect.Width - 1, rect.Height - 1);

            Color controlStart = StiColorUtils.Light(backColor, 30);
            Color controlEnd   = StiColorUtils.Dark(backColor, 10);

            Color controlStartLight = StiColorUtils.Light(controlStart, 20);
            Color controlEndLight   = StiColorUtils.Light(controlEnd, 20);

            Color controlStartDark = StiColorUtils.Dark(controlStart, 20);
            Color controlEndDark   = StiColorUtils.Dark(controlEnd, 20);

            Color clBorderStart = StiColorUtils.Dark(controlStart, 20);
            Color clBorderEnd   = StiColorUtils.Dark(controlEnd, 20);

            Color clStart = controlStart;
            Color clEnd   = controlEnd;

            if (isMouseOver)
            {
                clStart = controlStartLight;
                clEnd   = controlEndLight;
            }

            if (isPressed)
            {
                clStart = controlStartDark;
                clEnd   = controlEndDark;
            }

            var grRect2 = new Rectangle(btRect.X + 1, btRect.Y + 1, btRect.Width - 1, btRect.Height - 1);

            using (var brush = new LinearGradientBrush(grRect2, clBorderStart, clBorderEnd, 90f))
            {
                g.FillRectangle(brush, grRect2);
            }

            var grRect = new Rectangle(btRect.X + 1, btRect.Y + 1, btRect.Width - 2, btRect.Height - 2);

            using (var brush = new LinearGradientBrush(grRect, clStart, clEnd, 90f))
            {
                g.FillRectangle(brush, grRect);
            }


            var oldSmoothingMode = g.SmoothingMode;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            #region Paint border
            using (var pen = new Pen(StiColorUtils.Dark(SystemColors.ControlDark, 30)))
            {
                DrawRoundedRectangle(g, pen, btRect, new Size(4, 4));
                if (isDefault)
                {
                    g.DrawRectangle(pen, new Rectangle(btRect.X + 1, btRect.Y + 1, btRect.Width - 2, btRect.Height - 2));
                }
            }
            #endregion

            g.SmoothingMode = oldSmoothingMode;

            if (isFocused)
            {
                var focusRect = new Rectangle(rect.X + 4, rect.Y + 4, rect.Width - 7, rect.Height - 7);
                ControlPaint.DrawFocusRectangle(g, focusRect, SystemColors.ControlDark, SystemColors.Control);
            }

            Rectangle imageRect;
            Rectangle textRect;

            CalcRectangles(out textRect, out imageRect,
                           new Rectangle(rect.X + 4, rect.Y + 4, rect.Width - 8, rect.Height - 8),
                           g, isEnabled, imageList, imageIndex, image, text,
                           wordWrap, rightToLeft, foreColor, backColor,
                           font, imageAlign, textAlign, isPressed);

            try
            {
                DrawImage(g, isEnabled, imageRect, imageList, imageIndex, image);
            }
            catch
            {
            }

            DrawText(g, text, wordWrap, rightToLeft, isEnabled, foreColor, textRect, font,
                     textAlign, imageAlign);
        }
        protected override void OnPaint(PaintEventArgs p)
        {
            Graphics g = p.Graphics;

            int startTextPos = 8;

            if (AllowCollapse)
            {
                startTextPos = 24;
            }

            Rectangle rect     = ClientRectangle;
            Rectangle textRect = rect;

            var size = g.MeasureString(this.Text, Font);

            textRect.Width  = (int)size.Width + 4;
            textRect.Height = (int)size.Height;

            if (RightToLeft == RightToLeft.Yes)
            {
                textRect.X = (rect.Right - textRect.Width) - startTextPos;
            }
            else
            {
                textRect.X += startTextPos;
            }

            if (Text.Length == 0)
            {
                textRect.Width = 0;
            }

            Color disabledColor = StiColorUtils.GetDisabledColor(this);

            #region Draw Group Box
            int headerHeight = rect.Top + (Font.Height / 2);
            if (Text.Length == 0)
            {
                headerHeight = 0;
            }

            bool styleUsed = false;
            try
            {
                if (VisualStyleInformation.IsEnabledByUser && VisualStyleInformation.IsSupportedByOS)
                {
                    VisualStyleElement element;
                    if (this.Enabled)
                    {
                        element = VisualStyleElement.Button.GroupBox.Normal;
                    }
                    else
                    {
                        element = VisualStyleElement.Button.GroupBox.Disabled;
                    }

                    if (VisualStyleRenderer.IsElementDefined(element))
                    {
                        var renderer = new VisualStyleRenderer(element);
                        renderer.DrawBackground(g, new Rectangle(rect.X, rect.Y + headerHeight, rect.Width, rect.Height - headerHeight));
                        styleUsed = true;
                    }
                }
            }
            catch //In some cases strange errors occurred. In this cases draw group box with help of default painting.
            {
                styleUsed = false;
            }
            if (!styleUsed)
            {
                using (var penLight = new Pen(ControlPaint.Light(disabledColor, 1f)))
                    using (var penDark = new Pen(ControlPaint.Dark(disabledColor, 0f)))
                    {
                        g.DrawLine(penLight, rect.Left + 1, headerHeight, rect.Left + 1, rect.Height - 1);
                        g.DrawLine(penDark, rect.Left, headerHeight - 1, rect.Left, rect.Height - 2);
                        g.DrawLine(penLight, rect.Left, rect.Height - 1, rect.Width, rect.Height - 1);
                        g.DrawLine(penDark, rect.Left, rect.Height - 2, rect.Width - 1, rect.Height - 2);
                        g.DrawLine(penLight, rect.Left + 1, headerHeight, textRect.X + 1, headerHeight);
                        g.DrawLine(penDark, rect.Left, headerHeight - 1, textRect.X, headerHeight - 1);
                        g.DrawLine(penLight, (textRect.X + textRect.Width), headerHeight, rect.Width - 1, headerHeight);
                        g.DrawLine(penDark, (textRect.X + textRect.Width) + 1, headerHeight - 1, rect.Width - 2, headerHeight - 1);
                        g.DrawLine(penLight, rect.Width - 1, headerHeight, rect.Width - 1, rect.Height - 1);
                        g.DrawLine(penDark, rect.Width - 2, headerHeight - 1, rect.Width - 2, rect.Height - 2);
                    }
            }

            #endregion

            #region Draw text
            using (var sf = new StringFormat())
            {
                sf.FormatFlags  = StringFormatFlags.NoWrap;
                sf.Trimming     = StringTrimming.EllipsisCharacter;
                sf.Alignment    = StringAlignment.Center;
                sf.HotkeyPrefix = HotkeyPrefix.Show;

                if (RightToLeft == RightToLeft.Yes)
                {
                    sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                }

                if (styleUsed)
                {
                    using (var brush = new SolidBrush(this.BackColor))
                    {
                        g.FillRectangle(brush, textRect);
                    }
                }

                if (base.Enabled)
                {
                    using (var foreBrush = new SolidBrush(this.ForeColor))
                    {
                        g.DrawString(Text, Font, foreBrush, textRect, sf);
                    }
                }
                else
                {
                    ControlPaint.DrawStringDisabled(g, this.Text, this.Font, disabledColor, textRect, sf);
                }
            }
            #endregion

            if (AllowCollapse)
            {
                DrawCollapse(g);
            }
        }
        protected override void OnPaint(PaintEventArgs p)
        {
            UpdateSize();
            Graphics g    = p.Graphics;
            var      rect = new Rectangle(0, 0, Width, Height);

            #region Separator
            if (Style == ToolBarButtonStyle.Separator)
            {
                if (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
                {
                    int py = Height / 2 - 1;
                    g.DrawLine(SystemPens.ControlDark, 2, py, Width - 4, py);
                    g.DrawLine(SystemPens.ControlLightLight, 2, py + 1, Width - 4, py + 1);
                }
                else
                {
                    int px = Width / 2 - 1;
                    g.DrawLine(SystemPens.ControlDark, px, 2, px, Height - 4);
                    g.DrawLine(SystemPens.ControlLightLight, px + 1, 2, px + 1, Height - 4);
                }
            }
            #endregion

            else
            {
                bool isOffice2013Blue = false;
                if (Parent != null)
                {
                    var toolBar = Parent as StiToolBar;
                    if (toolBar != null && toolBar.ControlStyle == StiControlStyle.Office2013Blue)
                    {
                        isOffice2013Blue = true;
                    }
                }

                if (isOffice2013Blue)
                {
                    #region pushed | pressed
                    if (Enabled && (Pushed || IsPressed))
                    {
                        if (IsPressed)
                        {
                            using (var brush = new SolidBrush(StiStyleOffice2013Blue.ColorButtonPressed))
                            {
                                g.FillRectangle(brush, rect);
                            }
                        }
                        else
                        {
                            g.FillRectangle(StiBrushes.Selected, rect);
                        }
                    }
                    #endregion

                    if (!IsPressed)
                    {
                        if (IsMouseOver && (!DesignMode))
                        {
                            using (var brush = new SolidBrush(StiStyleOffice2013Blue.ColorButtonButtonMouseOver))
                            {
                                g.FillRectangle(brush, rect);
                            }
                        }
                        else if (DesignMode || Draw3DButton)
                        {
                            ControlPaint.DrawBorder3D(g, rect, Border3DStyle.RaisedInner, Border3DSide.All);
                        }
                    }

                    rect = new Rectangle(0, 0, Width, Height);
                    Rectangle imageRect;
                    Rectangle textRect;
                    Rectangle dropDownArrowRect;

                    CalcRectangles(out textRect, out imageRect, out dropDownArrowRect,
                                   new Rectangle(rect.X + 4, rect.Y + 4, rect.Width - 8, rect.Height - 8), g,
                                   DropDownMenu != null || IsDrawDropDownArrow);

                    try
                    {
                        if (AllowDrawImage)
                        {
                            DrawImage(g, imageRect);
                        }
                        if (AllowDrawText)
                        {
                            DrawText(g, textRect);
                        }
                        if (AllowDrawDrawDropDownArrow)
                        {
                            DrawDropDownArrow(g, dropDownArrowRect);
                        }
                    }
                    catch
                    {
                    }
                }
                else
                {
                    #region pushed | pressed
                    if (Enabled && (Pushed || IsPressed))
                    {
                        rect.X++;
                        rect.Y++;
                        rect.Width  -= 2;
                        rect.Height -= 2;

                        if (IsPressed)
                        {
                            using (var brush = new SolidBrush(StiColorUtils.Dark(StiColors.Selected, 50)))
                            {
                                g.FillRectangle(brush, rect);
                            }
                        }
                        else
                        {
                            g.FillRectangle(StiBrushes.Selected, rect);
                        }

                        rect.Width--;
                        rect.Height--;
                        g.DrawRectangle(StiPens.SelectedText, rect);

                        rect.X--;
                        rect.Y--;
                        rect.Width  += 3;
                        rect.Height += 3;
                    }
                    #endregion

                    if (!IsPressed)
                    {
                        if (IsMouseOver && (!DesignMode))
                        {
                            g.FillRectangle(StiBrushes.Focus, rect);

                            rect.Width--;
                            rect.Height--;
                            g.DrawRectangle(StiPens.SelectedText, rect);

                            if (IsDrawDropDownArrow || DropDownMenu != null)
                            {
                                g.DrawLine(StiPens.SelectedText, rect.Right - 10, rect.Y, rect.Right - 10, rect.Bottom);
                            }
                        }
                        else if (DesignMode || Draw3DButton)
                        {
                            ControlPaint.DrawBorder3D(g, rect, Border3DStyle.RaisedInner, Border3DSide.All);
                        }
                    }

                    rect = new Rectangle(0, 0, Width, Height);
                    Rectangle imageRect;
                    Rectangle textRect;
                    Rectangle dropDownArrowRect;

                    CalcRectangles(out textRect, out imageRect, out dropDownArrowRect,
                                   new Rectangle(rect.X + 4, rect.Y + 4, rect.Width - 8, rect.Height - 8), g,
                                   DropDownMenu != null || IsDrawDropDownArrow);

                    try
                    {
                        if (AllowDrawImage)
                        {
                            DrawImage(g, imageRect);
                        }
                        if (AllowDrawText)
                        {
                            DrawText(g, textRect);
                        }
                        if (AllowDrawDrawDropDownArrow)
                        {
                            DrawDropDownArrow(g, dropDownArrowRect);
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
        protected override void OnPaint(PaintEventArgs p)
        {
            var g = p.Graphics;

            #region Content
            var contentRect = new Rectangle(0, HeaderHeight, Width, Height - HeaderHeight - PanelDistance);

            if (BackgroundImage == null)
            {
                using (var brush = new SolidBrush(BackColor))
                {
                    g.FillRectangle(brush, contentRect.Left, contentRect.Top, contentRect.Width + 1, contentRect.Height + 1);
                }
            }
            else
            {
                StiControlPaint.DrawImageBackground(p.Graphics, BackgroundImage, contentRect);
            }

            if (DrawBorder)
            {
                g.DrawRectangle(BorderPen, 0, 0, Width - 1, Height - PanelDistance);
            }
            #endregion

            #region Header
            var headerRect = GetHeaderRect();
            var image      = !Collapsed ? upBitmap : downBitmap;

            Color textColor = Color.Black;

            #region Fill rectangle
            headerRect.Width++;
            headerRect.Height++;
            if (HeaderBackgroundImage == null)
            {
                if (Selected)
                {
                    if (isMouseOver)
                    {
                        using (var brush = new LinearGradientBrush(headerRect,
                                                                   StiColorUtils.Light(SelectedHeaderStartColor, 20),
                                                                   StiColorUtils.Light(SelectedHeaderEndColor, 20), 90))
                            g.FillRectangle(brush, headerRect);
                    }
                    else
                    {
                        using (var brush = new LinearGradientBrush(headerRect,
                                                                   SelectedHeaderStartColor,
                                                                   SelectedHeaderEndColor, 90))
                            g.FillRectangle(brush, headerRect);
                    }
                    textColor = SystemColors.ActiveCaptionText;
                }
                else
                {
                    if (isMouseOver)
                    {
                        using (var brush = new LinearGradientBrush(headerRect,
                                                                   StiColorUtils.Light(HeaderStartColor, 20),
                                                                   StiColorUtils.Light(HeaderEndColor, 20), 90))
                            g.FillRectangle(brush, headerRect);
                    }
                    else
                    {
                        using (var brush = new LinearGradientBrush(headerRect, HeaderStartColor, HeaderEndColor, 90))
                            g.FillRectangle(brush, headerRect);
                    }
                }
            }
            else
            {
                StiControlPaint.DrawImageBackground(p.Graphics, HeaderBackgroundImage, headerRect);
            }
            headerRect.Width--;
            headerRect.Height--;
            #endregion

            #region Draw button image
            if (image != null)
            {
                var imageRect = new Rectangle(headerRect.Width - 18, (headerRect.Height - 16) / 2, 16, 16);

                if (textColor != Color.Black && image != null)
                {
                    image = StiImageUtils.ReplaceImageColor((Bitmap)image, textColor, Color.Black);
                }
                g.DrawImage(image, imageRect);
            }
            #endregion

            #region Draw image
            int imageWidth = 0;
            if (Image != null)
            {
                var imageRect = new Rectangle(headerRect.X + 4,
                                              (headerRect.Height - Image.Size.Height) / 2, Image.Size.Width, Image.Size.Height);

                imageWidth = imageRect.Width + 2;

                g.DrawImage(Image, imageRect);
            }
            #endregion

            #region Draw header text
            var textRect = new Rectangle(5 + imageWidth, 0, headerRect.Width - 25 - imageWidth, headerRect.Height);

            if (textRect.Width > 0)
            {
                using (var sf = new StringFormat())
                {
                    sf.LineAlignment = StringAlignment.Center;
                    if (RightToLeft == RightToLeft.Yes)
                    {
                        sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                    }

                    sf.FormatFlags = StringFormatFlags.NoWrap;
                    sf.Trimming    = StringTrimming.EllipsisCharacter;

                    sf.HotkeyPrefix = HotkeyPrefix.Hide;

                    if (!TitleColor.IsEmpty)
                    {
                        textColor = TitleColor;
                    }
                    using (Brush brush = new SolidBrush(textColor))
                    {
                        g.DrawString(Text, TitleFont, brush, textRect, sf);
                    }
                }
            }
            #endregion

            if (DrawBorder)
            {
                g.DrawRectangle(BorderPen, headerRect);
            }
            #endregion
        }
        public static void DrawRadioButton(Graphics g, Rectangle rect, string text, Font font,
                                           Color foreColor, Color backColor,
                                           RightToLeft rightToLeft, bool isEnabled,
                                           bool isMouseOver, bool isFocused, bool isChecked,
                                           Appearance appearance)
        {
            Rectangle checkRect = Rectangle.Empty;
            Rectangle textRect  = Rectangle.Empty;

            textRect = new Rectangle(rect.X + 4, rect.Y, rect.Width - 4, rect.Height);
            if (rightToLeft == RightToLeft.No)
            {
                checkRect = new Rectangle(rect.X, rect.Y + (rect.Height - 12) / 2 - 1, 12, 12);
            }
            else
            {
                checkRect = new Rectangle(rect.Right - 15, rect.Y + (rect.Height - 12) / 2 - 1, 12, 12);
            }

            if (appearance == Appearance.Normal)
            {
                if (rightToLeft == RightToLeft.No)
                {
                    textRect.X     += 10;
                    textRect.Width -= 10;
                }
                else
                {
                    textRect.Width -= 16;
                }

                var oldSmoothingMode = g.SmoothingMode;
                g.SmoothingMode = SmoothingMode.AntiAlias;

                if (isEnabled && (isMouseOver || isFocused))
                {
                    g.DrawEllipse(StiPens.SelectedText,
                                  checkRect.X, checkRect.Y, checkRect.Width, checkRect.Height);
                }
                else
                {
                    if (!isEnabled)
                    {
                        using (var pen = new Pen(StiColorUtils.Dark(SystemColors.Control, 30)))
                        {
                            g.DrawEllipse(pen,
                                          checkRect.X, checkRect.Y, checkRect.Width, checkRect.Height);
                        }
                    }
                    else
                    {
                        g.DrawEllipse(SystemPens.ControlDark,
                                      checkRect.X, checkRect.Y, checkRect.Width, checkRect.Height);
                    }
                }

                if (isEnabled)
                {
                    using (var brush = new LinearGradientBrush(checkRect,
                                                               StiColors.ContentDark, SystemColors.ControlLightLight, 45))
                    {
                        g.FillEllipse(brush, checkRect.X + 1, checkRect.Y + 1, 10, 10);
                    }
                }
                else
                {
                    g.FillEllipse(SystemBrushes.Control, checkRect.X + 1, checkRect.Y + 1, 10, 10);
                }

                if (isChecked)
                {
                    if (isEnabled)
                    {
                        g.FillEllipse(Brushes.DarkGray, checkRect.X + 3, checkRect.Y + 3, 6, 6);
                        g.FillEllipse(Brushes.Black, checkRect.X + 4, checkRect.Y + 4, 4, 4);
                    }
                    else
                    {
                        g.FillEllipse(Brushes.DarkGray, checkRect.X + 3, checkRect.Y + 3, 6, 6);
                        g.FillEllipse(Brushes.DimGray, checkRect.X + 4, checkRect.Y + 4, 4, 4);
                    }
                }

                g.SmoothingMode = oldSmoothingMode;

                #region Paint focus
                if (isFocused)
                {
                    Rectangle focusRect = textRect;
                    SizeF     sizeText  = g.MeasureString(text, font);
                    focusRect.Width  = (int)sizeText.Width;
                    focusRect.Y      = (focusRect.Height - ((int)sizeText.Height + 2)) / 2;
                    focusRect.Height = (int)sizeText.Height + 2;

                    if (rightToLeft == RightToLeft.Yes)
                    {
                        focusRect.X = textRect.Right - focusRect.Width;
                    }

                    ControlPaint.DrawFocusRectangle(g, focusRect);
                }
                #endregion
            }
            else
            {
                StiButton.DrawButton(g, rect, text, font, foreColor, backColor, null, -1, null, rightToLeft,
                                     false, isEnabled, isMouseOver, isChecked, false, isFocused,
                                     ContentAlignment.BottomCenter, ContentAlignment.MiddleCenter);
            }

            #region Paint string
            if (appearance == Appearance.Normal)
            {
                using (var sf = new StringFormat())
                {
                    sf.FormatFlags   = StringFormatFlags.NoWrap;
                    sf.LineAlignment = StringAlignment.Center;
                    sf.Trimming      = StringTrimming.EllipsisCharacter;
                    sf.HotkeyPrefix  = HotkeyPrefix.Show;

                    if (rightToLeft == RightToLeft.Yes)
                    {
                        sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                    }

                    using (var foreBrush = new SolidBrush(foreColor))
                    {
                        if (isEnabled)
                        {
                            g.DrawString(text, font, foreBrush, textRect, sf);
                        }
                        else
                        {
                            ControlPaint.DrawStringDisabled(g, text, font, backColor, textRect, sf);
                        }
                    }
                }
            }
            #endregion
        }
        private void DrawPageTitleTopHorizontal(Graphics g, Pen penLight, Pen penDark, StiTabulatorPage page,
                                                Rectangle rect, Rectangle contentRect)
        {
            Point [] pts = new Point[] {
                new Point(rect.X, rect.Y),
                new Point(rect.X, rect.Bottom),
                new Point(rect.Right + 5, rect.Bottom + 1),
                new Point(rect.Right - 5, rect.Y)
            };

            using (var path = new GraphicsPath(FillMode.Alternate))
            {
                path.AddPolygon(pts);

                #region Draw page header
                if (tabulator.SelectedTab == page)
                {
                    using (var br = new SolidBrush(tabulator.BackColor))
                    {
                        g.FillPath(br, path);
                    }
                }
                else
                {
                    if (page.IsMouseOver)
                    {
                        using (var br = new SolidBrush(StiColorUtils.Dark(StiColors.Content, 0)))
                        {
                            g.FillPath(br, path);
                        }
                    }
                    else
                    {
                        using (var br = new SolidBrush(StiColorUtils.Dark(StiColors.Content, 10)))
                        {
                            g.FillPath(br, path);
                        }
                    }
                }
                #endregion

                #region Draw header lines
                if (tabulator.SelectedTab == page)
                {
                    g.DrawLine(penDark, pts[0], pts[1]);
                    g.DrawLine(penLight, pts[0].X + 1, pts[0].Y + 1, pts[1].X + 1, pts[1].Y + 1);

                    g.DrawLine(penDark, pts[2], pts[3]);

                    g.DrawLine(penDark, pts[0], pts[3]);
                    g.DrawLine(penLight, pts[0].X + 1, pts[0].Y + 1, pts[3].X - 1, pts[3].Y + 1);
                }
                else
                {
                    g.DrawLine(penDark, pts[0], pts[1]);
                    g.DrawLine(penDark, pts[0], pts[3]);
                    g.DrawLine(penDark, pts[2], pts[3]);
                }
                #endregion
            }
            tabulator.Mode.DrawTitleText(g, rect, page);
            tabulator.Mode.DrawTitleImage(g, rect, page);
        }
Esempio n. 18
0
        private void DrawPage(Graphics g, StiTabPage page)
        {
            if ((!page.Invisible) || DesignMode)
            {
                var rect = GetPageRectangle(g, page);

                if (rect.Width != 0 && rect.Height != 0)
                {
                    #region Calculate Path

                    var pts = new Point [] {};

                    #region Office2013
                    if (ControlStyle == StiControlStyle.Office2013Blue)
                    {
                        pts = new Point[] {
                            new Point(rect.X, rect.Y),
                            new Point(rect.X, rect.Bottom),
                            new Point(rect.Right, rect.Bottom),
                            new Point(rect.Right, rect.Y)
                        };
                    }
                    #endregion

                    #region Flat
                    else
                    {
                        if (!PositionAtBottom)
                        {
                            pts = new Point[] {
                                new Point(rect.X, rect.Y),
                                new Point(rect.X, rect.Bottom),
                                new Point(rect.Right + 5, rect.Bottom),
                                new Point(rect.Right - 5, rect.Y)
                            };
                        }
                        else
                        {
                            pts = new Point[] {
                                new Point(rect.X, rect.Y),
                                new Point(rect.X, rect.Bottom),
                                new Point(rect.Right - 5, rect.Bottom),
                                new Point(rect.Right + 5, rect.Y)
                            };
                        }
                    }
                    #endregion

                    #endregion


                    using (var path = new GraphicsPath(FillMode.Alternate))
                    {
                        path.AddPolygon(pts);

                        #region Draw page header

                        #region Office2013
                        if (ControlStyle == StiControlStyle.Office2013Blue)
                        {
                            if (SelectedTab == page)
                            {
                                using (var pathSelected = new GraphicsPath())
                                {
                                    pathSelected.AddPolygon(new[] {
                                        new Point(pts[0].X - 1, pts[0].Y - 1),
                                        new Point(pts[1].X - 1, pts[1].Y),
                                        new Point(pts[2].X + 1, pts[2].Y),
                                        new Point(pts[3].X + 1, pts[3].Y)
                                    });

                                    using (var br = new SolidBrush(Color.White))
                                    {
                                        g.FillPath(br, pathSelected);
                                    }
                                }
                            }
                            else
                            {
                                using (var br = new SolidBrush(Color.White))
                                {
                                    g.FillPath(br, path);
                                }
                            }
                        }
                        #endregion

                        #region Flat
                        else
                        {
                            if (SelectedTab == page)
                            {
                                var tabPage = GetTabPageAtPoint(this.PointToClient(Cursor.Position));
                                if (tabPage == page)
                                {
                                    using (var br = StiBrushes.GetControlLightBrush(rect, 90))
                                    {
                                        g.FillPath(br, path);
                                    }
                                }
                                else
                                {
                                    using (var br = StiBrushes.GetControlBrush(rect, 90))
                                    {
                                        g.FillPath(br, path);
                                    }
                                }
                            }
                            else
                            {
                                var tabPage = GetTabPageAtPoint(this.PointToClient(Cursor.Position));
                                if (tabPage == page)
                                {
                                    using (var br = new SolidBrush(StiColorUtils.Light(StiColors.Content, 15)))
                                    {
                                        g.FillPath(br, path);
                                    }
                                }
                                else
                                {
                                    g.FillPath(StiBrushes.Content, path);
                                }
                            }
                        }
                        #endregion

                        #endregion
                    }


                    Color textColor = ForeColor;
                    if (page != this.SelectedTab)
                    {
                        textColor = SystemColors.ControlDark;
                    }


                    #region Paint Image
                    SizeF imageSize = SizeF.Empty;
                    if (ImageList != null || page.Image != null)
                    {
                        int pageIndex = this.Controls.IndexOf(page);

                        if (ImageList != null || page.Image != null)
                        {
                            if (page.Image != null)
                            {
                                imageSize = page.Image.Size;
                            }
                            else
                            {
                                imageSize = ImageList.ImageSize;
                            }

                            Rectangle imageRect = new Rectangle(rect.X + 2,
                                                                (int)(rect.Y + (rect.Height - imageSize.Height) / 2),
                                                                (int)imageSize.Width, (int)imageSize.Height);

                            if (imageSize.Width != 0)
                            {
                                if (imageList != null && ImageList.Images.Count > pageIndex)
                                {
                                    ImageList.Draw(g, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height, pageIndex);
                                }
                                else if (page.Image != null)
                                {
                                    g.DrawImage(page.Image, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height);
                                }
                            }
                        }
                    }
                    #endregion

                    #region Paint text
                    var textRect = new Rectangle(rect.X + (int)imageSize.Width, rect.Y, rect.Width - (int)imageSize.Width, rect.Height);
                    using (var brush = new SolidBrush(textColor))
                    {
                        g.DrawString(page.Text, Font, brush, textRect, sfTabs);
                    }
                    #endregion

                    #region Draw header lines

                    #region Office2013 Style
                    if (ControlStyle == StiControlStyle.Office2013Blue)
                    {
                        using (var pen = new Pen(StiStyleOffice2013Blue.ColorLineGray))
                        {
                            if (SelectedTab == page)
                            {
                                if (!PositionAtBottom)
                                {
                                    g.DrawLine(pen, new Point(pts[0].X - 1, pts[0].Y - 1), new Point(pts[1].X - 1, pts[1].Y));
                                    g.DrawLine(pen, new Point(pts[0].X - 1, pts[0].Y - 1), new Point(pts[3].X + 1, pts[3].Y - 1));
                                    g.DrawLine(pen, new Point(pts[2].X + 1, pts[2].Y), new Point(pts[3].X + 1, pts[3].Y));
                                }
                                else
                                {
                                    g.DrawLine(pen, pts[1], pts[2]);
                                    g.DrawLine(pen, pts[2], pts[3]);
                                }
                            }
                            else
                            {
                                if (PositionAtBottom)
                                {
                                    g.DrawLine(pen, pts[0], pts[1]);
                                    g.DrawLine(pen, pts[1], pts[2]);
                                    g.DrawLine(pen, pts[2], pts[3]);
                                }
                                else
                                {
                                    g.DrawLine(pen, pts[0], pts[1]);
                                    g.DrawLine(pen, pts[0], pts[3]);
                                    g.DrawLine(pen, pts[2], pts[3]);
                                }
                            }
                        }
                    }
                    #endregion

                    #region Flat Style
                    else
                    {
                        if (SelectedTab == page)
                        {
                            g.DrawLine(SystemPens.ControlLightLight, pts[0], pts[1]);

                            if (!PositionAtBottom)
                            {
                                using (var brush = new LinearGradientBrush(
                                           new Rectangle(pts[3].X, pts[3].Y, pts[2].X - pts[3].X, pts[2].Y - pts[3].Y - 5),
                                           SystemColors.Control, SystemColors.ControlDark, 0f))

                                    using (var pen = new Pen(brush))
                                        g.DrawLine(pen, pts[2], pts[3]);

                                g.DrawLine(SystemPens.ControlLightLight, pts[0], pts[3]);
                            }
                            else
                            {
                                g.DrawLine(SystemPens.ControlDark, pts[1], pts[2]);
                                g.DrawLine(SystemPens.ControlDark, pts[2], pts[3]);
                            }
                        }
                        else
                        {
                            using (var pen = new Pen(StiColorUtils.Dark(SystemColors.Control, 40)))
                            {
                                if (PositionAtBottom)
                                {
                                    g.DrawLine(pen, pts[0], pts[1]);
                                    g.DrawLine(pen, pts[1], pts[2]);
                                    g.DrawLine(pen, pts[2], pts[3]);
                                }
                                else
                                {
                                    g.DrawLine(pen, pts[0], pts[1]);
                                    g.DrawLine(pen, pts[0], pts[3]);
                                    g.DrawLine(pen, pts[2], pts[3]);
                                }
                            }
                        }
                    }
                    #endregion

                    #endregion
                }
            }
        }