Пример #1
0
        private void DrawButtonNames()
        {
            var buttons     = Controls.OfType <Button>();
            var keybindings = KeybindingsManager.GetKeybindings()
                              .Select(a => a.Key.ToString())
                              .ToList();

            foreach (var button in buttons)
            {
                if (keybindings.Contains(button.Name))
                {
                    Print(button.Position.X + 12, button.Position.Y + 1, button.Name.ToString().Replace("_", " "), Color.White);
                }
            }
        }
Пример #2
0
        private void CreateKeybindingButtons()
        {
            var bindings = KeybindingsManager.GetKeybindings();

            var       row          = 12;
            const int maxPerColumn = 8;
            const int maxColumns   = 2;
            var       total        = 0;
            var       columns      = 0;

            foreach (var(key, value) in bindings)
            {
                if (total == maxPerColumn)
                {
                    columns++;
                    total = 0;
                    row   = 12;

                    if (columns == maxColumns)
                    {
                        // Show paging when the need arises?
                        throw new Exception("Exceeded max keybindings limit (16)");
                    }
                }

                var pos    = columns == 0 ? new Point(25, row) : new Point(65, row);
                var button = new Button(10, 3)
                {
                    Name        = key.ToString(),
                    Text        = value.ToString(),
                    Position    = pos,
                    UseMouse    = true,
                    UseKeyboard = false,
                };

                // Add key re-arrange method
                button.Click += TriggerKeybindingChangeCheck;
                Add(button);
                row += 3;
                total++;
            }
        }