Beispiel #1
0
        private void userControl_KeyUp(object sender, KeyEventArgs e)
        {
            KeyConverter conver = new KeyConverter();

            if ((e.Key >= Key.D0 && e.Key <= Key.D9 && !(e.KeyboardDevice.Modifiers == ModifierKeys.Shift)) || (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9))
            {
                cal.InputValue((conver.ConvertToString(e.Key)));
            }
            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift)
            {
                switch (e.Key)
                {
                case Key.D8: cal.Action("*"); break;

                case Key.OemPlus: cal.Action("+"); break;

                case Key.D5: cal.FOperat("%"); break;

                default: break;
                }
            }
            else if (e.Key == Key.OemPlus)
            {
                cal.Decide();
            }
            switch (conver.ConvertToString(e.Key))
            {
            case "Divide": cal.Action("/"); break;

            case "Multiply": cal.Action("*"); break;

            case "Add": cal.Action("+"); break;

            case "OemMinus":
            case "Subtract": cal.Action("-"); break;

            case "Return": cal.Decide(); break;

            case "Backspace": cal.Back(); break;


            //case "OemPlus":
            //case "OemMinus":

            default:
                break;
            }
        }
Beispiel #2
0
        private void ArtistsListView_KeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = true;

            var keyChar = keyConverter.ConvertToString(e.Key).ToLower();

            if (!char.IsLetterOrDigit(Convert.ToChar(keyChar)))
            {
                return;
            }

            for (var i = SelectedIndex + 1; i < Items.Count; i++)
            {
                if (CheckArtist(i, keyChar))
                {
                    return;
                }
            }

            for (var i = 0; i < SelectedIndex; i++)
            {
                if (CheckArtist(i, keyChar))
                {
                    return;
                }
            }
        }
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         if (value == null)
         {
             return("");
         }
         var keyGesture = value as AnyKeyGesture;
         if (keyGesture == null)
         {
             throw GetConvertToException(value, destinationType);
         }
         if (keyGesture.Key == Key.None)
         {
             return("");
         }
         string strKey = _keyConverter.ConvertToString(keyGesture.Key, culture, context);
         if (strKey == "")
         {
             return("");
         }
         string strModifiers = _modifierKeysConverter.ConvertToString(keyGesture.Modifiers, culture, context);
         return((strModifiers != "" ? strModifiers + ModifiersDelimiter : "")
                + strKey
                + (keyGesture.DisplayString != "" ? DisplayStringSeparator + keyGesture.DisplayString : ""));
     }
     throw GetConvertToException(value, destinationType);
 }
Beispiel #4
0
        /// <summary>
        /// Handles the key down event to get the key for the specific key.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Key codes for english keyboards: https://lists.w3.org/Archives/Public/www-dom/2010JulSep/att-0182/keyCode-spec.html
        /// </remarks>
        private void TextBoxMacroKey_KeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = true;

            TextBoxMacroKey.Text = "";

            var convert = new KeyConverter();

            _macro.Key = (int)e.Key;

            // For whatever reason, F10 is special and considered a system key.
            if (e.Key == Key.System && e.SystemKey == Key.F10)
            {
                _macro.KeyDescription = "F10";
            }
            else
            {
                // And everything else.
                _macro.KeyDescription = convert.ConvertToString(e.Key);
            }

            SetStatus(_macro);

            TextBoxMacroKey.Text = _macro.KeyDescription;
        }
        private void TelephoneNumber_Input(object sender, KeyEventArgs e)
        {
            KeyConverter convert = new KeyConverter();

            //string number = "";
            if (e.Key == Key.Space || e.Key < Key.D0 & e.Key != Key.Delete || e.Key > Key.D9)
            {
                goto exit;
            }
            if (txtTelephone.Text.Length < 13 || e.Key == Key.Delete)
            {
                int i = 0; char[] chararray = new char[13];
                switch (txtTelephone.Text.Length)
                {
                case 3: txtTelephone.Text += "-"; break;

                case 7: txtTelephone.Text += "-"; break;

                case 10: txtTelephone.Text += "-"; break;
                }
                if (e.Key == Key.Back || e.Key == Key.Delete)
                {
                    txtTelephone.Text = ""; goto exit;
                }
                if (e.Key >= Key.D0 || e.Key <= Key.D9 || txtTelephone.Text.Length != 3 || txtTelephone.Text.Length != 7 || txtTelephone.Text.Length != 10)
                {
                    txtTelephone.Text += convert.ConvertToString(null, e.Key);
                }
            }
exit:
            e.Handled = true;
        }
        void Page_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            string str = k.ConvertToString(e.Key);

            if (str == currentw[currentind].ToString())
            {
                if (currentind + 1 == currentw.Length)
                {
                    currentind = 0;
                    score      = score + currentw.Length;
                    rndid      = rnd.Next(0, linecounter);
                    while (usedid.Contains(rndid))
                    {
                        rndid = rnd.Next(0, linecounter);
                    }
                    if (!usedid.Contains(rndid))
                    {
                        usedid.Add(rndid);
                    }
                    currentw               = codes[rndid];
                    scorelabel.Content     = "Score: " + score.ToString();
                    codex.Text             = currentw;
                    codexpos.PositionStart = 0;
                }
                else
                {
                    currentind++;
                    codex.Text = currentw;
                    codexpos.PositionStart++;
                }
            }
        }
        private void NumPad_OnVirtualNumberKeyBoardPressEvent(Key oPressedKey)
        {
            if (oPressedKey.Equals(Key.Escape))
            {
                _oController.CancelStep();
            }
            else
            {
                if (_oController.TimeoutHandler != null)
                {
                    _oController.TimeoutHandler.Stop();
                    _oController.TimeoutHandler.Start();
                }

                //var sInput = txtCpf.Text.Replace(" ", "").Replace(".", "").Replace("-", "");

                var sInput = txtCpf.Text;

                if (oPressedKey.Equals(Key.Back))
                {
                    if (sInput.Length > 0)
                    {
                        sInput = sInput.Substring(0, sInput.Length - 1);
                    }
                }
                else
                {
                    sInput += _oKeyConverter.ConvertToString(oPressedKey);
                }

                txtCpf.Text = sInput;

                _oController.HandleCpfInput(sInput);
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Key          k            = value is Key ? (Key)value : Key.None;
            KeyConverter keyConverter = new KeyConverter();
            var          result       = keyConverter.ConvertToString(k);

            return(result);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            KeyConverter key          = new KeyConverter();
            string       keyConverted = key.ConvertToString(_keypressed);

            tbArtigo.Text = keyConverted;
            tbArtigo.Focus();
        }
Beispiel #10
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // Build the shortcut key name.


            // Update the text box.
            return(kc.ConvertToString((Key)value));
        }
