Ejemplo n.º 1
0
        public static string CreateKeyBindingStringForSingleKeyStroke(KeyStroke stroke)
        {
            var builder = new StringBuilder();

            AppendCommandForSingle(stroke, builder);
            return(builder.ToString());
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 public KeyBinding(string scope, KeyStroke stroke)
 {
     Scope         = scope;
     KeyStrokes    = new ReadOnlyCollection <KeyStroke>(new[] { stroke });
     CommandString = CreateCommandString(scope, KeyStrokes);
 }
Ejemplo n.º 4
0
 public KeyBinding(string scope, KeyStroke stroke)
 {
     Scope          = scope;
     KeyStrokes     = Enumerable.Repeat(stroke, 1);
     _commandString = new Lazy <string>(CreateCommandString);
 }