Esempio n. 1
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);

            if (null == ViewModel)
            {
                return;
            }

            Keyboard.Focus(this);

            _ZoomAndPanStartMatrix = ZoomAndPan.Matrix;

            _LeftButtonDownPos = e.GetPosition(this);
            _PrevMousePos      = _LeftButtonDownPos;

            if (!NodeGraphManager.IsNodeDragging &&
                !NodeGraphManager.IsConnecting &&
                !NodeGraphManager.IsSelecting)
            {
                Point mousePos = e.GetPosition(this);

                NodeGraphManager.BeginDragSelection(ViewModel.Model,
                                                    _ZoomAndPan.MatrixInv.Transform(mousePos));

                ViewModel.SelectionStartX = mousePos.X;
                ViewModel.SelectionWidth  = 0;
                ViewModel.SelectionStartY = mousePos.Y;
                ViewModel.SelectionHeight = 0;

                bool bCtrl  = Keyboard.IsKeyDown(Key.LeftCtrl);
                bool bShift = Keyboard.IsKeyDown(Key.LeftShift);
                bool bAlt   = Keyboard.IsKeyDown(Key.LeftAlt);

                if (!bCtrl && !bShift && !bAlt)
                {
                    NodeGraphManager.DeselectAllNodes(ViewModel.Model);
                }
            }
        }
Esempio n. 2
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (null == ViewModel)
            {
                return;
            }

            if (IsFocused)
            {
                if (Key.Delete == e.Key)
                {
                    FlowChart flowChart = ViewModel.Model;
                    flowChart.History.BeginTransaction("Destroy Selected Nodes");
                    {
                        NodeGraphManager.DestroySelectedNodes(ViewModel.Model);
                    }
                    flowChart.History.EndTransaction(false);
                }
                else if (Key.Escape == e.Key)
                {
                    FlowChart flowChart = ViewModel.Model;
                    flowChart.History.BeginTransaction("Destroy Selected Nodes");
                    {
                        NodeGraphManager.DeselectAllNodes(ViewModel.Model);
                    }
                    flowChart.History.EndTransaction(false);
                }
                else if (Key.A == e.Key)
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl))
                    {
                        NodeGraphManager.SelectAllNodes(ViewModel.Model);
                    }
                    else
                    {
                        FitNodesToView(false);
                    }
                }
                else if (Key.F == e.Key)
                {
                    FitNodesToView(true);
                }
                else if (Key.Z == e.Key)
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl))
                    {
                        History.NodeGraphHistory history = ViewModel.Model.History;
                        history.Undo();
                    }
                }
                else if (Key.Y == e.Key)
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl))
                    {
                        History.NodeGraphHistory history = ViewModel.Model.History;
                        history.Redo();
                    }
                }
            }
        }