private void Paintpanel_MouseMove(object sender, MouseEventArgs e) { Graphics g = Paintpanel.CreateGraphics(); if (e.Button == MouseButtons.Left) { fgg = Graphics.FromImage(fg); g.Clear(Color.White); if (type == 1) //creates new Rectangle and makes it the selected color { s = new Rect(); s.c = cpanel.BackColor; } else if (type == 2) //creates new oval and makes it the selected color { s = new Oval(); s.c = cpanel.BackColor; } else if (type == 3) //creates new line and makes it the selected color { s = new Line(); s.c = cpanel.BackColor; } s.paintShape(oldx, oldy, e.X, e.Y, g); g.DrawImage(fg, Paintpanel.Width, Paintpanel.Height); } }
private void Paintpanel_MouseUp(object sender, MouseEventArgs e) { Graphics fgg = Graphics.FromImage(fg); Graphics bgg = Graphics.FromImage(bg); bgg.DrawImage(fg, 0, 0); Paintpanel.CreateGraphics().DrawImage(bg, Paintpanel.Width, Paintpanel.Height); }