Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
 public static void UnbindKey(Feature feature, Action <KeyBindingEventArgs> callback)
 {
     if (!BindingCallbacks.ContainsKey(feature) || !BindingCallbacks[feature].Contains(callback))
     {
         return;
     }
     BindingCallbacks[feature].Remove(callback);
 }
Exemple #3
0
        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));
        }