コード例 #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)
        {
            if (IsZeroWidthOrHeight(CaptionRectangle))
            {
                return;
            }

            using (var antiAlias = new UseAntiAlias(e.Graphics))
            {
                var graphics = e.Graphics;

                using (var clearTypeGridFit = new UseClearTypeGridFit(graphics))
                {
                    bool bExpand         = Expand;
                    bool bShowBorder     = ShowBorder;
                    var  borderColor     = PanelColors.BorderColor;
                    var  borderRectangle = ClientRectangle;

                    switch (PanelStyle)
                    {
                    case PanelStyle.Default:
                    case PanelStyle.Office2007:
                        DrawCaptionbar(graphics, bExpand, bShowBorder, PanelStyle);
                        CalculatePanelHeights();
                        DrawBorders(graphics, this);
                        break;
                    }
                }
            }
        }
コード例 #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)
        {
            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;
                    }
                }
            }
        }
コード例 #3
0
ファイル: ProgressBar.cs プロジェクト: regous/GMap.NET
        /// <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,
                                _backgroundColor,
                                _valueColor,
                                _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);
                            }
                        }
                    }
                }
            }
        }
コード例 #4
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 BSE.Windows.Forms.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);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: XPanderPanel.cs プロジェクト: pkurowsk/NI-FAFOS
        /// <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;
               }
            }
             }
        }
コード例 #6
0
ファイル: Panel.cs プロジェクト: pkurowsk/NI-FAFOS
        /// <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 BSE.Windows.Forms.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);
                        }
                     }
                  }
               }
            }
             }
        }
コード例 #7
0
ファイル: Panel.cs プロジェクト: regous/GMap.NET
        /// <summary>
        ///     Raises the Paint event.
        /// </summary>
        /// <param name="e">A PaintEventArgs that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            var panelStyle = PanelStyle;

            if (_bShowCaptionbar == false)
            {
                return;
            }

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

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

                    var    image           = Image;
                    var    rightToLeft     = RightToLeft;
                    var    captionFont     = CaptionFont;
                    var    clientRectangle = ClientRectangle;
                    string strText         = Text;
                    var    dockStyle       = Dock;
                    bool   bExpand         = Expand;
                    if (_imageClosePanel == null)
                    {
                        _imageClosePanel = Resources.closePanel;
                    }

                    var colorCloseIcon = PanelColors.PanelCaptionCloseIcon;
                    if (colorCloseIcon == Color.Empty)
                    {
                        colorCloseIcon = colorText;
                    }

                    bool bShowExpandIcon = ShowExpandIcon;
                    bool bShowCloseIcon  = ShowCloseIcon;

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

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

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

                        return;
                    }

                    if (bShowExpandIcon || bShowCloseIcon)
                    {
                        var imageExpandPanel = GetExpandImage(dockStyle, bExpand);

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

                        if (_imgHoverBackground == null)
                        {
                            _imgHoverBackground = GetPanelIconBackground(
                                graphics,
                                ImageRectangle,
                                PanelColors.PanelCaptionSelectedGradientBegin,
                                PanelColors.PanelCaptionSelectedGradientEnd);
                        }

                        if (_imgHoverBackground != null)
                        {
                            var rectangleCloseIcon = RectangleCloseIcon;
                            if (rectangleCloseIcon != Rectangle.Empty)
                            {
                                if (HoverStateCloseIcon == HoverState.Hover)
                                {
                                    graphics.DrawImage(_imgHoverBackground, rectangleCloseIcon);
                                    DrawIcon(graphics,
                                             _imageClosePanel,
                                             rectangleCloseIcon,
                                             colorCloseIcon,
                                             rectangleCloseIcon.Y);
                                }
                            }

                            var rectangleExpandIcon = RectangleExpandIcon;
                            if (rectangleExpandIcon != Rectangle.Empty)
                            {
                                if (HoverStateExpandIcon == HoverState.Hover)
                                {
                                    graphics.DrawImage(_imgHoverBackground, rectangleExpandIcon);
                                    DrawIcon(graphics,
                                             imageExpandPanel,
                                             rectangleExpandIcon,
                                             colorText,
                                             rectangleExpandIcon.Y);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #8
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;
                        DrawProgressBar(
                            graphics,
                            this.ClientRectangle,
                            this.m_backgroundColor,
                            this.m_valueColor,
                            this.m_borderColor,
                            this.RightToLeft,
                            this.Minimum,
                            this.Maximum,
                            this.Value);

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

                                Rectangle stringRectangle = this.ClientRectangle;
                                graphics.DrawString(this.Text, this.Font, textBrush, stringRectangle, stringFormat);
                            }
                        }
                    }
                }
            }
        }