Ejemplo n.º 1
0
        internal void CompendiumMapDepthMap_KeyDown(object sender, KeyEventArgs e)
        {
            // TODO: This needs to be done better.
            if (e.OriginalSource is TextBox)
            {
                return;
            }

            INodeTypeProxy nodeType = null;

            if (e.Key == Key.I || e.Key == Key.A || e.Key == Key.P || e.Key == Key.D1 || e.Key == Key.NumPad1)
            {
                // I, A, P, ! or 1
                nodeType = _typeManager.GetNodeType("CompendiumIdeaNode");
            }
            else if (e.PlatformKeyCode == 187 || e.Key == Key.Add && Keyboard.Modifiers != ModifierKeys.Control)
            {
                // + or =
                nodeType = _typeManager.GetNodeType("CompendiumProNode");
            }
            else if (e.PlatformKeyCode == 189 || e.Key == Key.Subtract && Keyboard.Modifiers != ModifierKeys.Control)
            {
                // -
                nodeType = _typeManager.GetNodeType("CompendiumConNode");
            }
            else if (e.Key == Key.Q || e.Key == Key.Divide || e.PlatformKeyCode == 191)
            {
                // Q, ? or /
                nodeType = _typeManager.GetNodeType("CompendiumQuestionNode");
            }
            else if (e.Key == Key.M)
            {
                // M
                nodeType = _typeManager.GetNodeType("CompendiumMapNode");
            }
            else if (e.Key == Key.D)
            {
                // D
                nodeType = _typeManager.GetNodeType("CompendiumDecisionNode");
            }
            else if (e.Key == Key.Delete)
            {
                Navigator.DeleteNodes(SelectedNodes);
                Navigator.DeleteRelationships(SelectedRelationships);
            }
            else if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.Enter)
            {
                if (SelectedNodes.Length == 1)
                {
                    NPDHelper.ShowNodePropertiesDialog(SelectedNodes[0]);
                }
            }
            else if (Keyboard.Modifiers == ModifierKeys.Shift && e.Key == Key.R)
            {
                //Ctrl+R
                NodeSorter.SortLeftToRight();
            }
            else if (e.Key == Key.Down)
            {
                translateTransform.Y -= 10;
            }
            else if (e.Key == Key.Up)
            {
                translateTransform.Y += 10;
            }
            else if (e.Key == Key.Left)
            {
                translateTransform.X += 10;
            }
            else if (e.Key == Key.Right)
            {
                translateTransform.X -= 10;
            }
            else if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.Add)
            {
                Zoom(new Point(this.ActualWidth / 2, this.ActualHeight / 2), 0.2);
            }
            else if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.Subtract)
            {
                Zoom(new Point(this.ActualWidth / 2, this.ActualHeight / 2), -0.2);
            }
            else if (e.Key == Key.Back)
            {
                Navigator.GoBack();
            }

            if (nodeType != null)
            {
                Navigator.AddNode(nodeType, "", _currentMousePosition);
            }
        }
Ejemplo n.º 2
0
        private void CanvasContextMenu_Loaded(object sender, RoutedEventArgs e)
        {
            MenuItem addNodeMenuItem = new MenuItem();

            addNodeMenuItem.Header = new TextBlock()
            {
                Text = "Load Nodes", FontWeight = FontWeights.Bold
            };
            this.Items.Add(addNodeMenuItem);

            AddAddNodeMenuItem("Map Node", delegate(object sender2, RoutedEventArgs e2)
            {
                INodeTypeProxy nodeType = TypeManager.GetNodeType("CompendiumMapNode");
                Navigator.AddNode(nodeType, "", Location);
            });

            AddAddNodeMenuItem("Idea Node", delegate(object sender2, RoutedEventArgs e2)
            {
                INodeTypeProxy nodeType = TypeManager.GetNodeType("CompendiumIdeaNode");
                Navigator.AddNode(nodeType, "", Location);
            });

            AddAddNodeMenuItem("Question Node", delegate(object sender2, RoutedEventArgs e2)
            {
                INodeTypeProxy nodeType = TypeManager.GetNodeType("CompendiumQuestionNode");
                Navigator.AddNode(nodeType, "", Location);
            });

            AddAddNodeMenuItem("Pro Node", delegate(object sender2, RoutedEventArgs e2)
            {
                INodeTypeProxy nodeType = TypeManager.GetNodeType("CompendiumProNode");
                Navigator.AddNode(nodeType, "", Location);
            });

            AddAddNodeMenuItem("Con Node", delegate(object sender2, RoutedEventArgs e2)
            {
                INodeTypeProxy nodeType = TypeManager.GetNodeType("CompendiumConNode");
                Navigator.AddNode(nodeType, "", Location);
            });

            AddAddNodeMenuItem("Decision Node", delegate(object sender2, RoutedEventArgs e2)
            {
                INodeTypeProxy nodeType = TypeManager.GetNodeType("CompendiumDecisionNode");
                Navigator.AddNode(nodeType, "", Location);
            });

            Separator seperator1 = new Separator();

            this.Items.Add(seperator1);

            MenuItem pasteMenuItem = new MenuItem();

            pasteMenuItem.Header = "Paste";
            pasteMenuItem.Click += new RoutedEventHandler(pasteMenuItem_Click);
            this.Items.Add(pasteMenuItem);

            Separator seperator2 = new Separator();

            this.Items.Add(seperator2);

            MenuItem assignVideoMenuItem = new MenuItem();

            assignVideoMenuItem.Header = "Choose Video...";
            assignVideoMenuItem.Click += new RoutedEventHandler(assignVideoMenuItem_Click);
            this.Items.Add(assignVideoMenuItem);
        }