private void MainCanvas_Paint(object sender, PaintEventArgs e) { var graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode; // Apply scaling defined by Canvas.ZoomScale graphics.ScaleTransform(MainCanvas.ZoomScale, MainCanvas.ZoomScale, MatrixOrder.Append); // Apply the translation defined by the offset values. graphics.TranslateTransform(MainCanvas.OffsetX, MainCanvas.OffsetY, MatrixOrder.Append); // All drawing happens when this Canvas is painted on the screen. // You don't just draw a line and expect it to persist. The drawing will dissapear when you minimise then maximise the form. // So, if we do all drawing when the containing Panel is drawn, then any time we can see our Panel, all our lines/rectangles will have been drawn too. // This is a very important concept. When you want to research, do a Google search like: "Drawing Paint event", "Drawing OnPaint override". foreach (IDrawable drawable in MainCanvas.Drawables) { drawable.Draw(graphics); } // When you draw a shape, you may drag your mouse to construct the shape. While this happens, IsDrawing will be set to true. // We want to show the shape being created by the mouse moving, so we draw the Tool's "CreationDrawable" shape. if (Tool.IsDrawing) { Tool.CreationDrawable?.Draw(graphics); } MainCanvas.RefreshResizers(); UpdatePeripherals(); }