private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { isMousePressed = false; IShape shape; switch (curTool) { case Tool.Pen: break; case Tool.Line: shape = new MyLine(prevPoint, curPoint, pen); shapes.Add(shape); break; case Tool.Circle: shape = new MyCircle(prevPoint, curPoint, pen); shapes.Add(shape); break; case Tool.Rectangle: shape = new MyRectangle(prevPoint, curPoint, pen); shapes.Add(shape); break; case Tool.Triangle: shape = new MyTriangle(prevPoint, curPoint, pen); shapes.Add(shape); break; case Tool.Select: ShapesApplyNewPosition(); break; default: break; } prevPoint = e.Location; }
private void AddShapeToList(Point endPoint) { //Обрабатываются в клике if (this.typeTool == SHAPES.FILLTOOL || this.typeTool == SHAPES.COLORCHOICE) { return; } Shape currentShape = null; switch (this.typeTool) { case SHAPES.PEN: this.pointsOfMovement.Add(endPoint); MyPen myPen = new MyPen(this.pointsOfMovement); Pen pen = new Pen(this.colorChoicer.FColor, this.widthChiocer.LineWidth); myPen.Pen = pen; this.shapesList.Add(myPen); this.pointsOfMovement.Clear(); this.UpdateShapeListComboBox(); return; case SHAPES.LINE: currentShape = new MyLine(this.bPoint, endPoint); break; case SHAPES.RECTANGLE: currentShape = new MyRectangle(this.bPoint, endPoint); break; case SHAPES.FILLRECTANGLE: currentShape = new MyRectangle(this.bPoint, endPoint, true); break; case SHAPES.ELLIPS: currentShape = new MyEllipse(this.bPoint, endPoint); break; case SHAPES.FILLELLIPS: currentShape = new MyEllipse(this.bPoint, endPoint, true); break; default: throw new ShapeException("Неизвестный тип фигуры"); } Pen currentPen = new Pen(this.colorChoicer.FColor, this.widthChiocer.LineWidth); currentPen.DashStyle = this.lineStyleChoicer.SelectedStyle; currentShape.Pen = currentPen; if (this.hatchChoiser.SelectedHatch == null) { currentShape.Brush = new SolidBrush(this.colorChoicer.BColor); } else { currentShape.Brush = new HatchBrush((HatchStyle)this.hatchChoiser.SelectedHatch, this.colorChoicer.FColor, this.colorChoicer.BColor); } this.shapesList.Add(currentShape); this.UpdateShapeListComboBox(); this.pointsOfMovement.Clear(); }
public override object Clone() { MyLine clone = new MyLine(this.BeginPoint, this.EndPoint); clone.Pen = (Pen)this.Pen.Clone(); clone.Brush = (Brush)this.Brush.Clone(); clone.IsFill = this.IsFill; return clone; }