private void btnEdit_Click(object sender, EventArgs e) { if (dgvHotkeys.SelectedRows.Count > 0) { Hotkey selectedHotkey = (Hotkey)dgvHotkeys.SelectedRows[0].DataBoundItem; if (selectedHotkey != null) { Form hotkeyEdit = HotkeyEditFormFactory.GetHotkeyEditForm(selectedHotkey.Command, selectedHotkey); IHotkeyForm hotkeyEditConv = null; if (hotkeyEdit is IHotkeyForm) { hotkeyEditConv = (IHotkeyForm)hotkeyEdit; } else { throw new Exception("Somehow the form doesn't cast to IHotkeyForm. Developer bad! Bad developer!"); } DialogResult result = hotkeyEdit.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { Hotkeys.Remove(selectedHotkey); RemovedHotkeys.Add(selectedHotkey); Hotkeys.Add(hotkeyEditConv.Hotkey); AddedHotkeys.Add(hotkeyEditConv.Hotkey); } } } }
private void AddHotkeyCommandExecute([NotNull] object obj) { Assert.ArgumentNotNull(obj, "obj"); var oldHotkey = new Hotkey(); oldHotkey.Actions.Add(new SendTextAction()); var hotKeyToAdd = new GlobalHotkeyViewModel(oldHotkey, _actionDescriptions); var hotKeyEditDialog = new GlobalHotkeyEditDialog { DataContext = hotKeyToAdd, Owner = (Window)obj }; var dialogResult = hotKeyEditDialog.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value) { var hotkeyViewModel = Hotkeys.FirstOrDefault(hotk => hotk.Key == hotKeyToAdd.Key && hotk.ModifierKeys == hotKeyToAdd.ModifierKeys); if (hotkeyViewModel != null) { Hotkeys.Remove(hotkeyViewModel); } var hotkey = _hotkeys.FirstOrDefault(hotk => hotk.Key == hotKeyToAdd.Key && hotk.ModifierKeys == hotKeyToAdd.ModifierKeys); if (hotkey != null) { _hotkeys.Remove(hotkey); } Hotkeys.Add(hotKeyToAdd); _hotkeys.Add(hotKeyToAdd.Hotkey); } }
private void btnAdd_Click(object sender, EventArgs e) { int command = (int)((HotkeyTypeEnum)cbAddType.SelectedValue); Hotkey newHotkey = HotkeyTypeFactory.GetHotkeyType(command); newHotkey.Command = command; Form hotkeyEdit = HotkeyEditFormFactory.GetHotkeyEditForm(newHotkey.Command, newHotkey); IHotkeyForm hotkeyEditConv = null; if (hotkeyEdit is IHotkeyForm) { hotkeyEditConv = (IHotkeyForm)hotkeyEdit; } else { throw new Exception("Somehow the form doesn't cast to IHotkeyForm. Developer bad! Bad developer!"); } DialogResult result = hotkeyEdit.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { Hotkeys.Add(hotkeyEditConv.Hotkey); AddedHotkeys.Add(hotkeyEditConv.Hotkey); } }
public void RegisterHotkey(HotkeySettings hotkeySetting) { if (!Program.Settings.DisableHotkeys || hotkeySetting.TaskSettings.Job == HotkeyType.DisableHotkeys) { UnregisterHotkey(hotkeySetting, false); if (hotkeySetting.HotkeyInfo.Status != HotkeyStatus.Registered && hotkeySetting.HotkeyInfo.IsValidHotkey) { hotkeyForm.RegisterHotkey(hotkeySetting.HotkeyInfo); if (hotkeySetting.HotkeyInfo.Status == HotkeyStatus.Registered) { DebugHelper.WriteLine("Hotkey registered: " + hotkeySetting); } else if (hotkeySetting.HotkeyInfo.Status == HotkeyStatus.Failed) { DebugHelper.WriteLine("Hotkey register failed: " + hotkeySetting); } } } if (!Hotkeys.Contains(hotkeySetting)) { Hotkeys.Add(hotkeySetting); } }
public void AddHotkey(string HotkeyName, string Modifier, string KeyPress, bool Enabled) { Hotkey AddHotkey = new Hotkey(); AddHotkey.Name = HotkeyName; AddHotkey.Modifier = Modifier; AddHotkey.KeyCode = KeyPress; AddHotkey.Enabled = Enabled; Hotkeys.Add(AddHotkey); }
/// <summary> /// Add new hotkey to profile /// </summary> /// <param name="hotkey"></param> /// <returns> /// 0 : Hotkey already exists. <para /> /// otherwise : return the number of hotkeys in the profile ///</returns> public int AddHotkey(Hotkey hotkey) { if (HasHotkey(hotkey)) { return(0); } Hotkeys.Add(hotkey); return(HotkeyCount); }
/// <summary> /// Used to register a hotkey /// </summary> /// <param name="hotkey">A <c>Hotkey</c> object. See <see cref="Hotkey"/></param> /// <returns></returns> public bool AddHotkey(Hotkey hotkey) { if (Hotkeys.ContainsKey(hotkey.HotkeyId)) { return(false); } var registered = WinApi.RegisterHotKey(WindowHandle, hotkey.HotkeyId, hotkey.Modifiers, hotkey.VirtualKey); if (registered) { Hotkeys.Add(hotkey.HotkeyId, hotkey); } return(registered); }
/// <summary> /// Add hotkey if it was not present in this profile. If it had an existing one, /// replace it with the new hotkey /// </summary> /// <param name="hotkey"></param> /// <returns> -1 : No more hotkey is available <para /> /// 0 : Existing hotkey is editted <para /> /// 1 : New hotkey is added <para /> /// </returns> public int AddOrEditHotkeyIfExisting(Hotkey hotkey) { Hotkey hotkeyBefore = FindHotkeyOrNull(hotkey); if (hotkeyBefore != null) { hotkeyBefore.Action = hotkey.Action; hotkeyBefore.EndingAction = hotkey.EndingAction; return(0); } Hotkeys.Add(hotkey); return(1); }
public GlobalHotkey CreateHotkey(string hotkeyName) { var globalAtom = new GlobalAtom($"{Application.ProductName}_{hotkeyName}"); try { var hotkey = new GlobalHotkey(Form, globalAtom.Id); Hotkeys.Add(globalAtom, hotkey); return(hotkey); } catch { globalAtom.Dispose(); throw; } }
private void HotkeyRecorder_OnKeyDown(object sender, KeyEventArgs e) { if (!_recording || Hotkeys == null) { Hotkeys = null; Hotkeys = new List <Key>(); } if (Hotkeys.Contains(e.Key)) { return; } Hotkeys.Add(e.Key); _recording = true; KeyString.Content = HotkeyString; e.Handled = true; }
// Fills in Hotkeys list when application is started public void InitializeHotkeys() { List <string> hotkeyNames = hotkeyDataFile.GetHotkeyNames(); foreach (string name in hotkeyNames) { int groupNumber = int.Parse(hotkeyDataFile.GetStringAttribute("File", name)[0].ToString()); if (Groups.TryGetValue(groupNumber, out XMLHotkeyGroup group)) { Hotkeys.Add(new Hotkey( name, hotkeyDataFile.GetIntAttribute("ID", name), groupNumber, hotkeyDataFile.GetIntAttribute("DLC", name), hotkeyDataFile.GetStringAttribute("Function", name), group.GetBinding(name))); } } // Changes source of itemsControl to allow for display itemsControl.ItemsSource = SortHotkeys(Hotkeys); }
private void EditHotkeyCommandExecute([NotNull] object obj) { Assert.ArgumentNotNull(obj, "obj"); if (SelectedHotkey == null) { return; } var hotkeyViewModel = SelectedHotkey.Clone(); var hotKeyEditDialog = new GlobalHotkeyEditDialog { DataContext = hotkeyViewModel, Owner = (Window)obj }; var dialogResult = hotKeyEditDialog.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value) { var hotkeyViewModelToRemove = Hotkeys.FirstOrDefault(hotk => hotk.Key == hotkeyViewModel.Key && hotk.ModifierKeys == hotkeyViewModel.ModifierKeys); if (hotkeyViewModelToRemove != null) { Hotkeys.Remove(hotkeyViewModelToRemove); } var hotkey = _hotkeys.FirstOrDefault(hotk => hotk.Key == hotkeyViewModel.Key && hotk.ModifierKeys == hotkeyViewModel.ModifierKeys); if (hotkey != null) { _hotkeys.Remove(hotkey); } Hotkeys.Add(hotkeyViewModel); _hotkeys.Add(hotkeyViewModel.Hotkey); SelectedHotkey = hotkeyViewModel; } }
/// <summary> /// Adds a hotkey to the hotkeys list. /// </summary> public static void AddHotkey(GlobalHotkey hotkey) { Hotkeys.Add(hotkey); }
public void Bind(bool control, bool shift, KeyCode keyCode, Action action) { Hotkeys.Add(new Hotkey(control, shift, keyCode, action)); }
private static void OnGameLoad(EventArgs args) { Loading.OnLoadingComplete += delegate { Chat.Print( "<font color = \"#ff052b\">Dellen's cici wipi</font> <font color = \"#fcdfff\">Yuklendi </font> "); Menu = MainMenu.AddMenu("Dellen", "Dellen"); Hotkeys = Menu.AddSubMenu("Hotkeys", "Hotkeys"); Hotkeys.AddGroupLabel("Hotkey Settings"); var press1 = Hotkeys.Add("GGyaz", new KeyBind("GGYAZ", false, KeyBind.BindTypes.HoldActive, "{Right}".ToCharArray()[0])); var press2 = Hotkeys.Add("WPyaz", new KeyBind("WPyaz", false, KeyBind.BindTypes.HoldActive, "{Left}".ToCharArray()[0])); var press3 = Hotkeys.Add("ORT", new KeyBind("ORT", false, KeyBind.BindTypes.HoldActive, "{Up}".ToCharArray()[0])); var press4 = Hotkeys.Add("PENS", new KeyBind("PENS", false, KeyBind.BindTypes.HoldActive, "{Down}".ToCharArray()[0])); Game.OnUpdate += delegate { if (press1.CurrentValue) { if (duramk == false) { Chat.Say("/all "); Chat.Say("/all ###### ###### "); Chat.Say("/all ## ## "); Chat.Say("/all ## ## "); Chat.Say("/all ## #### ## ####"); Chat.Say("/all ## ## ## ##"); Chat.Say("/all ## ## ## ##"); Chat.Say("/all ###### ###### "); duramk = true; gameTime1 = Game.Time + 1; } if (Game.Time > gameTime1) { duramk = false; } } ; if (press2.CurrentValue) { if (duramk == false) { Chat.Say("/all "); Chat.Say("/all ## ## ####### "); Chat.Say("/all ## ## ## ## ##"); Chat.Say("/all ## ## ## ## ##"); Chat.Say("/all ## ## ## ####### "); Chat.Say("/all ## ## ## ## "); Chat.Say("/all ## ## ## ## "); Chat.Say("/all ### ### ## "); duramk = true; gameTime1 = Game.Time + 1; } if (Game.Time > gameTime1) { duramk = false; } } if (press3.CurrentValue) { if (duramk == false) { Chat.Say("/all /´¯/)"); Chat.Say("/all ,/¯ / "); Chat.Say("/all / / "); Chat.Say("/all /´¯/' '/´¯¯`·¸ "); Chat.Say("/all /'/ / / /¨¯\\ "); Chat.Say("/all ('( ´ ´ ¯~/' ') "); Chat.Say("/all |\\ ' / "); Chat.Say("/all '' \\ _ ·´ "); duramk = true; gameTime1 = Game.Time + 1; } if (Game.Time > gameTime1) { duramk = false; } } if (press4.CurrentValue) { if (duramk == false) { Game.Say("/all ____"); Game.Say("/all / / 7"); Game.Say("/all (__,__/\\ "); Game.Say("/all \\ \\ "); Game.Say("/all \\ \\ "); Game.Say("/all __\\ \\__"); Game.Say("/all ( \\ )"); Game.Say("/all \\___\\_____/ "); duramk = true; gameTime1 = Game.Time + 1; } if (Game.Time > gameTime1) { duramk = false; } } }; }; }