/// <summary> /// Creates a new instance of the XBezier class. /// </summary> /// <param name="point1"></param> /// <param name="point2"></param> /// <param name="point3"></param> /// <param name="point4"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <returns></returns> public XBezier Bezier( XPoint point1, XPoint point2, XPoint point3, XPoint point4, bool isStroked = true, bool isFilled = false) { var bezier = XBezier.Create( point1, point2, point3, point4, Context.Editor.Project.CurrentStyleLibrary.CurrentStyle, Context.Editor.Project.Options.PointShape, isStroked, isFilled); Context.Editor.AddWithHistory(bezier); return(bezier); }
/// <summary> /// Creates a new instance of the XBezier class. /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="x3"></param> /// <param name="y3"></param> /// <param name="x4"></param> /// <param name="y4"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <returns></returns> public XBezier Bezier( double x1 = 30, double y1 = 30, double x2 = 30, double y2 = 60, double x3 = 60, double y3 = 60, double x4 = 60, double y4 = 30, bool isStroked = true, bool isFilled = false) { var bezier = XBezier.Create( x1, y1, x2, y2, x3, y3, x4, y4, Context.Editor.Project.CurrentStyleLibrary.CurrentStyle, Context.Editor.Project.Options.PointShape, isStroked, isFilled); Context.Editor.AddWithHistory(bezier); return(bezier); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> public override void LeftDown(double x, double y) { double sx = _editor.Project.Options.SnapToGrid ? Editor.Snap(x, _editor.Project.Options.SnapX) : x; double sy = _editor.Project.Options.SnapToGrid ? Editor.Snap(y, _editor.Project.Options.SnapY) : y; switch (_currentState) { case State.None: { _shape = XBezier.Create( sx, sy, _editor.Project.CurrentStyleLibrary.CurrentStyle, _editor.Project.Options.PointShape, _editor.Project.Options.DefaultIsStroked, _editor.Project.Options.DefaultIsFilled); if (_editor.Project.Options.TryToConnect) { TryToConnectPoint1(_shape as XBezier, sx, sy); } _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_shape); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(_shape as XBezier); _editor.Project.CurrentContainer.HelperLayer.Invalidate(); _currentState = State.One; _editor.CancelAvailable = true; } break; case State.One: { var bezier = _shape as XBezier; if (bezier != null) { bezier.Point3.X = sx; bezier.Point3.Y = sy; bezier.Point4.X = sx; bezier.Point4.Y = sy; if (_editor.Project.Options.TryToConnect) { TryToConnectPoint4(_shape as XBezier, sx, sy); } _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateTwo(); Move(_shape as XBezier); _editor.Project.CurrentContainer.HelperLayer.Invalidate(); _currentState = State.Two; } } break; case State.Two: { var bezier = _shape as XBezier; if (bezier != null) { bezier.Point2.X = sx; bezier.Point2.Y = sy; if (_editor.Project.Options.TryToConnect) { TryToConnectPoint2(_shape as XBezier, sx, sy); } _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateThree(); Move(_shape as XBezier); _editor.Project.CurrentContainer.HelperLayer.Invalidate(); _currentState = State.Three; } } break; case State.Three: { var bezier = _shape as XBezier; if (bezier != null) { bezier.Point3.X = sx; bezier.Point3.Y = sy; if (_editor.Project.Options.TryToConnect) { TryToConnectPoint3(_shape as XBezier, sx, sy); } _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_shape); Remove(); Finalize(_shape as XBezier); _editor.AddWithHistory(_shape); _currentState = State.None; _editor.CancelAvailable = false; } } break; } }