Exemplo n.º 1
0
        public override void OnKeyUp(DesignCanvas canvas, KeyRoutedEventArgs args)
        {
            if (args.Key == VirtualKey.Menu)
            {
                _drawRectangle = false;

                Cursor = DefaultCursor;
                canvas.InvalidateCursor();
            }
            else if (args.Key == VirtualKey.Shift)
            {
                _linkAxes = false;
            }
            else if (args.Key == VirtualKey.Control)
            {
                _originAtCenter = false;
            }
            else if (args.Key == VirtualKey.Space)
            {
                _shouldMoveOrigin = false;
            }
            else
            {
                base.OnKeyUp(canvas, args);
                return;
            }

            args.Handled = true;
            canvas.Invalidate();
        }
Exemplo n.º 2
0
        public override void OnPointerMoved(DesignCanvas canvas, PointerRoutedEventArgs args)
        {
            base.OnPointerMoved(canvas, args);

            if (_origin.HasValue)
            {
                var pos = canvas.FromClientPosition(args.GetCurrentPoint(canvas).Position);

                var snapAxis = UIBroker.Axis.XY;
                if (args.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift))
                {
                    snapAxis = ClampToOrigin(pos, _origin.Value, out pos);
                }
                pos = UIBroker.SnapPointDirect(canvas.Layer, pos, 1f / canvas.ScaleFactor, snapAxis)
                      .ToPoint();

                if (_shouldMoveOrigin)
                {
                    _origin = new Point(
                        _origin.Value.X + pos.X - _anchor.X,
                        _origin.Value.Y + pos.Y - _anchor.Y);
                }
                _anchor = pos;

                _points = GetPointsWithEndpoints(canvas.Layer, addIntersections: !args.KeyModifiers.HasFlag(VirtualKeyModifiers.Menu));
                canvas.Invalidate();
            }
        }
Exemplo n.º 3
0
        public override void OnPointerMoved(DesignCanvas canvas, PointerRoutedEventArgs args)
        {
            base.OnPointerMoved(canvas, args);

            if (_origin.HasValue)
            {
                var pos = canvas.FromClientPosition(args.GetCurrentPoint(canvas).Position);
                if (args.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift))
                {
                    pos = ClampToOrigin(pos, _origin.Value);
                }

                if (_shouldMoveOrigin)
                {
                    _origin = new Point(
                        _origin.Value.X + pos.X - _anchor.X,
                        _origin.Value.Y + pos.Y - _anchor.Y);
                }
                _anchor = pos;

                _points = Slicing.IntersectPaths(canvas.Layer, _origin.Value.ToVector2(), _anchor.ToVector2());
                canvas.Invalidate();
            }

            Cursor = args.KeyModifiers.HasFlag(VirtualKeyModifiers.Menu) ? Cursors.KnifeWithPlus : DefaultCursor;
            canvas.InvalidateCursor();
        }
Exemplo n.º 4
0
        protected override void CompleteMove(DesignCanvas canvas)
        {
            base.CompleteMove(canvas);

            if (_points != null)
            {
                _points = null;

                canvas.Invalidate();
            }
            _origin = null;
        }
Exemplo n.º 5
0
        public override void OnPointerPressed(DesignCanvas canvas, PointerRoutedEventArgs args)
        {
            base.OnPointerPressed(canvas, args);

            var ptPoint = args.GetCurrentPoint(canvas);

            if (ptPoint.Properties.IsLeftButtonPressed)
            {
                var pos = canvas.FromClientPosition(ptPoint.Position);

                _origin = _anchor = UIBroker.SnapPointDirect(canvas.Layer, pos, 1f / canvas.ScaleFactor)
                                    .ToPoint();

                canvas.Invalidate();
            }
        }
Exemplo n.º 6
0
        public override void OnPointerMoved(DesignCanvas canvas, PointerRoutedEventArgs args)
        {
            base.OnPointerMoved(canvas, args);

            if (_origin.HasValue)
            {
                var pos = canvas.FromClientPosition(args.GetCurrentPoint(canvas).Position);
                if (_shouldMoveOrigin)
                {
                    var origin = _origin.Value;
                    origin.X += pos.X - _anchor.X;
                    origin.Y += pos.Y - _anchor.Y;
                    _origin   = origin;
                }
                _anchor = pos;

                canvas.Invalidate();
            }
        }
Exemplo n.º 7
0
        public override void OnKeyDown(DesignCanvas canvas, KeyRoutedEventArgs args)
        {
            if (args.Key == VirtualKey.Space && _origin != null)
            {
                _shouldMoveOrigin = true;
            }
            else if (args.Key == VirtualKey.Escape && _origin != null)
            {
                _origin = null;
                _points = null;

                canvas.Invalidate();
            }
            else
            {
                base.OnKeyDown(canvas, args);
                return;
            }

            args.Handled = true;
        }
Exemplo n.º 8
0
        public override void OnKeyDown(DesignCanvas canvas, KeyRoutedEventArgs args)
        {
            if (args.Key == VirtualKey.Menu)
            {
                _drawRectangle = true;

                Cursor = Cursors.CrossWithRectangle;
                canvas.InvalidateCursor();
            }
            else if (args.Key == VirtualKey.Shift)
            {
                _linkAxes = true;
            }
            else if (args.Key == VirtualKey.Control)
            {
                _originAtCenter = true;
            }
            else if (args.Key == VirtualKey.Space && _origin.HasValue)
            {
                _shouldMoveOrigin = true;
            }
            else if (args.Key == VirtualKey.Escape && _origin.HasValue)
            {
                _undoGroup.Reset();
                _undoGroup.Dispose();
                _undoGroup = null;
                _origin    = null;
                ((App)Application.Current).InvalidateData();
            }
            else
            {
                base.OnKeyDown(canvas, args);
                return;
            }

            args.Handled = true;
            canvas.Invalidate();
        }