Beispiel #1
0
 public void thisKeyUpExec(KeyObject keypress)
 {
     if (keypress.thisKey == Key.RIGHT)
     {
         arrowdir.X = 0;
     }
     if (keypress.thisKey == Key.LEFT)
     {
         arrowdir.X = 0;
     }
     if (keypress.thisKey == Key.UP)
     {
         arrowdir.Y = 0;
     }
     if (keypress.thisKey == Key.DOWN)
     {
         arrowdir.Y = 0;
     }
 }
Beispiel #2
0
        public void thisKeyDownExec(KeyObject keypress)
        {
            if (!GlobalNodeHandler.typing)
            {
                int x = keypress.currentMousePos.X;
                int y = keypress.currentMousePos.Y;

                if (keypress.thisKey == Key.N)
                {
                    /*if (GlobalNodeHandler.viewNode.GetLastChild() != null)
                     * {
                     *  GlobalNodeHandler.CreateNewNode(GlobalNodeHandler.viewNode.GetLastChild().xpos + GlobalNodeHandler.viewNode.GetLastChild().width + 200,
                     *      GlobalNodeHandler.viewNode.GetLastChild().ypos, false);
                     * }
                     * else if (GlobalNodeHandler.viewNode.GetChildren().Count == 0)
                     * {
                     *  GlobalNodeHandler.CreateNewNode(10, 1000 / 2, false);
                     *  //GlobalNodeHandler.ShowTextBox(new CalcPoint(10, 1000 / 2), activetextbox);
                     * }*/
                }
                if (keypress.thisKey == Key.I)
                {
                    if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(x, y)) != null)
                    {
                        GlobalNodeHandler.JumpInto(GlobalNodeHandler.clickedNode);
                        repaint(this, new EventArgs());
                    }
                }
                if (keypress.thisKey == Key.O)
                {
                    GlobalNodeHandler.JumpOut();
                    repaint(this, new EventArgs());
                }
                if (keypress.thisKey == Key.C)
                {
                    if (GlobalNodeHandler.clickedNode == null)
                    {
                        if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(x, y)) != null)
                        {
                            GlobalNodeHandler.clickedNode.setSelected(true);
                        }
                    }
                    else
                    {
                        if ((GlobalNodeHandler.rightNode = GlobalNodeHandler.viewNode.ContainsChildNode(x, y)) != null && GlobalNodeHandler.rightNode != GlobalNodeHandler.clickedNode)
                        {
                            GlobalNodeHandler.clickedNode.setSelected(false);
                            GlobalNodeHandler.clickedNode.AddConnection(GlobalNodeHandler.rightNode);

                            GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(3, "ConnectNodes", GlobalNodeHandler.clickedNode, GlobalNodeHandler.rightNode));

                            GlobalNodeHandler.clickedNode = null;
                            GlobalNodeHandler.rightNode   = null;
                        }
                        else if (GlobalNodeHandler.clickedNode != null)
                        {
                            GlobalNodeHandler.clickedNode.setSelected(false);
                            GlobalNodeHandler.clickedNode = null;
                        }
                    }
                }
                if (keypress.thisKey == Key.D)
                {
                    if (GlobalNodeHandler.clickedNode == null)
                    {
                        if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(x, y)) != null)
                        {
                            GlobalNodeHandler.clickedNode.setSelected(true);
                        }
                    }
                    else
                    {
                        if ((GlobalNodeHandler.rightNode = GlobalNodeHandler.viewNode.ContainsChildNode(x, y)) != null && GlobalNodeHandler.rightNode != GlobalNodeHandler.clickedNode)
                        {
                            GlobalNodeHandler.clickedNode.setSelected(false);
                            GlobalNodeHandler.clickedNode.DeleteConnection(GlobalNodeHandler.rightNode);

                            GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(4, "DeleteConnections", GlobalNodeHandler.clickedNode, GlobalNodeHandler.rightNode));

                            GlobalNodeHandler.clickedNode = null;
                            GlobalNodeHandler.rightNode   = null;
                        }
                        else if (GlobalNodeHandler.clickedNode != null)
                        {
                            GlobalNodeHandler.clickedNode.setSelected(false);
                            GlobalNodeHandler.clickedNode = null;
                        }
                    }
                }
                if (keypress.thisKey == Key.A)
                {
                    if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(x, y)) != null)
                    {
                        MindNodeAction action = new MindNodeAction(3, "DeleteConnections");
                        action.involvedNodes.Push(GlobalNodeHandler.clickedNode);
                        foreach (MindNode m in GlobalNodeHandler.clickedNode.connNodes)
                        {
                            action.involvedNodes.Push(GlobalNodeHandler.clickedNode);
                            action.involvedNodes.Push(m);
                        }
                        foreach (MindNode m in GlobalNodeHandler.clickedNode.backconnNodes)
                        {
                            action.involvedNodes.Push(m);
                            action.involvedNodes.Push(GlobalNodeHandler.clickedNode);
                        }
                        GlobalNodeHandler.actionLog.AddAction(action);

                        GlobalNodeHandler.clickedNode.DeleteAllConnections();
                    }
                }
                if (keypress.thisKey == Key.K)
                {
                    if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(x, y)) != null)
                    {
                        MindNodeAction action = new MindNodeAction(3, "DeleteConnections");
                        action.involvedNodes.Push(GlobalNodeHandler.clickedNode);
                        foreach (MindNode m in GlobalNodeHandler.clickedNode.connNodes)
                        {
                            action.involvedNodes.Push(GlobalNodeHandler.clickedNode);
                            action.involvedNodes.Push(m);
                        }
                        foreach (MindNode m in GlobalNodeHandler.clickedNode.backconnNodes)
                        {
                            action.involvedNodes.Push(m);
                            action.involvedNodes.Push(GlobalNodeHandler.clickedNode);
                        }
                        GlobalNodeHandler.actionLog.AddAction(action);

                        GlobalNodeHandler.clickedNode.DeleteAllConnections();

                        GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(1, "DeleteNode", GlobalNodeHandler.clickedNode));
                        GlobalNodeHandler.viewNode.DeleteNode(GlobalNodeHandler.clickedNode);
                    }
                }
                if (keypress.thisKey == Key.U)
                {
                    GlobalNodeHandler.actionLog.UndoLast();
                }
                if (keypress.thisKey == Key.R)
                {
                    GlobalNodeHandler.actionLog.RedoLast();
                }
                if (keypress.thisKey == Key.RIGHT)
                {
                    arrowdir.X = 1;
                    GlobalNodeHandler.viewNode.MoveView(arrowdir, 15);
                    //panel1.HorizontalScroll.Value = panel1.HorizontalScroll.Value + 15;
                }
                if (keypress.thisKey == Key.LEFT)
                {
                    arrowdir.X = -1;
                    GlobalNodeHandler.viewNode.MoveView(arrowdir, 15);
                    //if(panel1.HorizontalScroll.Value > 15)
                    //  panel1.HorizontalScroll.Value = panel1.HorizontalScroll.Value - 15;
                }
                if (keypress.thisKey == Key.UP)
                {
                    arrowdir.Y = -1;
                    GlobalNodeHandler.viewNode.MoveView(arrowdir, 15);
                    //panel1.VerticalScroll.Value = panel1.HorizontalScroll.Value + 15;
                }
                if (keypress.thisKey == Key.DOWN)
                {
                    arrowdir.Y = 1;
                    GlobalNodeHandler.viewNode.MoveView(arrowdir, 15);
                    //if (panel1.VerticalScroll.Value > 15)
                    //  panel1.VerticalScroll.Value = panel1.VerticalScroll.Value - 15;
                }
                repaint(this, new EventArgs());
            }
        }
        public void this_KeyDown(CoreWindow sender, KeyEventArgs e)
        {
            Key k = Key.NONE;

            if (e.VirtualKey == Windows.System.VirtualKey.N)
            {
                k = Key.N;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.I)
            {
                k = Key.I;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.O)
            {
                k = Key.O;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.C)
            {
                k = Key.C;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.D)
            {
                k = Key.D;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.A)
            {
                k = Key.A;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.K)
            {
                k = Key.K;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.U)
            {
                k = Key.U;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.R)
            {
                k = Key.R;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.Right)
            {
                k = Key.RIGHT;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.Left)
            {
                k = Key.LEFT;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.Up)
            {
                k = Key.UP;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.Down)
            {
                k = Key.DOWN;
            }

            KeyObject kevent = new KeyObject(k, lastMousePosition);

            keymanager.thisKeyDownExec(kevent);
        }