private void cmdOtherRules_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog d = new Microsoft.Win32.OpenFileDialog(); d.DefaultExt = ".xml"; d.Filter = "XML documents (.xml)|*.xml"; d.CheckFileExists = true; d.CheckPathExists = true; d.Multiselect = false; d.Title = "Please open the rules file."; // Show open file dialog box bool?result = d.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = d.FileName; //Backup original file. //RulesHelper.CreateBackup(); //Create file from backup RulesHelper.LoadFromFile(filename); InitTreeData(); _isLoadedFromFile = true; _tracker_DataChanged(); } }
private void loadRulesFileToolStripMenuItem_Click(object sender, EventArgs e) { //Load rules file //If one is already loaded, prompt to save OpenFileDialog openFileDialog; openFileDialog = new OpenFileDialog(); openFileDialog.AddExtension = true; openFileDialog.CheckFileExists = true; openFileDialog.CheckPathExists = true; openFileDialog.DefaultExt = "xml"; openFileDialog.Filter = "XML files (*.xml)|*.xml"; openFileDialog.Multiselect = false; openFileDialog.InitialDirectory = "c:\\"; DialogResult res = openFileDialog.ShowDialog(); if (res == DialogResult.OK) { RulesHelper.LoadFromFile(openFileDialog.FileName); rulesFileStatus = FileStatus.LOADED; putXmlDataIntoTree(); } else { MessageBox.Show("No rules file loaded. Please try again"); } }