<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using NHotkey;
using NHotkey.Wpf;
using Squirrel;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure.Hotkey;
using Wox.Plugin;
using Wox.ViewModel;

namespace Wox
{
    public class PublicAPIInstance : IPublicAPI
    {
        private Settings _settings;
        #region Constructor

        public PublicAPIInstance(MainViewModel mainVM, Settings settings)
        {
            MainVM = mainVM;
            _settings = settings;
            GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
            WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
            SetHotkey(_settings.Hotkey, OnHotkey);
            SetCustomPluginHotkey();

        }

        #endregion

        #region Properties

        public MainViewModel MainVM
        {
            get;
            set;
        }

        #endregion

        #region Public API

        public void ChangeQuery(string query, bool requery = false)
        {
            MainVM.QueryText = query;
            MainVM.OnCursorMovedToEnd();
        }

        public void ChangeQueryText(string query, bool selectAll = false)
        {
            MainVM.QueryText = query;
            MainVM.OnTextBoxSelected();
        }

        public void CloseApp()
        {
            //notifyIcon.Visible = false;
            Application.Current.Shutdown();
        }

        public void RestarApp()
        {
            UpdateManager.RestartApp();
        }

        public void HideApp()
        {<commit_msg>Dispose when restart<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using NHotkey;
using NHotkey.Wpf;
using Squirrel;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure.Hotkey;
using Wox.Plugin;
using Wox.ViewModel;

namespace Wox
{
    public class PublicAPIInstance : IPublicAPI
    {
        private Settings _settings;
        #region Constructor

        public PublicAPIInstance(MainViewModel mainVM, Settings settings)
        {
            MainVM = mainVM;
            _settings = settings;
            GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
            WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
            SetHotkey(_settings.Hotkey, OnHotkey);
            SetCustomPluginHotkey();

        }

        #endregion

        #region Properties

        public MainViewModel MainVM
        {
            get;
            set;
        }

        #endregion

        #region Public API

        public void ChangeQuery(string query, bool requery = false)
        {
            MainVM.QueryText = query;
            MainVM.OnCursorMovedToEnd();
        }

        public void ChangeQueryText(string query, bool selectAll = false)
        {
            MainVM.QueryText = query;
            MainVM.OnTextBoxSelected();
        }

        public void CloseApp()
        {
            //notifyIcon.Visible = false;
            Application.Current.Shutdown();
        }

        public void RestarApp()
        {
            // we must force dispose application
            // UpdateManager.RestartApp() will call Environment.Exit(0)
            // which will cause ungraceful exit
            ((IDisposable) Application.Current).Dispose();
            UpdateManager.RestartApp();
        }

        public void HideApp()
        {
{'fraction_non_alphanumeric': 0.0780708766320277, 'fraction_numerical': 0.0002664535038635758, 'mean_word_length': 2.061990212071778, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6476986', 'n_tokens_mistral': 997, 'n_tokens_neox': 976, 'n_words': 232}