private void ResetSettings() { try { _settings = WindowManagerSettings.Load(); } catch (Exception) { _settings = WindowManagerSettings.GetDefault(); _settings.Save(); } _settingsGrid.DataContext = _settings; if (_hotKeyManager != null) { _hotKeyManager.Dispose(); _hotKeyManager = null; } WindowManagerSettings s = _settings.Clone(); _hotKeyManager = new HotKeyManager(s); if (_hotKeyManager.Errors.Any()) { MessageBox.Show(_hotKeyManager.Errors.Aggregate((buff, a) => buff + "\n" + a), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { KeyboardUtilities.Disconnect(); hkm.Enabled = false; ArrayList tmp = new ArrayList(); foreach (GlobalHotKey a in hkm.EnumerateGlobalHotKeys) { tmp.Add(a); } foreach (GlobalHotKey VARIABLE in tmp) { hkm.RemoveGlobalHotKey(VARIABLE); } hkm.Dispose(); if (a != null) { if (a.f != null) { a.f.Dispose(); RainbowMage.HtmlRenderer.Renderer.Shutdown(); } } StopKeyPlay(); timeEndPeriod(1); }
//if (msg == (int)User32.WindowMessage.WM_SYSCOMMAND) //{ // // Execute the appropriate code for the System Menu item that was clicked // int int32 = wParam.ToInt32(); // if (int32 == DefaultTransparencyMenuId) // { // ClearTransparency(); // } // else if (int32 > TransparencyPercentId && int32 <= TransparencyPercentId + 100) // { // double percent = (int32 - TransparencyPercentId) / 100d; // byte transparency = (byte)(byte.MaxValue * percent); // SetTransparency(transparency); // } //} //return IntPtr.Zero; private void SettingsChanged() { if (_hotKeyManager != null) { _hotKeyManager.Dispose(); _hotKeyManager = null; } Settings s = _settings.Clone(); _hotKeyManager = new HotKeyManager(s); if (_hotKeyManager.Errors.Any()) { MessageBox.Show(_hotKeyManager.Errors.Aggregate((buff, a) => buff + "\n" + a), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void SetupHook() { var hotKeyManager = new HotKeyManager(); try { hotKeyManager.Register(Key.None, ModifierKeys.Alt); hotKeyManager.KeyPressed += (_, _) => { if (!Helper.GetSettings().OpenByHotKey) { return; } if (DateTime.Now - _lastKeyPressedTime > TimeSpan.FromMilliseconds(400)) { _lastKeyPressedTime = DateTime.Now; return; } foreach (var mainWindow in Helper.GetWindow <MainWindow>()) { mainWindow.ShowMainWindow(); } }; } catch (Exception ex) { hotKeyManager.Dispose(); ex.Log(); } }
public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { var hotKeyManager = new HotKeyManager(); var hotKeySubscription = hotKeyManager.Register(VirtualKeyCode.KEY_1, Modifiers.Shift); desktop.Exit += (sender, args) => { hotKeySubscription.Dispose(); hotKeyManager.Dispose(); }; var mainViewModel = new MainViewModel(); hotKeyManager.HotKeyPressed .ObserveOn(Avalonia.Threading.AvaloniaScheduler.Instance) .Subscribe(hotKey => mainViewModel.Text += $"HotKey: Id={hotKey.Id}, Key={hotKey.Key}, Modifiers={hotKey.Modifiers}{Environment.NewLine}"); desktop.MainWindow = new MainWindow { DataContext = mainViewModel }; } base.OnFrameworkInitializationCompleted(); }
//This method is called when the program closes to dispose and unregister the hotkeys private void MainWindow_FormClosed(object sender, FormClosedEventArgs e) { hkManager.Unregister(soloPublicKey); hkManager.Unregister(afkKey); hkManager.Dispose(); }
public void Register_hotkey_and_then_dispose_hotkeyManager_and_check_that_it_disposed_correct() { var winApi = Substitute.For <IWinApi>(); winApi.RegisterHotKey(IntPtr.Zero, 0, Key.A, ModifierKeys.Alt).ReturnsForAnyArgs(true); var manager = new HotKeyManager(winApi); var hotKey = new HotKey(Key.T, ModifierKeys.Shift); var label = "test"; manager.Register(label, hotKey); var resultHotKey = manager.GetHotkey(label); var resultLabel = manager.GetLabel(hotKey); Assert.That(resultHotKey, Is.EqualTo(hotKey)); Assert.That(resultLabel, Is.EqualTo(label)); manager.Dispose(); resultHotKey = manager.GetHotkey(label); resultLabel = manager.GetLabel(hotKey); Assert.That(resultHotKey, Is.Null); Assert.That(resultLabel, Is.Null.Or.Empty); }
public void OnExit() { ProcessMemory.CloseHandle(memory.ProcessHandle); memory = null; hotKeyManager.KeyPressed -= OnKeyPressed; hotKeyManager.Dispose(); }
private void Exit(object sender, EventArgs e) { notifyIcon.Visible = false; notifyIcon.Dispose(); hkm.Unregister(Key.PrintScreen, ModifierKeys.None); hkm.Dispose(); Application.Exit(); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { hotKeyManager.Unregister(_hotKeyF10); hotKeyManager.Unregister(_hotKeyF12); // Dispose the hotkey manager. hotKeyManager.Dispose(); KeyboardUtilities.Disconnect(); }
public void Dispose() { Dispatcher.Invoke(() => { _taskbarIcon.Visibility = Visibility.Hidden; _taskbarIcon.Dispose(); _hotKeyManager.Dispose(); }); }
private void StopAndDisposeProcessesAndEvents() { _registryMonitor.Stop(); _registryMonitor.Dispose(); _hkManager.Dispose(); _menuStrip.Dispose(); _superNotifyIcon.Dispose(); Icon.Dispose(); }
private void exitToolStripMenuItem_Click(object sender, EventArgs e) { _rightHotkey.Dispose(); _leftHotkey.Dispose(); closeToTray = false; this.Close(); }
protected override void OnClosed(EventArgs e) { base.OnClosed(e); // ウィンドウを閉じる際に、タスクトレイのアイコンを削除する。 this._notify.Dispose(); // HotKeyの登録解除 HotKeyManager.Dispose(); }
private void ExitToolStripMenuItem_Click(object sender, EventArgs e) { _RightHotkey.Dispose(); _LeftHotkey.Dispose(); _NumberHotkey.Dispose(); _CloseToTray = false; Close(); }
protected virtual void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { _hotKeyManager?.Dispose(); } _disposedValue = true; } }
/// <summary> /// Clears all current active Shortcut listeners and reloads the shortcuts to listen /// </summary> public void Reload() { _managerSettings = Config.Instance.ShortcutManagerSettings; _hotkeyManager?.Dispose(); _hotkeyManager = new HotKeyManager(); _hotkeyManager.KeyPressed += HotKeyPressed; _hotkeyManager.Register(_managerSettings.JamesHotKey.HotKey.ToGlobalHotKey()); foreach (Shortcut item in _managerSettings.Shortcuts) { _hotkeyManager.Register(item.HotKey.ToGlobalHotKey()); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Unloaded(object sender, RoutedEventArgs e) { // Unregister Ctrl+Alt+Key hotkey. foreach (var btn in myApp.mainViewModel.ActionButtons) { if (btn.TheHotKey != null) { hotKeyManager.Unregister(btn.TheHotKey); } } // Dispose the hotkey manager. hotKeyManager.Dispose(); }
private void exitToolStripMenuItem_Click(object sender, EventArgs e) { _rightHotkey.Dispose(); _leftHotkey.Dispose(); _numberHotkey.Dispose(); bwCheckVirtualDesktop.CancelAsync(); bwSplashTimer.CancelAsync(); bwCheckVirtualDesktop.Dispose(); bwSplashTimer.Dispose(); closeToTray = false; this.Close(); }
public void Dispose() { SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged; if (_hotkeys) { HotKeyManager.Dispose(); } AudioSource.Dispose(); RecentViewModel.Dispose(); // Remember things if not console. if (_persist) { Remember(); Settings.Save(); } }
public void Dispose() { RecordingViewModel.Dispose(); if (_hotkeys) { HotKeyManager.Dispose(); } AudioSource.Dispose(); RecentViewModel.Dispose(); // Remember things if not console. if (_persist) { _rememberByName.Remember(); Settings.Save(); } }
public void Dispose() { _recordingModel.Dispose(); if (_hotkeys) { _hotKeyManager.Dispose(); } _audioSource.Dispose(); _recentList.Dispose(); // Remember things if not console. if (_persist) { _rememberByName.Remember(); _settings.Save(); } }
public void Execute(object parameter) { switch (parameter.ToString()) { case "ShowWindow": try { var hotkey = hkManager.Register(Key.Space, ModifierKeys.Alt); hkManager.KeyPressed += HkManager_KeyPressed; } catch { } Show(); break; case "Quit": hkManager.Dispose(); Application.Current.Shutdown(); break; } }
private void ExitApplication(object sender, EventArgs e) { _hotKeyManager.Dispose(); BarIcon.Dispose(); Application.Exit(); }
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { Trace.WriteLine("EXITING..."); _hotkeymanager.Dispose(); Application.Exit(); }
public static void Destroy() => _hotKeyManager.Dispose();
public static void Destroy() { _hotKeyManager.KeyPressed -= HotKeyManagerPressed; _hotKeyManager.Dispose(); }
private void App_OnExit(object sender, ExitEventArgs e) { DisposeMutex(); PowerManager?.Dispose(); HotKeyManager?.Dispose(); }
public void Dispose() { _hotkeymanager.Dispose(); }
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { _hotKeyManager.Dispose(); }