private static void ni_Click(object sender, EventArgs e) { if (!tmpnames.All(kv => FirewallHelper.RemoveRule(kv.Value))) { MessageBox.Show(Resources.MSG_RULE_RM_FAILED, Resources.MSG_DLG_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } Environment.Exit(0); }
private void btnRemoveRule_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show(Common.Properties.Resources.MSG_RULE_DELETE, Common.Properties.Resources.MSG_DLG_TITLE, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { FirewallHelper.RemoveRule(((FirewallHelper.Rule)gridRules.SelectedItem).Name); initAllRules(); initRules(); } }
private static void ni_Click(object sender, EventArgs e) { LogHelper.Info("Now going to remove temporary rule(s)..."); if (!tmpnames.All(kv => FirewallHelper.RemoveRule(kv))) { MessageBox.Show(Resources.MSG_RULE_RM_FAILED, Resources.MSG_DLG_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } Environment.Exit(0); }
private static void RemoveExceptionByName(string[] args, FirewallHelper fwHelper) { if (args.Length == 2) { string appName = args[1]; fwHelper.RemoveRule(appName); Console.WriteLine("Removed {0} to exceptions list.", args[1]); } else { throw new ArgumentOutOfRangeException("-rN just has option."); } }
private void btnRemoveRule_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show(Common.Properties.Resources.MSG_RULE_DELETE, Common.Properties.Resources.MSG_DLG_TITLE, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { FirewallHelper.Rule selectedRule = (FirewallHelper.Rule)gridRules.SelectedItem; if (!FirewallHelper.RemoveRule(selectedRule.Name)) { MessageBox.Show(Common.Properties.Resources.MSG_RULE_DELETE_FAILED, Common.Properties.Resources.MSG_DLG_ERR_TITLE, MessageBoxButton.OK, MessageBoxImage.Error); return; } allRules.Remove(selectedRule); filterRules(); } }
private bool RemoveTempRulesAndNotfyIcon() { bool success = true; if (tempRules_.Count > 0) { LogHelper.Info("Now going to remove temporary rule(s)..."); success = tempRules_.TrueForAll(r => FirewallHelper.RemoveRule(r.Name)); } if (tempNotifyIcon_ != null) { tempNotifyIcon_.Dispose(); tempNotifyIcon_ = null; } return(success); }
private void btnRemoveRule_Click(object sender, RoutedEventArgs e) { System.Collections.IList selectedRules = gridRules.SelectedItems; if (selectedRules is null || selectedRules.Count == 0) { return; } if (MessageBox.Show(Common.Properties.Resources.MSG_RULE_DELETE, Common.Properties.Resources.MSG_DLG_TITLE, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { foreach (WFPRules::Rule selectedRule in selectedRules) { if (!FirewallHelper.RemoveRule(selectedRule.Name)) { MessageBox.Show(Common.Properties.Resources.MSG_RULE_DELETE_FAILED, Common.Properties.Resources.MSG_DLG_ERR_TITLE, MessageBoxButton.OK, MessageBoxImage.Error); return; } allRules.Remove(selectedRule); } filterRules(); } }
private static void RemoveExceptionByPath(string[] args, FirewallHelper fwHelper) { if (args.Length == 2) { string appPath = args[1] == "-g" ? PickAFile() : Path.GetFullPath(args[1]); if (appPath != null) { string appName = Path.GetFileNameWithoutExtension(appPath); fwHelper.RemoveRule(appName); Console.WriteLine("Removed {0} to exceptions list.", appName); } else { return; } } else { throw new ArgumentOutOfRangeException("-rP just has option."); } }