本文整理汇总了C#中System.Windows.Input.KeyGesture.GetDisplayStringForCulture方法的典型用法代码示例。如果您正苦于以下问题:C# KeyGesture.GetDisplayStringForCulture方法的具体用法?C# KeyGesture.GetDisplayStringForCulture怎么用?C# KeyGesture.GetDisplayStringForCulture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Input.KeyGesture
的用法示例。
在下文中一共展示了KeyGesture.GetDisplayStringForCulture方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDisplayStringForShortcut
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: GetDisplayStringForShortcut
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: GetInputGestureText
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: BindCommandAndInput
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);
}