public void LoadBindings(List <Hotkey> binds) { if (binds == null) { return; } m_selectedItem = null; int c = panel1.Controls.Count; for (int i = 0; i < c; i++) { Control ct = panel1.Controls[0]; panel1.Controls.RemoveAt(0); ct?.Dispose(); } foreach (Hotkey kb in binds) { KeyRebind krb = new KeyRebind(); krb.Function = kb.Function; krb.KeyBind = new Misc.Hotkey(kb.Keys); AddRebind(krb); krb.UpdateText(); } }
public void AddRebind() { KeyRebind krb = new KeyRebind(); krb.SelectionChanged += Krb_SelectionChanged; krb.Dock = DockStyle.Top; panel1.Controls.Add(krb); }
public void RemoveRebind() { if (SelectedItem == null) { return; } panel1.Controls.Remove(SelectedItem); m_selectedItem?.Dispose(); m_selectedItem = null; }
private void Krb_SelectionChanged(object sender, bool IsSelected) { if (!IsSelected) { return; } if (m_selectedItem != null) { m_selectedItem.IsSelected = false; } m_selectedItem = sender as KeyRebind; }
public void AddRebind(KeyRebind bind) { bind.SelectionChanged += Krb_SelectionChanged; bind.Dock = DockStyle.Top; panel1.Controls.Add(bind); }