Пример #1
0
        /// <summary>
        /// Dedects if an hotKey has been pressed an which hotKey has been pressed
        /// </summary>
        /// <param name="_key"></param>
        /// <param name="_hotKey">The pressed hotKey</param>
        /// <returns>Returns true if an hotKey has been pressed otherwise false</returns>
        public Boolean get_Event(Key _key, out TEnum _hotKey)
        {
            // set the _hotKey to the default HoKey None
            _hotKey = (TEnum)((HotKeyAttribute)this.hotKeys[0].GetCustomAttributes(typeof(HotKeyAttribute), true)[0]).HotKey;

            // if the class which contains all hotKeys isn't null
            if (this.hotKeyT != null)
            {
                // for each hotkey in the list of hotKeys
                foreach (PropertyInfo hotKey in this.hotKeys)
                {
                    // get the value of the current hotKey to check
                    String hotKeyValue = hotKey.GetValue(this.hotKeyT, null) as String;

                    // if the current combination of keys are a hotKey
                    if (this.is_HotKeyEvent(_key, hotKeyValue))
                    {
                        // initialize a hotKeyAttribute which contains the enum value of the hotKey
                        HotKeyAttribute hotKeyAttribute = ReflectionHandler.GetCustomAttribute <HotKeyAttribute>(hotKey, true);

                        if (hotKeyAttribute == null || (TEnum)hotKeyAttribute.HotKey == null)
                        {
                            return(false);
                        }

                        // get the enum value of the hotKey
                        _hotKey = (TEnum)hotKeyAttribute.HotKey;

                        // return true, means a hotKey has been pressed
                        return(true);
                    }
                }
            }

            return(false);
        }