Пример #1
0
 public static string GetDisplayStringForShortcut(KeyGesture kg)
 {
     string old = kg.GetDisplayStringForCulture(Thread.CurrentThread.CurrentUICulture);
     string text = KeyCodeConversion.KeyToUnicode(kg.Key.ToKeys());
     if (text != null && !text.Any(ch => char.IsWhiteSpace(ch))) {
         if ((kg.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
             text = StringParser.Format("${res:Global.Shortcuts.Alt}+{0}", text);
         if ((kg.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
             text = StringParser.Format("${res:Global.Shortcuts.Shift}+{0}", text);
         if ((kg.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
             text = StringParser.Format("${res:Global.Shortcuts.Ctrl}+{0}", text);
         if ((kg.Modifiers & ModifierKeys.Windows) == ModifierKeys.Windows)
             text = StringParser.Format("${res:Global.Shortcuts.Win}+{0}", text);
         return text;
     }
     return old;
 }
Пример #2
0
		public static string GetDisplayStringForShortcut(KeyGesture kg)
		{
			string old = kg.GetDisplayStringForCulture(Thread.CurrentThread.CurrentUICulture);
			string text = KeyCodeConversion.KeyToUnicode(kg.Key.ToKeys());
			if (text != null && !text.Any(ch => char.IsWhiteSpace(ch))) {
				if ((kg.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
					text = "Alt+" + text;
				if ((kg.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
					text = "Shift+" + text;
				if ((kg.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
					text = "Ctrl+" + text;
				if ((kg.Modifiers & ModifierKeys.Windows) == ModifierKeys.Windows)
					text = "Win+" + text;
				return text;
			}
			return old;
		}
Пример #3
0
 public static string GetInputGestureText(KeyGesture gesture)
 {
     if (gesture == null) return null;
     string ret = gesture.GetDisplayStringForCulture(System.Globalization.CultureInfo.CurrentCulture);
     return ret.Replace("Return", "Enter").Replace("Up", "↑").Replace("Down", "↓");
 }
Пример #4
0
 void BindCommandAndInput(ICommand command, KeyGesture gesture, ExecutedRoutedEventHandler handler, MenuItem bindItem)
 {
     CommandBindings.Add (new CommandBinding (command, handler));
     if (gesture != null)
         InputBindings.Add (new InputBinding (command, gesture));
     if (gesture != null && bindItem != null)
         bindItem.InputGestureText = gesture.GetDisplayStringForCulture (null);
 }