/// <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 = XPoint.Create(sx, sy, _editor.Project.Options.PointShape); if (_editor.Project.Options.TryToConnect) { if (!_editor.TryToSplitLine(x, y, _shape, true)) { _editor.AddWithHistory(_shape); } } else { _editor.AddWithHistory(_shape); } } break; } }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="treshold"></param> /// <param name="dx"></param> /// <param name="dy"></param> /// <returns></returns> public static Rect2 GetPointBounds(XPoint point, double treshold, double dx, double dy) { double radius = treshold / 2.0; return new Rect2( point.X - radius + dx, point.Y - radius + dy, treshold, treshold); }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isSmoothJoin"></param> /// <returns></returns> public static XLineSegment Create( XPoint point, bool isStroked, bool isSmoothJoin) { return new XLineSegment() { Point = point, IsStroked = isStroked, IsSmoothJoin = isSmoothJoin }; }
/// <summary> /// /// </summary> /// <param name="startPoint"></param> /// <param name="segments"></param> /// <param name="isFilled"></param> /// <param name="isClosed"></param> /// <returns></returns> public static XPathFigure Create( XPoint startPoint, IList<XPathSegment> segments, bool isFilled, bool isClosed) { return new XPathFigure() { StartPoint = startPoint, Segments = segments, IsFilled = isFilled, IsClosed = isClosed }; }
/// <summary> /// /// </summary> /// <param name="point1"></param> /// <param name="point2"></param> /// <param name="isStroked"></param> /// <param name="isSmoothJoin"></param> /// <returns></returns> public static XQuadraticBezierSegment Create( XPoint point1, XPoint point2, bool isStroked, bool isSmoothJoin) { return new XQuadraticBezierSegment() { Point1 = point1, Point2 = point2, IsStroked = isStroked, IsSmoothJoin = isSmoothJoin }; }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="size"></param> /// <param name="rotationAngle"></param> /// <param name="isLargeArc"></param> /// <param name="sweepDirection"></param> /// <param name="isStroked"></param> /// <param name="isSmoothJoin"></param> public void ArcTo( XPoint point, XPathSize size, double rotationAngle, bool isLargeArc = false, XSweepDirection sweepDirection = XSweepDirection.Clockwise, bool isStroked = true, bool isSmoothJoin = true) { var segment = XArcSegment.Create( point, size, rotationAngle, isLargeArc, sweepDirection, isStroked, isSmoothJoin); _figure.Segments.Add(segment); }
/// <summary> /// /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></returns> public static XLine Create( XPoint start, XPoint end, ShapeStyle style, BaseShape point, bool isStroked = true, string name = "") { return new XLine() { Name = name, Style = style, IsStroked = isStroked, IsFilled = false, Data = new Data() { Bindings = ImmutableArray.Create<ShapeBinding>(), Properties = ImmutableArray.Create<ShapeProperty>() }, Start = start, End = end }; }
/// <summary> /// /// </summary> /// <param name="tl"></param> /// <param name="br"></param> /// <param name="dx"></param> /// <param name="dy"></param> /// <returns></returns> private static Rect CreateRect(XPoint tl, XPoint br, double dx, double dy) { double tlx = Math.Min(tl.X, br.X); double tly = Math.Min(tl.Y, br.Y); double brx = Math.Max(tl.X, br.X); double bry = Math.Max(tl.Y, br.Y); return new Rect( new Point(tlx + dx, tly + dy), new Point(brx + dx, bry + dy)); }
/// <summary> /// /// </summary> public override void Remove() { if (_topLeftHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_topLeftHelperPoint); _topLeftHelperPoint = null; } if (_bottomRightHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_bottomRightHelperPoint); _bottomRightHelperPoint = null; } }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <returns></returns> public double Distance(XPoint point) { double dx = this.X - point.X; double dy = this.Y - point.Y; return Math.Sqrt(dx * dx + dy * dy); }
/// <summary> /// /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <param name="p3"></param> /// <param name="p4"></param> /// <param name="dx"></param> /// <param name="dy"></param> /// <returns></returns> public static GdiArc FromXArc(XPoint p1, XPoint p2, XPoint p3, XPoint p4, double dx, double dy) { double x1 = p1.X + dx; double y1 = p1.Y + dy; double x2 = p2.X + dx; double y2 = p2.Y + dy; double x3 = p3.X + dx; double y3 = p3.Y + dy; double x4 = p4.X + dx; double y4 = p4.Y + dy; var rect = Rect2.Create(x1, y1, x2, y2, dx, dy); double cx = rect.X + rect.Width / 2.0; double cy = rect.Y + rect.Height / 2.0; double radiusX = cx - rect.X; double radiusY = cy - rect.Y; double startAngle = Math.Atan2(y3 - cy, x3 - cx); double endAngle = Math.Atan2(y4 - cy, x4 - cx); double sweepAngle = (endAngle - startAngle) * 180.0 / Math.PI; if (sweepAngle < 0) sweepAngle += 360; startAngle *= 180.0 / Math.PI; endAngle *= 180.0 / Math.PI; return new GdiArc { X = rect.X, Y = rect.Y, Width = rect.Width, Height = rect.Height, RadiusX = radiusX, RadiusY = radiusY, StartAngle = startAngle, EndAngle = endAngle, SweepAngle = sweepAngle }; }
/// <summary> /// Creates a new instance of the XRectangle class. /// </summary> /// <param name="topLeft"></param> /// <param name="bottomRight"></param> /// /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="text"></param> /// <returns></returns> public XRectangle Rectangle( XPoint topLeft, XPoint bottomRight, bool isStroked = true, bool isFilled = false, string text = null) { var rectangle = XRectangle.Create( topLeft, bottomRight, Context.Editor.Project.CurrentStyleLibrary.CurrentStyle, Context.Editor.Project.Options.PointShape, isStroked, isFilled, text); Context.Editor.AddWithHistory(rectangle); return rectangle; }
/// <summary> /// Creates a new instance of the XText class. /// </summary> /// <param name="topLeft"></param> /// <param name="bottomRight"></param> /// <param name="text"></param> /// <param name="isStroked"></param> /// <returns></returns> public XText Text( XPoint topLeft, XPoint bottomRight, string text = "Text", bool isStroked = true) { var txt = XText.Create( topLeft, bottomRight, Context.Editor.Project.CurrentStyleLibrary.CurrentStyle, Context.Editor.Project.Options.PointShape, text, isStroked); Context.Editor.AddWithHistory(txt); return txt; }
/// <summary> /// /// </summary> public override void ToStateTwo() { if (_p1HelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_p1HelperPoint); _p1HelperPoint = null; } if (_p2HelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_p2HelperPoint); _p2HelperPoint = null; } _startLine = XLine.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_startLine); _startHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_startHelperPoint); }
/// <summary> /// /// </summary> public override void ToStateOne() { _style = _editor.Project.Options.HelperStyle; _helperPoint1 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_helperPoint1); _helperPoint3 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_helperPoint3); }
/// <summary> /// /// </summary> /// <param name="topLeft"></param> /// <param name="bottomRight"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="text"></param> /// <param name="name"></param> /// <returns></returns> public static XRectangle Create( XPoint topLeft, XPoint bottomRight, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string text = null, string name = "") { return new XRectangle() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, Data = new Data() { Bindings = ImmutableArray.Create<ShapeBinding>(), Properties = ImmutableArray.Create<ShapeProperty>() }, TopLeft = topLeft, BottomRight = bottomRight, Text = text, IsGrid = false, OffsetX = 30.0, OffsetY = 30.0, CellWidth = 30.0, CellHeight = 30.0 }; }
/// <summary> /// /// </summary> public override void ToStateOne() { _style = _editor.Project.Options.HelperStyle; _ellipse = XEllipse.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_ellipse); _p1HelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_p1HelperPoint); _p2HelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_p2HelperPoint); _centerHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_centerHelperPoint); }
/// <summary> /// /// </summary> /// <param name="topLeft"></param> /// <param name="bottomRight"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="text"></param> /// <param name="name"></param> /// <returns></returns> public static XEllipse Create( XPoint topLeft, XPoint bottomRight, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string text = null, string name = "") { return new XEllipse() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, Data = new Data() { Bindings = ImmutableArray.Create<ShapeBinding>(), Properties = ImmutableArray.Create<ShapeProperty>() }, TopLeft = topLeft, BottomRight = bottomRight, Text = text, }; }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="size"></param> /// <param name="rotationAngle"></param> /// <param name="isLargeArc"></param> /// <param name="sweepDirection"></param> /// <param name="isStroked"></param> /// <param name="isSmoothJoin"></param> /// <returns></returns> public static XArcSegment Create( XPoint point, XPathSize size, double rotationAngle, bool isLargeArc, XSweepDirection sweepDirection, bool isStroked, bool isSmoothJoin) { return new XArcSegment() { Point = point, Size = size, RotationAngle = rotationAngle, IsLargeArc = isLargeArc, SweepDirection = sweepDirection, IsStroked = isStroked, IsSmoothJoin = isSmoothJoin }; }
/// <summary> /// /// </summary> public override void ToStateTwo() { _style = _editor.Project.Options.HelperStyle; _line12 = XLine.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_line12); _line32 = XLine.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_line32); _helperPoint2 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_helperPoint2); }
/// <summary> /// /// </summary> public override void ToStateOne() { _topLeftHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_topLeftHelperPoint); _bottomRightHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_bottomRightHelperPoint); }
/// <summary> /// /// </summary> public override void 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); }
/// <summary> /// Creates a new instance of the XArc 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 XArc Arc( XPoint point1, XPoint point2, XPoint point3, XPoint point4, bool isStroked = true, bool isFilled = false) { var arc = XArc.Create( point1, point2, point3, point4, Context.Editor.Project.CurrentStyleLibrary.CurrentStyle, Context.Editor.Project.Options.PointShape, isStroked, isFilled); Context.Editor.AddWithHistory(arc); return arc; }
/// <summary> /// /// </summary> public override void Remove() { if (_line12 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_line12); _line12 = null; } if (_line32 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_line32); _line32 = null; } if (_helperPoint1 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_helperPoint1); _helperPoint1 = null; } if (_helperPoint2 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_helperPoint2); _helperPoint2 = null; } if (_helperPoint3 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_helperPoint3); _helperPoint3 = null; } _style = null; }
/// <summary> /// /// </summary> public override void Remove() { if (_ellipse != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_ellipse); _ellipse = null; } if (_startLine != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_startLine); _startLine = null; } if (_endLine != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_endLine); _endLine = null; } if (_p1HelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_p1HelperPoint); _p1HelperPoint = null; } if (_p2HelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_p2HelperPoint); _p2HelperPoint = null; } if (_centerHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_centerHelperPoint); _centerHelperPoint = null; } if (_startHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_startHelperPoint); _startHelperPoint = null; } if (_endHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_endHelperPoint); _endHelperPoint = null; } _style = null; }
/// <summary> /// Creates a new instance of the XImage class. /// </summary> /// <param name="path"></param> /// <param name="topLeft"></param> /// <param name="bottomRight"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="text"></param> /// <returns></returns> public XImage Image( string path, XPoint topLeft, XPoint bottomRight, bool isStroked = false, bool isFilled = false, string text = null) { var image = XImage.Create( topLeft, bottomRight, Context.Editor.Project.CurrentStyleLibrary.CurrentStyle, Context.Editor.Project.Options.PointShape, path, isStroked, isFilled, text); Context.Editor.AddWithHistory(image); return image; }
/// <summary> /// /// </summary> public override void ToStateThree() { if (_ellipse != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_ellipse); _ellipse = null; } _endLine = XLine.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_endLine); _endHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_endHelperPoint); }
/// <summary> /// Creates a new instance of the XLine class. /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="isStroked"></param> /// <returns></returns> public XLine Line(XPoint start, XPoint end, bool isStroked = true) { var line = XLine.Create( start, end, Context.Editor.Project.CurrentStyleLibrary.CurrentStyle, Context.Editor.Project.Options.PointShape, isStroked); Context.Editor.AddWithHistory(line); return line; }
/// <summary> /// /// </summary> /// <param name="point1"></param> /// <param name="point2"></param> /// <param name="point3"></param> /// <param name="point4"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="name"></param> /// <returns></returns> public static XArc Create( XPoint point1, XPoint point2, XPoint point3, XPoint point4, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string name = "") { return new XArc() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, Data = new Data() { Bindings = ImmutableArray.Create<ShapeBinding>(), Properties = ImmutableArray.Create<ShapeProperty>() }, Point1 = point1, Point2 = point2, Point3 = point3, Point4 = point4 }; }
/// <summary> /// Creates a new instance of the XQBezier class. /// </summary> /// <param name="point1"></param> /// <param name="point2"></param> /// <param name="point3"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <returns></returns> public XQBezier QBezier( XPoint point1, XPoint point2, XPoint point3, bool isStroked = true, bool isFilled = false) { var qbezier = XQBezier.Create( point1, point2, point3, Context.Editor.Project.CurrentStyleLibrary.CurrentStyle, Context.Editor.Project.Options.PointShape, isStroked, isFilled); Context.Editor.AddWithHistory(qbezier); return qbezier; }