public void saveCurrentItem_Click(object sender, EventArgs e) { string filename; string name; if (this.ActiveMdiChild.GetType() == typeof(graphDisplay)) { graphDisplay saveDisplay = (graphDisplay)this.ActiveMdiChild; saveDisplay.graphDisplay_Enter(sender, e); name = saveDisplay.graph1.name; try { filename = getSaveFilename("graph", name, Program.settings.workingDirectory); } catch { filename = ""; } if (filename != "" && filename != null) { designGraph.saveGraphToXml(filename, saveDisplay.graphControl1, saveDisplay.graph1); } } else if (this.ActiveMdiChild.GetType() == typeof(grammarRuleDisplay)) { grammarRuleDisplay saveDisplay = (grammarRuleDisplay)this.ActiveMdiChild; name = saveDisplay.rule.name; try { filename = getSaveFilename("grammar rule", name, Program.settings.rulesDirectory); } catch { filename = ""; } if (filename != "" && filename != null) { grammarRule.saveRuleToXml(filename, saveDisplay.rule, saveDisplay.graphControlLHS, saveDisplay.graphControlRHS, saveDisplay.globalLabelsLText, saveDisplay.globalLabelsRText); } } else if (this.ActiveMdiChild.GetType() == typeof(ruleSetDisplay)) { ruleSetDisplay saveDisplay = (ruleSetDisplay)this.ActiveMdiChild; name = saveDisplay.ruleset.name; try { filename = getSaveFilename("rule set", name, Program.settings.rulesDirectory); } catch { filename = ""; } if (filename != "" && filename != null) { ruleSet.saveRuleSetToXml(filename, saveDisplay.ruleset); } } else { MessageBox.Show("Please select an window that contains a graph, rule, or rule set.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void defineRuleSet(int index) { if ((this.ActiveMdiChild == null) || (this.ActiveMdiChild.GetType() != typeof(ruleSetDisplay))) { MessageBox.Show("The active window is not a Rule Set display.", "Active Window is not RuleSet.", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Program.rulesets.GetLength(0) <= index) { MessageBox.Show("There are only " + Program.settings.numOfRuleSets + " rulesets currently allocated." + " Please change number of rule sets in the global settings.", "RuleSet #" + index.ToString() + " not allocated.", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if ((Program.rulesets[index] == null) || (DialogResult.Yes == MessageBox.Show("The ruleset " + Program.rulesets[index].name + " is already loaded into rule set #" + index + ". Replace with active ruleset?", "RuleSet already defined.", MessageBoxButtons.YesNo, MessageBoxIcon.Information))) { ruleSetDisplay activeRSC = (ruleSetDisplay)this.ActiveMdiChild; Program.rulesets[index] = activeRSC.ruleset; activeRSC.ruleset.ruleSetIndex = index; } }