示例#1
0
        public static string CreateKeyBindingStringForSingleKeyStroke(KeyStroke stroke)
        {
            var builder = new StringBuilder();

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