Animatroller.Simulator.Control.Bulb.SuperSimpleBulb.OnPaint C# (CSharp) Method

OnPaint() protected method

Handles the Paint event for this UserControl
protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs
return void
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.offScreenBitmap == null ||
                this.ClientRectangle.Width != this.offScreenBitmap.Width ||
                this.ClientRectangle.Height != this.offScreenBitmap.Height)
            {
                if (this.offScreenBitmap != null)
                    this.offScreenBitmap.Dispose();

                this.offScreenBitmap = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
            }

            // Create an offscreen graphics object for double buffering
            using (System.Drawing.Graphics g = Graphics.FromImage(this.offScreenBitmap))
            {
                g.SmoothingMode = SmoothingMode.HighSpeed;
                // Draw the control
                drawControl(g);
                // Draw the image to the screen
                e.Graphics.DrawImageUnscaled(this.offScreenBitmap, 0, 0);
            }
        }