//public bool Focused
        //{
        //    get { return (bool)GetValue(FocusedProperty); }
        //    set { SetValue(FocusedProperty, value); }
        //}

        //// Using a DependencyProperty as the backing store for Watermark.  This enables animation, styling, binding, etc...
        //public static readonly DependencyProperty FocusedProperty = DependencyProperty.Register(
        //    "Focused",
        //    typeof(bool),
        //    typeof(KeyGestureSinkBox),
        //    new UIPropertyMetadata(false, OnFocusedChanged));

        //private static void OnFocusedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        //{
        //    if ((bool)e.NewValue)
        //    {
        //        FocusHelper.Focus(d, (UIElement) d);
        //    }
        //}

        private void updateTooltip()
        {
            var keyG = KeyGesture;

            string displayStr = keyG == null ? Text : KeyGestureStringConverter.Convert(keyG.Key, keyG.Modifiers, true); //keyG.GetDisplayString();

            ToolTip = displayStr;

            SetAccessibleNameAndNotifyScreenReaderAutomationIfKeyboardFocused(displayStr);
        }
 public override string ToString()
 {
     return(KeyGestureStringConverter.Convert(this));
 }
        private void OnKeyDown_TextBox(object sender, KeyEventArgs e)
        {
            var key = (e.Key == Key.System ? e.SystemKey : (e.Key == Key.ImeProcessed ? e.ImeProcessedKey : e.Key));

            // We ignore reserved keys (but they bubble-up in the UI tree for further processing, if any)
            if (key == Key.Escape || key == Key.Tab || key == Key.Return)
            {
                return;
            }

            // Any other key is captured so it doesn't bubble-up
            e.Handled = true;

            string keyStr = key.ToString();

            if (keyStr.IndexOf("ctrl", StringComparison.OrdinalIgnoreCase) >= 0 ||
                keyStr.IndexOf("shift", StringComparison.OrdinalIgnoreCase) >= 0 ||
                keyStr.IndexOf("alt", StringComparison.OrdinalIgnoreCase) >= 0 ||
                keyStr.IndexOf("win", StringComparison.OrdinalIgnoreCase) >= 0
                )
            {
                key = Key.None;
            }

            //////string common =
            //////                ((Keyboard.Modifiers & ModifierKeys.Shift) > 0 ? "SHIFT " : "")
            //////                +
            //////                ((Keyboard.Modifiers & ModifierKeys.Control) > 0 ? "CTRL " : "")
            //////                +
            //////                ((Keyboard.Modifiers & ModifierKeys.Alt) > 0 ? "ALT " : "")
            //////                +
            //////                ((Keyboard.Modifiers & ModifierKeys.Windows) > 0 ? "WIN " : "")
            //////                ;

            //////if (string.IsNullOrEmpty(common)) common = "NONE ";

            //////KeyGestureSerializedEncoded = "[ " + common + "] " + (key != Key.None ? key.ToString() : "");

            KeyGestureSerializedEncoded = KeyGestureStringConverter.Convert(key, Keyboard.Modifiers, true);

            //if (Text != KeyGestureSerializedEncoded)
            //{
            //    Text = KeyGestureSerializedEncoded;
            //}
            Text = KeyGestureSerializedEncoded;
            updateTooltip();

            //var converter = new KeyConverter();
            //string keyDisplayString = converter.ConvertToString(key);
            //ToolTip = common + (key != Key.None ?
            //    (!keyDisplayString.ToLower().Contains("oem") ?
            //    keyDisplayString :
            //    ("" + GetChar(KeyInterop.VirtualKeyFromKey(key))).ToUpper()) :
            //    "");

            var keyG = KeyGesture;

            string displayStr = keyG == null ? null : keyG.GetDisplayString();

            Console.WriteLine(Environment.NewLine + @"=====> "
                              + (keyG == null ? "INVALID" : displayStr)
                              + @" <==> "
                              + (keyG == null ? "INVALID" : KeyGestureStringConverter.Convert((KeyGesture)keyG)));
        }