Пример #1
0
        private void OnWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            this.Hide();
            // Dispose tray icon
            if (TrayIcon != null)
            {
                TrayIcon.NotifyIcon.Click -= OnTrayIconClick;
                TrayIcon.ContextMenu.MenuItems[0].Click -= OnTrayIconSettingsClick;
                TrayIcon.ContextMenu.MenuItems[1].Click -= OnTrayIconExitClick;
                TrayIcon.Dispose();
            }

            // Dispose stuff & stop scanning threads
            GameOverlay?.Dispose();
            if (MonsterHunter.IsActive)
            {
                MonsterHunter.StopScanning();
            }
            Discord?.Dispose();
            Scanner.StopScanning();
            UserSettings.RemoveFileWatcher();
            Settings.Instance.UninstallKeyboardHook();
            // Unhook events
            if (MonsterHunter.Player != null)
            {
                UnhookGameEvents();
            }
            this.RemoveHotKeys();
            this.UnhookEvents();
        }
Пример #2
0
 public void OnGameClose(object source, EventArgs e)
 {
     UnhookGameEvents();
     Discord.Dispose();
     Discord = null;
     if (UserSettings.PlayerConfig.HunterPie.Options.CloseWhenGameCloses)
     {
         Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => {
             this.Close();
         }));
     }
     MonsterHunter.StopScanning();
     Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => {
         GameOverlay.Dispose();
         GameOverlay = null;
     }));
     MonsterHunter.DestroyInstances();
 }