private KeyboardShortcutCollection ConfigureCommands() { var configuration = File.ReadAllLines(@"keyboard.trcfg"); var descriptors = new BlockDescriptor[] { ParagraphBlock.Descriptor, HeadingBlock.Descriptor, }; var addedCommands = new IContextualCommand[] { new BreakTextBlockCommand(), new DeleteNextCharacterCommand(), new DeletePreviousCharacterCommand(), new MergeTextBlocksCommand(), new MoveCaretBackwardCommand(), new MoveCaretForwardCommand(), new MoveCaretUpCommand(), new MoveCaretDownCommand(), new MoveCaretHomeCommand(), new MoveCaretEndCommand(), new MoveCaretPreviousWordCommand(), new MoveCaretNextWordCommand(), new UndoCommand(), new RedoCommand(), }; var allCommands = addedCommands .Concat(descriptors.SelectMany(d => d.GetCommands(_editor.Document))) .ToDictionary(c => c.Id, c => c, StringComparer.InvariantCultureIgnoreCase); var converter = new KeyGestureConverter(); var items = configuration .Where(s => !string.IsNullOrWhiteSpace(s)) .Select(s => s.Trim()) .Select(s => s.Split(new[] { " => " }, StringSplitOptions.RemoveEmptyEntries)) .Select(p => new { StringKey = p[0], Id = p[1] }) .Select(i => new { Key = (KeyGesture)converter.ConvertFromString(i.StringKey), Command = allCommands[i.Id] }) .GroupBy(i => i.Key) ; var keyboardShortcutCollection = new KeyboardShortcutCollection(); foreach (var aGroup in items) { keyboardShortcutCollection.Add(aGroup.Key.Modifiers, aGroup.Key.Key, aGroup.Select(it => it.Command).ToArray()); } return(keyboardShortcutCollection); }