private void Form1_MouseUp(object sender, MouseEventArgs e) { if (selectedShape == SelectedShape.none || isDrawing == false || capacityReached) { return; } isDrawing = false; secondLocation = e.Location; rchtPanel.Text = selectedShape.ToString() + " çizildi"; MyShape aShape; if (selectedShape == SelectedShape.circle) { aShape = new MyCircle(colorDialog1.Color, colorDialog2.Color, GetRectangle()); } else if (selectedShape == SelectedShape.square) { aShape = new MySquare(colorDialog1.Color, colorDialog2.Color, GetRectangle()); } else { aShape = new MyRectangle(colorDialog1.Color, colorDialog2.Color, GetRectangle()); } myCollector.AddShape(aShape); }
private Shape GetShape(ShapeType type, Point p1, Point p2) { if (type == ShapeType.Rectangle) { MyRectangle r = new MyRectangle(); int w = Math.Abs(p1.X - p2.X); int h = Math.Abs(p1.Y - p2.Y); r.Location = GetMinPoint(p1, p2); r.Height = h; r.Width = w; return(r); } else if (type == ShapeType.Circle) { MyCircle r = new MyCircle(); int w = Math.Abs(p1.X - p2.X); int h = Math.Abs(p1.Y - p2.Y); r.Location = GetMinPoint(p1, p2); r.Height = h; r.Width = w; return(r); } else if (selectedShape == ShapeType.Line) { MyLine line = new MyLine(); line.Location = p1; line.EndLocation = p2; return(line); } else { if (currentShape == null) { MyPencil newPencil = new MyPencil(); newPencil.Points.Add(p1); return(newPencil); } MyPencil p = currentShape as MyPencil; p.Points.Add(p2); return(p); } }
private Shape GetShape(ShapeType type, Point p1, Point p2) { if (type == ShapeType.Rectangle) { MyRectangle r = new MyRectangle(); int w = Math.Abs(p1.X - p2.X); int h = Math.Abs(p1.Y - p2.Y); r.Location = GetMinPoint(p1, p2); r.Height = h; r.Width = w; return(r); } else if (type == ShapeType.Circle) { MyCircle r = new MyCircle(); int w = Math.Abs(p1.X - p2.X); int h = Math.Abs(p1.Y - p2.Y); r.Location = GetMinPoint(p1, p2); r.Height = h; r.Width = w; return(r); } else { MyLine line = new MyLine(); line.Location = p1; line.EndLocation = p2; return(line); } }
private void DrawShape(Shape s) { if (s is MyRectangle) { MyRectangle r = s as MyRectangle; graphics.DrawRectangle(pen, r.Location.X, r.Location.Y, r.Width, r.Height); } else if (s is MyCircle) { MyCircle circle = s as MyCircle; graphics.DrawEllipse(pen, circle.Location.X, circle.Location.Y, circle.Width, circle.Height); } else if (s is MyLine) { MyLine l = s as MyLine; graphics.DrawLine(pen, l.Location, l.EndLocation); } }
private void DrawShape(Shape s) { if (s is MyPencil) { MyPencil p = s as MyPencil; if (p.Points.Count < 1) { return; } for (int i = 1; i < p.Points.Count; i++) { graphics.DrawLine(pen, p.Points[i - 1], p.Points[i]); } } else if (s is MyRectangle) { MyRectangle r = s as MyRectangle; graphics.DrawRectangle(pen, r.Location.X, r.Location.Y, r.Width, r.Height); } else if (s is MyCircle) { MyCircle circle = s as MyCircle; graphics.DrawEllipse(pen, circle.Location.X, circle.Location.Y, circle.Width, circle.Height); } else if (s is MyLine) { MyLine l = s as MyLine; graphics.DrawLine(pen, l.Location, l.EndLocation); } }