protected override void OnPaint(PaintEventArgs PaintEventArgs) { base.OnPaint(PaintEventArgs); if ((Width < 10) || (Height < 10)) { return; } if (!IsBackgroundDrawing) { return; } using (var bitmap = new Bitmap(Width, Height, PaintEventArgs.Graphics)) using (var graphics = Graphics.FromImage(bitmap)) { graphics.RenderBackgroundImage(ClientRectangle, BackColor, Width, Height, BackgroundImageLayout, BackgroundImage); var rectangle = ClientRectangle.Deflate(2); if (IsFocused) { graphics.RenderFocusedRaisedDimple(rectangle, BackColor); } else { graphics.RenderNonFocusedRaisedDimple(rectangle, BackColor); } RenderThumbDisk(graphics, rectangle, TheDial.Value, BackColor); graphics.RenderCaptions(rectangle, Font, TheCaptions); PaintEventArgs.Graphics.DrawImageUnscaled(bitmap, 0, 0); } }
protected override void OnPaint(PaintEventArgs PaintEventArgs) { base.OnPaint(PaintEventArgs); if ((Width < 10) || (Height < 10)) { return; } if (!IsBackgroundDrawing) { return; } using (var bitmap = new Bitmap(Width, Height, PaintEventArgs.Graphics)) using (var graphics = Graphics.FromImage(bitmap)) { graphics.RenderBackgroundImage(ClientRectangle, BackColor, Width, Height, BackgroundImageLayout, BackgroundImage); var rectangle = ClientRectangle.Deflate(1); var depthRaised = (Single)3; var depthDepressed = (Single)4; if (ThePushButton.Pressed) { if (IsFocused) { graphics.RenderFocusedDepressedRectangleButton(rectangle, BackColor, depthDepressed); } else { graphics.RenderNonFocusedDepressedRectangleButton(rectangle, BackColor, depthDepressed); } } else { if (IsFocused) { graphics.RenderFocusedRaisedRectangleButton(rectangle, BackColor, depthRaised); } else { graphics.RenderNonFocusedRaisedRectangleButton(rectangle, BackColor, depthRaised); } } graphics.RenderCaptions(ClientRectangle, Font, TheCaptions); PaintEventArgs.Graphics.DrawImageUnscaled(bitmap, 0, 0); } }