コード例 #1
0
ファイル: MapKeystrokeForm.cs プロジェクト: Bradsama/padtie
        public MapKeystrokeForm(PadTieForm main, Controller cc, KeyAction editing)
            : this(main, cc)
        {
            this.editing = editing;
            capturedKey = editing.Key;
            ctrl.Checked = shift.Checked = alt.Checked = false;
            continuous.Checked = editing.Continuous;

            foreach (Keys mod in editing.Modifiers) {
                if (mod == Keys.Control) ctrl.Checked = true;
                else if (mod == Keys.Shift) shift.Checked = true;
                else if (mod == Keys.Alt) alt.Checked = true;
            }

            keyBox.Text = Util.GetKeyName(editing.Key);
            slotCapture.SetInput(editing.SlotDescription, true);
        }
コード例 #2
0
ファイル: KeyAction.cs プロジェクト: Bradsama/padtie
        public static KeyAction Parse(InputCore core, string parseable)
        {
            string[]    parts     = parseable.Split(',');
            string[]    modChunks = parts[1].Split('|');
            List <Keys> mods      = new List <Keys> ();

            if (!string.IsNullOrEmpty(parts[1]))
            {
                foreach (string modChunk in modChunks)
                {
                    mods.Add((Keys)Enum.Parse(typeof(Keys), modChunk));
                }
            }
            var key       = (Keys)Enum.Parse(typeof(Keys), parts[0]);
            var keyAction = new KeyAction(key, mods.ToArray());

            if (parts.Length > 2 && !string.IsNullOrEmpty(parts[2]))
            {
                keyAction.Continuous = bool.Parse(parts[2]);
            }
            return(keyAction);
        }
コード例 #3
0
ファイル: KeyAction.cs プロジェクト: Bradsama/padtie
        public static KeyAction Parse(InputCore core, string parseable)
        {
            string[] parts = parseable.Split(',');
            string[] modChunks = parts[1].Split('|');
            List<Keys> mods = new List<Keys> ();

            if (!string.IsNullOrEmpty(parts[1]))
                foreach (string modChunk in modChunks)
                    mods.Add((Keys)Enum.Parse(typeof(Keys), modChunk));
            var key = (Keys)Enum.Parse(typeof(Keys), parts[0]);
            var keyAction = new KeyAction(key, mods.ToArray());
            if (parts.Length > 2 && !string.IsNullOrEmpty(parts[2])) {
                keyAction.Continuous = bool.Parse(parts[2]);
            }
            return keyAction;
        }
コード例 #4
0
ファイル: MapKeystrokeForm.cs プロジェクト: Bradsama/padtie
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (slotCapture.Value == null) {
                MessageBox.Show("Please use the Capture button and press a button or analog direction first.");
                return;
            }

            var slot = slotCapture.Value;
            var key = Keys.None;
            List<Keys> mods = new List<Keys>();

            if (ctrl.Checked)
                mods.Add(Keys.Control);
            if (shift.Checked)
                mods.Add(Keys.Shift);
            if (alt.Checked)
                mods.Add(Keys.Menu);
            if (meta.Checked)
                mods.Add(Keys.LWin);

            key = capturedKey;

            KeyAction action;

            if (editing != null) {
                action = editing;
                action.ChangeBinding(key, mods.ToArray());

                if (slot != action.SlotDescription)
                    MapUtil.Map(MainForm, Controller.Virtual, action.SlotDescription, null);
            } else {
                action = new KeyAction(key, mods.ToArray());
            }
            action.Continuous = continuous.Checked;
            MapUtil.Map(MainForm, Controller.Virtual, slot, action);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }