public static void UpdateKeyBindings(KeyBindings newBindings) { Keys.Clear(); foreach (var binding in newBindings) { Keys.Add(binding); var feature = (Feature)binding.Feature; if (!BindingCallbacks.ContainsKey(feature)) { continue; } try { foreach (var callback in BindingCallbacks[feature]) { callback(new KeyBindingEventArgs(Keys[feature], feature)); } } catch (Exception ex) { Error("Unexpeted error remapping key bindings.\nYou may need to restart the program for new mappings to take effect", ex); } } }
public static void UnbindKey(Feature feature, Action <KeyBindingEventArgs> callback) { if (!BindingCallbacks.ContainsKey(feature) || !BindingCallbacks[feature].Contains(callback)) { return; } BindingCallbacks[feature].Remove(callback); }
public static void BindKey(Feature feature, Action <KeyBindingEventArgs> callback) { if (!BindingCallbacks.ContainsKey(feature)) { BindingCallbacks.Add(feature, new List <Action <KeyBindingEventArgs> >()); } BindingCallbacks[feature].Add(callback); callback(new KeyBindingEventArgs(Keys[feature], feature)); }