private void paintZone_MouseMove(object sender, MouseEventArgs e) { if (_draw) { if (i == 1) { first = new Point(e.X, e.Y); i = 2; } else { second = new Point(e.X, e.Y); i = 1; _pencil = true; } paintZone.Refresh(); CPoint = new Point(e.X, e.Y); Graphics g = paintZone.CreateGraphics(); switch (_currItem) { case Item.pencil: using (Graphics gg = Graphics.FromImage(bmp)) { if (_pencil) { gg.DrawLine(new Pen(_paintColor, 1), first.X, first.Y, second.X, second.Y); } } break; case Item.rectangle: g.DrawRectangle(new Pen(_paintColor, _paintWidth), e.X, e.Y, SLoc.X - e.X, SLoc.Y - e.Y); g.DrawRectangle(new Pen(_paintColor, _paintWidth), SLoc.X, SLoc.Y, e.X - SLoc.X, e.Y - SLoc.Y); g.DrawRectangle(new Pen(_paintColor, _paintWidth), SLoc.X, e.Y, e.X - SLoc.X, SLoc.Y - e.Y); g.DrawRectangle(new Pen(_paintColor, _paintWidth), e.X, SLoc.Y, SLoc.X - e.X, e.Y - SLoc.Y); break; case Item.line: g.DrawLine(new Pen(_paintColor, _paintWidth), SLoc.X, SLoc.Y, e.X, e.Y); break; case Item.ellipse: g.DrawEllipse(new Pen(_paintColor, _paintWidth), SLoc.X, SLoc.Y, e.X - SLoc.X, e.Y - SLoc.Y); break; case Item.eraser: using (Graphics gg = Graphics.FromImage(bmp)) { gg.FillEllipse(Brushes.White, CPoint.X, CPoint.Y, _paintWidth, _paintWidth); } break; case Item.brush: using (Graphics gg = Graphics.FromImage(bmp)) { gg.FillEllipse(new SolidBrush(_paintColor), CPoint.X, CPoint.Y, _paintWidth, _paintWidth); } break; case Item.text: float[] dashValues = { 5, 2, 4, 4 }; Pen blackPen = new Pen(Color.Silver, 1); blackPen.DashPattern = dashValues; g.DrawRectangle(blackPen, SLoc.X, SLoc.Y, e.X - SLoc.X, e.Y - SLoc.Y); break; } g.Dispose(); } }
public override void DrawFill(Graphics Gp) { Gp.FillEllipse(PenDraw.Brush, controlPanel); }