Example #1
0
        /// <summary>
        /// Creates the type graph.
        /// </summary>
        /// <returns>The graph view model.</returns>
        public AGraphViewModel 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);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <summary>
        /// Creates the graph.
        /// </summary>
        /// <param name="pNodeCount">The node count.</param>
        /// <returns>The graph view model.</returns>
        public AGraphViewModel CreateRandomGraph(int pNodeCount)
        {
            GraphViewModel lGraph  = new GraphViewModel();
            Random         lRandom = new Random();

            for (int i = 0; i < pNodeCount; i++)
            {
                NodeViewModel lNode = this.CreateNode(string.Format("{0}", i), string.Format("NODE_{0}", i), lRandom.Next(1, 5), lRandom.Next(1, 3));
                lNode.X = 50 * i;
                lNode.Y = 100 * i;
                lGraph.AddNode(lNode);
            }

            return(lGraph);
        }