<commit_before>﻿using MahApps.Metro.Controls;
using Microsoft.Win32;
using Squirrel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;


namespace ScreamControl_WPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : MetroWindow
    {
        AlarmSystem _as;

        bool _closeGui, _mousePressed;
        float _actualHeight;
        float _alarmThreshold = 80;
        float AlarmThreshold
        {
            get
            {
                return _alarmThreshold;
            }
            set
            {
                if (_as != null)
                    _as.alarmThreshold = value;
                _alarmThreshold = value;
            }
        }

        delegate float MonitorVolumeCallback();

        public MainWindow()
        {
            InitializeComponent();

            App.LanguageChanged += LanguageChanged;
            CultureInfo currLang = App.Language;

            cbLang.Items.Clear();
            foreach (var lang in App.Languages)
            {
                ComboBoxItem cboxItem = new ComboBoxItem();
                cboxItem.Content = lang.NativeName;
                cboxItem.Tag = lang;
                cboxItem.IsSelected = lang.Equals(currLang);
                cbLang.Items.Add(cboxItem);
            }

            App.Language = currLang;


           
#if !DEBUG
            //Autostart
            if (!IsStartupItem())
            {
                RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                Assembly curAssembly = Assembly.GetExecutingAssembly();
                key.SetValue(curAssembly.GetName().Name, curAssembly.Location);
            }

            //Update
            using (var mgr = UpdateManager.GitHubUpdateManager("https://github.com/YSXrus/Scream-Control"))
            {
                await mgr.Result.UpdateApp(); //TODO: fix async execution
            }
#endif
        }

        private bool IsStartupItem()
        {
            RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            if (rkApp.GetValue("Scream Control") == null)
                return false;
            else
                return true;
        }

        #region Window initialization and things

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {<commit_msg>Preparation before update<commit_after>﻿using MahApps.Metro.Controls;
using Microsoft.Win32;
using Squirrel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;


namespace ScreamControl_WPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : MetroWindow
    {
        AlarmSystem _as;

        bool _closeGui, _mousePressed;
        float _actualHeight;
        float _alarmThreshold = 80;
        float AlarmThreshold
        {
            get
            {
                return _alarmThreshold;
            }
            set
            {
                if (_as != null)
                    _as.alarmThreshold = value;
                _alarmThreshold = value;
            }
        }

        delegate float MonitorVolumeCallback();

        public MainWindow()
        {
            InitializeComponent();

            App.LanguageChanged += LanguageChanged;
            CultureInfo currLang = App.Language;

            cbLang.Items.Clear();
            foreach (var lang in App.Languages)
            {
                ComboBoxItem cboxItem = new ComboBoxItem();
                cboxItem.Content = lang.NativeName;
                cboxItem.Tag = lang;
                cboxItem.IsSelected = lang.Equals(currLang);
                cbLang.Items.Add(cboxItem);
            }

            App.Language = currLang;
           
            //Update
#if !DEBUG
            //Autostart
            if (!IsStartupItem())
            {
                RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                Assembly curAssembly = Assembly.GetExecutingAssembly();
                key.SetValue(curAssembly.GetName().Name, curAssembly.Location);
            }

            Update();
#endif
        }

        private async void Update()
        {
            using (var mgr = UpdateManager.GitHubUpdateManager("https://github.com/YSXrus/Scream-Control"))
            {
               await mgr.Result.UpdateApp();
            }
        }

        private bool IsStartupItem()
        {
            RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            if (rkApp.GetValue("Scream Control") == null)
                return false;
            else
                return true;
        }

        #region Window initialization and things

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
{'fraction_non_alphanumeric': 0.088107202680067, 'fraction_numerical': 0.001340033500837521, 'mean_word_length': 1.84604385128694, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '4106170', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1493, 'n_words': 333}