private bool isDrawing = false;private Point pos;private Pen drawingPen;private void PageImage_MouseDown(object sender, MouseEventArgs e){ if (e.Button == MouseButtons.Left) { isDrawing = true; pos.X = e.X; pos.Y = e.Y; }}private void PageImage_MouseDrawMove(object sender, MouseEventArgs e){ if (isDrawing) { g.DrawLine(drawingPen, pos, e.Location); pos = e.Location; }}private void PageImage_MouseUp(object sender, MouseEventArgs e){ if (e.Button == MouseButtons.Left) { isDrawing = false; Bitmap bitmap = new Bitmap(pageImage.Image); bitmap.Save(pageImage.ImageLocation); }}
g = pageImage.CreateGraphics();