示例#1
0
        private void ShowProp(int index)
        {
            MacroModule           mod = GApp.MacroManager.GetModule(index);
            Keys                  key = Keys.None;
            IDictionaryEnumerator ie  = _keyToModule.GetEnumerator();

            while (ie.MoveNext())
            {
                if (ie.Value == mod)
                {
                    key = (Keys)(ie.Key);
                    break;
                }
            }

            ModuleProperty dlg = new ModuleProperty(this, mod, key);

            if (GCUtil.ShowModalDialog(this, dlg) == DialogResult.OK)
            {
                GApp.MacroManager.ReplaceModule(GApp.MacroManager.GetModule(index), dlg.Module);
                GApp.Options.Commands.ModifyMacroKey(dlg.Module.Index, dlg.ShortCut & Keys.Modifiers, dlg.ShortCut & Keys.KeyCode);
                ListViewItem li = _list.Items[index];
                li.Text             = dlg.Module.Title;
                li.SubItems[1].Text = dlg.Module.Path;
                li.SubItems[2].Text = UILibUtil.KeyString(dlg.ShortCut);
                li.SubItems[3].Text = GetInfoString(dlg.Module);
                _keyToModule.Remove(key);
                if (dlg.ShortCut != Keys.None)
                {
                    _keyToModule.Add(dlg.ShortCut, dlg.Module);
                }

                AdjustUI();
            }
        }
示例#2
0
        private void AddListItem(MacroModule mod, Keys shortcut)
        {
            ListViewItem li = new ListViewItem(mod.Title);

            li = _list.Items.Add(li);
            li.SubItems.Add(mod.Path);
            li.SubItems.Add(UILibUtil.KeyString(shortcut & Keys.Modifiers, shortcut & Keys.KeyCode, '+'));
            li.SubItems.Add(GetInfoString(mod));
        }
示例#3
0
        //シンプルなテキスト形式でのSave/Load
        public void Save(ConfigNode parent)
        {
            ConfigNode node = new ConfigNode("key-definition");

            foreach (Entry e in _entries)
            {
                if (e.KeyIsModified)
                {
                    node[e.CID.ToString()] = UILibUtil.KeyString(e.Modifiers, e.Key, ',');
                }
            }

            parent.AddChild(node);
        }
示例#4
0
        public void Save(ConfigNode parent)
        {
            ConfigNode node = new ConfigNode("module");

            node["path"]  = _path;
            node["title"] = _title;
            node["debug"] = _debugMode.ToString();
            Commands.Entry e = GApp.Options.Commands.FindMacroEntry(this.Index);
            if (e != null)
            {
                node["shortcut"] = UILibUtil.KeyString(e.Modifiers, e.Key, ',');
            }
            node["additional-assemblies"] = Concat(_additionalAssemblies);
            parent.AddChild(node);
        }
示例#5
0
        private string FormatKey(Keys key)
        {
            Keys body      = key & Keys.KeyCode;
            Keys modifiers = key & Keys.Modifiers;

            //modifierは常に表示する
            StringBuilder b = new StringBuilder();

            if ((modifiers & Keys.Control) != Keys.None)
            {
                b.Append("Ctrl");
            }
            if ((modifiers & Keys.Shift) != Keys.None)
            {
                if (b.Length > 0)
                {
                    b.Append('+');
                }
                b.Append("Shift");
            }
            if ((modifiers & Keys.Alt) != Keys.None)
            {
                if (b.Length > 0)
                {
                    b.Append('+');
                }
                b.Append("Alt");
            }
            if (b.Length > 0)
            {
                b.Append('+');
            }

            if (IsCharKey(body))
            {
                if (modifiers != Keys.None && modifiers != Keys.Shift)
                {
                    if (modifiers == Keys.Alt && (Keys.D0 <= body && body <= Keys.D9))
                    {
                        _key = Keys.None;
                    }
                    else
                    {
                        b.Append(UILibUtil.KeyString(body));
                        _key = key;
                    }
                }
                else
                {
                    _key = Keys.None;
                }
            }
            else if (IsTerminalKey(body))
            {
                if (modifiers != Keys.None)
                {
                    //カスタマイズ不能で固定されたショートカットキーは登録できない
                    if (modifiers == Keys.Control && IsScrollKey(body))
                    {
                        _key = Keys.None;
                    }
                    else
                    {
                        b.Append(UILibUtil.KeyString(body));
                        _key = key;
                    }
                }
                else
                {
                    _key = Keys.None;
                }
            }
            else if (IsFunctionKey(body))
            {
                b.Append(UILibUtil.KeyString(body));
                _key = key;
            }
            else if (!IsModifierKey(body))
            {
                _key = Keys.None;
            }

            return(b.ToString());
        }