<commit_before>﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;

namespace Janus
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow
    {
        public static readonly DataStore MainStore = new DataStore();
        public static bool Exiting { get; private set; }
        private static DataProvider _data;
        private static ObservableCollection<Watcher> _watchers;
        private static readonly string Startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
        private static readonly string Shortcut = Path.Combine(Startup, "Janus.url");

        public MainWindow()
        {
            InitializeComponent();
        }

        private void btnWatcher_Click(object sender, RoutedEventArgs e)
        {
            var createWindow = new CreateWindow();
            createWindow.Init();
            createWindow.Show();
        }

        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            Logging.WriteLine("Initialising Main Window");
            Hide();
            MainStore.Initialise();

            Logging.WriteLine("Loading Data");
            var d = MainStore.Load();
            Logging.WriteLine("Finished Loading Data");

            _data = d.DataProvider;
            _watchers = d.Watchers;

            if (_watchers.Count == 0)
            {
                Show();
            }
            else
            {
                NotificationSystem.Default.Push(NotifcationType.Info, "Janus", "Started in minimised mode. Double click 'Ja' icon to interact.");
            }
            ListBox.ItemsSource = _watchers;
            _watchers.CollectionChanged += Watchers_CollectionChanged;

            CbStartup.IsChecked = File.Exists(Shortcut);
        }

        private static void Watchers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            UpdateStore();
        }

        public static void UpdateStore()
        {
            Logging.WriteLine("Saving Data");
            MainStore.Store(new JanusData(_watchers, _data));
            Logging.WriteLine("Finished Saving Data");
        }

        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            if (btn?.DataContext is Watcher watcher)
            {
                watcher.Stop();
                _watchers.Remove(watcher);
            }

            //NotificationSystem.Default.Push(NotifcationType.Info, "Removed Watcher", "Removed watcher successfully.");
        }

        private async void btnSync_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;
            if (btn?.DataContext is Watcher watcher)
                await watcher.SynchroniseAsync().ConfigureAwait(false);
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;
            if (btn?.DataContext is Watcher watcher)
                UpdateStore();
        }

        private void CbStartup_OnClick(object sender, RoutedEventArgs e)
        {
            if (!CbStartup.IsChecked.HasValue) return;

            if (CbStartup.IsChecked.Value)
            {
                AddToStartup();
            }
            else
            {
                RemoveFromStartup();
            }
        }

        private static void RemoveFromStartup()
        {
            if (File.Exists(Shortcut))
            {
                File.Delete(Shortcut);
            }
        }

        private static void AddToStartup()
        {
            using (var writer = new StreamWriter(Shortcut))
            {
                var app = Assembly.GetExecutingAssembly().Location;
                writer.WriteLine("[InternetShortcut]");
                writer.WriteLine("URL=file:///" + app);
                writer.WriteLine("IconIndex=0");
                var icon = app.Replace('\\', '/');
                writer.WriteLine("IconFile=" + icon);
                writer.Flush();
            }
        }

        private void TrayIcon_OnTrayMouseDoubleClick(object sender, RoutedEventArgs e)
        {
            Show();
        }

        private void MainWindow_OnClosing(object sender, CancelEventArgs e)
        {
            if (Exiting) return;

            e.Cancel = true;
            Hide();
        }

        private void MenuItem_OnClick(object sender, RoutedEventArgs e)
        {
            Show();
        }

        private void Exit_OnClick(object sender, RoutedEventArgs e)
        {
            Exiting = true;
            Close();
        }


    }
}
<commit_msg>Invalidly changed to private..<commit_after>﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;

namespace Janus
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow
    {
        public static readonly DataStore MainStore = new DataStore();
        public static bool Exiting { get; private set; }
        public static DataProvider Data;
        public static ObservableCollection<Watcher> Watchers;
        private static readonly string Startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
        private static readonly string Shortcut = Path.Combine(Startup, "Janus.url");

        public MainWindow()
        {
            InitializeComponent();
        }

        private void btnWatcher_Click(object sender, RoutedEventArgs e)
        {
            var createWindow = new CreateWindow();
            createWindow.Init();
            createWindow.Show();
        }

        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            Logging.WriteLine("Initialising Main Window");
            Hide();
            MainStore.Initialise();

            Logging.WriteLine("Loading Data");
            var d = MainStore.Load();
            Logging.WriteLine("Finished Loading Data");

            Data = d.DataProvider;
            Watchers = d.Watchers;

            if (Watchers.Count == 0)
            {
                Show();
            }
            else
            {
                NotificationSystem.Default.Push(NotifcationType.Info, "Janus", "Started in minimised mode. Double click 'Ja' icon to interact.");
            }
            ListBox.ItemsSource = Watchers;
            Watchers.CollectionChanged += Watchers_CollectionChanged;

            CbStartup.IsChecked = File.Exists(Shortcut);
        }

        private static void Watchers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            UpdateStore();
        }

        public static void UpdateStore()
        {
            Logging.WriteLine("Saving Data");
            MainStore.Store(new JanusData(Watchers, Data));
            Logging.WriteLine("Finished Saving Data");
        }

        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            if (btn?.DataContext is Watcher watcher)
            {
                watcher.Stop();
                Watchers.Remove(watcher);
            }

            //NotificationSystem.Default.Push(NotifcationType.Info, "Removed Watcher", "Removed watcher successfully.");
        }

        private async void btnSync_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;
            if (btn?.DataContext is Watcher watcher)
                await watcher.SynchroniseAsync().ConfigureAwait(false);
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;
            if (btn?.DataContext is Watcher watcher)
                UpdateStore();
        }

        private void CbStartup_OnClick(object sender, RoutedEventArgs e)
        {
            if (!CbStartup.IsChecked.HasValue) return;

            if (CbStartup.IsChecked.Value)
            {
                AddToStartup();
            }
            else
            {
                RemoveFromStartup();
            }
        }

        private static void RemoveFromStartup()
        {
            if (File.Exists(Shortcut))
            {
                File.Delete(Shortcut);
            }
        }

        private static void AddToStartup()
        {
            using (var writer = new StreamWriter(Shortcut))
            {
                var app = Assembly.GetExecutingAssembly().Location;
                writer.WriteLine("[InternetShortcut]");
                writer.WriteLine("URL=file:///" + app);
                writer.WriteLine("IconIndex=0");
                var icon = app.Replace('\\', '/');
                writer.WriteLine("IconFile=" + icon);
                writer.Flush();
            }
        }

        private void TrayIcon_OnTrayMouseDoubleClick(object sender, RoutedEventArgs e)
        {
            Show();
        }

        private void MainWindow_OnClosing(object sender, CancelEventArgs e)
        {
            if (Exiting) return;

            e.Cancel = true;
            Hide();
        }

        private void MenuItem_OnClick(object sender, RoutedEventArgs e)
        {
            Show();
        }

        private void Exit_OnClick(object sender, RoutedEventArgs e)
        {
            Exiting = true;
            Close();
        }


    }
}

{'fraction_non_alphanumeric': 0.0844369212386737, 'fraction_numerical': 0.0003982873643333665, 'mean_word_length': 1.5518292682926829, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5685270', 'n_tokens_mistral': 2532, 'n_tokens_neox': 2372, 'n_words': 567}