コード例 #1
0
        private void OnAllocateKey(object sender, EventArgs args)
        {
            if (_keyConfigList.SelectedItems.Count == 0)
            {
                return;
            }

            CID  id   = (CID)_keyConfigList.SelectedItems[0].Tag;
            Keys key  = _hotKey.Key;
            int  code = GUtil.KeyToControlCode(key);

            if (code != -1)
            {
                if (GUtil.AskUserYesNo(this, String.Format(GApp.Strings.GetString("Message.OptionDialog.AskOverwriteToASCIIInput"), _hotKey.Text, code)) == DialogResult.No)
                {
                    return;
                }
            }

            Commands.Entry existing = _commands.FindEntry(key);
            if (existing != null && existing.CID != id)
            {
                if (GUtil.AskUserYesNo(this, String.Format(GApp.Strings.GetString("Message.OptionDialog.AskOverwriteCommand"), existing.Description)) == DialogResult.No)
                {
                    return;
                }

                existing.Key       = Keys.None;
                existing.Modifiers = Keys.None;
                FindListViewItem(existing.CID).SubItems[2].Text = "";
            }

            //設定を書き換え
            Commands.Entry e = _commands.FindEntry(id);
            Debug.Assert(e != null);
            _commands.ModifyKey(e.CID, key & Keys.Modifiers, key & Keys.KeyCode);
            _keyConfigList.SelectedItems[0].SubItems[2].Text = e.KeyDisplayString;
        }