예제 #1
0
        /// <summary>
        /// This method creates the node.
        /// </summary>
        /// <param name="pId">The identifier.</param>
        /// <param name="pTitle">The title.</param>
        /// <param name="pInputPort">The input port.</param>
        /// <param name="pOutputPort">The output port.</param>
        /// <returns>The initialized node</returns>
        public NodeViewModel CreateNode(string pId, string pTitle, int pInputPort, int pOutputPort)
        {
            NodeViewModel lNode = new NodeViewModel();
            lNode.DisplayString = pTitle;
            for (int i = 0; i < pInputPort; i++)
            {
                PortViewModel lPort = new PortViewModel();
                lPort.DisplayString = string.Format("IPort {0}", i);
                lPort.Direction = PortDirection.Input;

                lNode.Ports.Add(lPort);
            }

            for (int i = 0; i < pOutputPort; i++)
            {
                PortViewModel lPort = new PortViewModel();
                lPort.DisplayString = string.Format("OPort {0}", i);
                lPort.Direction = PortDirection.Output;

                lNode.Ports.Add(lPort);
            }
            return lNode;
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
 /// <summary>
 /// Removes a connection from the view model.
 /// </summary>
 /// <param name="pNode">The node to remove.</param>
 public void RemoveNode(NodeViewModel pNode)
 {
     this.mNodes.Remove(pNode);
     this.mGraphItems.Remove(pNode);
     if (this.NodeRemoved != null)
     {
         this.NodeRemoved(this, pNode);
     }
 }
예제 #4
0
 /// <summary>
 /// Adds a connection to view model.
 /// </summary>
 /// <param name="pNode">The node to add.</param>
 public void AddNode(NodeViewModel pNode)
 {
     this.mNodes.Add(pNode);
     this.mGraphItems.Add(pNode);
     if (this.NodeAdded != null)
     {
         this.NodeAdded(this, pNode);
     }
 }