Esempio n. 1
0
        /// <summary></summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            //base paint should always be called -- even if IsBasePaint is false
            //because the borders should always be painted by the framework.
            String orgText = Text;

            TextToDisplay = Text;
            base.Text     = String.Empty;
            base.OnPaint(e);
            base.Text = orgText;
            //Since we are modifying the Text, we need to Validate the Rect. Otherwise, the paint goes in recursion.
            NativeWindowCommon.ValidateRect(this.Handle, IntPtr.Zero);

            //fixedbug #:735118: when the button is UseVisualStyleBackColor=true(no color is set) and it is normal button
            //                   let window to paint the backgound of the control.
            // QCR #997321: if the button has gradient style then we should paint the background.
            bool paintBackground = !UseVisualStyleBackColor || (GradientStyle != GradientStyle.None);

            ButtonRenderer.DrawButton(this, e, paintBackground, true);
        }
Esempio n. 2
0
        /// <summary></summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs pevent)
        {
#if PocketPC
            base.OnPaint(pevent);
#else
            //We need to call base.OnPaint even if isBasePaint=false because the border and the radio
            //should be drawn by the Framework.
            base.OnPaint(pevent);

            if (!IsBasePaint && Image == null)
            {
                if (Appearance == Appearance.Normal)
                {
                    CheckBoxAndRadioButtonRenderer.DrawTextAndFocusRect(this, pevent, TextToDisplay, this.ClientRectangle, OFFSET_TEXT);
                }
                else
                {
                    ButtonRenderer.DrawButton(this, pevent, true, true);
                }
            }
#endif
        }
Esempio n. 3
0
        /// <summary></summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (IsBasePaint)
            {
                base.OnPaint(e);
            }
            else
            {
#if !PocketPC
                //Simulate Transparency
                if (BackColor == Color.Transparent || BackColor.A < 255)
                {
                    if (Parent is ISupportsTransparentChildRendering)
                    {
                        ((ISupportsTransparentChildRendering)Parent).TransparentChild = this;
                    }

                    System.Drawing.Drawing2D.GraphicsContainer g = e.Graphics.BeginContainer();
                    Rectangle translateRect = this.Bounds;
                    e.Graphics.TranslateTransform(-Left, -Top);
                    PaintEventArgs pe = new PaintEventArgs(e.Graphics, translateRect);
                    this.InvokePaintBackground(Parent, pe);
                    this.InvokePaint(Parent, pe);
                    e.Graphics.ResetTransform();
                    e.Graphics.EndContainer(g);
                    pe.Dispose();

                    if (Parent is ISupportsTransparentChildRendering)
                    {
                        ((ISupportsTransparentChildRendering)Parent).TransparentChild = null;
                    }
                }
#endif

                TextToDisplay = Text;
                ButtonRenderer.DrawButton(this, e, true, true);
            }
        }
Esempio n. 4
0
        /// <summary></summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            //For Desktop:
            //Always call base.OnPaint() to let the Framework render the border and the box.
            //Image is always to be rendered by the Framework.
            //If Image is not available, then only...
            //1. Appearance=Normal, just draw the text.
            //2. Appearance=Button, paint the background and text.

            //Since we do not want the Framework to paint the Text, set it to "" (blank) before calling base.OnPaint() and
            //reset it later.
            String orgText = Text;

            TextToDisplay = Text;
            base.Text     = String.Empty;

            if (BackColor == Color.Transparent && Parent is ISupportsTransparentChildRendering)
            {
                ((ISupportsTransparentChildRendering)Parent).TransparentChild = this;
            }

            base.OnPaint(e);

            if (BackColor == Color.Transparent && Parent is ISupportsTransparentChildRendering)
            {
                ((ISupportsTransparentChildRendering)Parent).TransparentChild = null;
            }

            base.Text = orgText;
            //Since we are modifying the Text, we need to Validate the Rect. Otherwise, the paint will go in recursion.
            win32.NativeWindowCommon.ValidateRect(this.Handle, IntPtr.Zero);

            if (Image == null)
            {
                if (Appearance == Appearance.Normal)
                {
                    Rectangle textRect = new Rectangle();
                    textRect = ClientRectangle;
                    //Padding also includes the padding set for the BOX. But it is not needed while rendering the text.
                    //So, ignore it.
                    textRect.Location = new Point(textRect.Left + Padding.Left, textRect.Top + Padding.Top - checkTopPadding);
                    textRect.Size     = new Size(textRect.Width - (Padding.Left + Padding.Right), textRect.Height - (Padding.Top + Padding.Bottom - checkTopPadding));

                    CheckBoxAndRadioButtonRenderer.DrawTextAndFocusRect(this, e, TextToDisplay, textRect, textOffset);
                }
                else
                {
                    ButtonRenderer.DrawButton(this, e, true, true);
                }
            }
            else
            {
                if (Focused && Appearance == Appearance.Normal)
                {
                    CheckBoxAndRadioButtonRenderer.DrawFocusRectOnCheckBoxGlyph(this, e.Graphics);
                }
            }

            // paint the border
            if (BorderType != BorderType.NoBorder)
            {
                BorderRenderer.PaintBorder(e.Graphics, ClientRectangle, ForeColor, ControlStyle.TwoD, false, BorderType);
            }
        }