Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();

            using var cacheFs      = CacheFileManager.GetFileCache("exclude.json");
            using var streamReader = new StreamReader(cacheFs);
            exceptions             = JsonConvert.DeserializeObject <List <string> >(streamReader.ReadToEnd());

            monitor = ProcessMonitor.GetInstance();
            monitor.OnWindowChanged += Mon_OnWindowChanged;
            monitor.OnStopped       += Monitor_OnStopped;
            this.Closing            += MainWindow_Closing;
        }
Exemple #2
0
        public ExceptionConfigurationWindow()
        {
            InitializeComponent();

            using var cacheFs      = CacheFileManager.GetFileCache("exclude.json");
            using var streamReader = new StreamReader(cacheFs);
            var exceptions = JsonConvert.DeserializeObject <List <string> >(streamReader.ReadToEnd());

            var stackPanel = new StackPanel();

            stackPanel.HorizontalAlignment = HorizontalAlignment.Left;
            stackPanel.VerticalAlignment   = VerticalAlignment.Top;

            foreach (var session in GetSessionNames())
            {
                var checkBox = new CheckBox();
                checkBox.Content = session;
                if (exceptions.Contains(session))
                {
                    checkBox.IsChecked = true;
                }
                checkBox.Click += (s, e) =>
                {
                    if (checkBox.IsChecked.Value)
                    {
                        exceptions.Add(session);
                    }
                    else
                    {
                        exceptions.Remove(session);
                    }
                };

                stackPanel.Children.Add(checkBox);
            }

            this.ScrollViewer.Content = stackPanel;
            this.Closing += (s, e) =>
            {
                MessageBox.Show($"Exclude list has been updated, restart the program to take effect.");
                CacheFileManager.SaveCache("exclude.json", JsonConvert.SerializeObject(exceptions));
            };
        }