private void openScenarioFromFile() { // Opens new scenario using open file dialog OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Hsx file (.hsx)|*.hsx|All files|*.*"; dialog.Title = "Open Scenario"; if (dialog.ShowDialog() != DialogResult.OK) { return; } // Loads new scenario using components specified in given HSX file from dialog string filename = dialog.FileName; XqlParser myParser = new XqlParser(filename); List <Hashtable> result; // Determine paths result = myParser.Query("SELECT path FROM hsx"); string rootPath = (string)result[0]["path"]; result = myParser.Query("SELECT filename FROM scenario"); string scenPath = (string)rootPath + result[0]["filename"]; result = myParser.Query("SELECT filename FROM targetdeck"); string trgtPath = (string)rootPath + result[0]["filename"]; result = myParser.Query("SELECT filename FROM model"); string modlPath = (string)rootPath + result[0]["filename"]; // Create new scenario component from file and attach to form ScenarioComponent newScenario = new ScenarioComponent(); newScenario.FromFile(scenPath); ScenarioForm scenarioForm = new ScenarioForm(newScenario, this); scenarioForm.FileTarget = filename; _scenarios.Add(scenarioForm); // Form takes care of itself via node update? // Create new targetdeck from file and attach to scenario TargetdeckComponent newTargetdeck = new TargetdeckComponent(); newTargetdeck.FromFile(trgtPath); newScenario.Targetdeck = newTargetdeck; // Create new model from file and attach to scenario ModelComponent newModel = new ModelComponent(); newModel.FromFile(modlPath); newScenario.Model = newModel; // Update node tree and select scenario UpdateScenarioNode(scenarioForm); TreeNode node = getNodeFromForm(scenarioForm); mainTreeView.SelectedNode = node; }