Beispiel #1
0
        public bool Equals(KeyBindingSet other)
        {
            // TODO: full IEquatable<KeyBindingSet> implementation
            // the current solutions is just enough to detect whether a custom set equals a predefined one
            // and is not a real equality check. See KeyBindingsPanel.SelectCurrentScheme().
            if (other == null)
            {
                return(false);
            }

            var otherSet    = other.GetAllBindings();
            var allBindings = GetAllBindings();

            if (otherSet.Count != allBindings.Count)
            {
                return(false);
            }
            foreach (var binding in allBindings)
            {
                string accel;
                if (!otherSet.TryGetValue(binding.Key, out accel) || accel != binding.Value)
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #2
0
        IDictionary <string, string> GetAllBindings()
        {
            if (parent == null)
            {
                return(bindings.Where(b => !string.IsNullOrEmpty(b.Value)).ToDictionary(b => b.Key, b => b.Value));
            }

            var pbindings   = parent.GetAllBindings();
            var allBindings = new Dictionary <string, string> ();

            foreach (var cmd in bindings.Keys.Concat(pbindings.Keys).Distinct())
            {
                var accel = string.Empty;
                if (!bindings.TryGetValue(cmd, out accel))
                {
                    pbindings.TryGetValue(cmd, out accel);
                }
                if (!string.IsNullOrEmpty(accel))
                {
                    allBindings [cmd] = accel;
                }
            }
            return(allBindings);
        }