public void SetUp() { this.shortcutsMananger = new ShortcutsManager(); this.shortcut = new NiceShortcut(); this.shortcut.Name = "Winamp"; this.shortcut.Command = "Winamp"; this.shortcut.KeyCode = System.Windows.Forms.Keys.W; this.shortcut.Control = true; }
private void RegisteShortcut(NiceShortcut shortcut, Form form) { shortcut.Pressed += delegate { try { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = shortcut.Command; Process.Start(startInfo); } catch(Exception ex) { ShortcutsManager.ShowError(string.Format("Whoops, fail to execute command '{0}'.\n {1}", shortcut.Command, ex.Message)); } }; if (shortcut.GetCanRegister(form)) shortcut.Register(form); else ShortcutsManager.ShowError("Whoops, looks like attempts to register will fail or throw an exception, show an error/visual user feedback"); }
public void UnregisterShortcut(NiceShortcut shortcut) { if (shortcut.Registered) shortcut.Unregister(); }
public void SetUp() { this.shortcut = new NiceShortcut(); }