/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); double sx = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; double sy = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { _point = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); if (_editor.Project.Options.TryToConnect) { if (!_editor.TryToSplitLine(x, y, _point, true)) { _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, _point); } } else { _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, _point); } } break; } }
/// <summary> /// Transfer selection state to <see cref="ToolState.One"/>. /// </summary> public void ToStateOne() { _helperPoint1 = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperPoint1); _helperPoint4 = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperPoint4); }
/// <summary> /// Transfer selection state to <see cref="ToolState.One"/>. /// </summary> public void ToStateOne() { _startHelperPoint = XPoint.Create(0, 0, _point); _endHelperPoint = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_startHelperPoint); _layer.Shapes = _layer.Shapes.Add(_endHelperPoint); }
/// <summary> /// Transfer selection state to <see cref="ToolState.One"/>. /// </summary> public void ToStateOne() { _topLeftHelperPoint = XPoint.Create(0, 0, _point); _bottomRightHelperPoint = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_topLeftHelperPoint); _layer.Shapes = _layer.Shapes.Add(_bottomRightHelperPoint); }
/// <summary> /// Transfer selection state to <see cref="ToolState.Two"/>. /// </summary> public void ToStateTwo() { _line12 = XLine.Create(0, 0, _style, null); _helperPoint2 = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_line12); _layer.Shapes = _layer.Shapes.Add(_helperPoint2); }
/// <inheritdoc/> public override void ToStateOne() { base.ToStateOne(); _startHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_startHelperPoint); _endHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_endHelperPoint); }
private static ImmutableArray <XPoint> ToXPoints(this IEnumerable <Point> points, double dx, double dy) { var xpoints = ImmutableArray.CreateBuilder <XPoint>(); foreach (var point in points) { xpoints.Add(XPoint.Create(point.X + dx, point.Y + dy)); } return(xpoints.ToImmutable()); }
/// <summary> /// /// </summary> /// <param name="points"></param> /// <returns></returns> public static IList <XPoint> ToXPoints(this IList <Point> points) { var xpoints = new List <XPoint>(); foreach (var point in points) { xpoints.Add(XPoint.Create(point.X, point.Y)); } return(xpoints); }
/// <summary> /// Transfer selection state to <see cref="ToolState.One"/>. /// </summary> public void ToStateOne() { _helperRectangle = XRectangle.Create(0, 0, _style, null); _topLeftHelperPoint = XPoint.Create(0, 0, _point); _bottomRightHelperPoint = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperRectangle); _layer.Shapes = _layer.Shapes.Add(_topLeftHelperPoint); _layer.Shapes = _layer.Shapes.Add(_bottomRightHelperPoint); }
/// <summary> /// Transfer selection state to <see cref="ToolState.Three"/>. /// </summary> public void ToStateThree() { _line43 = XLine.Create(0, 0, _style, null); _line23 = XLine.Create(0, 0, _style, null); _helperPoint3 = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_line43); _layer.Shapes = _layer.Shapes.Add(_line23); _layer.Shapes = _layer.Shapes.Add(_helperPoint3); }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); if (_isInitialized && _editor.CurrentPathTool != _previousPathTool) { SwitchPathTool(x, y); return; } switch (_editor.CurrentPathTool) { case PathTool.Line: { _toolPathLine.LeftDown(x, y); } break; case PathTool.Arc: { _toolPathArc.LeftDown(x, y); } break; case PathTool.CubicBezier: { _toolPathCubicBezier.LeftDown(x, y); } break; case PathTool.QuadraticBezier: { _toolPathQuadraticBezier.LeftDown(x, y); } break; case PathTool.Move: { double sx = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; double sy = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; // Start new figure. var start = _editor.TryToGetConnectionPoint(sx, sy) ?? XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _context.BeginFigure( start, _editor.Project.Options.DefaultIsFilled, _editor.Project.Options.DefaultIsClosed); // Switch to path tool before Move tool. _editor.CurrentPathTool = _movePathTool; SwitchPathTool(x, y); } break; } }
/// <summary> /// Transfer selection state to <see cref="ToolState.One"/>. /// </summary> public void ToStateOne() { _ellipse = XEllipse.Create(0, 0, _style, null); _p1HelperPoint = XPoint.Create(0, 0, _point); _p2HelperPoint = XPoint.Create(0, 0, _point); _centerHelperPoint = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_ellipse); _layer.Shapes = _layer.Shapes.Add(_p1HelperPoint); _layer.Shapes = _layer.Shapes.Add(_p2HelperPoint); _layer.Shapes = _layer.Shapes.Add(_centerHelperPoint); }
/// <inheritdoc/> XPoint IShapeFactory.Point(double x, double y, bool isStandalone) { var point = XPoint.Create( x, y, _editor.Project.Options.PointShape); if (isStandalone) { _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, point); } return(point); }
/// <summary> /// Transfer selection state to <see cref="ToolState.Three"/>. /// </summary> public void ToStateThree() { if (_ellipse != null) { _layer.Shapes = _layer.Shapes.Remove(_ellipse); _ellipse = null; } _endLine = XLine.Create(0, 0, _style, null); _endHelperPoint = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_endLine); _layer.Shapes = _layer.Shapes.Add(_endHelperPoint); }
/// <summary> /// Transfer selection state to <see cref="ToolState.Two"/>. /// </summary> public void ToStateTwo() { if (_p1HelperPoint != null) { _layer.Shapes = _layer.Shapes.Remove(_p1HelperPoint); _p1HelperPoint = null; } if (_p2HelperPoint != null) { _layer.Shapes = _layer.Shapes.Remove(_p2HelperPoint); _p2HelperPoint = null; } _startLine = XLine.Create(0, 0, _style, null); _startHelperPoint = XPoint.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_startLine); _layer.Shapes = _layer.Shapes.Add(_startHelperPoint); }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); double sx = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; double sy = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { _cubicBezier.Point1 = _editor.TryToGetConnectionPoint(sx, sy) ?? XPoint.Create(sx, sy, _editor.Project.Options.PointShape); if (!_toolPath._isInitialized) { _toolPath.InitializeWorkingPath(_cubicBezier.Point1); } else { _cubicBezier.Point1 = _toolPath.GetLastPathPoint(); } _cubicBezier.Point2 = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _cubicBezier.Point3 = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _cubicBezier.Point4 = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _toolPath._context.CubicBezierTo( _cubicBezier.Point2, _cubicBezier.Point3, _cubicBezier.Point4, _editor.Project.Options.DefaultIsStroked, _editor.Project.Options.DefaultIsSmoothJoin); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(null); _currentState = ToolState.One; _editor.CancelAvailable = true; } break; case ToolState.One: { _cubicBezier.Point4.X = sx; _cubicBezier.Point4.Y = sy; if (_editor.Project.Options.TryToConnect) { var point3 = _editor.TryToGetConnectionPoint(sx, sy); if (point3 != null) { var figure = _toolPath._geometry.Figures.LastOrDefault(); var cubicBezier = figure.Segments.LastOrDefault() as XCubicBezierSegment; cubicBezier.Point3 = point3; _cubicBezier.Point4 = point3; } } _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateTwo(); Move(null); _currentState = ToolState.Two; } break; case ToolState.Two: { _cubicBezier.Point2.X = sx; _cubicBezier.Point2.Y = sy; if (_editor.Project.Options.TryToConnect) { var point1 = _editor.TryToGetConnectionPoint(sx, sy); if (point1 != null) { var figure = _toolPath._geometry.Figures.LastOrDefault(); var cubicBezier = figure.Segments.LastOrDefault() as XCubicBezierSegment; cubicBezier.Point1 = point1; _cubicBezier.Point2 = point1; } } _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateThree(); Move(null); _currentState = ToolState.Three; } break; case ToolState.Three: { _cubicBezier.Point3.X = sx; _cubicBezier.Point3.Y = sy; if (_editor.Project.Options.TryToConnect) { var point2 = _editor.TryToGetConnectionPoint(sx, sy); if (point2 != null) { var figure = _toolPath._geometry.Figures.LastOrDefault(); var cubicBezier = figure.Segments.LastOrDefault() as XCubicBezierSegment; cubicBezier.Point2 = point2; _cubicBezier.Point3 = point2; } } _cubicBezier.Point1 = _cubicBezier.Point4; _cubicBezier.Point2 = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _cubicBezier.Point3 = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _cubicBezier.Point4 = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _toolPath._context.CubicBezierTo( _cubicBezier.Point2, _cubicBezier.Point3, _cubicBezier.Point4, _editor.Project.Options.DefaultIsStroked, _editor.Project.Options.DefaultIsSmoothJoin); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); Remove(); ToStateOne(); Move(null); _currentState = ToolState.One; } break; } }
/// <summary> /// Initializes static designer context. /// </summary> /// <param name="renderer">The design time renderer instance.</param> /// <param name="clipboard">The design time clipboard instance.</param> /// <param name="jsonSerializer">The design time Json serializer instance.</param> /// <param name="xamlSerializer">The design time Xaml serializer instance.</param> /// <returns>The new instance of the <see cref="DesignerContext"/> class.</returns> public static void InitializeContext(ShapeRenderer renderer, ITextClipboard clipboard, ITextSerializer jsonSerializer, ITextSerializer xamlSerializer) { // Editor Editor = new ProjectEditor() { CurrentTool = Tool.Selection, CurrentPathTool = PathTool.Line, CommandManager = new DesignerCommandManager(), Renderers = new ShapeRenderer[] { renderer }, ProjectFactory = new ProjectFactory(), TextClipboard = clipboard, JsonSerializer = jsonSerializer, XamlSerializer = xamlSerializer }.Defaults(); // Recent Projects Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project")); Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project")); // Commands Editor.InitializeCommands(); InitializeCommands(Editor); Editor.CommandManager.RegisterCommands(); // New Project Editor.OnNew(null); // Data var db = XDatabase.Create("Db"); var fields = new string[] { "Column0", "Column1" }; var columns = ImmutableArray.CreateRange(fields.Select(c => XColumn.Create(db, c))); db.Columns = columns; var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => XValue.Create(c)); var record = XRecord.Create( db, db.Columns, ImmutableArray.CreateRange(values)); db.Records = db.Records.Add(record); db.CurrentRecord = record; Database = db; Data = XContext.Create(record); Record = record; // Project IProjectFactory factory = new ProjectFactory(); Project = factory.GetProject(); Template = XContainer.CreateTemplate(); Page = XContainer.CreatePage(); var layer = Page.Layers.FirstOrDefault(); layer.Shapes = layer.Shapes.Add(XLine.Create(0, 0, null, null)); Page.CurrentLayer = layer; Page.CurrentShape = layer.Shapes.FirstOrDefault(); Page.Template = Template; Document = XDocument.Create(); Layer = XLayer.Create(); Options = XOptions.Create(); // State State = ShapeState.Create(); // Style ArgbColor = ArgbColor.Create(); ArrowStyle = ArrowStyle.Create(); FontStyle = FontStyle.Create(); LineFixedLength = LineFixedLength.Create(); LineStyle = LineStyle.Create(); Style = ShapeStyle.Create("Default"); TextStyle = TextStyle.Create(); // Shapes Arc = XArc.Create(0, 0, Style, null); CubicBezier = XCubicBezier.Create(0, 0, Style, null); Ellipse = XEllipse.Create(0, 0, Style, null); Group = XGroup.Create(Constants.DefaulGroupName); Image = XImage.Create(0, 0, Style, null, "key"); Line = XLine.Create(0, 0, Style, null); Path = XPath.Create("Path", Style, null); Point = XPoint.Create(); QuadraticBezier = XQuadraticBezier.Create(0, 0, Style, null); Rectangle = XRectangle.Create(0, 0, Style, null); Text = XText.Create(0, 0, Style, null, "Text"); // Path ArcSegment = XArcSegment.Create(XPoint.Create(), XPathSize.Create(), 180, true, XSweepDirection.Clockwise, true, true); CubicBezierSegment = XCubicBezierSegment.Create(XPoint.Create(), XPoint.Create(), XPoint.Create(), true, true); LineSegment = XLineSegment.Create(XPoint.Create(), true, true); PathFigure = XPathFigure.Create(XPoint.Create(), false, true); PathGeometry = XPathGeometry.Create(ImmutableArray.Create <XPathFigure>(), XFillRule.EvenOdd); PathSize = XPathSize.Create(); PolyCubicBezierSegment = XPolyCubicBezierSegment.Create(ImmutableArray.Create <XPoint>(), true, true); PolyLineSegment = XPolyLineSegment.Create(ImmutableArray.Create <XPoint>(), true, true); PolyQuadraticBezierSegment = XPolyQuadraticBezierSegment.Create(ImmutableArray.Create <XPoint>(), true, true); QuadraticBezierSegment = XQuadraticBezierSegment.Create(XPoint.Create(), XPoint.Create(), true, true); }
/// <summary> /// /// </summary> /// <param name="pg"></param> /// <param name="dx"></param> /// <param name="dy"></param> /// <returns></returns> public static XPathGeometry ToXPathGeometry(this PathGeometry pg, double dx, double dy) { var geometry = XPathGeometry.Create( ImmutableArray.Create <XPathFigure>(), pg.FillRule == FillRule.EvenOdd ? XFillRule.EvenOdd : XFillRule.Nonzero); var context = new XPathGeometryContext(geometry); foreach (var pf in pg.Figures) { context.BeginFigure( XPoint.Create(pf.StartPoint.X + dx, pf.StartPoint.Y + dy), pf.IsFilled, pf.IsClosed); foreach (var segment in pf.Segments) { if (segment is ArcSegment) { var arcSegment = segment as ArcSegment; context.ArcTo( XPoint.Create(arcSegment.Point.X + dx, arcSegment.Point.Y + dy), XPathSize.Create(arcSegment.Size.Width, arcSegment.Size.Height), arcSegment.RotationAngle, arcSegment.IsLargeArc, arcSegment.SweepDirection == SweepDirection.Clockwise ? XSweepDirection.Clockwise : XSweepDirection.Counterclockwise, arcSegment.IsStroked, arcSegment.IsSmoothJoin); } else if (segment is BezierSegment) { var cubicBezierSegment = segment as BezierSegment; context.CubicBezierTo( XPoint.Create(cubicBezierSegment.Point1.X + dx, cubicBezierSegment.Point1.Y + dy), XPoint.Create(cubicBezierSegment.Point2.X + dx, cubicBezierSegment.Point2.Y + dy), XPoint.Create(cubicBezierSegment.Point3.X + dx, cubicBezierSegment.Point3.Y + dy), cubicBezierSegment.IsStroked, cubicBezierSegment.IsSmoothJoin); } else if (segment is LineSegment) { var lineSegment = segment as LineSegment; context.LineTo( XPoint.Create(lineSegment.Point.X + dx, lineSegment.Point.Y + dy), lineSegment.IsStroked, lineSegment.IsSmoothJoin); } else if (segment is PolyBezierSegment) { var polyCubicBezierSegment = segment as PolyBezierSegment; context.PolyCubicBezierTo( ToXPoints(polyCubicBezierSegment.Points, dx, dy), polyCubicBezierSegment.IsStroked, polyCubicBezierSegment.IsSmoothJoin); } else if (segment is PolyLineSegment) { var polyLineSegment = segment as PolyLineSegment; context.PolyLineTo( ToXPoints(polyLineSegment.Points, dx, dy), polyLineSegment.IsStroked, polyLineSegment.IsSmoothJoin); } else if (segment is PolyQuadraticBezierSegment) { var polyQuadraticSegment = segment as PolyQuadraticBezierSegment; context.PolyQuadraticBezierTo( ToXPoints(polyQuadraticSegment.Points, dx, dy), polyQuadraticSegment.IsStroked, polyQuadraticSegment.IsSmoothJoin); } else if (segment is QuadraticBezierSegment) { var quadraticBezierSegment = segment as QuadraticBezierSegment; context.QuadraticBezierTo( XPoint.Create(quadraticBezierSegment.Point1.X + dx, quadraticBezierSegment.Point1.Y + dy), XPoint.Create(quadraticBezierSegment.Point2.X + dx, quadraticBezierSegment.Point2.Y + dy), quadraticBezierSegment.IsStroked, quadraticBezierSegment.IsSmoothJoin); } else { throw new NotSupportedException("Not supported segment type: " + segment.GetType()); } } } return(geometry); }
/// <summary> /// /// </summary> /// <param name="pg"></param> /// <returns></returns> public static XPathGeometry ToXPathGeometry(this PathGeometry pg) { var xpg = XPathGeometry.Create( new List <XPathFigure>(), pg.FillRule == FillRule.EvenOdd ? XFillRule.EvenOdd : XFillRule.Nonzero); foreach (var pf in pg.Figures) { xpg.BeginFigure( XPoint.Create(pf.StartPoint.X, pf.StartPoint.Y), pf.IsFilled, pf.IsClosed); foreach (var segment in pf.Segments) { if (segment is ArcSegment) { var arcSegment = segment as ArcSegment; xpg.ArcTo( XPoint.Create(arcSegment.Point.X, arcSegment.Point.Y), XPathSize.Create(arcSegment.Size.Width, arcSegment.Size.Height), arcSegment.RotationAngle, arcSegment.IsLargeArc, arcSegment.SweepDirection == SweepDirection.Clockwise ? XSweepDirection.Clockwise : XSweepDirection.Counterclockwise, arcSegment.IsStroked, arcSegment.IsSmoothJoin); } else if (segment is BezierSegment) { var bezierSegment = segment as BezierSegment; xpg.BezierTo( XPoint.Create(bezierSegment.Point1.X, bezierSegment.Point1.Y), XPoint.Create(bezierSegment.Point2.X, bezierSegment.Point2.Y), XPoint.Create(bezierSegment.Point3.X, bezierSegment.Point3.Y), bezierSegment.IsStroked, bezierSegment.IsSmoothJoin); } else if (segment is LineSegment) { var lineSegment = segment as LineSegment; xpg.LineTo( XPoint.Create(lineSegment.Point.X, lineSegment.Point.Y), lineSegment.IsStroked, lineSegment.IsSmoothJoin); } else if (segment is PolyBezierSegment) { var polyBezierSegment = segment as PolyBezierSegment; xpg.PolyBezierTo( ToXPoints(polyBezierSegment.Points), polyBezierSegment.IsStroked, polyBezierSegment.IsSmoothJoin); } else if (segment is PolyLineSegment) { var polyLineSegment = segment as PolyLineSegment; xpg.PolyLineTo( ToXPoints(polyLineSegment.Points), polyLineSegment.IsStroked, polyLineSegment.IsSmoothJoin); } else if (segment is PolyQuadraticBezierSegment) { var polyQuadraticSegment = segment as PolyQuadraticBezierSegment; xpg.PolyQuadraticBezierTo( ToXPoints(polyQuadraticSegment.Points), polyQuadraticSegment.IsStroked, polyQuadraticSegment.IsSmoothJoin); } else if (segment is QuadraticBezierSegment) { var qbezierSegment = segment as QuadraticBezierSegment; xpg.QuadraticBezierTo( XPoint.Create(qbezierSegment.Point1.X, qbezierSegment.Point1.Y), XPoint.Create(qbezierSegment.Point2.X, qbezierSegment.Point2.Y), qbezierSegment.IsStroked, qbezierSegment.IsSmoothJoin); } else { throw new NotSupportedException("Not supported segment type: " + segment.GetType()); } } } return(xpg); }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); double sx = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; double sy = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { _arc.Start = _editor.TryToGetConnectionPoint(sx, sy) ?? XPoint.Create(sx, sy, _editor.Project.Options.PointShape); if (!_toolPath._isInitialized) { _toolPath.InitializeWorkingPath(_arc.Start); } else { _arc.Start = _toolPath.GetLastPathPoint(); } _arc.End = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _toolPath._context.ArcTo( _arc.End, XPathSize.Create( Abs(_arc.Start.X - _arc.End.X), Abs(_arc.Start.Y - _arc.End.Y)), _defaultRotationAngle, _defaultIsLargeArc, _defaultSweepDirection, _editor.Project.Options.DefaultIsStroked, _editor.Project.Options.DefaultIsSmoothJoin); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(null); _currentState = ToolState.One; _editor.CancelAvailable = true; } break; case ToolState.One: { _arc.End.X = sx; _arc.End.Y = sy; if (_editor.Project.Options.TryToConnect) { var end = _editor.TryToGetConnectionPoint(sx, sy); if (end != null) { _arc.End = end; } } _arc.Start = _arc.End; _arc.End = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _toolPath._context.ArcTo( _arc.End, XPathSize.Create( Abs(_arc.Start.X - _arc.End.X), Abs(_arc.Start.Y - _arc.End.Y)), _defaultRotationAngle, _defaultIsLargeArc, _defaultSweepDirection, _editor.Project.Options.DefaultIsStroked, _editor.Project.Options.DefaultIsSmoothJoin); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); Move(null); _currentState = ToolState.One; } break; } }
/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); double sx = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; double sy = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { _line.Start = _editor.TryToGetConnectionPoint(sx, sy) ?? XPoint.Create(sx, sy, _editor.Project.Options.PointShape); if (!_toolPath._isInitialized) { _toolPath.InitializeWorkingPath(_line.Start); } else { _line.Start = _toolPath.GetLastPathPoint(); } _line.End = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _toolPath._context.LineTo( _line.End, _editor.Project.Options.DefaultIsStroked, _editor.Project.Options.DefaultIsSmoothJoin); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(null); _currentState = ToolState.One; _editor.CancelAvailable = true; } break; case ToolState.One: { _line.End.X = sx; _line.End.Y = sy; if (_editor.Project.Options.TryToConnect) { var end = _editor.TryToGetConnectionPoint(sx, sy); if (end != null) { var figure = _toolPath._geometry.Figures.LastOrDefault(); var line = figure.Segments.LastOrDefault() as XLineSegment; line.Point = end; } } _line.Start = _line.End; _line.End = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); _toolPath._context.LineTo(_line.End, _editor.Project.Options.DefaultIsStroked, _editor.Project.Options.DefaultIsSmoothJoin); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); Move(null); _currentState = ToolState.One; } break; } }