Beispiel #1
0
        private CommandGestureScopeMapping GetCommandMapping(KeyboardShortcutsUserShortcutsData shortcut,
                                                             IEnumerable <GestureScope> allScopes)
        {
            var cdb = _commandService.GetCommandDefinitionBy("CU", shortcut.Command);

            if (cdb == null || !(cdb is CommandDefinition cb))
            {
                return(null);
            }
            var mapping = GetMapping(shortcut, allScopes);

            return(mapping == null ? null : new CommandGestureScopeMapping(cb, mapping));
        }
Beispiel #2
0
        private GestureScopeMapping GetMapping(KeyboardShortcutsUserShortcutsData shortcut,
                                               IEnumerable <GestureScope> allScopes)
        {
            var scopeId =
                _keyBindingsSettings.KeyboardShortcuts.ScopeDefinitions.FirstOrDefault(
                    x => x.Name == shortcut.Scope)
                ?.ID;

            if (string.IsNullOrEmpty(scopeId))
            {
                return(null);
            }
            var scope = allScopes.FirstOrDefault(x => x.Id.Equals(new Guid(scopeId)));

            if (scope == null)
            {
                return(null);
            }
            return(new GestureScopeMapping(scope,
                                           (MultiKeyGesture) new MultiKeyGestureConverter().ConvertFrom(null, CultureInfo.CurrentCulture,
                                                                                                        shortcut.Value)));
        }