Пример #1
0
        private void ResizeStarted(object sender, ResizeStartedEventArgs e)
        {
            var overlay = sender as ResizeOverlay;
            var element = (overlay.DataContext as LayoutElement);

            _currentAction = new ResizeAction(element, e.Position.ToString(), _guidelines.GenerateGuidelines(Elements.Where(el => el != element).Select(el => el.Bounds)));
        }
Пример #2
0
        private void DragSelected()
        {
            var moveAction = _currentAction as MoveAction
                             ?? new MoveAction(
                Elements.Where(el => el.Selected),
                _guidelines.GenerateGuidelines(Elements.Where(el => el.Selected == false).Select(el => el.Bounds)));

            moveAction.Update(MoveVector);
            _currentAction = moveAction;
        }
Пример #3
0
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                var mouseAction = GetMouseAction();

                if (_currentAction is MoveAction)
                {
                    _currentAction.SetComplete();
                    ActionManager?.Push(_currentAction);
                    _currentAction = null;
                }

                switch (mouseAction)
                {
                case MouseAction.Click:
                    if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) == false)
                    {
                        foreach (var element in Elements.Where(el => el != _mouseDownTarget))
                        {
                            element.Selected = false;
                        }
                    }
                    break;

                case MouseAction.DragSelect:
                    SelectFromRect(_dragRect);
                    break;
                }

                _mouseDownPoint = null;
                ReleaseMouseCapture();
                UpdateDragRect();
            }

            base.OnMouseUp(e);
        }
Пример #4
0
 public void Push(DesignerAction action)
 {
     _index++;
     _actions = _actions.Take(_index).ToList();
     _actions.Add(action);
 }