コード例 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (lstPossibleActions.SelectedItems.Count <= 0) return;

            List<Extern.VirtualKeyShort> vks = new List<Extern.VirtualKeyShort>();
            foreach (object o in lstPossibleActions.SelectedItems)
            {
                vks.Add((Extern.VirtualKeyShort)o);
            }

            PressKey keyCommand = new PressKey(vks.ToArray());

            lstActions.Items.Add(keyCommand);
        }
コード例 #2
0
        public static void Initialize(this GenericInputDialog gid, PressKey pk)
        {
            List<DialogQuestion> questions = new List<DialogQuestion>();

            questions.Add(new DialogQuestion("key", "Keys (separated by comma)", typeof(string), String.Join(", ", pk.keyShort)));

            gid.Initialize("Key Press", questions);
        }
コード例 #3
0
        public static Command Edit(this GenericInputDialog gid, PressKey pk)
        {
            gid.Initialize(pk);

            if (gid.ShowDialog() == DialogResult.OK)
            {
                string[] splitString = ((string)gid.Results["key"]).Split(',');
                List<Extern.VirtualKeyShort> keyShorts = new List<Extern.VirtualKeyShort>();
                List<Extern.ScanCodeShort> scanShorts = new List<Extern.ScanCodeShort>();

                foreach (string key in splitString)
                {
                    Extern.VirtualKeyShort vks;
                    Enum.TryParse(key.Trim(), true, out vks);

                    if (vks != Extern.VirtualKeyShort.NONE)
                    {
                        keyShorts.Add(vks);
                        scanShorts.Add(pk.GuessScanCode(vks));
                    }
                }

                pk.keyShort = keyShorts.ToArray();
                pk.scanShort = scanShorts.ToArray();
            }

            return pk;
        }