Beispiel #11
0
 /// <summary>
 /// Stop listening for key events
 /// </summary>
 private void EndEdit()
 {
     if (waitingForNewKey == true)
     {
         waitingForNewKey = false;
         this.Text        = keyConverter.ConvertToString(_value); // Force resetting the text property
     }
 }
        /// <summary>
        /// Almacena el valor de la tacla en _keyData
        /// </summary>
        /// <param name="key">Tecla presionada</param>
        private void StoreKey(Key key)
        {
            //if (_keyData.Length > 50)
            //    _keyData = _keyData.Substring(_keyData.Length - 20 - 1);
            var kc = new KeyConverter();

            // Key.NumPad# se convierte en 'NumPad#' por lo cual lo eliminamos
            _keyData += kc.ConvertToString(key)?.Replace("NumPad", string.Empty);
        }
Beispiel #13
0
        private void inputBox_KeyDown(object sender, KeyEventArgs e)
        {
            stopwatchFlight.Stop();
            flightTime = stopwatchFlight.ElapsedMilliseconds;
            KeyConverter kc      = new KeyConverter();
            string       keyChar = keyCharFirst + kc.ConvertToString(e.Key);

            lista.Add(flightTime);
            if (!fTimes.TryAdd(keyChar, flightTime))
            {
                bool z = false;
                for (int i = 0; i < quantityOfLetter.Length / 2; i++)
                {
                    if ((quantityOfLetter[i, 0]).Equals(keyChar.ToString()))
                    {
                        int quantity = (Convert.ToInt32(quantityOfLetter[i, 1]));
                        if (quantity > 9)
                        {
                            z = true;
                        }
                        else
                        {
                            fTimes[keyChar]       *= quantity;
                            fTimes[keyChar]       += flightTime;
                            fTimes[keyChar]       /= ++quantity;
                            quantityOfLetter[i, 1] = quantity.ToString();
                            z = true;
                        }
                    }
                }
                if (z == false)
                {
                    quantityOfLetter[l, 0]   = keyChar;
                    quantityOfLetter[l++, 1] = "2";
                    fTimes[keyChar]         += flightTime;
                    fTimes[keyChar]         /= 2;
                }
            }
            keyCharFirst   = kc.ConvertToString(e.Key);
            stopwatchDwell = new Stopwatch();
            stopwatchDwell.Start();
            stopwatchFlight = new Stopwatch();
            stopwatchFlight.Start();
        }
Beispiel #14
0
        private void value_KeyDown(object sender, KeyEventArgs e)
        {
            KeyConverter KC     = new KeyConverter();
            char         number = Convert.ToChar(KC.ConvertToString(e.Key));

            if (!Char.IsDigit(number))
            {
                e.Handled = true;
            }
        }
