Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="image"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public void TryToConnectBottomRight(XImage image, 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)
            {
                image.BottomRight = result as XPoint;
            }
        }
Пример #2
0
        /// <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;
            }
        }
Пример #3
0
        /// <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;
            }
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arc"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public bool TryToConnectPoint3(XArc arc, 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)
            {
                arc.Point3 = result as XPoint;
                return(true);
            }
            return(false);
        }
Пример #5
0
        /// <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;
            }
        }