public void ResetSkillSlotKeyText(HotKeyType hotKeyType) { switch (hotKeyType) { case HotKeyType.SkillKey1: foreach (var slotText in skillSlotText1) { slotText.text = GetHotKey(HotKeyType.SkillKey1).ToString(); } break; case HotKeyType.SkillKey2: foreach (var slotText in skillSlotText2) { slotText.text = GetHotKey(HotKeyType.SkillKey2).ToString(); } break; case HotKeyType.SkillKey3: foreach (var slotText in skillSlotText3) { slotText.text = GetHotKey(HotKeyType.SkillKey3).ToString(); } break; case HotKeyType.SkillKey4: foreach (var slotText in skillSlotText4) { slotText.text = GetHotKey(HotKeyType.SkillKey4).ToString(); } break; } }
/// <summary> /// 添加快捷键 /// </summary> /// <param name="keyType"></param> /// <param name="hotKey"></param> public void addHotKey(HotKeyType keyType, IHotKey hotKey) { if (!hotKeyDic.ContainsKey(keyType)) { hotKeyDic.Add(keyType, hotKey); } }
public static HotKey Get(HotKeyType type) { var text = Get(type.ToString()); if (string.IsNullOrWhiteSpace(text)) { return(null); } var temp = text.Split('#'); var hotkey = HotKey.FromType(type); hotkey.Modifiers = (KeyModifier)Enum.Parse(typeof(KeyModifier), temp[0]); switch (temp[1]) { case "`": hotkey.Key = Keys.Oemtilde; break; case "Enter": hotkey.Key = Keys.Enter; break; case "CapsLock": hotkey.Key = Keys.CapsLock; break; default: hotkey.Key = (Keys)Enum.Parse(typeof(Keys), temp[1]); break; } return(hotkey); }
/// <summary> /// 重置快捷键 /// </summary> /// <param name="keyType"></param> /// <param name="newKeyCode"></param> public void resetHotKey(HotKeyType keyType, KeyCode newKeyCode) { if (hotKeyDic.ContainsKey(keyType)) { hotKeyDic[keyType].resetHotKey(newKeyCode); } }
void ApplyCurrentHotkey() { if (!Visible || currentHotkey == null) { return; } switch (currentHotkeyType) { case HotKeyType.Switch: settings.SwitchHotkey = currentHotkey; break; case HotKeyType.Convert: settings.ConvertSelectionHotkey = currentHotkey; break; case HotKeyType.SwitchLayout: settings.SwitchLayoutHotkey = currentHotkey; break; default: break; } currentHotkeyType = HotKeyType.None; }
/// <summary> /// 移除快捷键 /// </summary> /// <param name="keyType"></param> public void removeHotKey(HotKeyType keyType) { if (hotKeyDic.ContainsKey(keyType)) { hotKeyDic.Remove(keyType); } }
private void UnRegisterHotKey(HotKeyType hkType) { lock (_hookLock) { _hook.KeyPressed -= _hotKeysHadlers[hkType]; _hook.UnregisterHotKey((int)hkType); } }
private void UnRegisterHotKey(HotKeyType hkType) { lock (_hookLock) { _hook.KeyPressed -= _hotKeysHadlers[hkType]; _hook.UnregisterHotKey((int) hkType); } }
private void RegisterHotKey(ModifierHookKeys modifierHook, Keys key, HotKeyType hkType) { UnRegisterHotKey(hkType); lock (_hookLock) { _hook.KeyPressed += _hotKeysHadlers[hkType]; _hook.RegisterHotKey(modifierHook, key, (int) HotKeyType.OpenProgram); } }
private void RegisterHotKey(ModifierHookKeys modifierHook, Keys key, HotKeyType hkType) { UnRegisterHotKey(hkType); lock (_hookLock) { _hook.KeyPressed += _hotKeysHadlers[hkType]; _hook.RegisterHotKey(modifierHook, key, (int)HotKeyType.OpenProgram); } }
void InitializeHotkeyBoxes() { textBoxSwitchHotkey.GotFocus += (s, e) => currentHotkeyType = HotKeyType.Switch; textBoxSwitchHotkey.Enter += (s, e) => currentHotkeyType = HotKeyType.Switch; textBoxSwitchHotkey.LostFocus += (s, e) => ApplyCurrentHotkey(); textBoxSwitchHotkey.Leave += (s, e) => ApplyCurrentHotkey(); textBoxConvertHotkey.GotFocus += (s, e) => currentHotkeyType = HotKeyType.Convert; textBoxConvertHotkey.Enter += (s, e) => currentHotkeyType = HotKeyType.Convert; textBoxConvertHotkey.LostFocus += (s, e) => ApplyCurrentHotkey(); textBoxConvertHotkey.Leave += (s, e) => ApplyCurrentHotkey(); currentHotkeyType = HotKeyType.None; kbdHook = new KeyboardHook(); kbdHook.KeyboardEvent += kbdHook_KeyboardEvent; }
public void CheckKeyDuplicateInDictionary(KeyCode oldKeyCode, HotKeyType typeOfNewKeyCode, KeyCode newKeyCode) { foreach (var hotKey in hotKeyDict) { // If new keyCode duplicate with other type (not same type of itself). if (newKeyCode == hotKey.Value && typeOfNewKeyCode != hotKey.Key) { // Change KeyCode hotKeyDict[hotKey.Key] = oldKeyCode; ResetSkillSlotKeyText(hotKey.Key); return; } } }
public static HotKey FromType(HotKeyType hotKeyType) { var type = typeof(HotKeyType); var attrs = type.GetField(hotKeyType.ToString()).GetCustomAttributes(typeof(HotKey), false); if (attrs.Length == 0) { return(null); } var attr = attrs[0] as HotKey; // ReSharper disable once PossibleNullReferenceException attr.HotKeyType = hotKeyType; return(attr); }
//设置技能 public void SetHotKeySkill(int id) { bool isSeted = SkillHotKeyController._instance.CheckKey(id); if (!isSeted) //判断技能是否冷却 { this.type = HotKeyType.Skill; this.id = id; this.info = SkillsInfo._instance.GetSkillInfoById(id); this.hotKey_image.sprite = Resources.Load <Sprite>(info.icon_name); } else { Debug.Log("技能冷却中"); } }
private static Keys GetHotKeyFromConfig(HotKeySettings hotKeysConfig, HotKeyType type) { switch (type) { case HotKeyType.Cancel: return(hotKeysConfig.Cancel); case HotKeyType.Pause: return(hotKeysConfig.Pause); case HotKeyType.Record: return(hotKeysConfig.Record); case HotKeyType.Stop: return(hotKeysConfig.Stop); default: throw new InvalidOperationException(); } }
void InitializeHotkeyBoxes() { textBoxConverLastHotkey.GotFocus += (s, e) => currentHotkeyType = HotKeyType.ConvertLast; textBoxConverLastHotkey.Enter += (s, e) => currentHotkeyType = HotKeyType.ConvertLast; textBoxConverLastHotkey.LostFocus += (s, e) => ApplyCurrentHotkey(); textBoxConverLastHotkey.Leave += (s, e) => ApplyCurrentHotkey(); textBoxConvertSelectionHotkey.GotFocus += (s, e) => currentHotkeyType = HotKeyType.ConvertSelection; textBoxConvertSelectionHotkey.Enter += (s, e) => currentHotkeyType = HotKeyType.ConvertSelection; textBoxConvertSelectionHotkey.LostFocus += (s, e) => ApplyCurrentHotkey(); textBoxConvertSelectionHotkey.Leave += (s, e) => ApplyCurrentHotkey(); textBoxSwitchLayoutHotkey.GotFocus += (s, e) => currentHotkeyType = HotKeyType.SwitchLayout; textBoxSwitchLayoutHotkey.Enter += (s, e) => currentHotkeyType = HotKeyType.SwitchLayout; textBoxSwitchLayoutHotkey.LostFocus += (s, e) => ApplyCurrentHotkey(); textBoxSwitchLayoutHotkey.Leave += (s, e) => ApplyCurrentHotkey(); textBoxAutoSwitchingHotkey.GotFocus += (s, e) => currentHotkeyType = HotKeyType.ToggleAutoSwitching; textBoxAutoSwitchingHotkey.Enter += (s, e) => currentHotkeyType = HotKeyType.ToggleAutoSwitching; textBoxAutoSwitchingHotkey.LostFocus += (s, e) => ApplyCurrentHotkey(); textBoxAutoSwitchingHotkey.Leave += (s, e) => ApplyCurrentHotkey(); currentHotkeyType = HotKeyType.None; kbdHook = new KeyboardHook(); kbdHook.KeyboardEvent += kbdHook_KeyboardEvent; }
void ApplyCurrentHotkey() { if (!Visible || currentHotkey == null) { return; } switch (currentHotkeyType) { case HotKeyType.Switch: settings.SwitchHotkey = currentHotkey; break; case HotKeyType.Convert: settings.ConvertSelectionHotkey = currentHotkey; break; default: break; } currentHotkeyType = HotKeyType.None; }
/// <summary> /// 获取快捷键枚举的int类型值 /// </summary> /// <param name="hotKeyValue"></param> /// <returns></returns> public static int AsInt(this HotKeyType hotKeyValue) { return((int)hotKeyValue); }
public static HotKey Get(HotKeyType type) { return(Settings.Hotkeys.Get(type) ?? FromType(type)); }
private static Keys GetHotKeyFromConfig(HotKeySettings hotKeysConfig, HotKeyType type) { switch (type) { case HotKeyType.Cancel: return hotKeysConfig.Cancel; case HotKeyType.Pause: return hotKeysConfig.Pause; case HotKeyType.Record: return hotKeysConfig.Record; case HotKeyType.Stop: return hotKeysConfig.Stop; default: throw new InvalidOperationException(); } }
public static KeyCode GetHotKey(HotKeyType type) { return(hotKeyDict[type]); }