private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RuleSetSelector selectorForm = new RuleSetSelector();
            selectorForm.RuleSetDataCollection.AddRange(ruleSetDataDictionary.Values);
            selectorForm.Instructions = "Select the RuleSets you would like to export.  Note that version numbers are not included in the output file, and only a single RuleSet with a given Name can be exported to the same file.";
            DialogResult selectorResult = selectorForm.ShowDialog();

            if (selectorResult == DialogResult.OK && selectorForm.SelectedRuleSetDataCollection.Count > 0)
            {
                RuleDefinitions ruleDefinitions = new RuleDefinitions();
                foreach (RuleSetData data in selectorForm.SelectedRuleSetDataCollection)
                {
                    ruleDefinitions.RuleSets.Add(data.RuleSet);
                }

                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter = "Rules files (*.rules)|*.rules";
                dialog.AddExtension = true;
                dialog.DefaultExt = "rules";
                DialogResult result = dialog.ShowDialog();

                if (result == DialogResult.OK && !String.IsNullOrEmpty(dialog.FileName))
                {
                    XmlTextWriter writer = new XmlTextWriter(dialog.FileName, null);
                    serializer.Serialize(writer, ruleDefinitions);
                    writer.Flush();
                    writer.Close();
                }
            }
            else
            {
                MessageBox.Show("No RuleSets selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Filter = "Rules files (*.rules)|*.rules";
            DialogResult fileResult = fileDialog.ShowDialog();

            if (fileResult == DialogResult.OK && !String.IsNullOrEmpty(fileDialog.FileName))
            {
                XmlTextReader reader = new XmlTextReader(fileDialog.FileName);
                object objectRuleSet = null; ;

                try
                {
                    objectRuleSet = serializer.Deserialize(reader);
                }
                catch  (Exception ex)
                {
                    MessageBox.Show(String.Format(CultureInfo.InvariantCulture, "Error loading file.  \r\n\n{0}", ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                reader.Close();

                RuleDefinitions ruleDefinitions = objectRuleSet as RuleDefinitions;

                if (ruleDefinitions != null)
                {
                    if (ruleDefinitions.RuleSets.Count > 0)
                    {
                        RuleSetData ruleSetData = null;
                        List<RuleSetData> ruleSetDataCollection = new List<RuleSetData>();
                        foreach (RuleSet ruleSet in ruleDefinitions.RuleSets)
                        {
                            ruleSetData = this.CreateRuleSetData(ruleSet); 
                            
                            //find the next available major version
                            ruleSetData.MajorVersion = this.GetNextMajorVersion(ruleSet.Name);
                            ruleSetDataCollection.Add(ruleSetData);
                        }

                        RuleSetSelector selectorForm = new RuleSetSelector();
                        selectorForm.RuleSetDataCollection.AddRange(ruleSetDataCollection);
                        selectorForm.SelectAll = true;
                        selectorForm.Instructions = "Select the RuleSets you would like to import.  Each RuleSet has been assigned the next available Major Version number.";
                        DialogResult selectorResult = selectorForm.ShowDialog();

                        if (selectorResult == DialogResult.OK && selectorForm.SelectedRuleSetDataCollection != null)
                        {
                            foreach (RuleSetData data in selectorForm.SelectedRuleSetDataCollection)
                            {
                                this.AddRuleSetData(data);
                                this.GetThisType(Path.GetDirectoryName(fileDialog.FileName), Path.GetFileName(fileDialog.FileName));
                            }
                            this.treeView1_AfterSelect(this, new TreeViewEventArgs(treeView1.SelectedNode));  //force this call so that assembly and activity information if populated on form
                        }
                    }
                    else
                    {
                        MessageBox.Show("File does not contain any RuleSets.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("File is not a valid .rules file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }