コード例 #1
0
ファイル: PresetFirewall.xaml.cs プロジェクト: mx57/priv10
        private void CmbOffAccess_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (SuspendChange > 0)
            {
                return;
            }

            FirewallPreset.OffState = (ProgramConfig.AccessLevels)(cmbOffAccess.SelectedItem as ComboBoxItem).Tag;
            cmbOffAccess.Background = ProgramControl.GetAccessColor(FirewallPreset.OffState);

            LoadRules();
        }
コード例 #2
0
        private void cmbAccess_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbService.Visibility == Visibility.Visible && cmbService.SelectedIndex == -1)
            {
                btnApply.IsEnabled = false;
                return;
            }

            ProgramSet.Config.AccessLevels NetAccess = (ProgramSet.Config.AccessLevels)(cmbAccess.SelectedItem as ComboBoxItem).Tag;
            cmbAccess.Background = ProgramControl.GetAccessColor(NetAccess);
            btnApply.IsEnabled   = NetAccess != ProgramSet.Config.AccessLevels.Unconfigured;
        }
コード例 #3
0
ファイル: PresetFirewall.xaml.cs プロジェクト: mx57/priv10
        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();
        }
コード例 #4
0
        public ProgramTreeControl()
        {
            InitializeComponent();

            this.hdrDescr.Content     = Translate.fmt("lbl_descr");
            this.hdrCat.Content       = Translate.fmt("lbl_log_type");
            this.hdrAccess.Content    = Translate.fmt("lbl_access");
            this.hdrRules.Content     = Translate.fmt("lbl_rules");
            this.hdrAllowed.Content   = Translate.fmt("filter_recent_allowed");
            this.hdrBlocked.Content   = Translate.fmt("filter_recent_blocked");
            this.hdrActivity.Content  = Translate.fmt("sort_act");
            this.hdrSockets.Content   = Translate.fmt("lbl_socks");
            this.hdrUpRate.Content    = Translate.fmt("lbl_upload");
            this.hdrDownRate.Content  = Translate.fmt("lbl_download");
            this.hdrUpTotal.Content   = Translate.fmt("lbl_uploaded");
            this.hdrDownTotal.Content = Translate.fmt("lbl_downloaded");
            this.hdrProg.Content      = Translate.fmt("lbl_program");

            treeView.Loaded += (sender, e) => {
                headerPresenter = WpfFunc.FindChild <GridViewHeaderRowPresenter>(treeView);
                if (headerPresenter == null)
                {
                    return;
                }

                allColumns = headerPresenter.Columns.Cast <GridViewColumn>().ToArray();

                Restore(App.GetConfig("GUI", "progTree_Columns", ""));

                headerMenu = new ContextMenu();
                ContextMenuService.SetContextMenu(headerPresenter, headerMenu);

                if (headerMenu.Items.Count == 0)
                {
                    CreateHeaderMenu();
                }
            };

            treeView.Root      = root = new ProgTreeRoot("");
            treeView.ShowRoot  = false;
            treeView.ShowLines = false;

            treeView.PreviewKeyDown += TreeView_KeyDown;


            var contextMenu = new ContextMenu();


            menuAdd    = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_add_prog"), null, TryFindResource("Icon_Plus"));
            menuAddSub = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_add_to_set"), null, TryFindResource("Icon_Plus"));
            contextMenu.Items.Add(new Separator());
            menuRemove = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_del_progs"), null, TryFindResource("Icon_Remove"));
            contextMenu.Items.Add(new Separator());
            menuMerge = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_merge_progs"), null, TryFindResource("Icon_Merge"));
            menuSplit = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_split_progs"), null, TryFindResource("Icon_Split"));
            contextMenu.Items.Add(new Separator());

            menuAccess       = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_access_prog"), null, TryFindResource("Icon_NetAccess"));
            menuAccessNone   = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_none"), null, null, ProgramSet.Config.AccessLevels.Unconfigured);
            menuAccessAllow  = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_allow"), null, null, ProgramSet.Config.AccessLevels.FullAccess);
            menuAccessCustom = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_edit"), null, null, ProgramSet.Config.AccessLevels.CustomConfig);
            //menuAccessIn = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_inbound"), null, null, ProgramSet.Config.AccessLevels.InBoundAccess);
            //menuAccessOut = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_outbound"), null, null, ProgramSet.Config.AccessLevels.OutBoundAccess);
            menuAccessLan   = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_lan"), null, null, ProgramSet.Config.AccessLevels.LocalOnly);
            menuAccessBlock = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_block"), null, null, ProgramSet.Config.AccessLevels.BlockAccess);
            foreach (MenuItem item in menuAccess.Items)
            {
                item.Background = ProgramControl.GetAccessColor((ProgramSet.Config.AccessLevels)item.Tag);
                //item.IsCheckable = true;
            }

            menuNotify             = WpfFunc.AddMenu(contextMenu, Translate.fmt("lbl_notify"), null);
            menuNotify.IsCheckable = true;

            contextMenu.Items.Add(new Separator());
            menuRename   = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_rename_prog"), null, TryFindResource("Icon_Rename"));
            menuSetIcon  = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_icon_prog"), null, TryFindResource("Icon_SetIcon"));
            menuCategory = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_cat_prog"), null, TryFindResource("Icon_Category"));

            treeView.ContextMenu = contextMenu;
        }
コード例 #5
0
        public ConnectionNotify()
        {
            InitializeComponent();

            this.btnPrev.Content            = Translate.fmt("lbl_prev");
            this.btnNext.Content            = Translate.fmt("lbl_next");
            this.lblRemember.Content        = Translate.fmt("lbl_remember");
            this.btnIgnore.Content          = Translate.fmt("lbl_ignore");
            this.btnApply.Content           = Translate.fmt("lbl_apply");
            this.consGrid.Columns[0].Header = Translate.fmt("lbl_protocol");
            this.consGrid.Columns[1].Header = Translate.fmt("lbl_ip_port");
            this.consGrid.Columns[2].Header = Translate.fmt("lbl_remote_host");
            this.consGrid.Columns[3].Header = Translate.fmt("lbl_time_stamp");
            this.consGrid.Columns[4].Header = Translate.fmt("lbl_pid");

            consGridExt = new DataGridExt(consGrid);
            consGridExt.Restore(App.GetConfig("GUI", "consGrid_Columns", ""));


            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_none"), Tag = ProgramSet.Config.AccessLevels.Unconfigured
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_silence"), Tag = ProgramSet.Config.AccessLevels.StopNotify
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_allow"), Tag = ProgramSet.Config.AccessLevels.FullAccess
            });
            //cmbAccess.Items.Add(new ComboBoxItem() { Content = Translate.fmt("acl_outbound"), Tag = ProgramSet.Config.AccessLevels.OutBoundAccess });
            //cmbAccess.Items.Add(new ComboBoxItem() { Content = Translate.fmt("acl_inbound"), Tag = ProgramSet.Config.AccessLevels.InBoundAccess });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_edit"), Tag = ProgramSet.Config.AccessLevels.CustomConfig
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_lan"), Tag = ProgramSet.Config.AccessLevels.LocalOnly
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_block"), Tag = ProgramSet.Config.AccessLevels.BlockAccess
            });
            foreach (ComboBoxItem item in cmbAccess.Items)
            {
                item.Background = ProgramControl.GetAccessColor((ProgramSet.Config.AccessLevels)item.Tag);
            }

#if DEBUG
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "1 min"), Tag = 60
            });
#endif
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "5 min"), Tag = 5 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "15 min"), Tag = 15 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "1 h"), Tag = 60 * 60
            });
            cmbRemember.SelectedIndex = cmbRemember.Items.Count - 1; // default is 1h
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "24 h"), Tag = 24 * 60 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_permanent"), Tag = 0
            });
        }
コード例 #6
0
        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 <Priv10Engine.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>();

            btnIgnore.IsEnabled = true;
            consGrid.Items.Clear();
            foreach (Priv10Engine.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;
        }