private void PictureBox1_MouseMove(object sender, MouseEventArgs e) { Graphics g = pictureBox1.CreateGraphics(); switch (Mode) { case Mode.DrawLine: if (e.Button == MouseButtons.Left) { pictureBox1.Refresh(); ShapePoint shape = new DrawLine(Color.FromArgb(button5.BackColor.R, button5.BackColor.G, button5.BackColor.B), MouseX, MouseY, e.X, e.Y); shape.Draw(g); } break; case Mode.DrawCircle: if (e.Button == MouseButtons.Left) { pictureBox1.Refresh(); ShapePoint shape = new DrawCircle(Color.FromArgb(button5.BackColor.R, button5.BackColor.G, button5.BackColor.B), MouseX, MouseY, (e.X - MouseX)); shape.Draw(g); } break; } }
private void PictureBox1_MouseUp(object sender, MouseEventArgs e) { switch (Mode) { case Mode.DrawLine: ShapePoint line = new DrawLine(Color.FromArgb(button5.BackColor.R, button5.BackColor.G, button5.BackColor.B), MouseX, MouseY, e.X, e.Y); AddShape(line); break; case Mode.DrawCircle: ShapePoint circle = new DrawCircle(Color.FromArgb(button5.BackColor.R, button5.BackColor.G, button5.BackColor.B), MouseX, MouseY, (e.X - MouseX)); AddShape(circle); break; } }