Exemplo n.º 1
0
 private void editor_OnKeyModified(string name, Keys prevKey, Keys arg, KeyEdit editor)
 {
     if (!KeyManager.IsMapped(arg))
     {
         KeyManager[name] = arg;
         KeyManager.SaveConfigSettings();
     }
     else
     {
         editor.Key  = prevKey;
         editor.Text = prevKey.ToString();
         Dialog.Popup(GUI, "Key assigned!", "Key " + arg.ToString() + " already assigned.", Dialog.ButtonType.OK);
     }
 }
Exemplo n.º 2
0
        public KeyEditor(DwarfGUI gui, GUIComponent parent, KeyManager keyManager, int numRows, int numColumns) :
            base(gui, parent)
        {
            Keys[] reserved =
            {
                Keys.Up,
                Keys.Left,
                Keys.Right,
                Keys.Down,
                Keys.LeftControl,
                Keys.LeftShift,
                Keys.RightShift,
                Keys.LeftAlt,
                Keys.RightAlt,
                Keys.RightControl,
                Keys.Escape
            };
            ReservedKeys = new List <Keys>();
            ReservedKeys.AddRange(reserved);

            KeyManager = keyManager;

            Layout = new GridLayout(gui, this, numRows, numColumns * 2);

            int r = 0;
            int c = 0;

            foreach (KeyValuePair <string, Keys> button in KeyManager.Buttons)
            {
                if (r == numRows)
                {
                    r = 0;
                    c++;
                }

                Label   keyLabel = new Label(gui, Layout, button.Key, gui.DefaultFont);
                KeyEdit editor   = new KeyEdit(gui, Layout, button.Value);
                Layout.SetComponentPosition(keyLabel, c * 2, r, 1, 1);
                Layout.SetComponentPosition(editor, c * 2 + 1, r, 1, 1);


                string name = button.Key;

                editor.OnKeyModified += (prevKey, arg, keyedit) => editor_OnKeyModified(name, prevKey, arg, keyedit);

                r++;
            }
        }
Exemplo n.º 3
0
 private void KeyEdit_OnKeyModified(Keys prevKey, Keys arg, KeyEdit editor)
 {
 }
Exemplo n.º 4
0
 private void KeyEdit_OnKeyModified(Keys prevKey, Keys arg, KeyEdit editor)
 {
 }
Exemplo n.º 5
0
        public KeyEditor(DwarfGUI gui, GUIComponent parent, KeyManager keyManager, int numRows, int numColumns)
            : base(gui, parent)
        {
            Keys[] reserved =
            {
                Keys.Up,
                Keys.Left,
                Keys.Right,
                Keys.Down,
                Keys.LeftControl,
                Keys.LeftShift,
                Keys.RightShift,
                Keys.LeftAlt,
                Keys.RightAlt,
                Keys.RightControl,
                Keys.Escape
            };
            ReservedKeys = new List<Keys>();
            ReservedKeys.AddRange(reserved);

            KeyManager = keyManager;

            Layout = new GridLayout(gui, this, numRows, numColumns * 2);

            int r = 0;
            int c = 0;

            foreach(KeyValuePair<string, Keys> button in KeyManager.Buttons)
            {
                if(r == numRows)
                {
                    r = 0;
                    c++;
                }

                Label keyLabel = new Label(gui, Layout, button.Key, gui.DefaultFont);
                KeyEdit editor = new KeyEdit(gui, Layout, button.Value);
                Layout.SetComponentPosition(keyLabel, c * 2, r, 1, 1);
                Layout.SetComponentPosition(editor, c * 2 + 1, r, 1, 1);

                string name = button.Key;

                editor.OnKeyModified += (prevKey, arg, keyedit) => editor_OnKeyModified(name, prevKey, arg, keyedit);

                r++;
            }
        }
Exemplo n.º 6
0
        private void editor_OnKeyModified(string name, Keys prevKey, Keys arg, KeyEdit editor)
        {
            if(!KeyManager.IsMapped(arg))
            {
                KeyManager[name] = arg;
                KeyManager.SaveConfigSettings();
            }
            else
            {
                editor.Key = prevKey;
                editor.Text = prevKey.ToString();
                Dialog.Popup(GUI, "Key assigned!", "Key " + arg.ToString() + " already assigned.", Dialog.ButtonType.OK);

            }
        }