private void btnAddConversation_Click(object sender, RoutedEventArgs e) { Conversation newConvo = new Conversation(); newConvo.ID = projie.Assets.Conversations.Count(); newConvo.Fields.Add(new Field { Title = "Title", Value = "New Conversation" }); newConvo.Fields.Add(new Field { Title = "Description", Value = "A new conversation." }); newConvo.Fields.Add(new Field { Title = "Actor", Value = "1" }); newConvo.Fields.Add(new Field { Title = "Conversant", Value = "1" }); DialogEntry convoStart = new DialogEntry(); convoStart.ID = 0; convoStart.IsRoot = true; convoStart.Fields.Add(new Field { Title = "Title", Value = "START" }); convoStart.Fields.Add(new Field { Title = "Actor", Value = "1", Type = "Actor" }); convoStart.Fields.Add(new Field { Title = "Conversant", Value = "1", Type = "Actor" }); newConvo.DialogEntries.Add(convoStart); projie.Assets.Conversations.Add(newConvo); lstConversations.ItemsSource = AddConversations(projie); }
public void AddNode(string parentNode) { if (loadedConversation != -1) { TreeNode nodeTree = tcMain.FindName(parentNode.Remove(0, 1)) as TreeNode; NodeControl ndctl = nodeTree.Content as NodeControl; DialogEntry newDialogue = new DialogEntry(); Link newDialogueLink = new Link(); NodeControl newDialogueNode = new NodeControl(); ConversationItem convoInfo = lstConversations.Items[loadedConversation] as ConversationItem; int parentID = (int)ndctl.lblID.Content; int newNodeID = projie.Assets.Conversations[loadedConversation].DialogEntries.OrderByDescending(p => p.ID).First().ID + 1; //Create Dialogue Item in Project newDialogue.ID = newNodeID; newDialogue.ConditionsString = ""; newDialogue.FalseCondtionAction = "Block"; newDialogue.NodeColor = "White"; newDialogue.UserScript = ""; newDialogue.Fields.Add(new Field { Title = "Title", Value = "New Dialogue", Type = "Text" }); newDialogue.Fields.Add(new Field { Title = "Actor", Value = ndctl.lblConversantID.Content.ToString(), Type = "Actor" }); newDialogue.Fields.Add(new Field { Title = "Conversant", Value = ndctl.lblActorID.Content.ToString(), Type = "Actor" }); newDialogue.Fields.Add(new Field { Title = "Menu Text", Value = "", Type = "Text" }); newDialogue.Fields.Add(new Field { Title = "Dialogue Text", Value = "", Type = "Text" }); //Add to conversation projie.Assets.Conversations[loadedConversation].DialogEntries.Add(newDialogue); //Set link to parent. newDialogueLink.DestinationConvoID = loadedConversation; newDialogueLink.OriginConvoID = loadedConversation; newDialogueLink.OriginDialogID = parentID; newDialogueLink.DestinationDialogID = newNodeID; projie.Assets.Conversations[loadedConversation].DialogEntries.Where(p => p.ID == parentID).First().OutgoingLinks.Add(newDialogueLink); //Setup for Physical Node newDialogueNode.Name = "_node_" + newNodeID; newDialogueNode.lblID.Content = newNodeID; newDialogueNode.lblDialogueName.Text = "New Dialogue"; newDialogueNode.lblActorID.Content = ndctl.lblConversantID.Content.ToString(); newDialogueNode.lblActor.Text = ndctl.lblConversant.Text; newDialogueNode.lblConversantID.Content = ndctl.lblActorID.Content.ToString(); newDialogueNode.lblConversant.Text = ndctl.lblActor.Text; newDialogueNode.lblConversationID.Content = loadedConversation; newDialogueNode.lblLinkTo.Content = "0"; //Add to tree. rowLinkRow.Height = new GridLength(0); tcMain.AddNode(newDialogueNode, "node_" + newNodeID, "node_" + parentID).BringIntoView(); history.Do("add", new List<TreeNode> { tcMain.Children.OfType<TreeNode>().First(p => p.Name == "node_" + newNodeID) }, new List<DialogEntry> { newDialogue }); needsSave = true; } }