private void Mouse_Move(object sender, MouseEventArgs e) { Bitmap imgbmp = copy.Clone() as Bitmap; if (rysuj == true)//myszka kliknięta { switch (wybranyItem) { case Item.prostokat: { Graphics p = Graphics.FromImage(imgbmp); PB.Image = imgbmp; p.DrawLine(new Pen(new SolidBrush(maluj_kolor)), new Point(x, y), new Point(x, e.Y)); p.DrawLine(new Pen(new SolidBrush(maluj_kolor)), new Point(x, y), new Point(e.X, y)); p.DrawLine(new Pen(new SolidBrush(maluj_kolor)), new Point(e.X, e.Y), new Point(x, e.Y)); p.DrawLine(new Pen(new SolidBrush(maluj_kolor)), new Point(e.X, e.Y), new Point(e.X, y)); p.Dispose(); } break; case Item.elipsa: Graphics el = Graphics.FromImage(imgbmp); PB.Image = imgbmp; el.DrawEllipse(new Pen(new SolidBrush(maluj_kolor)), x, y, e.X - x, e.Y - y); el.Dispose(); break; case Item.pedzel: if (toolStripTextBox1.Text != String.Empty) { Graphics pd = Graphics.FromImage(PB.Image); pd.FillEllipse(new SolidBrush(maluj_kolor), e.X - x + x, e.Y - y + y, Convert.ToInt32(toolStripTextBox1.Text), Convert.ToInt32(toolStripTextBox1.Text)); copy = PB.Image.Clone() as Bitmap; pd.Dispose(); Graphics g = PB.CreateGraphics(); g.FillEllipse(new SolidBrush(maluj_kolor), e.X - x + x, e.Y - y + y, Convert.ToInt32(toolStripTextBox1.Text), Convert.ToInt32(toolStripTextBox1.Text)); g.Dispose(); } break; case Item.gumka: if (toolStripTextBox1.Text != String.Empty) { Graphics gm = Graphics.FromImage(PB.Image); gm.FillRectangle(new SolidBrush(Color.White), e.X - x + x, e.Y - y + y, Convert.ToInt32(toolStripTextBox1.Text), Convert.ToInt32(toolStripTextBox1.Text)); copy = PB.Image.Clone() as Bitmap; gm.Dispose(); Graphics g = PB.CreateGraphics(); g.FillRectangle(new SolidBrush(Color.White), e.X - x + x, e.Y - y + y, Convert.ToInt32(toolStripTextBox1.Text), Convert.ToInt32(toolStripTextBox1.Text)); g.Dispose(); } else { Graphics gm = Graphics.FromImage(PB.Image); gm.FillRectangle(new SolidBrush(Color.White), e.X - x + x, e.Y - y + y, 30, 30); copy = PB.Image.Clone() as Bitmap; gm.Dispose(); Graphics g = PB.CreateGraphics(); g.FillRectangle(new SolidBrush(Color.White), e.X - x + x, e.Y - y + y, 30, 30); g.Dispose(); } break; case Item.linia: Graphics ln = Graphics.FromImage(imgbmp); ln.DrawLine(new Pen(new SolidBrush(maluj_kolor)), new Point(x, y), new Point(e.X, e.Y)); ln.Dispose(); PB.Image = imgbmp; break; } } }