private void Setup() { var labeldesc = new Label(this) { Dock = Dock.Top, AutoSizeToContents = true, Alignment = Pos.CenterH | Pos.Top, Text = "Enter your new key combination and press enter", }; Panel container = new Panel(this) { Dock = Dock.Bottom, Padding = new Padding(0, 10, 0, 10), MouseInputEnabled = false, KeyboardInputEnabled = false, AutoSizeToContents = true, }; _kblabel = new Label(container) { Dock = Dock.Fill, Alignment = Pos.Center, Text = _binding.ToString(), }; }
public override void Think() { base.Think(); if (IsOnTop) { var hk = InputUtils.ReadHotkey(); bool changemade = false; if (ModifierOnly) { hk.Key = (OpenTK.Input.Key)(-1); } if (!hk.IsEmpty) { if (_lasthit.IsEmpty) { _binding = hk; changemade = true; } else { if (hk.UsesModifiers) { var mods = InputUtils.SplitModifiers(hk.Modifiers); var oldmods = InputUtils.SplitModifiers(_binding.Modifiers); foreach (var v in mods) { if (!oldmods.Contains(v)) { changemade = true; } } } if (hk.UsesKeys && hk.Key != _binding.Key || hk.UsesMouse && hk.MouseButton != _binding.MouseButton) { changemade = true; } } if (changemade) { _binding = hk; _kblabel.Text = _binding.ToString(); } } if (!hk.IsBindingEqual(_lasthit)) { _lasthit = hk; } } }