private void cmbProtocol_SelectionChanged(object sender, SelectionChangedEventArgs e) { ContentControl protocol = (cmbProtocol.SelectedItem as ContentControl); int? protType; if (protocol == null) { protType = ParseProtocol(cmbProtocol.Text); } else { protType = (int)protocol.Tag; } if (curProtocol == protType) { return; } curProtocol = protType; if (curProtocol == null) { return; } if (protType == (int)FirewallRule.KnownProtocols.TCP || protType == (int)FirewallRule.KnownProtocols.UDP) { tabParams.SelectedItem = tabPorts; } else if (protType == (int)FirewallRule.KnownProtocols.ICMP || protType == (int)FirewallRule.KnownProtocols.ICMPv6) { tabParams.SelectedItem = tabICMP; cmbICMP.Items.Clear(); cmbICMP.Items.Add(new ContentControl() { Content = Translate.fmt("icmp_all"), Tag = "*" }); bool v6 = (protType == (int)FirewallRule.KnownProtocols.ICMPv6); Dictionary <int, string> types = (v6 ? NetFunc.KnownIcmp6Types : NetFunc.KnownIcmp4Types); foreach (int type in types.Keys) { cmbICMP.Items.Add(new ContentControl() { Content = type.ToString() + ":* (" + types[type] + ")", Tag = type.ToString() + ":*" }); } cmbICMP.Items.Add(new ContentControl() { Content = "3:4 (Type 3, Code 4)", Tag = "3:4" }); // why does windows firewall has this explicitly if (!WpfFunc.CmbSelect(cmbICMP, Rule.GetIcmpTypesAndCodes()) && Rule.IcmpTypesAndCodes != null) { cmbICMP.Text = Rule.GetIcmpTypesAndCodes(); } } else { tabParams.SelectedItem = tabNone; } UpdatePorts(); someThing_Changed(sender, e); }