public void AddInList(Keys keys, Keys?modeKeys, KeyAction action)
        {
            KeyItem item = new KeyItem(keys, modeKeys, action);

            map.AddItem(item);
            list.Add(NamedAction.OfKeyItem(item));
        }
Exemple #2
0
        public static NamedAction OfKeyItem(KeyItem item)
        {
            string name = "[NONE]";
            string hint = null;
            Getter <Controller, bool> doOnDown = null;
            KeyAction action = item.action;

            if (action != null)
            {
                if (action.name != null)
                {
                    name = action.name;
                    int index = name.IndexOf('\\');
                    if (index != -1)
                    {
                        name = name.Substring(index + 1);
                    }
                    name = name.ToUpperInvariant();
                }
                if (item.keys != Keys.None)
                {
                    if (keysConverter == null)
                    {
                        keysConverter = new KeysConverter();
                    }
                    hint = item.keys == Keys.Alt ? "Alt" : keysConverter.ConvertToString(item.keys);
                }
                doOnDown = action.doOnDown;
            }
            return(new NamedAction(name, hint, doOnDown));
        }
Exemple #3
0
        public KeyItem(Keys keys, Keys?modeKeys, KeyAction action)
        {
            this.keys     = keys;
            this.modeKeys = modeKeys;
            this.action   = action;

            next = null;
        }
Exemple #4
0
 public KeyMap()
 {
     _items          = new RWList <KeyItem>();
     items           = _items;
     itemByKeys      = new Dictionary <Keys, KeyItem>();
     modeItemsByKeys = new Dictionary <Keys, RWList <KeyItem> >();
     doubleClickItem = null;
     altChars        = new Dictionary <char, char>();
 }
Exemple #5
0
 public void AddItem(KeyItem item, bool asMain)
 {
     if (item.modeKeys != null)
     {
         item = new KeyItem(item.keys | item.modeKeys.Value, item.modeKeys, item.action)
                .SetDoubleClick(item.doubleClick);
     }
     _items.Add(item);
     if (item.keys != Keys.None)
     {
         KeyItem prevItem;
         itemByKeys.TryGetValue(item.keys, out prevItem);
         if (asMain)
         {
             item.next             = prevItem;
             itemByKeys[item.keys] = item;
         }
         else
         {
             KeyItem lastItem = prevItem;
             for (; lastItem != null && lastItem.next != null; lastItem = lastItem.next)
             {
                 ;
             }
             if (lastItem != null)
             {
                 lastItem.next = item;
             }
             else
             {
                 itemByKeys.Add(item.keys, item);
             }
         }
         if (item.modeKeys != null)
         {
             RWList <KeyItem> items;
             modeItemsByKeys.TryGetValue(item.modeKeys.Value, out items);
             if (items == null)
             {
                 items = new RWList <KeyItem>();
                 modeItemsByKeys.Add(item.modeKeys.Value, items);
             }
             items.Add(item);
         }
     }
     if (item.doubleClick)
     {
         if (asMain)
         {
             item.next       = doubleClickItem;
             doubleClickItem = item;
         }
         else
         {
             KeyItem lastItem = doubleClickItem;
             for (; lastItem != null && lastItem.next != null; lastItem = lastItem.next)
             {
                 ;
             }
             if (lastItem != null)
             {
                 lastItem.next = item;
             }
             else
             {
                 doubleClickItem = item;
             }
         }
     }
 }
Exemple #6
0
 public void AddItem(KeyItem item)
 {
     AddItem(item, false);
 }
        public void Add(Keys keys, Keys?modeKeys, KeyAction action)
        {
            KeyItem item = new KeyItem(keys, modeKeys, action);

            map.AddItem(item);
        }