Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pevent"></param>
        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            //Simulate Transparency
            if (BackColor == Color.Transparent || BackColor.A < 255)
            {
                if (Parent is ISupportsTransparentChildRendering)
                {
                    ((ISupportsTransparentChildRendering)Parent).TransparentChild = this;
                }

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

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

            ControlRenderer.FillRectAccordingToGradientStyle(pevent.Graphics, this.ClientRectangle, BackColor, ForeColor,
                                                             ControlStyle.NoBorder, false, GradientColor, GradientStyle);

            if (TransparentChild != null && DesignMode)
            {
                ControlRenderer.RenderOwnerDrawnControlsOfParent(pevent.Graphics, TransparentChild);
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            if (BackColor == Color.Transparent || BackColor.A < 255)
            {
                if (Parent is ISupportsTransparentChildRendering)
                {
                    ((ISupportsTransparentChildRendering)Parent).TransparentChild = this;
                }

                int hScrollHeight = (this.HScroll ? SystemInformation.HorizontalScrollBarHeight : 0);
                int vScrollWidth  = (this.VScroll ? SystemInformation.VerticalScrollBarWidth : 0);

                int borderWidth    = ((this.Width - this.ClientSize.Width) - vScrollWidth) / 2;
                int titleBarHeight = this.Height - this.ClientSize.Height - (2 * borderWidth) - hScrollHeight;

                System.Drawing.Drawing2D.GraphicsContainer g = e.Graphics.BeginContainer();
                Rectangle translateRect = this.Bounds;
                e.Graphics.TranslateTransform(-(Left + borderWidth), -(Top + titleBarHeight + borderWidth));
                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;
                }
            }

            ControlRenderer.PaintBackgoundColorAndImage(this, e.Graphics, true, DisplayRectangle);

            if (TransparentChild != null && DesignMode)
            {
                ControlRenderer.RenderOwnerDrawnControlsOfParent(e.Graphics, TransparentChild);
            }
        }