private void Add_btn_Click(object sender, RoutedEventArgs e) { var add_rule_window = new AddRule_Window(rule_lists.backup_rule_lists.Count); add_rule_window.ShowDialog(); if (add_rule_window.rule != null) { // Check directory for validity. if (add_rule_window.rule.directory.StartsWith(source_base) == false) { MyMessageBox.show("The rule just added is not a subdirectory " + "of the source field. Therefore it is rejected. " + "(\"" + add_rule_window.rule.directory + "\" not a subdirectory of \"" + source_base + "\")", "Error"); return; } // Add new rule to rule_list. rule_lists.add_rule(add_rule_window.rule, add_rule_window.Category); modified = true; AddBackup_Page.redraw_backup_rules_listbox(Rules_lb, rule_lists); } }
/// <summary> /// Event handler for adding a rule. /// </summary> private void Add_btn_Click(object sender, RoutedEventArgs e) { // Check that there is a valid source directory. string directory = Source_tb.Text.Trim(); WindowsBackup_App.remove_ending_slash(ref directory); Source_tb.Text = directory; if (Directory.Exists(Source_tb.Text) == false) { MyMessageBox.show("Before adding rules, the source field needs " + "to be an existing directory.", "Error"); return; } var add_rule_window = new AddRule_Window(rule_lists.backup_rule_lists.Count); add_rule_window.ShowDialog(); if (add_rule_window.rule != null) { // Check directory for validity. if (add_rule_window.rule.directory.StartsWith(Source_tb.Text) == false) { MyMessageBox.show("The rule just added is not a subdirectory " + "of the source field. Therefore it is rejected. " + "(\"" + add_rule_window.rule.directory + "\" not a subdirectory of \"" + Source_tb.Text + "\")", "Error"); return; } // Add new rule to rule_list. rule_lists.add_rule(add_rule_window.rule, add_rule_window.Category); redraw_backup_rules_listbox(BackupRules_lb, rule_lists); } }