Exemplo n.º 1
0
        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:
                    //default:
                    DrawCaptionbar(graphics, bExpand, bShowBorder, this.PanelStyle);
                    CalculatePanelHeights();
                    DrawBorders(graphics, this);
                    //        break;
                    //}
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            PanelStyle panelStyle = this.PanelStyle;

            if (this._isShowCaptionbar == 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        bShowExpondPanelProfessionalStyle = this.ShowExpondPanelProfessionalStyle;
                    ColorScheme colorSchema = this.ColorScheme;

                    if ((bShowExpondPanelProfessionalStyle == true) &&
                        (colorSchema == ColorScheme.Professional) &&
                        (panelStyle != PanelStyle.Office2007))
                    {
                        colorGradientBegin  = this.PanelColors.ExpondPanelCaptionGradientBegin;
                        colorGradientEnd    = this.PanelColors.ExpondPanelCaptionGradientEnd;
                        colorGradientMiddle = this.PanelColors.ExpondPanelCaptionGradientMiddle;
                        colorText           = this.PanelColors.ExpondPanelCaptionText;
                    }

                    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._imageClosePanel == null)
                    {
                        this._imageClosePanel = StaticResource.ClosePanel;
                    }
                    Color colorCloseIcon = this.PanelColors.PanelCaptionCloseIcon;
                    if (colorCloseIcon == Color.Empty)
                    {
                        colorCloseIcon = colorText;
                    }
                    bool bShowExpandIcon = this.ShowExpandIcon;
                    bool bShowCloseIcon  = this.ShowCloseIcon;

                    //switch (panelStyle)
                    //{
                    //    case PanelStyle.Default:
                    //    case PanelStyle.Office2007:
                    //    default:
                    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._imageClosePanel,
                            colorCloseIcon,
                            ref this.RectangleCloseIcon,
                            bShowExpandIcon,
                            bExpand,
                            imageExpandPanel,
                            colorText,
                            ref this.RectangleExpandIcon,
                            captionFont,
                            colorText,
                            this.PanelColors.PanelCollapsedCaptionText,
                            strText);

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