In general, the problem is that when you click on the panel, a Block object is created and it is drawn:
private void DrawingPanel_Click(object sender, EventArgs e) { Point ptr = PointToClient(Cursor.Position); ptr.X -= DrawingPanelOffset.X; ptr.Y -= DrawingPanelOffset.Y; b = new Block(0, "Class", "Model", ptr); DrawingPanel.Invalidate(); } private void DrawingPanel_Paint(object sender, PaintEventArgs e) { if (b != null) b.Draw(e.Graphics); } Directly block code
public void Draw(Graphics g) { Pen BlackPen = new Pen(Color.Black, 4); g.DrawRectangle(BlackPen, Location.X, Location.Y, Location.X + 80, Location.Y + 80); } As a result, when you click on different places of the panel, different figures are obtained.
As you can see, the figure stretches and increases in size. What can be done to correct this error?


