public static ConversationStage FromXML(XElement xml) { ConversationStage stage = new ConversationStage(); if (xml.Element("Id") != null) { stage.StageId = Convert.ToInt32(xml.Element("Id").Value); } if (xml.Element("Name") != null) { stage.StageName = xml.Element("Name").Value; } if (xml.Element("Action") != null) { stage.StageAction = Scripter.Script.FromXML(xml.Element("Action").Element("Script"), stage.StageAction); } if (xml.Element("Choices") != null) { stage.Choices = new ObservableCollection <ConversationChoice>(from a in xml.Element("Choices").Elements() select ConversationChoice.FromXML(a)); } return(stage); }
public void NewStage() { var stage = new NewConversationStage(); stage.associatedConvo = this; if (Stages.Count() > 0) { stage.txtId.Text = (this.Stages.Select(a => a.StageId).Max() + 10).ToString(); } else { stage.txtId.Text = "10"; } stage.ShowDialog(); if (stage.DialogResult == true) { var res = new ConversationStage(); res.StageId = Convert.ToInt32(stage.txtId.Text); res.StageName = stage.txtFriendlyName.Text; Stages.Add(res); Stages = new ObservableCollection <ConversationStage>(Stages.OrderBy(a => a.StageId)); SelectedStage = res; } }
public static Conversation FromXML(XElement xml) { Conversation c = new Conversation(); if (xml.Element("Name") != null) { c.Name = xml.Element("Name").Value; } if (xml.Element("GroupName") != null) { c.GroupName = xml.Element("GroupName").Value; } if (xml.Element("Id") != null) { c.Id = Guid.Parse(xml.Element("Id").Value); } if (xml.Element("StartStage") != null) { c.StartingStage = Convert.ToInt32(xml.Element("StartStage").Value); } if (xml.Element("Stages") != null) { c.Stages = new ObservableCollection <ConversationStage>(xml.Element("Stages").Elements().Select(a => ConversationStage.FromXML(a))); } return(c); }