private void updateProperty(object sender, PropertyString.PropertyStringEventArgs e) { switch (e.Key) { default: break; case PropertyString.Keys.ScenarioAuthor: ScenarioAuthor = e.Value; break; case PropertyString.Keys.ScenarioName: ScenarioName = e.Value; break; case PropertyString.Keys.ScenarioDescription: ScenarioDescription = e.Value; break; case PropertyString.Keys.StepName: selStep.SetName(e.Value); break; case PropertyString.Keys.StepDescription: selStep.Step.Description = e.Value; break; } }
private void loadFile(string filepath) { StreamReader sr = new StreamReader(filepath); // Read savefile metadata indicating data formatting // Supports II:T1 file structure string metadata = sr.ReadLine(); if (!metadata.StartsWith(".ii:t1")) { loadFail(); return; } // Savefile type 1: validated and encrypted // Line 1 is metadata (.ii:t1) // Line 2 is hash for validation (hash taken of raw string data, unobfuscated) // Line 3 is savefile data encrypted by AES encoding string hash = sr.ReadLine().Trim(); string file = Encryption.DecryptAES(sr.ReadToEnd().Trim()); if (hash != Encryption.HashSHA256(file)) { loadFail(); return; } StringReader sRead = new StringReader(file); string line, pline; StringBuilder pbuffer; Scenario sc = new Scenario(false); try { while ((line = sRead.ReadLine()) != null) { if (line == "> Begin: Scenario") { pbuffer = new StringBuilder(); while ((pline = sRead.ReadLine()) != null && pline != "> End: Scenario") { pbuffer.AppendLine(pline); } sc.Load_Process(pbuffer.ToString()); } } } catch { loadFail(); } finally { sRead.Close(); } // Convert loaded scenario to Scenario Editor data structures ScenarioAuthor = sc.Author; ScenarioName = sc.Name; ScenarioDescription = sc.Description; Steps.Clear(); canvasDesigner.Children.Clear(); for (int i = 0; i < sc.Steps.Count; i++) { // Add to the main Steps stack ItemStep ist = new ItemStep(); ist.Init(); ist.Step = sc.Steps [i]; ist.SetNumber(i); ist.SetName(ist.Step.Name); // After all UIElements are initialized, will need to "refresh" the line positions via loadIProgressions isLoading = true; ist.LayoutUpdated += loadIProgressions; ist.IStep.MouseLeftButtonDown += IStep_MouseLeftButtonDown; ist.IStep.MouseLeftButtonUp += IStep_MouseLeftButtonUp; ist.IStep.MouseMove += IStep_MouseMove; ist.IStepEnd.MouseLeftButtonDown += IStepEnd_MouseLeftButtonDown; // Add to lists and display elements Steps.Add(ist); canvasDesigner.Children.Add(ist); Canvas.SetZIndex(ist, 1); Canvas.SetLeft(ist, ist.Step.IPositionX); Canvas.SetTop(ist, ist.Step.IPositionY); } // Refresh the Properties View with the newly selected step selectStep(Steps.Count > 0 ? Steps [0] : null); updatePropertyView(); updateScenarioProperty(); drawIProgressions(); expStepProperty.IsExpanded = true; expProgressionProperty.IsExpanded = true; }