public static string CreateKeyBindingStringForSingleKeyStroke(KeyStroke stroke) { var builder = new StringBuilder(); AppendCommandForSingle(stroke, builder); return(builder.ToString()); }
private static void AppendCommandForSingle(KeyStroke stroke, StringBuilder builder) { if (0 != (stroke.KeyModifiers & KeyModifiers.Control)) { builder.Append("Ctrl+"); } if (0 != (stroke.KeyModifiers & KeyModifiers.Shift)) { builder.Append("Shift+"); } if (0 != (stroke.KeyModifiers & KeyModifiers.Alt)) { builder.Append("Alt+"); } EnsureVsMap(); var input = stroke.KeyInput; var query = _vsMap.Where(x => x.Value == input); if (query.Any()) { builder.Append(query.First().Key); } else if (Char.IsLetter(input.Char)) { builder.Append(Char.ToUpper(input.Char)); } else if (input.Char == ' ') { builder.Append("Space"); } else { builder.Append(input.Char); } }
public KeyBinding(string scope, KeyStroke stroke) { Scope = scope; KeyStrokes = new ReadOnlyCollection <KeyStroke>(new[] { stroke }); CommandString = CreateCommandString(scope, KeyStrokes); }
public KeyBinding(string scope, KeyStroke stroke) { Scope = scope; KeyStrokes = Enumerable.Repeat(stroke, 1); _commandString = new Lazy <string>(CreateCommandString); }