/// <summary> /// saves the current filter tree as a prepared filter tree /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveAsPrepared_Click(object sender, EventArgs e) { Parser p = GetFilterTreeParser(); if (p == null) { Message.Exclaim("Filter tree is blank."); return; } if (p.RootFilters == null || p.RootFilters.Length < 1) { Message.Exclaim("No filter tree is active."); return; } NameForm nf = new NameForm((string)PreparedFilterTrees.SelectedItem); do { nf.StartPosition = FormStartPosition.CenterParent; if (nf.ShowDialog(this) != DialogResult.OK) { return; } if (string.IsNullOrEmpty(nf.FileName)) { return; } if (!PreparedFilterTrees.Items.Contains(nf.FileName)) { break; } }while (!Message.YesNo(nf.FileName + " already exists. Do you want to overwrite it?")); string prepared_filter_tree_name = nf.FileName; string prepared_filter_tree_file = prepared_filter_tree_dir + "\\" + prepared_filter_tree_name + "." + Program.FilterTreeFileExtension; if (!Directory.Exists(prepared_filter_tree_dir)) { Directory.CreateDirectory(prepared_filter_tree_dir); } FileInfo fi = new FileInfo(prepared_filter_tree_file); if (fi.Exists) { Directory.CreateDirectory(deleted_prepared_filter_tree_dir); string new_old_file = deleted_prepared_filter_tree_dir + "\\" + prepared_filter_tree_name + "_" + DateTime.Now.ToString("yyMMddHHmmss") + "." + Program.FilterTreeFileExtension; fi.MoveTo(new_old_file); Message.Inform("The old prepared filter tree was moved to the folder:\n" + deleted_prepared_filter_tree_dir); } p.WriteFilterTreeToXmlFile(prepared_filter_tree_file); load_prepared_filter_trees(); FilterTreeChanged = false; }
/// <summary> /// saves the current filter tree as a prepared filter tree /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveAsPrepared_Click(object sender, EventArgs e) { Parser p = GetFilterTreeParser(); if (p == null) { Message.Exclaim("Filter tree is blank."); return; } if (p.RootFilters == null || p.RootFilters.Length < 1) { Message.Exclaim("No filter tree is active."); return; } NameForm nf = new NameForm((string)PreparedFilterTrees.SelectedItem); do { nf.StartPosition = FormStartPosition.CenterParent; if (nf.ShowDialog(this) != DialogResult.OK) return; if (string.IsNullOrEmpty(nf.FileName)) return; if (!PreparedFilterTrees.Items.Contains(nf.FileName)) break; } while (!Message.YesNo(nf.FileName + " already exists. Do you want to overwrite it?")); string prepared_filter_tree_name = nf.FileName; string prepared_filter_tree_file = prepared_filter_tree_dir + "\\" + prepared_filter_tree_name + "." + Program.FilterTreeFileExtension; if (!Directory.Exists(prepared_filter_tree_dir)) Directory.CreateDirectory(prepared_filter_tree_dir); FileInfo fi = new FileInfo(prepared_filter_tree_file); if (fi.Exists) { Directory.CreateDirectory(deleted_prepared_filter_tree_dir); string new_old_file = deleted_prepared_filter_tree_dir + "\\" + prepared_filter_tree_name + "_" + DateTime.Now.ToString("yyMMddHHmmss") + "." + Program.FilterTreeFileExtension; fi.MoveTo(new_old_file); Message.Inform("The old prepared filter tree was moved to the folder:\n" + deleted_prepared_filter_tree_dir); } p.WriteFilterTreeToXmlFile(prepared_filter_tree_file); load_prepared_filter_trees(); FilterTreeChanged = false; }