private void Window_Loaded(object sender, RoutedEventArgs e) { HotKeyHost hotKeyHost = new HotKeyHost((HwndSource)HwndSource.FromVisual(App.Current.MainWindow)); hotKeyHost.AddHotKey(new CustomHotKey("SumClipboard", Key.F5, ModifierKeys.Control, true)); hotKeyHost.AddHotKey(new CustomHotKey("AddClipboard", Key.F6, ModifierKeys.Control, true)); hotKeyHost.HotKeyPressed += pressevent; }
private void InitialiseHotKey(Window window) { _hotKeyHost = new HotKeyHost(window); _hotKeyHost.AddHotKey(_showCommandHotKey); _hotKeyHost.AddHotKey(_showProcessHotKey); _hotKeyHost.AddHotKey(_showClipboardHotKey); _hotKeyHost.AddHotKey(_showDirHotKey); // _hotKeyHost.AddHotKey(_showSettingsHotKey); }
private void assignHotkeys(object sender, RoutedEventArgs e) { hotkeyHost = new HotKeyHost((HwndSource)HwndSource.FromVisual(this)); hotkeyHost.AddHotKey(new ShowUserListHotkey("ShowUserListHotkey", Key.U, ModifierKeys.Control | ModifierKeys.Shift, true)); hotkeyHost.AddHotKey(new ShowServerChatHotkey("ShowServerChatHotkey", Key.S, ModifierKeys.Shift | ModifierKeys.Control, true)); hotkeyHost.AddHotKey(new ShowGameListHotkey("ShowGameListHotkey", Key.G, ModifierKeys.Shift | ModifierKeys.Control, true)); hotkeyHost.AddHotKey(new BeginDisconnectHotkey("BeginDisconnectHotkey", Key.D, ModifierKeys.Control | ModifierKeys.Shift, true)); hotkeyHost.AddHotKey(new MinimizeAllWindowsHotkey("MinimizeAllWindowsHotkey", Key.M, ModifierKeys.Shift | ModifierKeys.Control, true)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { HotKeyHost hotKeyHost = new HotKeyHost((HwndSource)HwndSource.FromVisual(App.Current.MainWindow)); hotKeyHost.AddHotKey(new CustomHotKey("Execute", Key.F5, ModifierKeys.None, true, new EventHandler(delegate { btnExecute_Click(sender, e); }))); this.LoadParamSet(); }
private void ConfigureHotKeys() { foreach (HotKey h in _config.Fields.Elpis_HotKeys.Values) { _keyHost.AddHotKey(h); } if (new List <HotKey>(_config.Fields.Elpis_HotKeys.Values).Count == 0) { _keyHost.AddHotKey(new HotKey(PlayerCommands.PlayPause, Key.Space, ModifierKeys.None, false, true)); _keyHost.AddHotKey(new HotKey(PlayerCommands.PlayPause, Key.MediaPlayPause, ModifierKeys.None, true, true)); _keyHost.AddHotKey(new HotKey(PlayerCommands.Next, Key.Right, ModifierKeys.None, false, true)); _keyHost.AddHotKey(new HotKey(PlayerCommands.Next, Key.MediaNextTrack, ModifierKeys.None, true, true)); _keyHost.AddHotKey(new HotKey(PlayerCommands.ThumbsUp, Key.Up, ModifierKeys.None, false, true)); _keyHost.AddHotKey(new HotKey(PlayerCommands.ThumbsDown, Key.Down, ModifierKeys.None, false, true)); } Dictionary <int, HotkeyConfig> keys = new Dictionary <int, HotkeyConfig>(); foreach (KeyValuePair <int, HotKey> pair in _keyHost.HotKeys) { keys.Add(pair.Key, new HotkeyConfig(pair.Value)); } _config.Fields.Elpis_HotKeys = keys; _config.SaveConfig(); }
public void register_hotkey() { HotKeyHost hotKeyHost = new HotKeyHost((HwndSource)HwndSource.FromVisual(this)); HotKey hotkey = new HotKey(Key.P, ModifierKeys.Shift | ModifierKeys.Control, true); hotkey.HotKeyPressed += new EventHandler <HotKeyEventArgs>(delegate(Object o, HotKeyEventArgs e) { AppController.Current.open_compose_window(); }); hotKeyHost.AddHotKey(hotkey); }
private void OverlayMenu_Click(object sender, RoutedEventArgs e) { overlay = new Overlay(); overlay.SetCurrentClient(MyClient); overlay.Show(); IEnumerable<Monitor> monitors = Monitor.AllMonitors; foreach (Monitor mymonitor in monitors) { if (mymonitor.IsPrimary == true) { overlay.Left = mymonitor.Bounds.Right - overlay.Width; overlay.Top = mymonitor.Bounds.Top; } } overlay.Topmost = true; HotKeyHost hotKeyHost = new HotKeyHost((HwndSource) PresentationSource.FromVisual(Application.Current.MainWindow)); hotKeyHost.AddHotKey(new CustomHotKey("ToggleOverlay", Key.O, ModifierKeys.Control | ModifierKeys.Alt, true)); hotKeyHost.HotKeyPressed += handleHotkeyPress; }
public void register_hotkey() { HotKeyHost hotKeyHost = new HotKeyHost((HwndSource)HwndSource.FromVisual(this)); HotKey hotkey = new HotKey(Key.P, ModifierKeys.Shift|ModifierKeys.Control, true); hotkey.HotKeyPressed += new EventHandler<HotKeyEventArgs>(delegate(Object o, HotKeyEventArgs e) { AppController.Current.open_compose_window(); }); hotKeyHost.AddHotKey(hotkey); }
private void btnAddHotKey_Click(object sender, RoutedEventArgs e) { _keyHost.AddHotKey(new HotKey(PlayerCommands.PlayPause, Key.None, ModifierKeys.None)); }
private void OverlayMenu_Click(object sender, RoutedEventArgs e) { if (_overlay == null) { _overlay = new Overlay(); _overlay.SetCurrentClient(MyClient); _overlay.Show(); IEnumerable<Monitor> monitors = Monitor.AllMonitors; if (Settings.Default.OverlayMonitor != "") { Logger.Debug("Overlaymonitor is" + Settings.Default.OverlayMonitor); foreach (Monitor mymonitor in monitors) { if (mymonitor.Name == Settings.Default.OverlayMonitor) { _overlay.Left = mymonitor.Bounds.Right - _overlay.Width; _overlay.Top = mymonitor.Bounds.Top; _overlay.Topmost = true; Logger.Debug("Overlay coordinates set to " + _overlay.Left + " x " + _overlay.Top); HotKeyHost hotKeyHost = new HotKeyHost((HwndSource)PresentationSource.FromVisual(Application.Current.MainWindow)); //hotKeyHost.AddHotKey(new CustomHotKey("ToggleOverlay", Key.O, ModifierKeys.Control | ModifierKeys.Alt , true)); //hotKeyHost.AddHotKey(new CustomHotKey("CopyClientSystemname", Key.C, ModifierKeys.Control | ModifierKeys.Alt , true)); //hotKeyHost.HotKeyPressed += HandleHotkeyPress; // Broken all of a sudden? May require recode. } } } else { foreach (Monitor mymonitor in monitors) { Logger.Debug("Monitor ID: " + mymonitor.Name); if (mymonitor.IsPrimary) { _overlay.Left = mymonitor.Bounds.Right - _overlay.Width; _overlay.Top = mymonitor.Bounds.Top; } } _overlay.Topmost = true; HotKeyHost hotKeyHost = new HotKeyHost((HwndSource)PresentationSource.FromVisual(Application.Current.MainWindow)); hotKeyHost.AddHotKey(new CustomHotKey("ToggleOverlay", Key.O, ModifierKeys.Control | ModifierKeys.Alt, true)); hotKeyHost.AddHotKey(new CustomHotKey("CopyClientSystemname", Key.C, ModifierKeys.Control | ModifierKeys.Alt, true)); hotKeyHost.HotKeyPressed += HandleHotkeyPress; } } else { _overlay.Close(); } }
/////////////////////////////////////////// #endregion #region Event Handlers // Loaded event for this MainWindow [E] void MainWindow_Loaded(object sender, RoutedEventArgs e) { #region HotKeys Registrtion // Associate Hot Keys >>> HotKeyHost KeyHost = new HotKeyHost((HwndSource)HwndSource.FromVisual(this)); HotKey[] hotKeys = new HotKey[11]; hotKeys[0] = new HotKey(Key.Home, ModifierKeys.Control | ModifierKeys.Alt, true); hotKeys[1] = new HotKey(Key.PageDown, ModifierKeys.Control | ModifierKeys.Alt, true); hotKeys[2] = new HotKey(Key.PageUp, ModifierKeys.Control | ModifierKeys.Alt, true); hotKeys[3] = new HotKey(Key.Right, ModifierKeys.Control | ModifierKeys.Alt, true); hotKeys[4] = new HotKey(Key.Left, ModifierKeys.Control | ModifierKeys.Alt, true); hotKeys[5] = new HotKey(Key.Up, ModifierKeys.Control | ModifierKeys.Alt, true); hotKeys[6] = new HotKey(Key.Down, ModifierKeys.Control | ModifierKeys.Alt, true); hotKeys[7] = new HotKey(Key.MediaPlayPause, ModifierKeys.None, true); hotKeys[8] = new HotKey(Key.MediaNextTrack, ModifierKeys.None, true); hotKeys[9] = new HotKey(Key.MediaPreviousTrack, ModifierKeys.None, true); hotKeys[10] = new HotKey(Key.End, ModifierKeys.Alt | ModifierKeys.Control, true); // <--- hotKeys[0].HotKeyPressed += (o, s) => { PlayPause(); }; hotKeys[1].HotKeyPressed += (o, s) => { PlayNext(); }; hotKeys[2].HotKeyPressed += (o, s) => { PlayPrevious(); }; hotKeys[3].HotKeyPressed += (o, s) => { seekForward(2000); }; hotKeys[4].HotKeyPressed += (o, s) => { seekBackword(2000); }; hotKeys[5].HotKeyPressed += (o, s) => { VolumeUp(); }; hotKeys[6].HotKeyPressed += (o, s) => { VolumeDown(); }; hotKeys[7].HotKeyPressed += (o, s) => { PlayPause(); }; hotKeys[8].HotKeyPressed += (o, s) => { PlayNext(); }; hotKeys[9].HotKeyPressed += (o, s) => { PlayPrevious(); }; hotKeys[10].HotKeyPressed += (o, s) => { StopPlay(); }; foreach (HotKey hKey in hotKeys) { try { KeyHost.AddHotKey(hKey); } catch { continue; } } #endregion // Reading User Preferences from Registry >>> ReadRegistrys(); // Window DragMove Logic >>> this.MouseLeftButtonDown += (o, s) => { if (s.LeftButton == MouseButtonState.Pressed) { this.DragMove(); } }; // initialize ISoundEngine instance...! soundEngine = new ISoundEngine(); // initialize PlayerEvents class instance with event handlers...! player_events = new PlayerEvents(); player_events.TimerInterval = TimeSpan.FromSeconds(0.8); player_events.IsTimerEnable = false; player_events.OnTimerTick += player_events_OnTimerTick; player_events.OnSoundFinished += player_events_OnSoundFinished; // initialize HoverCountdown instance, to manage visibility for elements...! HoverVisibility = new HoverCountdown(this, TimeSpan.FromSeconds(5)); HoverVisibility.OnMouseMove += HoverVisibility_OnMouseMove; HoverVisibility.OnTimeElapsed += HoverVisibility_OnTimeElapsed; // Adding command arguments to the play list >> string[] cmdArg = Environment.GetCommandLineArgs(); if (cmdArg.Length > 1) { ////////////////////////////////////////////// fileManager.AddFiles(cmdArg, false, true); ////////////////////////////////////////////// } }
private void Window_Loaded(object sender, RoutedEventArgs e) { HotKeyHost hotKeyHost = new HotKeyHost((HwndSource)HwndSource.FromVisual(App.Current.MainWindow)); hotKeyHost.AddHotKey(new CustomHotKey("ToggleOverlay", Key.F1, ModifierKeys.None, true,this)); hotKeyHost.AddHotKey(new CustomHotKey("ToggleBot", Key.F2, ModifierKeys.None, true, this)); hotKeyHost.AddHotKey(new CustomHotKey("ChangeBotMode", Key.F3, ModifierKeys.None, true, this)); backgroundWorker.WorkerReportsProgress = true; backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.DoWork += backgroundWorker_DoWork; backgroundWorker.ProgressChanged += backgroundWorker_ProgressChanged; LoadBots(); var le = new LogEntry(); le.BotScriptInfo = "init"; le.EnemyScriptInfo = "init"; le.Message = "Loaded!"; log.Insert(0, le); System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 5); // dispatcherTimer.Start(); }