private void localizer_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { var d = new XmlLocalization.ClientDeserializer(); using (FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read)) { m_localizer = d.Read(stream); } } }
public ConversationForm(string conversation, string localization) { InitializeComponent(); var d = new Viking.Deserializer(); Conversation c; using (var stream = new FileStream(conversation, FileMode.Open)) { c = d.Read(stream); } using (FileStream stream = new FileStream(localization, FileMode.Open, FileAccess.Read)) { var asd = new XmlLocalization.ClientDeserializer(); m_localizer = asd.Read(stream); } var start = c.Nodes.OfType <Viking.Nodes.Start>().Single(); VikingProcessor processor = new VikingProcessor(Localize, CharacterName); processor.Approve += p => { var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Characters with " + string.Join(" or ", p.Select(Personality)) + " personality agree with this decision"); Console.ForegroundColor = color; }; processor.Disapprove += p => { var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Characters with " + string.Join(" or ", p.Select(Personality)) + " personality do not agree with this decision"); Console.ForegroundColor = color; }; processor.EnteringDialog += () => { Console.WriteLine("ENTERING DIALOGUE"); Console.ReadKey(); }; processor.ExitingDialog += () => { Console.WriteLine("EXITING DIALOGUE"); Console.ReadKey(); }; processor.PlaySpeech += (speaker, speech) => { Console.WriteLine(speaker + " says: " + speech); Console.ReadKey(); }; Viking.Nodes.Node node = start; do { var next = node.Process(processor).ToArray(); if (next.Count() > 1) { Form f = new Form(); var ff = new FlowLayoutPanel(); f.Controls.Add(ff); ff.Dock = DockStyle.Fill; foreach (var option in next) { var o = option; var b = new Button(); try { b.Text = option.Text; b.Click += (x, y) => { f.Close(); node = o.Node; }; b.AutoSize = true; b.Height = 100; } catch { b.Dispose(); throw; } ff.Controls.Add(b); } f.ShowDialog(); //node = next.First().Node; } else if (next.Count() > 0) { node = next.First().Node; } else { node = null; } } while (node != null); }