/// <summary> /// /// </summary> /// <param name="ellipse"></param> /// <param name="x"></param> /// <param name="y"></param> public void TryToConnectBottomRight(XEllipse ellipse, double x, double y) { var result = ShapeBounds.HitTest(_editor.Project.CurrentContainer, new Vector2(x, y), _editor.Project.Options.HitTreshold); if (result != null && result is XPoint) { ellipse.BottomRight = result as XPoint; } }
/// <summary> /// /// </summary> /// <param name="text"></param> /// <param name="x"></param> /// <param name="y"></param> public void TryToConnectTopLeft(XText text, double x, double y) { var result = ShapeBounds.HitTest(_editor.Project.CurrentContainer, new Vector2(x, y), _editor.Project.Options.HitTreshold); if (result != null && result is XPoint) { text.TopLeft = result as XPoint; } }
/// <summary> /// /// </summary> /// <param name="bezier"></param> /// <param name="x"></param> /// <param name="y"></param> public void TryToConnectPoint4(XBezier bezier, double x, double y) { var result = ShapeBounds.HitTest(_editor.Project.CurrentContainer, new Vector2(x, y), _editor.Project.Options.HitTreshold); if (result != null && result is XPoint) { bezier.Point4 = result as XPoint; } }
/// <summary> /// /// </summary> /// <param name="line"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public bool TryToConnectEnd(XLine line, double x, double y) { var result = ShapeBounds.HitTest(_editor.Project.CurrentContainer, new Vector2(x, y), _editor.Project.Options.HitTreshold); if (result != null && result is XPoint) { line.End = result as XPoint; return(true); } return(false); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> public override void LeftDown(double x, double y) { switch (_currentState) { case State.None: { _editor.Dehover(); if (_editor.Renderers[0].State.SelectedShape == null && _editor.Renderers[0].State.SelectedShapes != null) { var result = ShapeBounds.HitTest(_editor.Project.CurrentContainer, new Vector2(x, y), _editor.Project.Options.HitTreshold); if (result != null) { _startX = _editor.Project.Options.SnapToGrid ? Editor.Snap(x, _editor.Project.Options.SnapX) : x; _startY = _editor.Project.Options.SnapToGrid ? Editor.Snap(y, _editor.Project.Options.SnapY) : y; _historyX = _startX; _historyY = _startY; GenerateMoveSelectionCache(); _currentState = State.One; _editor.CancelAvailable = true; break; } } if (_editor.TryToSelectShape(_editor.Project.CurrentContainer, x, y)) { _startX = _editor.Project.Options.SnapToGrid ? Editor.Snap(x, _editor.Project.Options.SnapX) : x; _startY = _editor.Project.Options.SnapToGrid ? Editor.Snap(y, _editor.Project.Options.SnapY) : y; _historyX = _startX; _historyY = _startY; GenerateMoveSelectionCache(); _currentState = State.One; _editor.CancelAvailable = true; break; } _shape = XRectangle.Create( x, y, _editor.Project.Options.SelectionStyle, null, true, true); _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_shape); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); _currentState = State.One; _editor.CancelAvailable = true; } break; case State.One: { var rectangle = _shape as XRectangle; if (rectangle != null) { rectangle.BottomRight.X = x; rectangle.BottomRight.Y = y; _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_shape); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); _currentState = State.None; _editor.CancelAvailable = false; } } break; } }