public ProgramListControl() { InitializeComponent(); ProgramList = new ControlList <ProgramControl, ProgramSet>(this.processScroll, (prog) => { return(new ProgramControl(prog, CatModel)); }, (prog) => prog.guid.ToString(), (list) => { list.Sort(DoSort); }, (item) => { return(CurFilter != null && FirewallPage.DoFilter(CurFilter, item.progSet)); }); ProgramList.SelectionChanged += (s, e) => { SelectionChanged?.Invoke(this, e); }; SuspendChange++; //this.rbbSort.Header = Translate.fmt("lbl_sort_and"); this.lblSort.Content = Translate.fmt("lbl_sort"); //this.chkNoLocal.Content = Translate.fmt("chk_ignore_local"); //this.chkNoLan.Content = Translate.fmt("chk_ignore_lan"); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_no"), Sorts.Unsorted); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_name"), Sorts.Name); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_rname"), Sorts.NameRev); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_act"), Sorts.LastActivity); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_rate"), Sorts.DataRate); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_socks"), Sorts.SocketCount); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_count"), Sorts.ModuleCount); WpfFunc.CmbSelect(cmbSort, ((Sorts)App.GetConfigInt("GUI", "SortList", 0)).ToString()); this.chkNoLocal.IsChecked = App.GetConfigInt("GUI", "ActNoLocal", 0) == 1; this.chkNoLan.IsChecked = App.GetConfigInt("GUI", "ActNoLan", 0) == 1; SuspendChange--; }
/*protected ObservableCollection<ProgramSet> ProgramSets = null; * public ObservableCollection<ProgramSet> ItemsSource { get { return ProgramSets; } set { * if(ProgramSets != null) * ProgramSets.CollectionChanged -= ProgramSets_CollectionChanged; * ProgramSets = value; * ProgramSets.CollectionChanged += ProgramSets_CollectionChanged; * } } * * private void ProgramSets_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) * { * } */ public ProgramListControl() { InitializeComponent(); SelectedPrograms = new List <ProgramControl>(); SuspendChange++; //this.rbbSort.Header = Translate.fmt("lbl_sort_and"); this.lblSort.Content = Translate.fmt("lbl_sort"); //this.chkNoLocal.Content = Translate.fmt("chk_ignore_local"); //this.chkNoLan.Content = Translate.fmt("chk_ignore_lan"); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_no"), Sorts.Unsorted); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_name"), Sorts.Name); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_rname"), Sorts.NameRev); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_act"), Sorts.LastActivity); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_rate"), Sorts.DataRate); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_socks"), Sorts.SocketCount); WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_count"), Sorts.ModuleCount); WpfFunc.CmbSelect(cmbSort, ((Sorts)App.GetConfigInt("GUI", "SortList", 0)).ToString()); this.chkNoLocal.IsChecked = App.GetConfigInt("GUI", "ActNoLocal", 0) == 1; this.chkNoLan.IsChecked = App.GetConfigInt("GUI", "ActNoLan", 0) == 1; SuspendChange--; this.processScroll.PreviewKeyDown += process_KeyEventHandler; }
private void OnPresetGroupChanged(object sender, EventArgs e) { if (PresetList.SelectedItems.Count != 1) { return; } if (CurrentPreset != null && CurrentPreset.guid == PresetList.SelectedItems.First().preset.guid) { return; } CurrentPreset = PresetList.SelectedItems.First().preset.Clone(); this.txtName.Text = CurrentPreset.Name; this.txtInfo.Text = CurrentPreset.Description; WpfFunc.CmbSelect(this.cmbUndo, CurrentPreset.AutoUndo.ToString()); foreach (var item in CurrentPreset.Items.Values) { item.Sync(); } PresetItemList.UpdateItems(CurrentPreset.Items.Values.ToList()); CollapseAll(); }
public NetworkSocketList() { InitializeComponent(); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_all"), FirewallPage.FilterPreset.Socket.Any); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_web"), FirewallPage.FilterPreset.Socket.Web).Background = new SolidColorBrush(Colors.DodgerBlue); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_tcp"), FirewallPage.FilterPreset.Socket.TCP).Background = new SolidColorBrush(Colors.Turquoise); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_client"), FirewallPage.FilterPreset.Socket.Client).Background = new SolidColorBrush(Colors.Gold); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_server"), FirewallPage.FilterPreset.Socket.Server).Background = new SolidColorBrush(Colors.DarkOrange); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_udp"), FirewallPage.FilterPreset.Socket.UDP).Background = new SolidColorBrush(Colors.Violet); //WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_raw"), FirewallPage.FilterPreset.Socket.Raw); this.txtSockFilter.LabelText = Translate.fmt("lbl_text_filter"); //this.chkNoINet.ToolTip = Translate.fmt("str_no_inet"); //this.chkNoLAN.ToolTip = Translate.fmt("str_no_lan"); //this.chkNoMulti.ToolTip = Translate.fmt("str_no_multi"); //this.chkNoLocal.ToolTip = Translate.fmt("str_no_local"); this.socksGrid.Columns[1].Header = Translate.fmt("lbl_name"); this.socksGrid.Columns[2].Header = Translate.fmt("lbl_time_stamp"); this.socksGrid.Columns[3].Header = Translate.fmt("lbl_state"); this.socksGrid.Columns[4].Header = Translate.fmt("lbl_protocol"); this.socksGrid.Columns[5].Header = Translate.fmt("lbl_remote_ip"); this.socksGrid.Columns[6].Header = Translate.fmt("lbl_remote_port"); this.socksGrid.Columns[7].Header = Translate.fmt("lbl_local_ip"); this.socksGrid.Columns[8].Header = Translate.fmt("lbl_local_port"); this.socksGrid.Columns[9].Header = Translate.fmt("lbl_access"); this.socksGrid.Columns[10].Header = Translate.fmt("lbl_upload"); this.socksGrid.Columns[11].Header = Translate.fmt("lbl_download"); this.socksGrid.Columns[12].Header = Translate.fmt("lbl_uploaded"); this.socksGrid.Columns[13].Header = Translate.fmt("lbl_downloaded"); this.socksGrid.Columns[14].Header = Translate.fmt("lbl_program"); socksGridExt = new DataGridExt(socksGrid); socksGridExt.Restore(App.GetConfig("GUI", "socksGrid_Columns", "")); SocketList = new ObservableCollection <SocketItem>(); socksGrid.ItemsSource = SocketList; UwpFunc.AddBinding(socksGrid, new KeyGesture(Key.F, ModifierKeys.Control), (s, e) => { this.txtSockFilter.Focus(); }); //UwpFunc.AddBinding(socksGrid, new KeyGesture(Key.Delete), btnRemoveRule_Click); try { textFilter = App.GetConfig("NetSocks", "Filter", ""); txtSockFilter.Text = textFilter; WpfFunc.CmbSelect(sockType, ((FirewallPage.FilterPreset.Socket)App.GetConfigInt("NetSocks", "Types", 0)).ToString()); //this.chkNoLocal.IsChecked = App.GetConfigInt("NetSocks", "NoLocal", 0) == 1; //this.chkNoMulti.IsChecked = App.GetConfigInt("NetSocks", "NoMulti", 0) == 1; //this.chkNoLAN.IsChecked = App.GetConfigInt("NetSocks", "NoLan", 0) == 1; //this.chkNoINet.IsChecked = App.GetConfigInt("NetSocks", "NoINet", 0) == 1; } catch { } CheckSockets(); }
private void LoadCurrent(bool bUpdate = false) { if (!bUpdate) { Program.Config.AccessLevels NetAccess = Program.Config.AccessLevels.Unconfigured; cmbAccess.Background = ProgramControl.GetAccessColor(NetAccess); WpfFunc.CmbSelect(cmbAccess, NetAccess.ToString()); } btnApply.IsEnabled = false; ProgramList.ID id = mEventList.ElementAt(curIndex); Tuple <Program, List <Program.LogEntry> > list = mEvents[id]; int PID = list.Item2.Count > 0 ? list.Item2.First().PID : 0; imgIcon.Source = ImgFunc.GetIcon(list.Item1.GetIcon(), imgIcon.Width); //lblName.Text = id.GetDisplayName(false); grpBox.Header = id.GetDisplayName(false); lblPID.Text = string.Format("{0} ({1})", System.IO.Path.GetFileName(id.Path), PID); switch (id.Type) { //case ProgramList.Types.Program: lblSubName.Text = ""; break; case ProgramList.Types.Service: lblSubName.Text = id.Name; break; case ProgramList.Types.App: lblSubName.Text = App.engine.appMgr.GetAppName(id.Name); break; default: lblSubName.Text = ""; break; } lblPath.Text = id.Path; /*lstEvents.Items.Clear(); * foreach (Program.LogEntry entry in list.Item2) * { * string info = ""; * info += NetFunc.Protocol2SStr(entry.Protocol) + "://"; * * switch (entry.Protocol) * { * case (int)FirewallRule.KnownProtocols.TCP: * case (int)FirewallRule.KnownProtocols.UDP: * info += entry.RemoteAddress + ":" + entry.RemotePort; * break; * } * * lstEvents.Items.Add(new ListBoxItem() { Content = info}); * }*/ consGrid.Items.Clear(); foreach (Program.LogEntry entry in list.Item2) { consGrid.Items.Insert(0, new ConEntry(entry)); } }
public void DoUpdate(TweakPreset.SingleTweak item) { this.item = item; SuspendChange++; label.Content = item.TweakName; // todo: poepr name translation support xxxx <<<<<<<<<<<< int Value = item.OnState == null ? -1 : item.OnState == true ? 1 : 0; WpfFunc.CmbSelect(cmbPreset, Value.ToString()); cmbPreset.Background = GetPresetColor(Value); SuspendChange--; TweakList.Tweak tweak = App.tweaks.GetTweak(item.TweakName); if (tweak == null) { return; } string infoStr = ""; switch (tweak.Type) { case TweakList.TweakType.SetRegistry: case TweakList.TweakType.SetGPO: infoStr += tweak.Path + "\r\n"; infoStr += tweak.Key + " = " + tweak.Value + "\r\n"; break; case TweakList.TweakType.DisableTask: infoStr += "Disable Scheduled Task: " + tweak.Path + "\\" + tweak.Key + "\r\n"; break; case TweakList.TweakType.DisableService: infoStr += "Disable Service: " + tweak.Key + "\r\n"; break; case TweakList.TweakType.BlockFile: infoStr += "Dissable Access to: " + tweak.Path + "\r\n"; break; //case TweakType.UseFirewall: // infoStr += "Set Firewal roule" + "\r\n"; // break; default: infoStr = "Unknown Tweak Type"; break; } info.Text = infoStr; }
public void SetItem(FirewallPreset firewallPreset) { FirewallPreset = firewallPreset; SuspendChange++; presetName.Content = FirewallPreset.Name; WpfFunc.CmbSelect(cmbOnAccess, FirewallPreset.OnState.ToString()); cmbOnAccess.Background = ProgramControl.GetAccessColor(FirewallPreset.OnState); WpfFunc.CmbSelect(cmbOffAccess, FirewallPreset.OffState.ToString()); cmbOffAccess.Background = ProgramControl.GetAccessColor(FirewallPreset.OffState); SuspendChange--; LoadRules(); }
public void DoUpdate() { SuspendChange++; icon.Source = ImgFunc.GetIcon(Program.GetIcon(), icon.Width); //name.Content = process.Name; name.Text = Program.config.Name; info.Content = Translate.fmt("lbl_info", Program.blockedConnections, Program.allowedConnections); WpfFunc.CmbSelect(category, Program.config.Category == null ? "" : Program.config.Category); if (Program.config.NetAccess == Program.Config.AccessLevels.Unconfigured) { cmbAccess.Background = GetAccessColor(Program.config.CurAccess); WpfFunc.CmbSelect(cmbAccess, Program.config.CurAccess.ToString()); } else { if (Program.config.NetAccess != Program.Config.AccessLevels.Unconfigured && Program.config.NetAccess != Program.config.CurAccess) { cmbAccess.Background /*grid.Background*/ = FindResource("Stripes") as DrawingBrush; } else { cmbAccess.Background = GetAccessColor(Program.config.NetAccess); } WpfFunc.CmbSelect(cmbAccess, Program.config.NetAccess.ToString()); } chkNotify.IsChecked = Program.config.GetNotify(); progGrid.Items.Clear(); foreach (ProgramList.ID id in Program.IDs) { progGrid.Items.Insert(0, new IDEntry(id)); } btnSplit.IsEnabled = Program.IDs.Count > 1; SuspendChange--; }
private void lstAddr_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListBoxItem item = (lstAddr.SelectedItem as ListBoxItem); if (item != null && item.Tag != null) { if (!WpfFunc.CmbSelect(cmbEdit, (string)item.Tag)) { cmbEdit.Text = (string)item.Tag; } } else { cmbEdit.Text = ""; } gridEdit.Visibility = Visibility.Visible; //lstAddr.IsEnabled = false; }
public void DoUpdate(FirewallPreset.SingleRule rule) { this.rule = rule; SuspendChange++; PresetMode Value = GetPresetMode(rule.OnState, rule.OffState); WpfFunc.CmbSelect(cmbPreset, Value.ToString()); cmbPreset.Background = GetPresetColor(Value, this); SuspendChange--; if (FwRule == null) { label.Content = rule.RuleId; return; } label.Content = App.GetResourceStr(FwRule.Name); info.Text = App.GetResourceStr(GetRuleDescription(FwRule, true)); info.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(FwRule.Action == FirewallRule.Actions.Block ? "#ffe6e9" : "#e9fce9")); }
public InputWnd(string prompt, List <string> items, string defValue = "", bool editable = true, string title = null) { InitializeComponent(); if (title != null) { this.Title = title; } lblPrompt.Content = prompt; txtValue.Visibility = Visibility.Collapsed; cmbValue.Visibility = Visibility.Visible; cmbValue.IsEditable = editable; foreach (var item in items) { cmbValue.Items.Add(new ComboBoxItem() { Content = item, Tag = item }); } if (!WpfFunc.CmbSelect(cmbValue, defValue)) { cmbValue.Text = defValue; } }
public void DoUpdate(ProgramSet progSet) { this.progSet = progSet; SuspendChange++; ImgFunc.GetIconAsync(progSet.GetIcon(), icon.Width, (ImageSource src) => { if (Application.Current != null) { Application.Current.Dispatcher.Invoke(new Action(() => { icon.Source = src; })); } return(0); }); //name.Content = process.Name; name.Text = progSet.config.Name; int blockedConnections = 0; int allowedConnections = 0; int socketCount = 0; UInt64 uploadRate = 0; UInt64 downloadRate = 0; foreach (Program prog in progSet.Programs.Values) { blockedConnections += prog.BlockedCount; allowedConnections += prog.AllowedCount; socketCount += prog.SocketCount; uploadRate += prog.UploadRate; downloadRate += prog.DownloadRate; } info.Content = Translate.fmt("lbl_prog_info", blockedConnections, allowedConnections, socketCount, FileOps.FormatSize((decimal)uploadRate), FileOps.FormatSize((decimal)downloadRate)); WpfFunc.CmbSelect(category, progSet.config.Category == null ? "" : progSet.config.Category); WpfFunc.CmbSelect(cmbAccess, progSet.config.GetAccess().ToString()); if (progSet.config.NetAccess != ProgramSet.Config.AccessLevels.Unconfigured && progSet.config.NetAccess != progSet.config.CurAccess) { cmbAccess.Background /*grid.Background*/ = FindResource("Stripes") as DrawingBrush; } else { cmbAccess.Background = GetAccessColor(progSet.config.GetAccess()); } chkNotify.IsChecked = progSet.config.GetNotify(); progGrid.Items.Clear(); foreach (Program prog in progSet.Programs.Values) { progGrid.Items.Insert(0, new ProgEntry(prog)); } btnSplit.IsEnabled = progSet.Programs.Count > 1; SuspendChange--; }
public RuleWindow(List <Program> progs, FirewallRule rule) { InitializeComponent(); this.Title = Translate.fmt("wnd_rule"); this.grpRule.Header = Translate.fmt("lbl_rule"); this.lblName.Text = Translate.fmt("lbl_name"); this.lblGroup.Text = Translate.fmt("lbl_group"); this.grpProgram.Header = Translate.fmt("lbl_program"); this.lblProgram.Text = Translate.fmt("lbl_program"); this.lblExecutable.Text = Translate.fmt("lbl_exe"); this.lblService.Text = Translate.fmt("lbl_svc"); this.lblApp.Text = Translate.fmt("lbl_app"); this.grpAction.Header = Translate.fmt("grp_action"); this.lblAction.Text = Translate.fmt("lbl_action"); this.radProfileAll.Content = Translate.fmt("lbl_prof_all"); this.radProfileCustom.Content = Translate.fmt("lbl_prof_sel"); this.chkPublic.Content = Translate.fmt("lbl_prof_pub"); this.chkDomain.Content = Translate.fmt("lbl_prof_dmn"); this.chkPrivate.Content = Translate.fmt("lbl_prof_priv"); this.radNicAll.Content = Translate.fmt("lbl_itf_all"); this.radNicCustom.Content = Translate.fmt("lbl_itf_select"); this.chkLAN.Content = Translate.fmt("lbl_itf_lan"); this.chkVPN.Content = Translate.fmt("lbl_itf_vpn"); this.chkWiFi.Content = Translate.fmt("lbl_itf_wifi"); this.grpNetwork.Header = Translate.fmt("grp_network"); this.lblDirection.Text = Translate.fmt("lbl_direction"); this.lblProtocol.Text = Translate.fmt("lbl_protocol"); this.lblLocalPorts.Text = Translate.fmt("lbl_local_port"); this.lblRemotePorts.Text = Translate.fmt("lbl_remote_port"); this.lblICMP.Text = Translate.fmt("lbl_icmp"); this.lblLocalIP.Text = Translate.fmt("lbl_local_ip"); this.lblRemoteIP.Text = Translate.fmt("lbl_remote_ip"); this.btnOK.Content = Translate.fmt("lbl_ok"); this.btnCancel.Content = Translate.fmt("lbl_cancel"); Rule = rule; bool bNew = Rule.guid == null; viewModel = new RuleWindowViewModel(); DataContext = viewModel; //txtName.Text = Rule.Name; viewModel.RuleName = Rule.Name; cmbGroup.ItemsSource = GroupModel.GetInstance().GetGroups(); if (!WpfFunc.CmbSelect(cmbGroup, Rule.Grouping)) { cmbGroup.Text = Rule.Grouping; } txtInfo.Text = Rule.Description; foreach (Program prog in progs) { ContentControl program = new ContentControl() { Content = prog.Description, Tag = prog.ID }; cmbProgram.Items.Add(program); if (Rule.ProgID != null && prog.ID.CompareTo(Rule.ProgID) == 0) { cmbProgram.SelectedItem = program; } } cmbAction.Items.Add(new ContentControl() { Content = Translate.fmt("str_allow"), Tag = FirewallRule.Actions.Allow }); cmbAction.Items.Add(new ContentControl() { Content = Translate.fmt("str_block"), Tag = FirewallRule.Actions.Block }); //WpfFunc.CmbSelect(cmbAction, Rule.Action.ToString()); viewModel.RuleAction = WpfFunc.CmbPick(cmbAction, Rule.Action.ToString()); if (Rule.Profile == (int)FirewallRule.Profiles.All) { radProfileAll.IsChecked = true; chkPrivate.IsChecked = true; chkDomain.IsChecked = true; chkPublic.IsChecked = true; } else { radProfileCustom.IsChecked = true; chkPrivate.IsChecked = ((Rule.Profile & (int)FirewallRule.Profiles.Private) != 0); chkDomain.IsChecked = ((Rule.Profile & (int)FirewallRule.Profiles.Domain) != 0); chkPublic.IsChecked = ((Rule.Profile & (int)FirewallRule.Profiles.Public) != 0); } if (Rule.Interface == (int)FirewallRule.Interfaces.All) { radNicAll.IsChecked = true; chkLAN.IsChecked = true; chkVPN.IsChecked = true; chkWiFi.IsChecked = true; } else { radNicCustom.IsChecked = true; chkLAN.IsChecked = ((Rule.Interface & (int)FirewallRule.Interfaces.Lan) != 0); chkVPN.IsChecked = ((Rule.Interface & (int)FirewallRule.Interfaces.RemoteAccess) != 0); chkWiFi.IsChecked = ((Rule.Interface & (int)FirewallRule.Interfaces.Wireless) != 0); } if (bNew) { cmbDirection.Items.Add(new ContentControl() { Content = Translate.fmt("str_inandout"), Tag = FirewallRule.Directions.Bidirectiona }); } cmbDirection.Items.Add(new ContentControl() { Content = Translate.fmt("str_outbound"), Tag = FirewallRule.Directions.Outboun }); cmbDirection.Items.Add(new ContentControl() { Content = Translate.fmt("str_inbound"), Tag = FirewallRule.Directions.Inbound }); WpfFunc.CmbSelect(cmbDirection, Rule.Direction.ToString()); cmbProtocol.Items.Add(new ContentControl() { Content = Translate.fmt("pro_any"), Tag = (int)NetFunc.KnownProtocols.Any }); for (int i = (int)NetFunc.KnownProtocols.Min; i <= (int)NetFunc.KnownProtocols.Max; i++) { string name = NetFunc.Protocol2Str((UInt32)i); if (name != null) { cmbProtocol.Items.Add(new ContentControl() { Content = i.ToString() + " - " + name, Tag = i }); } } //if (!WpfFunc.CmbSelect(cmbProtocol, Rule.Protocol.ToString())) // cmbProtocol.Text = Rule.Protocol.ToString(); viewModel.Protocol = WpfFunc.CmbPick(cmbProtocol, Rule.Protocol.ToString()); if (viewModel.Protocol == null) { viewModel.ProtocolTxt = Rule.Protocol.ToString(); } UpdatePorts(); addrDest.Address = Rule.RemoteAddresses; addrSrc.Address = Rule.LocalAddresses; WpfFunc.LoadWnd(this, "Rule"); }
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); }
private void LoadCurrent(bool bUpdate = false) { if (!bUpdate) { ProgramSet.Config.AccessLevels NetAccess = ProgramSet.Config.AccessLevels.Unconfigured; cmbAccess.Background = ProgramControl.GetAccessColor(NetAccess); WpfFunc.CmbSelect(cmbAccess, NetAccess.ToString()); } btnApply.IsEnabled = false; ProgramID id = mEventList.ElementAt(curIndex); Tuple <Program, List <Engine.FwEventArgs> > list = mEvents[id]; //int PID = list.Item2.Count > 0 ? list.Item2.First().FwEvent.ProcessId : 0; string FilePath = list.Item2.Count > 0 ? list.Item2.First().entry.FwEvent.ProcessFileName : ""; imgIcon.Source = ImgFunc.GetIcon(FilePath, imgIcon.Width); // todo: use .progSet.GetIcon instead? //lblName.Text = id.GetDisplayName(false); grpBox.Header = list.Item1.Description; //lblPID.Text = string.Format("{0} ({1})", System.IO.Path.GetFileName(id.Path), PID); lblPID.Text = System.IO.Path.GetFileName(id.Path); List <string> services = new List <string>(); consGrid.Items.Clear(); foreach (Engine.FwEventArgs args in list.Item2) { consGrid.Items.Insert(0, new ConEntry(args.entry)); if (args.services != null) { foreach (var service in args.services) { if (!services.Contains(service)) { services.Add(service); } } } } if (services.Count > 0) { cmbService.Visibility = Visibility.Visible; cmbService.Items.Clear(); foreach (var service in services) { cmbService.Items.Add(service); } cmbService.SelectedIndex = -1; cmbService.Text = Translate.fmt("msg_pick_svc"); } else { cmbService.Visibility = Visibility.Collapsed; switch (id.Type) { //case ProgramList.Types.Program: lblSubName.Text = ""; break; case ProgramID.Types.Service: lblSubName.Text = id.GetServiceId(); break; case ProgramID.Types.App: lblSubName.Text = id.GetPackageName(); break; default: lblSubName.Text = ""; break; } } lblPath.Text = id.Path; }
public void Refresh() { bHold = true; chkTray.IsChecked = App.GetConfigInt("Startup", "Tray", 1) != 0; chkAutoStart.IsChecked = App.IsAutoStart(); chkService.IsChecked = Priv10Service.IsInstalled(); chkNoUAC.IsChecked = AdminFunc.IsSkipUac(App.Key); chkTweakCheck.IsChecked = App.GetConfigInt("TweakGuard", "AutoCheck", 1) != 0; chkTweakFix.IsEnabled = chkTweakCheck.IsChecked == true; chkTweakFix.IsChecked = App.GetConfigInt("TweakGuard", "AutoFix", 0) != 0; chkUseFW.IsChecked = App.GetConfigInt("Firewall", "Enabled", 0) != 0; if (App.client.IsConnected()) { var mode = App.client.GetFilteringMode(); radWhitelist.IsChecked = mode == FirewallManager.FilteringModes.WhiteList; radBlacklist.IsChecked = mode == FirewallManager.FilteringModes.BlackList; radDisabled.IsChecked = mode == FirewallManager.FilteringModes.NoFiltering; var pol = App.client.GetAuditPolicy(); switch (pol) { case FirewallMonitor.Auditing.All: cmbAudit.SelectedItem = lblAuditAll; break; case FirewallMonitor.Auditing.Blocked: cmbAudit.SelectedItem = lblAuditBlock; break; default: cmbAudit.SelectedItem = lblAuditNone; break; } chkGuardFW.IsEnabled = chkUseFW.IsChecked == true; chkGuardFW.IsChecked = App.client.IsFirewallGuard(); chkEnableDNS.IsChecked = App.GetConfigInt("DnsProxy", "Enabled", 0) != 0; } else { chkUseFW.IsEnabled = false; radWhitelist.IsEnabled = false; radBlacklist.IsEnabled = false; radDisabled.IsEnabled = false; cmbAudit.IsEnabled = false; chkGuardFW.IsEnabled = false; chkEnableDNS.IsEnabled = false; } var fix_mode = App.GetConfigInt("Firewall", "GuardMode", 0); radFix.IsChecked = fix_mode == (int)FirewallGuard.Mode.Fix; radDisable.IsChecked = fix_mode == (int)FirewallGuard.Mode.Disable; radAlert.IsChecked = fix_mode == (int)FirewallGuard.Mode.Alert; radFix.IsEnabled = radDisable.IsEnabled = radAlert.IsEnabled = (chkGuardFW.IsChecked != false && chkGuardFW.IsEnabled); chkNotifyFW.IsEnabled = chkUseFW.IsChecked == true; chkNotifyFW.IsChecked = App.GetConfigInt("Firewall", "NotifyConnections", 1) != 0; chkDnsInspector.IsChecked = App.GetConfigInt("DnsInspector", "Enabled", 0) != 0; chkReverseDNS.IsChecked = App.GetConfigInt("DnsInspector", "UseReverseDNS", 0) != 0; // DNS chkLocalDNS.IsChecked = App.GetConfigInt("DnsProxy", "SetLocal", 0) != 0; string UpstreamDNS = App.GetConfig("DNSProxy", "UpstreamDNS", "8.8.8.8"); if (!WpfFunc.CmbSelect(cmbRootDNS, UpstreamDNS)) { cmbRootDNS.Text = UpstreamDNS; } CheckDNS(); //this.btnBackup.IsEnabled = this.btnRestore.IsEnabled = !App.isPortable; bHold = false; }
public FirewallLogList() { InitializeComponent(); //this.grpLog.Header = Translate.fmt("gtp_con_log"); /*this.grpLogTools.Header = Translate.fmt("grp_tools"); * this.grpLogView.Header = Translate.fmt("grp_view"); * * this.btnMkRule.Content = Translate.fmt("btn_mk_rule"); * this.btnClearLog.Content = Translate.fmt("btn_clear_log"); * this.lblShowCons.Content = Translate.fmt("lbl_show_cons"); * this.chkNoLocal.Content = Translate.fmt("chk_hide_local"); * this.chkNoLAN.Content = Translate.fmt("chk_hide_lan"); * this.lblFilterCons.Content = Translate.fmt("lbl_filter_cons");*/ this.txtConFilter.LabelText = Translate.fmt("lbl_text_filter"); this.cmbAll.Content = Translate.fmt("str_all_events"); this.cmbAllow.Content = Translate.fmt("str_allowed"); this.cmbBlock.Content = Translate.fmt("str_blocked"); this.chkNoINet.ToolTip = Translate.fmt("str_no_inet"); this.chkNoLAN.ToolTip = Translate.fmt("str_no_lan"); this.chkNoMulti.ToolTip = Translate.fmt("str_no_multi"); this.chkNoLocal.ToolTip = Translate.fmt("str_no_local"); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_protocols_any"), FirewallPage.FilterPreset.Socket.Any); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_web"), FirewallPage.FilterPreset.Socket.Web).Background = new SolidColorBrush(Colors.DodgerBlue); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_tcp"), FirewallPage.FilterPreset.Socket.TCP).Background = new SolidColorBrush(Colors.Turquoise); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_client"), FirewallPage.FilterPreset.Socket.Client).Background = new SolidColorBrush(Colors.Gold); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_server"), FirewallPage.FilterPreset.Socket.Server).Background = new SolidColorBrush(Colors.DarkOrange); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_udp"), FirewallPage.FilterPreset.Socket.UDP).Background = new SolidColorBrush(Colors.Violet); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_protocols_other"), FirewallPage.FilterPreset.Socket.Other).Background = new SolidColorBrush(Colors.LightGray); int i = 0; this.logGrid.Columns[++i].Header = Translate.fmt("lbl_name"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_time_stamp"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_action"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_direction"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_protocol"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_remote_ip"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_remote_port"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_local_ip"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_local_port"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_program"); LogList = new ObservableCollection <LogItem>(); logGrid.ItemsSource = LogList; logGridExt = new DataGridExt(logGrid); logGridExt.Restore(App.GetConfig("FwLog", "Columns", "")); UwpFunc.AddBinding(logGrid, new KeyGesture(Key.F, ModifierKeys.Control), (s, e) => { this.txtConFilter.Focus(); }); try { textFilter = App.GetConfig("FwLog", "Filter", ""); txtConFilter.Text = textFilter; cmbConTypes.SelectedIndex = App.GetConfigInt("FwLog", "Events", 0); WpfFunc.CmbSelect(sockType, ((FirewallPage.FilterPreset.Socket)App.GetConfigInt("FwLog", "Types", 0)).ToString()); //this.chkAllowed.IsChecked = App.GetConfigInt("FwLog", "ShowAllowed", 1) == 1; //this.chkBlocked.IsChecked = App.GetConfigInt("FwLog", "ShowBlocked", 1) == 1; this.chkNoLocal.IsChecked = App.GetConfigInt("FwLog", "NoLocal", 0) == 1; this.chkNoMulti.IsChecked = App.GetConfigInt("FwLog", "NoMulti", 0) == 1; this.chkNoLAN.IsChecked = App.GetConfigInt("FwLog", "NoLan", 0) == 1; this.chkNoINet.IsChecked = App.GetConfigInt("FwLog", "NoINet", 0) == 1; } catch { } //mConLimit = App.engine.programs.MaxLogLength * 10; // todo logLimit = App.GetConfigInt("GUI", "LogLimit", 1000); CheckLogLines(); }