コード例 #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);
        }