Drawing on a Panel (System.Drawing.Drawing2D)

AndyNakamura 51 Reputation points
2021-02-18T17:08:06.627+00:00

I'm completely new to using the drawing facilities in vb.net
Nevertheless I've managed to create a prototype drawing on a Panel.
It's just a rectangle with the top right corner bevelled, then there are a couple of circles tangential to the bevel. The dimensions of the rectangle and bevel size and angle are from textboxes. (It's sort of the worlds worst cad program).
Because the bevel can be small relative to the size of the rectangle I have translated and zoomed so that no matter the size of the rectangle the bevel always fills the panel.
Currently more or less the whole code is in the paint event of the Panel including the translate and zoom requirements.
What I want is to be able to press a button and zoom out so the whole rectangle is shown, but I don't know how to do it.
I'm wondering if I should only have the actual drawing elements in the Panel Paint event and have all the calcs as form variables including translate and scale variables?
Anyway, what is the correct way to go about drawing on a panel or does anyone know of any good examples or tutorials.
Just want to avoid thirty two prototypes.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,714 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 84,471 Reputation points
    2021-02-19T07:42:43.277+00:00

    You can see this recent thread about zooming with drawing in Paint event and scale variables (PictureBox inside a Panel, by same thing for any control)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.