private void RulesGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var item = rulesGrid.SelectedItem as FirewallRuleList.RuleItem; if (item == null) { return; } RuleWindow ruleWnd = new RuleWindow(new List <Program>() { item.Prog }, item.Rule); if (ruleWnd.ShowDialog() != true) { return; } if (!App.client.UpdateRule(item.Rule)) { MessageBox.Show(Translate.fmt("msg_rule_failed"), App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } RemoveCurrent(); }
private bool MakeCustom(Program prog, UInt64 expiration, ConEntry entry = null) { FirewallRuleEx rule = new FirewallRuleEx() { guid = null, Profile = (int)FirewallRule.Profiles.All, Interface = (int)FirewallRule.Interfaces.All, Enabled = true }; rule.SetProgID(prog.ID); rule.Name = FirewallManager.MakeRuleName(FirewallManager.CustomName, expiration != 0, prog.Description); rule.Grouping = FirewallManager.RuleGroup; if (entry != null) { rule.Direction = entry.Entry.FwEvent.Direction; rule.Protocol = (int)entry.Entry.FwEvent.Protocol; switch (entry.Entry.FwEvent.Protocol) { /*case (int)FirewallRule.KnownProtocols.ICMP: * case (int)FirewallRule.KnownProtocols.ICMPv6: * * break;*/ case (int)FirewallRule.KnownProtocols.TCP: case (int)FirewallRule.KnownProtocols.UDP: rule.LocalPorts = "*"; rule.RemotePorts = entry.Entry.FwEvent.RemotePort.ToString(); break; } rule.LocalAddresses = "*"; rule.RemoteAddresses = entry.Entry.FwEvent.RemoteAddress.ToString(); } else { rule.Direction = FirewallRule.Directions.Bidirectiona; } RuleWindow ruleWnd = new RuleWindow(new List <Program>() { prog }, rule); ruleWnd.Topmost = true; if (ruleWnd.ShowDialog() != true) { return(false); } if (!App.client.UpdateRule(rule, expiration)) { MessageBox.Show(Translate.fmt("msg_rule_failed"), App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); return(false); } return(true); }
private void editBTN_Click(object sender, RoutedEventArgs e) { try { var selectedRule = GetSelectedRule(); var ruleWindow = new RuleWindow(selectedRule); } catch (Exception ex) { ErrorHelper.Handle(ex); } }
private void Label_MouseDoubleClick(object sender, MouseButtonEventArgs e) { RuleWindow ruleWnd = new RuleWindow(null, FwRule); if (ruleWnd.ShowDialog() != true) { return; } if (!App.client.UpdateRule(FwRule)) { MessageBox.Show(Translate.fmt("msg_rule_failed"), App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } }
private void newRuleBTN_Click(object sender, RoutedEventArgs e) { var ruleWindow = new RuleWindow(); CreateRuleGrid(); }