<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
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.Shapes;
using GW2PAO.ViewModels;

namespace GW2PAO.Views
{
    /// <summary>
    /// Interaction logic for ShellView.xaml
    /// </summary>
    [Export]
    public partial class ShellView : OverlayWindow
    {
        [Import]
        private ShellViewModel ViewModel
        {
            set
            {
                this.DataContext = value;
            }
        }

        public ShellView()
        {
            // All overlay windows created will be children of this window
            OverlayWindow.OwnerWindow = this;

            InitializeComponent();

            this.Left = Properties.Settings.Default.OverlayIconX;
            this.Top = Properties.Settings.Default.OverlayIconY;

            this.Loaded += ShellView_Loaded;
            this.Closed += ShellView_Closed;
        }

        private void ShellView_Loaded(object sender, RoutedEventArgs e)
        {
            if (Properties.Settings.Default.FirstTimeRun)
            {
                Task.Factory.StartNew(() =>
                {
                    System.Threading.Thread.Sleep(500);
                    this.Dispatcher.Invoke(() => this.NowRunningPopup.IsOpen = true);
                });
            }
        }

        private void ShellView_Closed(object sender, EventArgs e)
        {
            this.TrayIcon.Dispose();
        }

        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    this.DragMove();<commit_msg>Fixed issue where the tray icon was not properly cleaned up when closing the program.<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
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.Shapes;
using GW2PAO.Infrastructure;
using GW2PAO.Utility;
using GW2PAO.ViewModels;
using Microsoft.Practices.Prism.Commands;

namespace GW2PAO.Views
{
    /// <summary>
    /// Interaction logic for ShellView.xaml
    /// </summary>
    [Export]
    public partial class ShellView : OverlayWindow
    {
        [Import]
        private ShellViewModel ViewModel
        {
            set
            {
                this.DataContext = value;
            }
        }

        public ShellView()
        {
            // All overlay windows created will be children of this window
            OverlayWindow.OwnerWindow = this;

            InitializeComponent();

            this.Left = Properties.Settings.Default.OverlayIconX;
            this.Top = Properties.Settings.Default.OverlayIconY;

            this.Loaded += ShellView_Loaded;

            Commands.ApplicationShutdownCommand.RegisterCommand(new DelegateCommand(this.CleanupTrayIcon));

            this.Closing += ShellView_Closing;
        }

        private void ShellView_Loaded(object sender, RoutedEventArgs e)
        {
            if (Properties.Settings.Default.FirstTimeRun)
            {
                Task.Factory.StartNew(() =>
                {
                    System.Threading.Thread.Sleep(500);
                    this.Dispatcher.Invoke(() => this.NowRunningPopup.IsOpen = true);
                });
            }
        }

        private void CleanupTrayIcon()
        {
            Threading.InvokeOnUI(() => this.TrayIcon.Dispose());
        }

        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    this.DragMove();
{'fraction_non_alphanumeric': 0.09022038567493113, 'fraction_numerical': 0.0027548209366391185, 'mean_word_length': 1.9599184782608696, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, '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': '1529787', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1112, 'n_words': 233}