public void GetInstance_ControlShiftF9WithSpaces_PropertiesAreCorrect()
        {
            HotKey hotkey = HotKey.GetInstance(" control , shift + F9 ");

            Assert.AreEqual(Keys.F9, hotkey.Key);
            Assert.AreEqual(HotkeyModifier.MOD_SHIFT | HotkeyModifier.MOD_CONTROL, hotkey.Modifier);
        }
        public void GetInstance_ShiftF10_PropertiesAreCorrect()
        {
            HotKey hotkey = HotKey.GetInstance("shift+F10");

            Assert.AreEqual(Keys.F10, hotkey.Key);
            Assert.AreEqual(HotkeyModifier.MOD_SHIFT, hotkey.Modifier);
        }
Esempio n. 3
0
        private static HotKey GetHotKey(IList <string> parts)
        {
            string keyString = parts[0];
            Key    key       = (Key)Enum.Parse(typeof(Key), keyString, true);

            int allModifier = parts.Skip(1).Select(v => v.ToLower())
                              .Sum(modifierString => (int)Enum.Parse(typeof(KeyModifier), modifierString, true));

            return(HotKey.GetInstance(key, (KeyModifier)allModifier));
        }
        /// <summary>
        /// Set HotKey
        /// </summary>
        /// <param name="hkcombo"></param>
        /// <param name="action"></param>
        /// <param name="errmsg"></param>
        private void SetHotKey(string hkcombo, Action action, string errmsg)
        {
            var hk = HotKey.GetInstance(hkcombo);

            if (hk != null)
            {
                if (this.HotkeyHandler.Exist(hk) == false)
                {
                    hk.SetConditionalAction(action, () => !ctrlConfigurationMode.IsVisible);

                    this.HotkeyHandler.RegisterHotKey(hk);
                }
            }
            else
            {
                this.AllowFurtherAction = false;
                MessageDialog.Show(errmsg);
                this.AllowFurtherAction = true;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Set HotKey
        /// </summary>
        /// <param name="hkcombo"></param>
        /// <param name="action"></param>
        /// <param name="errmsg"></param>
        private void SetHotKey(string hkcombo, Action action, string errmsg)
        {
            var hk = HotKey.GetInstance(hkcombo);

            if (hk != null)
            {
                if (this.HotkeyHandler.Exist(hk) == false)
                {
                    hk.Action = action;

                    this.HotkeyHandler.RegisterHotKey(hk);
                }
            }
            else
            {
                this.AllowFurtherAction = false;
                MessageDialog.Show(errmsg);
                this.AllowFurtherAction = true;
            }
        }
 public void GetInstance_InputIsNull_ThrowsArgumentNullException()
 {
     HotKey.GetInstance(null);
 }