コード例 #1
0
        private void OnKeyDown(object sender, KeyboardKeyEventArgs e)
        {
            if (!Focused)
            {
                return;
            }

            if (TextBoxHandler.TextBox != null)
            {
                if (e.Control && e.Key == Key.Minus)
                {
                    if (TextBoxHandler.TextBox == null)
                    {
                        return;
                    }

                    var connection = TextBoxHandler.EditingConnection;
                    connection.ParentNode.RemoveOutput(connection);
                    TextBoxHandler.Destroy(false);
                    connection.ParentNode.BuildConnections();
                    return;
                }

                TextBoxHandler.TextBox.OnKey(e);
                return;
            }

            KeybindHandler.Consume(new KeyCombo(e));
        }
コード例 #2
0
        private void AddOutput(Node node)
        {
            var c = new Connection(node, NodeSide.Output, 0, "Dialog Option");

            node.Outputs.Add(c);
            node.BuildConnections();
            TextBoxHandler.StartEditing(this, c);
        }
コード例 #3
0
        private void OnMouseDown(object sender, MouseButtonEventArgs mouseButtonEventArgs)
        {
            switch (mouseButtonEventArgs.Button)
            {
            case MouseButton.Right:
                CreateContextMenu(Graph.PickNode(_mouseCanvasSpace.X, _mouseCanvasSpace.Y), _mouseCanvasSpace.X,
                                  _mouseCanvasSpace.Y);
                _contextMenu.Visible = true;
                break;

            case MouseButton.Middle:
                _draggingBackground = true;
                break;

            case MouseButton.Left:
                var x = _mouseCanvasSpace.X;
                var y = _mouseCanvasSpace.Y;

                if (_contextMenu.Visible)
                {
                    foreach (var menuItem in _contextMenu)
                    {
                        if (!menuItem.Pick(MouseScreenSpace.X, MouseScreenSpace.Y))
                        {
                            continue;
                        }

                        menuItem.Action.Invoke(menuItem);
                        _contextMenu.Visible = false;
                        if (Selection.CreatingConnectedNode)
                        {
                            Selection.CreatingConnectedNode = false;
                            Selection.DraggingConnection    = null;
                        }
                        return;
                    }

                    Selection.CreatingConnectedNode = false;
                    Selection.DraggingConnection    = null;
                    _contextMenu.Visible            = false;
                }

                var clickedTextBox = TextBoxHandler.PickAndCreate(this, Graph, x, y);
                if (clickedTextBox != null)
                {
                    clickedTextBox.OnMouseDown(mouseButtonEventArgs);
                    return;
                }
                else
                {
                    TextBoxHandler.Destroy();
                }

                var clickedConnection = Graph.PickConnection(x, y, _draggingConnectionPredicate);
                if (clickedConnection != null)
                {
                    Selection.Clear();

                    if (Keyboard[Key.ShiftLeft])
                    {
                        Graph.ClearConnectionsFrom(clickedConnection);
                    }
                    else
                    {
                        Selection.DraggingConnection = clickedConnection;
                    }
                    return;
                }

                var clickedNode = Graph.PickNode(x, y);
                if (clickedNode != null)
                {
                    if (!Selection.SelectedNodes.Contains(clickedNode))
                    {
                        Selection.Select(clickedNode);
                    }

                    Selection.IsDraggingNode = true;

                    _draggingNodeOffset.Clear();
                    foreach (var selectedNode in Selection.SelectedNodes)
                    {
                        _draggingNodeOffset.Add(selectedNode, new Vector2(x - selectedNode.X, y - selectedNode.Y));
                    }

                    return;
                }

                Selection.SelectionRectangle =
                    new Rectangle(_mouseCanvasSpace.X, _mouseCanvasSpace.Y, 0, 0);
                break;
            }
        }