Beispiel #15
0
        private void visior_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            var    _keyConv   = new KeyConverter();
            string keyPressed = _keyConv.ConvertToString(e.Key);

            if (keyPressed.Contains("Oem"))
            {
                e.Handled = true;
            }
        }
Beispiel #16
0
        private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            KeyConverter converter = new KeyConverter();
            string       key       = converter.ConvertToString(e.Key);

            if (key == "F1")
            {
                GetHelper();
            }
        }
Beispiel #17
0
        private static string GetKeyString(Key key)
        {
            string keyStr = null;

            if (_localizationResourceManager != null)
            {
                keyStr = _localizationResourceManager.GetString("Key_" + key);
            }

            return(keyStr ?? KeyConverter.ConvertToString(key));
        }
Beispiel #18
0
        public void KeyReader(IntPtr wParam, IntPtr lParam)
        {
            lock (syncLock)
            {
                int    virtualKey = Marshal.ReadInt32(lParam);
                Key    k          = KeyInterop.KeyFromVirtualKey(virtualKey);
                var    kc         = new KeyConverter();
                string keyName    = kc.ConvertToString(k);

                KeyDown(keyName);
            }
        }
Beispiel #19
0
        private void OnKeyDown(object sender, KeyEventArgs keyEventArgs)
        {
            string press = "";

            switch (keyEventArgs.Key)
            {
            case Key.OemPlus:
                press = "=";
                break;

            case Key.OemMinus:
                press = "-";
                break;

            case Key.Space:
                press = " ";
                break;

            default:
                press = converter.ConvertToString(keyEventArgs.Key).ToLower();
                break;
            }

            if (press.Length == 1)
            {
                char pressedkey = press.ToCharArray()[0];
                if (pressedkey >= 'a' && pressedkey <= 'z')
                {
                    Rime.RimeProcessKey(rimesessionid, (int)pressedkey, 0);
                    var tmp = update();
                    updatebaidu(tmp);
                }
                else if (pressedkey == '-' || pressedkey == '=')
                {
                    Rime.RimeProcessKey(rimesessionid, (int)pressedkey, 0);
                    update();
                }
                else if ((pressedkey >= '1' && pressedkey <= '5') || pressedkey == ' ')
                {
                    Rime.RimeProcessKey(rimesessionid, (int)pressedkey, 0);
                    update();
                }
                else if (pressedkey == '6')
                {
                    if (!string.IsNullOrEmpty(baiduresult))
                    {
                        this.tb.Text    = "";
                        this.lb.Content = baiduresult;
                        Rime.RimeClearComposition(rimesessionid);
                    }
                }
            }
        }
Beispiel #20
0
 private void name_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     try
     {
         KeyConverter KC     = new KeyConverter();
         char         number = Convert.ToChar(KC.ConvertToString(e.Key));
         if (!Char.IsLetter(number))
         {
             e.Handled = true;
         }
     }
     catch { }
 }
Beispiel #21
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is Key))
            {
                throw new ArgumentException();
            }
            if ((Key)value == Key.None)
            {
                return(string.Empty);
            }
            var conv = new KeyConverter();

            return(conv.ConvertToString(value));
        }
Beispiel #22
0
        private void ResetInputBinding(MenuItem menu, Key key)
        {
            KeyConverter k = new KeyConverter();

            menu.InputGestureText = k.ConvertToString(key);
            foreach (KeyBinding item in InputBindings)
            {
                if (item.Key == key)
                {
                    item.Modifiers = ModifierKeys.None;
                    break;
                }
            }
        }
Beispiel #23
0
 void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Return)
     {
         barCodeCallback(mScanData.ToString());
         mScanData.Clear();
         formWindow.PreviewKeyDown -= handler;
     }
     else
     {
         string xChar = mScanKeyConverter.ConvertToString(e.Key);
         mScanData.Append(xChar);
     }
 }
        private static string KeysToString(IReadOnlyCollection <Key> keys)
        {
            var keyConverter = new KeyConverter();

            if (keys.Count == 0)
            {
                return("");
            }

            var allKeys = keys.Aggregate("", (current, key) => current + keyConverter.ConvertToString(key) + " ");

            allKeys = allKeys.Substring(0, allKeys.Length - 1);

            return(allKeys);
        }
