public void AddHotkey(Hotkey hotkey) { var result = hotkeyListener.Add(hotkey); if (!result) { logService.AddEntry(this, $"Failed to add Hotkey {hotkey} to the listener", Enum.LogLevel.Error); } }
public void InitializeKeybinds() { Hotkey startCombat = new Hotkey(Keys.Control, Keys.Q); startListener.Add(startCombat); startListener.HotkeyPressed += ToggleCombatMode; }
public Keybinds() { Hotkey screenshootButton = new Hotkey(Keys.Control, Keys.P); listener.Add(screenshootButton); listener.HotkeyPressed += TakeScreenshot; }
public MainForm() { InitializeComponent(); var hk = new HotkeyListener(); Hotkey unlockHotKey = new Hotkey(Keys.Control | Keys.M); hk.Add(unlockHotKey); hk.HotkeyPressed += HKPressedEvent; }
private void Form1_Load(object sender, EventArgs e) { txtSeconds.Value = 1; hotkeyListener.Add(new[] { hkStart, hkStop }); hotkeyListener.HotkeyPressed += Hkl_HotkeyPressed; mainTimer.Tick += MainTimer_Run; delayTimer.Tick += DelayTimer_Run; UpdateStatus(); }
public HotkeyListenerService(IEventBus eventBus, ISettingsService settingsService, HotkeyListener hotkeyListener, ILogService logService) : base(eventBus) { this.hotkeyListener = hotkeyListener; this.settingsService = settingsService; this.logService = logService; var pausedSubscription = new Subscription <PausedEvent>(PausedHandler); SubscribeBus(pausedSubscription); hotkeyListener.HotkeyPressed += OnHotkeyPressed; foreach (var hotkey in settingsService.Settings.Hotkeys.Values.ToList().Where(x => x != null)) { AddHotkey(hotkey); } hotkeyListener.Add(new Hotkey(System.Windows.Forms.Keys.Escape)); }
private void MainForm_Load(object sender, EventArgs e) { // Register the clipping hotkey. hotkeyListener.Add(clippingHotkey); // Displays a "no available clipped texts" status. RequireStatusLabelIfNothing(); // Suspend listening to hotkeys when the Settings Form is active. hotkeyListener.SuspendOn(settingsForm); // This event is used to listen to any hotkey presses. hotkeyListener.HotkeyPressed += HotkeyListener_HotkeyPressed; // This event is used to listen to any updated hotkeys. hotkeyListener.HotkeyUpdated += HotkeyListener_HotkeyUpdated; // This is used to display to the user the current clipping hotkey. SetClippingHotkeyInfo(clippingHotkey); }
private void AddButton_Click(object sender, EventArgs e) { //if(string.IsNullOrWhiteSpace()) int first = (int)(Keys)BindButton1CB.SelectedItem; int third = (int)(Keys)BindButton3CB.SelectedItem; if (BindButton2CB.Enabled == true) { int second = (int)(Keys)BindButton2CB.SelectedItem; if (BindButton1CB.SelectedIndex != BindButton2CB.SelectedIndex && !string.IsNullOrWhiteSpace(AddressBox.Text)) { Bind b = new Bind() { FullName = fullName, Name = name, AutoLoad = AutoLoadCB.SelectedIndex, FirstBind = first, SecondBind = second, ThirdBind = third }; binds.Add(b); hkl.Add(new Hotkey((Keys)first | (Keys)second, (Keys)third)); LoadList(); xd.Element("root").Add(new XElement("HotKey", new XAttribute("FullName", b.FullName), new XAttribute("Name", b.Name), new XAttribute("AutoLoad", b.AutoLoad), new XAttribute("first", b.FirstBind), new XAttribute("second", b.SecondBind), new XAttribute("third", b.ThirdBind))); xd.Save(path); AutoLoadFunc(); Form1 fm = new Form1(); fm.loadVoiceLines(); fm.playVoiceLine(2); } else { MessageBox.Show("Вы добавили одинаковые горячие кнопки!"); } } else { if (BindButton1CB.SelectedIndex != BindButton2CB.SelectedIndex && !string.IsNullOrWhiteSpace(AddressBox.Text)) { Bind b = new Bind() { FullName = fullName, Name = name, AutoLoad = AutoLoadCB.SelectedIndex, FirstBind = first, ThirdBind = third }; binds.Add(b); hkl.Add(new Hotkey((Keys)first, (Keys)third)); LoadList(); xd.Element("root").Add(new XElement("HotKey", new XAttribute("FullName", b.FullName), new XAttribute("Name", b.Name), new XAttribute("AutoLoad", b.AutoLoad), new XAttribute("first", b.FirstBind), new XAttribute("second", 0), new XAttribute("third", b.ThirdBind))); xd.Save(path); Form1 fm = new Form1(); fm.loadVoiceLines(); fm.playVoiceLine(2); AutoLoadFunc(); } else { MessageBox.Show("Вы добавили одинаковые горячие кнопки!"); } } }