Exemple #1
0
 public AssignViewModel(KeyAssignEditorViewModel parent,
                        Key key, ModifierKeys modifier, KeyAssignGroup group,
                        string action, string argument)
 {
     this._parent   = parent;
     this._key      = key;
     this._modifier = modifier;
     this._group    = group;
     this._action   = action;
     this._argument = argument;
 }
        public IEnumerable <KeyAssign> GetAssigns(Key key, KeyAssignGroup group)
        {
            var iteration = Enumerable.Empty <KeyAssign>();
            var dir       = GetDictionary(group);
            IList <KeyAssign> bindings;

            if (dir.TryGetValue(key, out bindings))
            {
                iteration = iteration.Concat(bindings);
            }
            return(iteration);
        }
        public void SetAssign(KeyAssignGroup group, KeyAssign assign)
        {
            IList <KeyAssign> bindings;
            var targetDic = GetDictionary(group);

            if (targetDic.TryGetValue(assign.Key, out bindings))
            {
                bindings.Add(assign);
            }
            else
            {
                targetDic.Add(assign.Key, new List <KeyAssign>(new[] { assign }));
            }
        }
 public IEnumerable<KeyAssign> GetAssigns(Key key, KeyAssignGroup group)
 {
     var iteration = Enumerable.Empty<KeyAssign>();
     var dir = GetDictionary(group);
     IList<KeyAssign> bindings;
     if (dir.TryGetValue(key, out bindings))
     {
         iteration = iteration.Concat(bindings);
     }
     if (group != KeyAssignGroup.Global)
     {
         IList<KeyAssign> globalBindings;
         if (GlobalBindings.TryGetValue(key, out globalBindings))
         {
             iteration = iteration.Concat(globalBindings);
         }
     }
     return iteration;
 }
        public IDictionary <Key, IList <KeyAssign> > GetDictionary(KeyAssignGroup group)
        {
            switch (group)
            {
            case KeyAssignGroup.Global:
                return(GlobalBindings);

            case KeyAssignGroup.Input:
                return(InputBindings);

            case KeyAssignGroup.Timeline:
                return(TimelineBindings);

            case KeyAssignGroup.Search:
                return(SearchBindings);

            default:
                throw new ArgumentOutOfRangeException("group");
            }
        }
 private IEnumerable<KeyAssign> EnumerateAssigns(KeyAssignGroup? searchFrom = null)
 {
     if (searchFrom == null)
     {
         return EnumerableEx.Concat(
             GlobalBindings.Values,
             TimelineBindings.Values,
             InputBindings.Values,
             SearchBindings.Values)
                            .SelectMany(items => items);
     }
     switch (searchFrom.Value)
     {
         case KeyAssignGroup.Global:
             return GlobalBindings.Values.SelectMany(items => items);
         case KeyAssignGroup.Timeline:
             return TimelineBindings.Values.SelectMany(items => items);
         case KeyAssignGroup.Input:
             return InputBindings.Values.SelectMany(items => items);
         case KeyAssignGroup.Search:
             return SearchBindings.Values.SelectMany(items => items);
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
 public IEnumerable<KeyAssign> FindAssignFromActionName(IEnumerable<string> actionNames, KeyAssignGroup? searchFrom = null)
 {
     return EnumerateAssigns(searchFrom)
         .Where(k => k.Actions.Count() == 1 &&
             k.Actions.Select(a => a.ActionName).SequenceEqual(actionNames));
 }
 public IEnumerable<KeyAssign> FindAssignFromActionName(string actionName, KeyAssignGroup? searchFrom = null)
 {
     return EnumerateAssigns(searchFrom)
         .Where(k => k.Actions.Count() == 1 &&
             k.Actions.First().ActionName == actionName);
 }
 public IDictionary<Key, IList<KeyAssign>> GetDictionary(KeyAssignGroup group)
 {
     switch (group)
     {
         case KeyAssignGroup.Global:
             return GlobalBindings;
         case KeyAssignGroup.Input:
             return InputBindings;
         case KeyAssignGroup.Timeline:
             return TimelineBindings;
         case KeyAssignGroup.Search:
             return SearchBindings;
         default:
             throw new ArgumentOutOfRangeException("group");
     }
 }
 public void SetAssign(KeyAssignGroup group, KeyAssign assign)
 {
     IList<KeyAssign> bindings;
     var targetDic = GetDictionary(group);
     if (targetDic.TryGetValue(assign.Key, out bindings))
     {
         bindings.Add(assign);
     }
     else
     {
         targetDic.Add(assign.Key, new List<KeyAssign>(new[] { assign }));
     }
 }
 public AssignViewModel(KeyAssignEditorViewModel parent,
     Key key, ModifierKeys modifier, KeyAssignGroup group,
     string action, string argument)
 {
     this._parent = parent;
     this._key = key;
     this._modifier = modifier;
     this._group = group;
     this._action = action;
     this._argument = argument;
 }