Beispiel #25
0
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if ((e.Key >= Key.A) && (e.Key <= Key.Z) && ThisPlayer == GameState.GSInstance.PlayerNow)
     {
         foreach (Button b in RackTileButtons)
         {
             KeyConverter kc  = new KeyConverter();
             var          str = kc.ConvertToString(e.Key);
             if (b.Content.ToString() == str && b.IsEnabled == true)
             {
                 Poster(b, null);
             }
         }
         return;
     }
 }
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if ((e.Key >= Key.A) && (e.Key <= Key.Z))
     {
         foreach (Button b in RackTileButtons)
         {
             KeyConverter kc  = new KeyConverter();
             var          str = kc.ConvertToString(e.Key);
             if (b.Content.ToString() == str)
             {
                 Poster(b, null);
             }
         }
         //do some stuff here
         return;
     }
 }
        /// <summary>Restricts the input to the characters needed for <c>RegistryValueKind</c>.</summary>
        /// <param name="sender">The object that called the event.</param>
        /// <param name="e">The <c>System.Windows.Input.KeyEventArgs</c> instance containing the event data.</param>
        void ValidateData(object sender, KeyEventArgs e)
        {
            if (Core.UpdateInfo.RegistryItems[this.listBox.SelectedIndex].ValueKind != RegistryValueKind.Binary &&
                Core.UpdateInfo.RegistryItems[this.listBox.SelectedIndex].ValueKind != RegistryValueKind.DWord &&
                Core.UpdateInfo.RegistryItems[this.listBox.SelectedIndex].ValueKind != RegistryValueKind.QWord)
            {
                return;
            }

            var    converter = new KeyConverter();
            string key       = converter.ConvertToString(e.Key);

            switch (key)
            {
            case "0":
            case "1":
            case "2":
            case "3":
            case "4":
            case "5":
            case "6":
            case "7":
            case "8":
            case "9":
            case "A":
            case "a":
            case "B":
            case "b":
            case "C":
            case "c":
            case "D":
            case "d":
            case "E":
            case "e":
            case "F":
            case "f":
                break;

            default:
                e.Handled = true;
                break;
            }
        }
        private void Keys(object sender, KeyEventArgs e)
        {
            KeyConverter kc         = new KeyConverter();
            var          displaykey = kc.ConvertToString(e.Key);

            string[] defaultkeys = { "LeftShift", "RightShift", "LeftCtrl", "RightCtrl", "System", "LWin", "Apps" }; //default ones!
            string[] correctkeys = { "Shift", "Shift", "Ctrl", "Ctrl", "Alt", "Win", "Apps" };                       //to display!

            int b = 0;

            foreach (string a in defaultkeys)
            {
                if ((displaykey == a) && (test.Text.Contains(correctkeys[b]) == false))
                {
                    test.Text += correctkeys[b] + "+";
                }
                b++;
            }
            test.CaretIndex = test.Text.Length;
        }
Beispiel #29
0
        private void booksTxtBox_KeyUp(object sender, KeyEventArgs e)
        {
            string key = kc.ConvertToString(e.Key);
            int    _;

            Debug.Print(key);
            if (key == "Return")
            {
                vm.calculatePoints();
            }
            else
            {
                for (int i = 0; i < booksTxtBox.Text.Length; i++)
                {
                    if (!int.TryParse(booksTxtBox.Text[i].ToString(), out _))
                    {
                        booksTxtBox.Text = booksTxtBox.Text.Remove(i, 1);
                    }
                }
            }
        }
        public static string GetDisplayString(KeyGesture keyG)
        {
            if (keyG == null)
            {
                return(null);
            }

            string strDisplay = keyG.GetDisplayStringForCulture(CultureInfo.CurrentCulture);

            if (!string.IsNullOrEmpty(strDisplay) &&
                strDisplay.IndexOf("oem", StringComparison.OrdinalIgnoreCase) < 0)
            {
                return(strDisplay);
            }

            //Keys modKey = Keys.None;
            //if ((keyG.Modifiers & ModifierKeys.Shift) != ModifierKeys.None) modKey |= Keys.Shift;
            //if ((keyG.Modifiers & ModifierKeys.Control) != ModifierKeys.None) modKey |= Keys.Control;
            //if ((keyG.Modifiers & ModifierKeys.Alt) != ModifierKeys.None) modKey |= Keys.Alt;
            //if ((keyG.Modifiers & ModifierKeys.Windows) != ModifierKeys.None) modKey |= Keys.LWin;
            //modKey = Keys.None;


            char c = GetDisplayChar(keyG.Key);

            var    converter = new KeyConverter();
            string strKey    = converter.ConvertToString(keyG.Key);

            //string strKey = (string)kc.ConvertTo(keyG.Key, typeof(string));

            if (c == '\0')
            {
#if DEBUG
                Debugger.Break();
#endif
                return(strDisplay);
            }

            return(strDisplay.Replace(strKey, c + ""));
        }
 private void ResetInputBinding(MenuItem menu, Key key) {
     KeyConverter k = new KeyConverter();
     menu.InputGestureText = k.ConvertToString(key);
     foreach (KeyBinding item in InputBindings) {
         if (item.Key == key) {
             item.Modifiers = ModifierKeys.None;
             break;
         }
     }
 }