Ejemplo n.º 1
0
    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;
        }
    }
Ejemplo n.º 2
0
 /// <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);
     }
 }
Ejemplo n.º 3
0
            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);
            }
Ejemplo n.º 4
0
 /// <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);
     }
 }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 移除快捷键
 /// </summary>
 /// <param name="keyType"></param>
 public void removeHotKey(HotKeyType keyType)
 {
     if (hotKeyDic.ContainsKey(keyType))
     {
         hotKeyDic.Remove(keyType);
     }
 }
Ejemplo n.º 7
0
 private void UnRegisterHotKey(HotKeyType hkType)
 {
     lock (_hookLock)
     {
         _hook.KeyPressed -= _hotKeysHadlers[hkType];
         _hook.UnregisterHotKey((int)hkType);
     }
 }
Ejemplo n.º 8
0
 private void UnRegisterHotKey(HotKeyType hkType)
 {
     lock (_hookLock)
     {
         _hook.KeyPressed -= _hotKeysHadlers[hkType];
         _hook.UnregisterHotKey((int) hkType);
     }
 }
Ejemplo n.º 9
0
 private void RegisterHotKey(ModifierHookKeys modifierHook, Keys key, HotKeyType hkType)
 {
     UnRegisterHotKey(hkType);
     lock (_hookLock)
     {
         _hook.KeyPressed += _hotKeysHadlers[hkType];
         _hook.RegisterHotKey(modifierHook, key, (int) HotKeyType.OpenProgram);
     }
 }
Ejemplo n.º 10
0
 private void RegisterHotKey(ModifierHookKeys modifierHook, Keys key, HotKeyType hkType)
 {
     UnRegisterHotKey(hkType);
     lock (_hookLock)
     {
         _hook.KeyPressed += _hotKeysHadlers[hkType];
         _hook.RegisterHotKey(modifierHook, key, (int)HotKeyType.OpenProgram);
     }
 }
Ejemplo n.º 11
0
 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;
 }
Ejemplo n.º 12
0
 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;
         }
     }
 }
Ejemplo n.º 13
0
        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("技能冷却中");
        }
    }
Ejemplo n.º 15
0
        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();
            }
        }
Ejemplo n.º 16
0
 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;
 }
Ejemplo n.º 17
0
 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;
 }
Ejemplo n.º 18
0
 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;
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 获取快捷键枚举的int类型值
        /// </summary>
        /// <param name="hotKeyValue"></param>
        /// <returns></returns>

        public static int AsInt(this HotKeyType hotKeyValue)
        {
            return((int)hotKeyValue);
        }
Ejemplo n.º 20
0
 public static HotKey Get(HotKeyType type)
 {
     return(Settings.Hotkeys.Get(type) ?? FromType(type));
 }
Ejemplo n.º 21
0
 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();
      }
 }
Ejemplo n.º 22
0
 public static KeyCode GetHotKey(HotKeyType type)
 {
     return(hotKeyDict[type]);
 }