/// <summary>
        /// Raises the Paint event.
        /// </summary>
        /// <param name="e">A PaintEventArgs that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (IsZeroWidthOrHeight(this.CaptionRectangle) == true)
            {
                return;
            }

            using (UseAntiAlias antiAlias = new UseAntiAlias(e.Graphics))
            {
                Graphics graphics = e.Graphics;
                using (UseClearTypeGridFit clearTypeGridFit = new UseClearTypeGridFit(graphics))
                {
                    bool      bExpand         = this.Expand;
                    bool      bShowBorder     = this.ShowBorder;
                    Color     borderColor     = this.PanelColors.BorderColor;
                    Rectangle borderRectangle = this.ClientRectangle;

                    switch (this.PanelStyle)
                    {
                    case PanelStyle.Default:
                    case PanelStyle.Office2007:
                        DrawCaptionbar(graphics, bExpand, bShowBorder, this.PanelStyle);
                        CalculatePanelHeights();
                        DrawBorders(graphics, this);
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Raises the <see cref="System.Windows.Forms.ToolStripRenderer.RenderButtonBackground"/> event.
        /// </summary>
        /// <param name="e">A <see cref="System.Windows.Forms.ToolStripItemRenderEventArgs"/> that contains the event data.</param>
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            if (ColorTable.UseSystemColors == true)
            {
                base.OnRenderDropDownButtonBackground(e);
            }
            else
            {
                ToolStripButton item         = e.Item as ToolStripButton;
                Rectangle       buttonBounds = new Rectangle(Point.Empty, item.Size);
                if (IsZeroWidthOrHeight(buttonBounds) == true)
                {
                    return;
                }
                Graphics graphics = e.Graphics;
                ProfessionalColorTable colorTable = ColorTable as ProfessionalColorTable;
                if (colorTable != null)
                {
                    using (UseAntiAlias antiAlias = new UseAntiAlias(graphics))
                    {
                        Rectangle buttonRectangle = GetButtonRectangle(buttonBounds);

                        if (item.Checked == true)
                        {
                            //Draws the border of the button for the checked ToolStripButton control
                            DrawButtonBorder(graphics, buttonRectangle, colorTable.ButtonPressedBorder);
                        }
                        if ((item.Selected == true) && (item.Pressed == false))
                        {
                            //Renders the upper button part of the selected ToolStripButton control
                            RenderButton(graphics, buttonRectangle, colorTable.MenuItemTopLevelSelectedGradientBegin);
                            //Draws the border of the button for the selected ToolStripButton control
                            DrawButtonBorder(graphics, buttonRectangle, colorTable.ButtonSelectedHighlightBorder);
                            //DrawButtonBorder(graphics, buttonRectangle, Color.FromArgb(196, 194, 196));
                        }
                        if (item.Pressed == true)
                        {
                            //Renders the upper button part of the pressed ToolStripButton control
                            RenderButton(graphics, buttonRectangle, colorTable.MenuItemPressedGradientBegin);
                            //Draws the inner border of the button for the pressed ToolStripButton control
                            DrawInnerButtonBorder(graphics, buttonRectangle, colorTable.ButtonSelectedHighlightBorder);
                            //Draws the outer border of the button for the pressed ToolStripButton control
                            DrawButtonBorder(graphics, buttonRectangle, colorTable.MenuBorder);
                        }
                    }
                }
                else
                {
                    base.OnRenderDropDownButtonBackground(e);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Raises the <see cref="System.Windows.Forms.ToolStripRenderer.RenderMenuItemBackground"/> event.
        /// </summary>
        /// <param name="e">A <see cref="System.Windows.Forms.ToolStripItemRenderEventArgs"/> that contains the event data.</param>
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripMenuItem item   = e.Item as ToolStripMenuItem;
            Rectangle         bounds = new Rectangle(Point.Empty, item.Size);

            if (IsZeroWidthOrHeight(bounds) == true)
            {
                return;
            }
            Graphics graphics = e.Graphics;
            ProfessionalColorTable colorTable = ColorTable as Kesoft.Windows.Forms.Panels.ProfessionalColorTable;

            if (colorTable != null)
            {
                using (UseAntiAlias useAntiAlias = new UseAntiAlias(graphics))
                {
                    if (e.ToolStrip is MenuStrip)
                    {
                        if ((item.Selected == true) && (item.Pressed == false))
                        {
                            RenderMenuItem(graphics, bounds, colorTable.MenuItemTopLevelSelectedGradientBegin);
                            ControlPaint.DrawBorder(e.Graphics, bounds, colorTable.MenuItemTopLevelSelectedBorder, ButtonBorderStyle.Solid);
                        }
                        if (item.Pressed == true)
                        {
                            RenderButton(graphics, bounds, ColorTable.MenuItemPressedGradientBegin);
                            Rectangle innerBorderRectangle = bounds;
                            innerBorderRectangle.Inflate(-1, -1);
                            ControlPaint.DrawBorder(e.Graphics, innerBorderRectangle, ColorTable.ButtonSelectedHighlightBorder, ButtonBorderStyle.Solid);
                            ControlPaint.DrawBorder(e.Graphics, bounds, ColorTable.MenuBorder, ButtonBorderStyle.Solid);
                        }
                    }
                    else
                    {
                        base.OnRenderMenuItemBackground(e);
                    }
                }
            }
            else
            {
                base.OnRenderMenuItemBackground(e);
            }
        }
        /// <summary>
        /// Raises the Paint event.
        /// </summary>
        /// <param name="e">A PaintEventArgs that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            using (var antiAlias = new UseAntiAlias(e.Graphics))
            {
                var graphics = e.Graphics;
                DrawProgressBar(
                    graphics,
                    ClientRectangle,
                    m_backgroundColor,
                    m_valueColor,
                    m_borderColor,
                    RightToLeft,
                    Minimum,
                    Maximum,
                    Value);

                if (string.IsNullOrEmpty(Text) == false)
                {
                    using (var useClearTypeGridFit = new UseClearTypeGridFit(graphics))
                    {
                        using (var textBrush = new SolidBrush(ForeColor))
                        {
                            using (var stringFormat = new StringFormat())
                            {
                                stringFormat.FormatFlags = StringFormatFlags.NoWrap;
                                if (RightToLeft == RightToLeft.Yes)
                                {
                                    stringFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                                }
                                stringFormat.Trimming      = StringTrimming.EllipsisCharacter;
                                stringFormat.LineAlignment = StringAlignment.Center;
                                stringFormat.Alignment     = StringAlignment.Center;

                                var stringRectangle = ClientRectangle;
                                graphics.DrawString(Text, Font, textBrush, stringRectangle, stringFormat);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Raises the <see cref="System.Windows.Forms.ToolStripRenderer.OnRenderSplitButtonBackground"/> event.
        /// </summary>
        /// <param name="e">A <see cref="System.Windows.Forms.ToolStripItemRenderEventArgs"/> that contains the event data.</param>
        protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            if (ColorTable.UseSystemColors == true)
            {
                base.OnRenderDropDownButtonBackground(e);
            }
            else
            {
                ToolStripSplitButton item         = e.Item as ToolStripSplitButton;
                Rectangle            buttonBounds = new Rectangle(Point.Empty, item.ButtonBounds.Size);
                if (IsZeroWidthOrHeight(buttonBounds) == true)
                {
                    return;
                }
                Graphics graphics = e.Graphics;
                ProfessionalColorTable colorTable = ColorTable as ProfessionalColorTable;
                if (colorTable != null)
                {
                    using (UseAntiAlias antiAlias = new UseAntiAlias(graphics))
                    {
                        Rectangle buttonRectangle         = GetButtonRectangle(buttonBounds);
                        Rectangle dropDownButtonBounds    = new Rectangle(item.DropDownButtonBounds.Location, item.DropDownButtonBounds.Size);
                        Rectangle dropDownButtonRectangle = GetButtonRectangle(dropDownButtonBounds);

                        if ((item.Selected == true) && (item.Pressed == false) && (item.ButtonPressed == false))
                        {
                            //Renders the upper button part of the selected ToolStripSplitButton control
                            RenderButton(graphics, buttonRectangle, colorTable.MenuItemTopLevelSelectedGradientBegin);
                            //Renders the dropDownButton part of the selected ToolStripSplitButton control
                            RenderButton(graphics, dropDownButtonRectangle, colorTable.MenuItemTopLevelSelectedGradientBegin);
                            //Draws the border of the button part for the selected ToolStripSplitButton control
                            DrawButtonBorder(graphics, buttonRectangle, colorTable.ButtonSelectedHighlightBorder);
                            //Draws the border of the dropDownButton part for the selected ToolStripSplitButton control
                            DrawButtonBorder(graphics, dropDownButtonRectangle, colorTable.ButtonSelectedHighlightBorder);
                        }
                        if (item.ButtonPressed == true)
                        {
                            //Renders the upper button part of the pressed ToolStripSplitButton control
                            RenderButton(graphics, buttonRectangle, colorTable.MenuItemPressedGradientBegin);
                            //Renders the dropDownButton part of the pressed ToolStripSplitButton control
                            RenderButton(graphics, dropDownButtonRectangle, colorTable.MenuItemPressedGradientBegin);
                            //Draws the inner border of the button part for the pressed ToolStripSplitButton control
                            DrawInnerButtonBorder(graphics, buttonRectangle, colorTable.ButtonSelectedHighlightBorder);
                            //Draws the outer border of the button part for the pressed ToolStripSplitButton control
                            DrawButtonBorder(graphics, buttonRectangle, colorTable.MenuBorder);
                            //Draws the inner border of the dropDownButton part for the pressed ToolStripSplitButton control
                            DrawInnerButtonBorder(graphics, dropDownButtonRectangle, colorTable.ButtonSelectedHighlightBorder);
                            //Draws the outer border of the dropDownButton part for the pressed ToolStripSplitButton control
                            DrawButtonBorder(graphics, dropDownButtonRectangle, colorTable.MenuBorder);
                        }
                        if (item.DropDownButtonPressed == true)
                        {
                            //Renders the upper button part of the pressed ToolStripSplitButton control
                            RenderButton(graphics, buttonRectangle, colorTable.MenuItemTopLevelSelectedGradientBegin);
                            //Renders the dropDownButton part of the pressed ToolStripSplitButton control
                            RenderButton(graphics, dropDownButtonRectangle, colorTable.MenuItemTopLevelSelectedGradientBegin);
                            //Draws the border of the button part for the pressed ToolStripSplitButton control
                            DrawButtonBorder(graphics, buttonRectangle, ColorTable.ButtonSelectedHighlightBorder);
                            //Draws the border of the dropDownButton part for the pressed ToolStripSplitButton control
                            DrawButtonBorder(graphics, dropDownButtonRectangle, ColorTable.ButtonSelectedHighlightBorder);
                        }
                        if (e.Item.Owner is MenuStrip)
                        {
                            base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, dropDownButtonBounds, colorTable.MenuItemText, ArrowDirection.Down));
                        }
                        if (e.Item.Owner is StatusStrip)
                        {
                            base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, dropDownButtonBounds, colorTable.StatusStripText, ArrowDirection.Down));
                        }
                        if (e.Item.Owner is ToolStrip)
                        {
                            base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, dropDownButtonBounds, colorTable.ToolStripText, ArrowDirection.Down));
                        }
                    }
                }
                else
                {
                    base.OnRenderDropDownButtonBackground(e);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Raises the Paint event.
        /// </summary>
        /// <param name="e">A PaintEventArgs that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            PanelStyle panelStyle = this.PanelStyle;

            if (this.m_bShowCaptionbar == false)
            {
                return;
            }

            using (UseAntiAlias antiAlias = new UseAntiAlias(e.Graphics))
            {
                Graphics graphics = e.Graphics;
                using (UseClearTypeGridFit clearTypeGridFit = new UseClearTypeGridFit(graphics))
                {
                    Rectangle   captionRectangle    = this.CaptionRectangle;
                    Color       colorGradientBegin  = this.PanelColors.PanelCaptionGradientBegin;
                    Color       colorGradientEnd    = this.PanelColors.PanelCaptionGradientEnd;
                    Color       colorGradientMiddle = this.PanelColors.PanelCaptionGradientMiddle;
                    Color       colorText           = this.PanelColors.PanelCaptionText;
                    bool        bShowXPanderPanelProfessionalStyle = this.ShowXPanderPanelProfessionalStyle;
                    ColorScheme colorSchema = this.ColorScheme;

                    if ((bShowXPanderPanelProfessionalStyle == true) &&
                        (colorSchema == ColorScheme.Professional) &&
                        (panelStyle != PanelStyle.Office2007))
                    {
                        colorGradientBegin  = this.PanelColors.XPanderPanelCaptionGradientBegin;
                        colorGradientEnd    = this.PanelColors.XPanderPanelCaptionGradientEnd;
                        colorGradientMiddle = this.PanelColors.XPanderPanelCaptionGradientMiddle;
                        colorText           = this.PanelColors.XPanderPanelCaptionText;
                    }

                    Image       image           = this.Image;
                    RightToLeft rightToLeft     = this.RightToLeft;
                    Font        captionFont     = this.CaptionFont;
                    Rectangle   clientRectangle = this.ClientRectangle;
                    string      strText         = this.Text;
                    DockStyle   dockStyle       = this.Dock;
                    bool        bExpand         = this.Expand;
                    if (this.m_imageClosePanel == null)
                    {
                        this.m_imageClosePanel = Resources.closePanel;
                    }
                    Color colorCloseIcon = this.PanelColors.PanelCaptionCloseIcon;
                    if (colorCloseIcon == Color.Empty)
                    {
                        colorCloseIcon = colorText;
                    }
                    bool bShowExpandIcon = this.ShowExpandIcon;
                    bool bShowCloseIcon  = this.ShowCloseIcon;

                    switch (panelStyle)
                    {
                    case Kesoft.Windows.Forms.Panels.PanelStyle.Default:
                    case PanelStyle.Office2007:
                        DrawStyleDefault(graphics,
                                         captionRectangle,
                                         colorGradientBegin,
                                         colorGradientEnd,
                                         colorGradientMiddle);
                        break;
                    }

                    DrawBorder(
                        graphics,
                        clientRectangle,
                        captionRectangle,
                        this.PanelColors.BorderColor,
                        this.PanelColors.InnerBorderColor);

                    if ((dockStyle == DockStyle.Fill) || (dockStyle == DockStyle.None) ||
                        ((bShowExpandIcon == false) && (bShowCloseIcon == false)))
                    {
                        DrawImagesAndText(
                            graphics,
                            captionRectangle,
                            CaptionSpacing,
                            this.ImageRectangle,
                            image,
                            rightToLeft,
                            captionFont,
                            colorText,
                            strText);

                        return;
                    }
                    if ((bShowExpandIcon == true) || (bShowCloseIcon == true))
                    {
                        Image imageExpandPanel = GetExpandImage(dockStyle, bExpand);

                        DrawImagesAndText(
                            graphics,
                            dockStyle,
                            CaptionSpacing,
                            captionRectangle,
                            clientRectangle,
                            this.ImageRectangle,
                            image,
                            rightToLeft,
                            bShowCloseIcon,
                            this.m_imageClosePanel,
                            colorCloseIcon,
                            ref this.RectangleCloseIcon,
                            bShowExpandIcon,
                            bExpand,
                            imageExpandPanel,
                            colorText,
                            ref this.RectangleExpandIcon,
                            captionFont,
                            colorText,
                            this.PanelColors.PanelCollapsedCaptionText,
                            strText);

                        if (this.m_imgHoverBackground == null)
                        {
                            this.m_imgHoverBackground = GetPanelIconBackground(
                                graphics,
                                this.ImageRectangle,
                                this.PanelColors.PanelCaptionSelectedGradientBegin,
                                this.PanelColors.PanelCaptionSelectedGradientEnd);
                        }
                        if (this.m_imgHoverBackground != null)
                        {
                            Rectangle rectangleCloseIcon = this.RectangleCloseIcon;
                            if (rectangleCloseIcon != Rectangle.Empty)
                            {
                                if (this.HoverStateCloseIcon == HoverState.Hover)
                                {
                                    graphics.DrawImage(this.m_imgHoverBackground, rectangleCloseIcon);
                                    DrawIcon(graphics, this.m_imageClosePanel, rectangleCloseIcon, colorCloseIcon, rectangleCloseIcon.Y);
                                }
                            }
                            Rectangle rectangleExpandIcon = this.RectangleExpandIcon;
                            if (rectangleExpandIcon != Rectangle.Empty)
                            {
                                if (this.HoverStateExpandIcon == HoverState.Hover)
                                {
                                    graphics.DrawImage(this.m_imgHoverBackground, rectangleExpandIcon);
                                    DrawIcon(graphics, imageExpandPanel, rectangleExpandIcon, colorText, rectangleExpandIcon.Y);
                                }
                            }
                        }
                    }
                }
            }
        }