/// <summary> /// Closes the application. /// </summary> private void ExitApplication() { MainWindow.Close(); NotifyIcon.Dispose(); NotifyIcon = null; HotkeyListener.Dispose(); HotkeyListener = null; Shutdown(1); }
/// <summary> /// Called when the machine state changes. /// Needed to reattach the hotkey listener after a machine went to sleep and woke up again. /// </summary> /// <param name="sender">The class that triggered the event</param> /// <param name="e">The event</param> private void ListenerEvent(object sender, CustomEventArgs e) { if ((bool)e.Value) // True if the event is a log in/wake up { HotkeyListener?.Dispose(); HotkeyListener = new HotkeyListener(); ASDL.ReattachHotkeyListener(HotkeyListener); } }