示例#1
0
        /// <include file='doc\ToolStripPopupButton.uex' path='docs/doc[@for="ToolStripDropDownButton.OnPaint"]/*' />
        /// <devdoc>
        /// Inheriting classes should override this method to handle this event.
        /// </devdoc>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (this.Owner != null)
            {
                ToolStripRenderer renderer = this.Renderer;
                Graphics          g        = e.Graphics;

                renderer.DrawDropDownButtonBackground(new ToolStripItemRenderEventArgs(e.Graphics, this));

                if ((DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image)
                {
                    renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(g, this, InternalLayout.ImageRectangle));
                }

                if ((DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text)
                {
                    renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, this.Text, InternalLayout.TextRectangle, this.ForeColor, this.Font, InternalLayout.TextFormat));
                }
                if (ShowDropDownArrow)
                {
                    ToolStripDropDownButton.ToolStripDropDownButtonInternalLayout layout = InternalLayout as ToolStripDropDownButtonInternalLayout;
                    Rectangle dropDownArrowRect = (layout != null) ? layout.DropDownArrowRect :Rectangle.Empty;

                    Color arrowColor = Enabled ? SystemColors.ControlText : SystemColors.ControlDark;
                    renderer.DrawArrow(new ToolStripArrowRenderEventArgs(g, this, dropDownArrowRect, arrowColor, ArrowDirection.Down));
                }
            }
        }
        /// <summary>
        ///  Inheriting classes should override this method to handle this event.
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Owner != null)
            {
                ToolStripRenderer renderer = Renderer;
                Graphics          g        = e.Graphics;

                renderer.DrawDropDownButtonBackground(new ToolStripItemRenderEventArgs(e.Graphics, this));

                if ((DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image)
                {
                    renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(g, this, InternalLayout.ImageRectangle));
                }

                if ((DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text)
                {
                    renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, Text, InternalLayout.TextRectangle, ForeColor, Font, InternalLayout.TextFormat));
                }
                if (ShowDropDownArrow)
                {
                    Rectangle dropDownArrowRect = (InternalLayout is ToolStripDropDownButtonInternalLayout layout) ? layout.DropDownArrowRect : Rectangle.Empty;

                    Color arrowColor;
                    if (Selected && !Pressed && SystemInformation.HighContrast)
                    {
                        arrowColor = Enabled ? SystemColors.HighlightText : SystemColors.ControlDark;
                    }
                    else
                    {
                        arrowColor = Enabled ? SystemColors.ControlText : SystemColors.ControlDark;
                    }
                    renderer.DrawArrow(new ToolStripArrowRenderEventArgs(g, this, dropDownArrowRect, arrowColor, ArrowDirection.Down));
                }
            }
        }
示例#3
0
 protected override void OnRenderArrow(System.Windows.Forms.ToolStripArrowRenderEventArgs e)
 {
     if (currentRenderer != null)
     {
         currentRenderer.DrawArrow(e);
         return;
     }
     base.OnRenderArrow(e);
 }
示例#4
0
 protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
 {
     if (_currentRenderer != null)
     {
         _currentRenderer.DrawArrow(e);
     }
     else
     {
         base.OnRenderArrow(e);
     }
 }
示例#5
0
 protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
 {
     renderer.DrawArrow(e);
 }
 protected override void OnPaint(PaintEventArgs e)
 {
     if (base.Owner != null)
     {
         ToolStripRenderer renderer = base.Renderer;
         Graphics          g        = e.Graphics;
         renderer.DrawMenuItemBackground(new ToolStripItemRenderEventArgs(g, this));
         Color menuText = SystemColors.MenuText;
         if (base.IsForeColorSet)
         {
             menuText = this.ForeColor;
         }
         else if (!this.IsTopLevel || ToolStripManager.VisualStylesEnabled)
         {
             if (this.Selected || this.Pressed)
             {
                 menuText = SystemColors.HighlightText;
             }
             else
             {
                 menuText = SystemColors.MenuText;
             }
         }
         bool flag = this.RightToLeft == RightToLeft.Yes;
         ToolStripMenuItemInternalLayout internalLayout = base.InternalLayout as ToolStripMenuItemInternalLayout;
         if ((internalLayout != null) && internalLayout.UseMenuLayout)
         {
             if ((this.CheckState != System.Windows.Forms.CheckState.Unchecked) && internalLayout.PaintCheck)
             {
                 Rectangle checkRectangle = internalLayout.CheckRectangle;
                 if (!internalLayout.ShowCheckMargin)
                 {
                     checkRectangle = internalLayout.ImageRectangle;
                 }
                 if (checkRectangle.Width != 0)
                 {
                     renderer.DrawItemCheck(new ToolStripItemImageRenderEventArgs(g, this, this.CheckedImage, checkRectangle));
                 }
             }
             if ((this.DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text)
             {
                 renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, this.Text, base.InternalLayout.TextRectangle, menuText, this.Font, flag ? ContentAlignment.MiddleRight : ContentAlignment.MiddleLeft));
                 bool showShortcutKeys = this.ShowShortcutKeys;
                 if (!base.DesignMode)
                 {
                     showShortcutKeys = showShortcutKeys && !this.HasDropDownItems;
                 }
                 if (showShortcutKeys)
                 {
                     renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, this.GetShortcutText(), base.InternalLayout.TextRectangle, menuText, this.Font, flag ? ContentAlignment.MiddleLeft : ContentAlignment.MiddleRight));
                 }
             }
             if (this.HasDropDownItems)
             {
                 ArrowDirection arrowDirection = flag ? ArrowDirection.Left : ArrowDirection.Right;
                 Color          arrowColor     = (this.Selected || this.Pressed) ? SystemColors.HighlightText : SystemColors.MenuText;
                 arrowColor = this.Enabled ? arrowColor : SystemColors.ControlDark;
                 renderer.DrawArrow(new ToolStripArrowRenderEventArgs(g, this, internalLayout.ArrowRectangle, arrowColor, arrowDirection));
             }
             if ((internalLayout.PaintImage && ((this.DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image)) && (this.Image != null))
             {
                 renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(g, this, base.InternalLayout.ImageRectangle));
             }
         }
         else
         {
             if ((this.DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text)
             {
                 renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, this.Text, base.InternalLayout.TextRectangle, menuText, this.Font, base.InternalLayout.TextFormat));
             }
             if (((this.DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) && (this.Image != null))
             {
                 renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(g, this, base.InternalLayout.ImageRectangle));
             }
         }
     }
 }