コード例 #1
0
 private void rebuildGraph(GraphControl graph)
 {
     Dictionary<String, CConnectionFields> inputs = new Dictionary<String, CConnectionFields>();
     Dictionary<String, CConnectionFields> outputs = new Dictionary<String, CConnectionFields>();
     foreach(CNodeFields node in m_graphFields.Nodes)
     {
         m_idNameMap.Add(node.id, node.name);
         Node n = new Node(node.Title);
         n.Location = node.Location;
         foreach(CNodeItemFields item in node.Items)
         {
             String name = "";
             if(item.name != null)
                 name = item.name.Split(':')[1];
             if (item.Input != null)
             {
                 foreach (CConnectionFields conn in item.Input)
                 {
                     if (!inputs.ContainsKey(conn.id))
                         inputs.Add(conn.id, conn);
                 }
             }
             if (item.Output != null)
             {
                 foreach (CConnectionFields conn in item.Output)
                 {
                     if (!outputs.ContainsKey(conn.id))
                         outputs.Add(conn.id, conn);
                 }
             }
             switch (item.ItemType)
             {
                 case "Graph.Items.NodeCompositeItem":
                     {
                         NodeCompositeItem temp = new NodeCompositeItem(item.IOMode);
                         temp.Name = name;
                         foreach(CItemPartFields part in item.ItemParts)
                         {
                             switch(part.PartType)
                             {
                                 case "Graph.Items.ItemTextBoxPart":
                                     {
                                         ItemTextBoxPart p = new ItemTextBoxPart(part.Text);
                                         p.Name = part.name;
                                         temp.AddPart(p);
                                     }
                                     break;
                                 default:
                                     {
                                     }
                                     break;
                             }
                         }
                         if (item.Tag != null)
                             temp.Tag = TagFactory.GetTagObject(item.Tag);
                         if (temp.Name.Contains("button_"))
                             temp.Clicked += m_parentForm.GetConvMouseHandler();
                         m_itemMap.Add(item.id, temp);
                         m_idNameMap.Add(item.id, name);
                         n.AddItem(temp);
                     }
                     break;
                 case "Graph.Items.NodeTextBoxItem":
                     {
                         NodeTextBoxItem temp = new NodeTextBoxItem(item.Text, item.IOMode);
                         temp.Name = name;
                         if (item.Tag != null)
                             temp.Tag = TagFactory.GetTagObject(item.Tag);
                         m_itemMap.Add(item.id, temp);
                         m_idNameMap.Add(item.id, name);
                         n.AddItem(temp);
                     }
                     break;
                 case "Graph.Items.NodeLabelItem":
                     {
                         NodeLabelItem temp = new NodeLabelItem(item.Text, item.IOMode);
                         temp.Name = name;
                         if (item.Tag != null)
                             temp.Tag = TagFactory.GetTagObject(item.Tag);
                         m_itemMap.Add(item.id, temp);
                         m_idNameMap.Add(item.id, name);
                         if (temp.Name == "EditNodeItem")
                             temp.Clicked += m_parentForm.GetEditMouseHandler();
                         n.AddItem(temp);
                     }
                     break;
                 default:
                     {
                         //NodeItem temp = new NodeItem(item.IOMode);
                     }
                     break;
             }
         }
         graph.AddNode(n);
     }
     rebuildConnections(graph, inputs, outputs);
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: RichardRanft/T3DConvoEdit
 private void lblConvoNode_MouseDown(object sender, MouseEventArgs e)
 {
     List<Node> nodes = (List<Node>)graphCtrl.Nodes;
     String nodeName = m_settings.Attributes["[Default]"]["DEFAULTNODENAME"] + "_" + getConvNodeCount().ToString().PadLeft(4, '0');
     var node = new Node("Conversation Node");
     var nodeNameItem = new NodeTextBoxItem(nodeName);
     nodeNameItem.Name = "NodeName";
     node.AddItem(nodeNameItem);
     NodeTextBoxItem displayText = new NodeTextBoxItem("Enter NPC text", NodeIOMode.None);
     displayText.Name = "DisplayText";
     node.AddItem(displayText);
     var inputLabel = new NodeLabelItem("Conversation input", NodeIOMode.Input) { Tag = TagType.LABEL };
     inputLabel.Name = nodeName + "_in";
     node.AddItem(inputLabel);
     var editNode = new NodeLabelItem("Click Here To Edit Output List");
     editNode.Name = "EditNodeItem";
     editNode.Clicked += new EventHandler<NodeItemEventArgs>(editOutputListNode_MouseDown);
     node.AddItem(editNode);
     NodeCompositeItem firstButton = new NodeCompositeItem(NodeIOMode.Output) { Tag = TagType.TEXTBOX };
     firstButton.Name = "button_1";
     ItemTextBoxPart btnText = new ItemTextBoxPart("Enter player text");
     btnText.Name = "ConvText";
     ItemTextBoxPart btnMethod = new ItemTextBoxPart("Enter script method");
     btnMethod.Name = "ConvMethod";
     firstButton.AddPart(btnText);
     firstButton.AddPart(btnMethod);
     firstButton.Clicked += new EventHandler<NodeItemEventArgs>(editConvNode_MouseDown);
     node.AddItem(firstButton);
     this.DoDragDrop(node, DragDropEffects.Copy);
 }