Пример #1
0
        /// <summary>
        /// キー入力テキストを設定
        /// </summary>
        /// <param name="text"></param>
        public void SetKeyText(string text)
        {
            var textList = new List <string>(text.Split(InputKeySeparator.ToCharArray()));

            foreach (var keyText in textList)
            {
                var key = keyText.Trim();
                switch (key)
                {
                case "Ctrl": Key |= Keys.Control; break;

                case "Shift": Key |= Keys.Shift; break;

                case "Alt": Key |= Keys.Alt; break;
                }

                Keys parseKey;
                if (Enum.TryParse(key, out parseKey))
                {
                    Key |= parseKey;
                }
            }

            textBoxKeyEdit.Text = KeysToString(Key);
        }
Пример #2
0
        /// <summary>
        /// キー入力テキストを設定
        /// </summary>
        /// <param name="text"></param>
        private static Keys KeyTextToKey(string text)
        {
            var textList = new List <string>(text.Split(InputKeySeparator.ToCharArray()));

            Keys keyValue = 0;

            foreach (var keyText in textList)
            {
                var key = keyText.Trim();
                switch (key)
                {
                case "Ctrl": keyValue |= Keys.Control; break;

                case "Shift": keyValue |= Keys.Shift; break;

                case "Alt": keyValue |= Keys.Alt; break;
                }

                Keys parseKey;
                if (Enum.TryParse(key, out parseKey))
                {
                    keyValue |= parseKey;
                }
            }

            return(keyValue);
        }