Пример #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            PanelStyle panelStyle = PanelStyle;

            if (m_bShowCaptionbar)
            {
                using (new UseAntiAlias(e.Graphics))
                {
                    Graphics graphics = e.Graphics;
                    using (new UseClearTypeGridFit(graphics))
                    {
                        Rectangle   captionRectangle    = base.CaptionRectangle;
                        Color       colorGradientBegin  = base.PanelColors.PanelCaptionGradientBegin;
                        Color       colorGradientEnd    = base.PanelColors.PanelCaptionGradientEnd;
                        Color       colorGradientMiddle = base.PanelColors.PanelCaptionGradientMiddle;
                        Color       color = base.PanelColors.PanelCaptionText;
                        bool        showXPanderPanelProfessionalStyle = ShowXPanderPanelProfessionalStyle;
                        ColorScheme colorScheme = ColorScheme;
                        if (showXPanderPanelProfessionalStyle && colorScheme == ColorScheme.Professional && panelStyle != PanelStyle.Office2007)
                        {
                            colorGradientBegin  = base.PanelColors.XPanderPanelCaptionGradientBegin;
                            colorGradientEnd    = base.PanelColors.XPanderPanelCaptionGradientEnd;
                            colorGradientMiddle = base.PanelColors.XPanderPanelCaptionGradientMiddle;
                            color = base.PanelColors.XPanderPanelCaptionText;
                        }
                        Image       image           = base.Image;
                        RightToLeft rightToLeft     = RightToLeft;
                        Font        captionFont     = base.CaptionFont;
                        Rectangle   clientRectangle = base.ClientRectangle;
                        string      text            = Text;
                        DockStyle   dock            = Dock;
                        bool        expand          = Expand;
                        if (m_imageClosePanel == null)
                        {
                            m_imageClosePanel = Resources.closePanel;
                        }
                        Color color2 = base.PanelColors.PanelCaptionCloseIcon;
                        if (color2 == Color.Empty)
                        {
                            color2 = color;
                        }
                        bool showExpandIcon = ShowExpandIcon;
                        bool showCloseIcon  = ShowCloseIcon;
                        switch (panelStyle)
                        {
                        case PanelStyle.Default:
                        case PanelStyle.Office2007:
                            DrawStyleDefault(graphics, captionRectangle, colorGradientBegin, colorGradientEnd, colorGradientMiddle);
                            break;
                        }
                        DrawBorder(graphics, clientRectangle, captionRectangle, base.PanelColors.BorderColor, base.PanelColors.InnerBorderColor);
                        if (dock == DockStyle.Fill || dock == DockStyle.None || (!showExpandIcon && !showCloseIcon))
                        {
                            BasePanel.DrawImagesAndText(graphics, captionRectangle, 3, base.ImageRectangle, image, rightToLeft, captionFont, color, text);
                        }
                        else if (showExpandIcon || showCloseIcon)
                        {
                            Image expandImage = GetExpandImage(dock, expand);
                            BasePanel.DrawImagesAndText(graphics, dock, 3, captionRectangle, clientRectangle, base.ImageRectangle, image, rightToLeft, showCloseIcon, m_imageClosePanel, color2, ref RectangleCloseIcon, showExpandIcon, expand, expandImage, color, ref RectangleExpandIcon, captionFont, color, base.PanelColors.PanelCollapsedCaptionText, text);
                            if (m_imgHoverBackground == null)
                            {
                                m_imgHoverBackground = GetPanelIconBackground(graphics, base.ImageRectangle, base.PanelColors.PanelCaptionSelectedGradientBegin, base.PanelColors.PanelCaptionSelectedGradientEnd);
                            }
                            if (m_imgHoverBackground != null)
                            {
                                Rectangle rectangleCloseIcon = RectangleCloseIcon;
                                if (rectangleCloseIcon != Rectangle.Empty && base.HoverStateCloseIcon == HoverState.Hover)
                                {
                                    graphics.DrawImage(m_imgHoverBackground, rectangleCloseIcon);
                                    BasePanel.DrawIcon(graphics, m_imageClosePanel, rectangleCloseIcon, color2, rectangleCloseIcon.Y);
                                }
                                Rectangle rectangleExpandIcon = RectangleExpandIcon;
                                if (rectangleExpandIcon != Rectangle.Empty && base.HoverStateExpandIcon == HoverState.Hover)
                                {
                                    graphics.DrawImage(m_imgHoverBackground, rectangleExpandIcon);
                                    BasePanel.DrawIcon(graphics, expandImage, rectangleExpandIcon, color, rectangleExpandIcon.Y);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void DrawCaptionbar(Graphics graphics, bool bExpand, bool bShowBorder, PanelStyle panelStyle)
        {
            Rectangle captionRectangle    = base.CaptionRectangle;
            Color     color               = base.PanelColors.XPanderPanelCaptionGradientBegin;
            Color     color2              = base.PanelColors.XPanderPanelCaptionGradientEnd;
            Color     color3              = base.PanelColors.XPanderPanelCaptionGradientMiddle;
            Color     color4              = base.PanelColors.XPanderPanelCaptionText;
            Color     foreColorCloseIcon  = base.PanelColors.XPanderPanelCaptionCloseIcon;
            Color     foreColorExpandIcon = base.PanelColors.XPanderPanelCaptionExpandIcon;
            bool      flag = (base.HoverStateCaptionBar == HoverState.Hover) ? true : false;

            if (m_imageClosePanel == null)
            {
                m_imageClosePanel = Resources.closePanel;
            }
            if (m_imageChevronUp == null)
            {
                m_imageChevronUp = Resources.ChevronUp;
            }
            if (m_imageChevronDown == null)
            {
                m_imageChevronDown = Resources.ChevronDown;
            }
            m_imageChevron = m_imageChevronDown;
            if (bExpand)
            {
                m_imageChevron = m_imageChevronUp;
            }
            if (m_captionStyle == CaptionStyle.Normal)
            {
                if (flag)
                {
                    color  = base.PanelColors.XPanderPanelSelectedCaptionBegin;
                    color2 = base.PanelColors.XPanderPanelSelectedCaptionEnd;
                    color3 = base.PanelColors.XPanderPanelSelectedCaptionMiddle;
                    if (bExpand)
                    {
                        color  = base.PanelColors.XPanderPanelPressedCaptionBegin;
                        color2 = base.PanelColors.XPanderPanelPressedCaptionEnd;
                        color3 = base.PanelColors.XPanderPanelPressedCaptionMiddle;
                    }
                    color4              = base.PanelColors.XPanderPanelSelectedCaptionText;
                    foreColorCloseIcon  = color4;
                    foreColorExpandIcon = color4;
                }
                else if (bExpand)
                {
                    color               = base.PanelColors.XPanderPanelCheckedCaptionBegin;
                    color2              = base.PanelColors.XPanderPanelCheckedCaptionEnd;
                    color3              = base.PanelColors.XPanderPanelCheckedCaptionMiddle;
                    color4              = base.PanelColors.XPanderPanelSelectedCaptionText;
                    foreColorCloseIcon  = color4;
                    foreColorExpandIcon = color4;
                }
                if (panelStyle != PanelStyle.Office2007)
                {
                    BasePanel.RenderDoubleBackgroundGradient(graphics, captionRectangle, color, color3, color2, LinearGradientMode.Vertical, flipHorizontal: false);
                }
                else
                {
                    BasePanel.RenderButtonBackground(graphics, captionRectangle, color, color3, color2);
                }
            }
            else
            {
                Color xPanderPanelFlatCaptionGradientBegin = base.PanelColors.XPanderPanelFlatCaptionGradientBegin;
                Color xPanderPanelFlatCaptionGradientEnd   = base.PanelColors.XPanderPanelFlatCaptionGradientEnd;
                Color innerBorderColor = base.PanelColors.InnerBorderColor;
                color4 = base.PanelColors.XPanderPanelCaptionText;
                foreColorExpandIcon = color4;
                BasePanel.RenderFlatButtonBackground(graphics, captionRectangle, xPanderPanelFlatCaptionGradientBegin, xPanderPanelFlatCaptionGradientEnd, flag);
                DrawInnerBorders(graphics, this);
            }
            BasePanel.DrawImagesAndText(graphics, captionRectangle, 3, base.ImageRectangle, base.Image, RightToLeft, m_bIsClosable, ShowCloseIcon, m_imageClosePanel, foreColorCloseIcon, ref RectangleCloseIcon, ShowExpandIcon, m_imageChevron, foreColorExpandIcon, ref RectangleExpandIcon, base.CaptionFont, color4, Text);
        }