コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: mastertnt/XGraph
        /// <summary>
        /// Creates the type graph.
        /// </summary>
        /// <returns>The graph view model.</returns>
        public GraphViewModel CreateTypeGraph()
        {
            GraphViewModel lGraph = new GraphViewModel();
            NodeViewModel lNode0 = new TypeNodeViewModel(typeof(SampleClass));
            lGraph.AddNode(lNode0);

            NodeViewModel lNode1 = new TypeNodeViewModel(typeof(SampleClass1VeryTooMuchLong));
            lGraph.AddNode(lNode1);

            NodeViewModel lNode2 = new NodeViewModel();
            lNode2.DisplayString = "Empty node";
            lGraph.AddNode(lNode2);

            int i = 0;
            foreach (NodeViewModel lNode in lGraph.Nodes)
            {
                lNode.X = 300 * i;
                lNode.Y = 100 * i;
                i++;
            }

            ConnectionViewModel lConnectionViewModel = new ConnectionViewModel();
            lConnectionViewModel.Output = lGraph.Nodes.ElementAt(0).Ports.FirstOrDefault(pPort => pPort.Direction == PortDirection.Output);
            lConnectionViewModel.Input = lGraph.Nodes.ElementAt(1).Ports.FirstOrDefault(pPort => pPort.Direction == PortDirection.Input);
            lGraph.AddConnection(lConnectionViewModel);

            return lGraph;
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: mastertnt/XGraph
 /// <summary>
 /// Delegate called when the "Add" button is clicked.
 /// </summary>
 /// <param name="pSender">The button sender.</param>
 /// <param name="pEventArgs">The event arguments.</param>
 private void OnAddButtonClicked(object pSender, RoutedEventArgs pEventArgs)
 {
     GraphViewModel lRootViewModel = this.GraphView.DataContext as GraphViewModel;
     NodeViewModel lNode1 = new TypeNodeViewModel(typeof(SampleClass1VeryTooMuchLong));
     lRootViewModel.AddNode(lNode1);
 }