Example #1
0
        /// <summary>
        /// Raises the Paint event.
        /// </summary>
        /// <param name="e">A PaintEventArgs that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            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.None:
                        case PanelStyle.Default:
                            DrawStyleDefault(graphics, bExpand, bShowBorder);
                            CalculatePanelHeights();
                            DrawBorder(graphics, bShowBorder, borderColor, borderRectangle);
                            break;
                        case PanelStyle.Aqua:
                            DrawStyleAqua(graphics, bExpand);
                            CalculatePanelHeights();
                            break;
                        case PanelStyle.Office2007:
                            DrawOffice2007(graphics, bExpand, bShowBorder);
                            CalculatePanelHeights();
                            DrawBorder(graphics, bShowBorder, borderColor, borderRectangle);
                            break;
                    }
                }
            }
        }
Example #2
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 (panelStyle == PanelStyle.None)
            {
                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 Windows.Forms.PanelStyle.Default:
                        case PanelStyle.Office2007:
                            DrawStyleDefault(graphics,
                                captionRectangle,
                                colorGradientBegin,
                                colorGradientEnd,
                                colorGradientMiddle,
                                bShowXPanderPanelProfessionalStyle);
                            break;
                        case PanelStyle.Aqua:
                            DrawStyleAqua(graphics,
                                captionRectangle,
                                colorGradientBegin,
                                colorGradientEnd);
                            break;
                    }

                    DrawBorder(
                        graphics,
                        panelStyle,
                        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,
                            panelStyle,
                            dockStyle,
                            CaptionSpacing,
                            captionRectangle,
                            clientRectangle,
                            this.ImageRectangle,
                            image,
                            rightToLeft,
                            bShowCloseIcon,
                            this.m_imageClosePanel,
                            colorCloseIcon,
                            ref this.RectangleClosePanelIcon,
                            bShowExpandIcon,
                            bExpand,
                            imageExpandPanel,
                            colorText,
                            ref this.RectangleExandPanelIcon,
                            captionFont,
                            colorText,
                            this.PanelColors.PanelCollapsedCaptionText,
                            strText);
                    }
                }
            }
        }