<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Animation;
using EDEngineer.Models;
using EDEngineer.Utils;
using EDEngineer.Utils.System;
using EDEngineer.Utils.UI;
using Application = System.Windows.Application;
using Button = System.Windows.Controls.Button;
using DataGridCell = System.Windows.Controls.DataGridCell;

namespace EDEngineer
{
    public partial class MainWindow
    {
        private readonly MainWindowViewModel viewModel;

        public MainWindow()
        {
            var procName = Process.GetCurrentProcess().ProcessName;
            var processes = Process.GetProcessesByName(procName);

            if (processes.Length > 1)
            {
                System.Windows.Forms.MessageBox.Show($"EDEngineer already running, you can bring it up with your shortcut ({SettingsManager.Shortcut}).",
                    "Oops", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Application.Current.Shutdown();
                return;
            }

            SettingsManager.Init();
            InitializeComponent();
            viewModel = new MainWindowViewModel();
            DataContext = viewModel;

            var blueprintsView = new CollectionViewSource {Source = viewModel.Blueprints}.View;
            viewModel.Filters.Monitor(blueprintsView, viewModel.State.Cargo.Select(c => c.Value));
            Blueprints.ItemsSource = blueprintsView;

            Commodities.ItemsSource = viewModel.FilterView(Kind.Commodity, new CollectionViewSource { Source = viewModel.State.Cargo }.View);
            Materials.ItemsSource = viewModel.FilterView(Kind.Material, new CollectionViewSource { Source = viewModel.State.Cargo }.View);
            Data.ItemsSource = viewModel.FilterView(Kind.Data, new CollectionViewSource { Source = viewModel.State.Cargo }.View);
        }

        private void MainWindowLoaded(object sender, RoutedEventArgs args)
        {
            Opacity = 1;

            var dimensions = SettingsManager.Dimensions;

            Width = dimensions.Width;
            Left = dimensions.Left;

            if (AllowsTransparency)
            {
                Top = dimensions.Top;
                Height = dimensions.Height;
                ToggleEditMode.Content = "Unlock Window";
            }
            else
            {
                Top = dimensions.Top - SystemInformation.ToolWindowCaptionHeight;
                Height = dimensions.Height + SystemInformation.ToolWindowCaptionHeight;
                ToggleEditMode.Content = "Lock Window";
                ResetWindowPositionButton.Visibility = Visibility.Visible;
                ShowZeroesToggleButton.Visibility = Visibility.Hidden;
            }

            icon = TrayIconManager.Init((o, e) => ShowWindow(), (o, e) => Close(), ConfigureShortcut);

            var shortcut = SettingsManager.Shortcut;

            HotkeyManager.RegisterHotKey(this, (Keys)new KeysConverter().ConvertFromString(shortcut));
        }

        private void ConfigureShortcut(object sender, EventArgs e)
        {
            string shortcut;<commit_msg>cleanup<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Animation;
using EDEngineer.Models;
using EDEngineer.Utils;
using EDEngineer.Utils.System;
using EDEngineer.Utils.UI;
using Application = System.Windows.Application;
using Button = System.Windows.Controls.Button;
using DataGridCell = System.Windows.Controls.DataGridCell;

namespace EDEngineer
{
    public partial class MainWindow
    {
        private readonly MainWindowViewModel viewModel;

        public MainWindow()
        {
            var procName = Process.GetCurrentProcess().ProcessName;
            var processes = Process.GetProcessesByName(procName);

            if (processes.Length > 1)
            {
                System.Windows.Forms.MessageBox.Show($"EDEngineer already running, you can bring it up with your shortcut ({SettingsManager.Shortcut}).",
                    "Oops", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Application.Current.Shutdown();
                return;
            }
            
            SettingsManager.Init();
            InitializeComponent();
            viewModel = new MainWindowViewModel();
            DataContext = viewModel;

            var blueprintsView = new CollectionViewSource {Source = viewModel.Blueprints}.View;
            viewModel.Filters.Monitor(blueprintsView, viewModel.State.Cargo.Select(c => c.Value));
            Blueprints.ItemsSource = blueprintsView;

            Commodities.ItemsSource = viewModel.FilterView(Kind.Commodity, new CollectionViewSource { Source = viewModel.State.Cargo }.View);
            Materials.ItemsSource = viewModel.FilterView(Kind.Material, new CollectionViewSource { Source = viewModel.State.Cargo }.View);
            Data.ItemsSource = viewModel.FilterView(Kind.Data, new CollectionViewSource { Source = viewModel.State.Cargo }.View);
        }

        private void MainWindowLoaded(object sender, RoutedEventArgs args)
        {
            var dimensions = SettingsManager.Dimensions;

            Width = dimensions.Width;
            Left = dimensions.Left;

            if (AllowsTransparency)
            {
                Top = dimensions.Top;
                Height = dimensions.Height;
                ToggleEditMode.Content = "Unlock Window";
            }
            else
            {
                Top = dimensions.Top - SystemInformation.ToolWindowCaptionHeight;
                Height = dimensions.Height + SystemInformation.ToolWindowCaptionHeight;
                ToggleEditMode.Content = "Lock Window";
                ResetWindowPositionButton.Visibility = Visibility.Visible;
                ShowZeroesToggleButton.Visibility = Visibility.Hidden;
            }

            icon = TrayIconManager.Init((o, e) => ShowWindow(), (o, e) => Close(), ConfigureShortcut);

            var shortcut = SettingsManager.Shortcut;

            HotkeyManager.RegisterHotKey(this, (Keys)new KeysConverter().ConvertFromString(shortcut));
        }

        private void ConfigureShortcut(object sender, EventArgs e)
        {
            string shortcut;
{'fraction_non_alphanumeric': 0.08635178209214721, 'fraction_numerical': 0.00043465662126919734, 'mean_word_length': 2.5454545454545454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5736205', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1686, 'n_words': 365}