/// <summary> /// Updates all controls contents according to the currently selected blocked connection /// </summary> private void showConn() { var activeConn = (CurrentConn)lstConnections.SelectedItem; if (FirewallHelper.getProtocolAsString(activeConn.Protocol) == "Unknown") //FIXME: No string comparison, please! { OptionsView.IsProtocolChecked = false; } else { //On by default. Also: needed to be able to specify port! OptionsView.IsProtocolChecked = true; } OptionsView.IsTargetPortEnabled = FirewallHelper.IsIPProtocol(activeConn.Protocol); OptionsView.IsTargetPortChecked = FirewallHelper.IsIPProtocol(activeConn.Protocol); OptionsView.IsLocalPortChecked = (activeConn.LocalPortArray.Count == 1 && activeConn.LocalPortArray[0] != 0 && activeConn.LocalPortArray[0] < IPHelper.GetMaxUserPort()); if (!String.IsNullOrEmpty(activeConn.CurrentService)) { OptionsView.IsService = true; OptionsView.IsServiceMultiple = false; OptionsView.IsServiceRuleChecked = true; OptionsView.SingleServiceName = activeConn.CurrentServiceDesc; } else if (activeConn.PossibleServices != null && activeConn.PossibleServices.Length > 0) { OptionsView.IsService = true; if (activeConn.PossibleServices.Length > 1) { OptionsView.IsServiceMultiple = true; OptionsView.SingleServiceName = ""; } else { OptionsView.IsServiceMultiple = false; OptionsView.SingleServiceName = activeConn.PossibleServicesDesc.FirstOrDefault(); } OptionsView.IsServiceRuleChecked = false; //If we're unsure, let's choose the safe option. There are executables out there that run services but also open connections outside of those services. A false positive in such a case would create a rule that doesn't work. } else { OptionsView.IsService = false; OptionsView.IsServiceMultiple = false; OptionsView.IsServiceRuleChecked = false; OptionsView.SingleServiceName = ""; } OptionsView.IsAppEnabled = !String.IsNullOrEmpty(activeConn.CurrentAppPkgId); NotifyPropertyChanged("OptionsView"); }