public static byte[] ConvertStroke(KeyboardTypes keyB, PreviewKeyDownEventArgs e) { var empty = new byte[0]; Dictionary <Keys, byte[]> keyMap = null; switch (keyB) { case KeyboardTypes.American: if (_americanKeyboard == null) { buildAmericanKeyboard(); } keyMap = _americanKeyboard; break; } //if (keyMap == null) return empty; var code = e.KeyCode; var data = e.KeyData; var val = e.KeyValue; var mods = e.Modifiers; byte[] byteList; if (keyMap.TryGetValue(data, out byteList)) { return(byteList); } return(empty); }
/// <summary> /// Initializes a new instance of the <see cref="T:Virtex.Lib.Vrtc.Core.Input.KeyBindings"/> class with the specified /// keyboard type. /// </summary> /// <param name="KeyboardPreset">Keyboard preset.</param> public KeyBindings(vxEngine Engine, KeyboardTypes KeyboardPreset) { this.Engine = Engine; string te = Engine.Language.Get(vxLocalization.KeyName_Forward); switch (KeyboardPreset) { case KeyboardTypes.QWERTY: Add(vxKeyBindingID.Forward, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Forward), Keys.W)); Add(vxKeyBindingID.Back, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Back), Keys.S)); Add(vxKeyBindingID.Left, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Left), Keys.A)); Add(vxKeyBindingID.Right, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Right), Keys.D)); Add(vxKeyBindingID.Jump, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Jump), Keys.Space)); Add(vxKeyBindingID.Croutch, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Croutch), Keys.LeftControl)); Add(vxKeyBindingID.Interact1, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Interact1), Keys.Q)); Add(vxKeyBindingID.Interact2, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Interact2), Keys.E)); break; case KeyboardTypes.AZERTY: Add(vxKeyBindingID.Forward, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Forward), Keys.Z)); Add(vxKeyBindingID.Back, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Back), Keys.S)); Add(vxKeyBindingID.Left, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Left), Keys.Q)); Add(vxKeyBindingID.Right, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Right), Keys.D)); Add(vxKeyBindingID.Jump, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Jump), Keys.Space)); Add(vxKeyBindingID.Croutch, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Croutch), Keys.LeftControl)); Add(vxKeyBindingID.Interact1, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Interact1), Keys.A)); Add(vxKeyBindingID.Interact2, new KeyBinding(Engine.Language.Get(vxLocalization.KeyName_Interact2), Keys.E)); break; } }
private HardwareConfiguration(string data) { var subcode = data.Substring(0, 2); if (subcode != "HG") { throw new InvalidDataException( string.Format("Expected sub-code of \"{0}\" but got \"{1}\".", "HG", subcode)); } if (!int.TryParse(data.Substring(2, 5), NumberStyles.None, CultureInfo.InvariantCulture, out _firmwareVersion)) { throw new InvalidDataException("Couldn't parse firmware version from hardware configuration data."); } if (!DateTime.TryParseExact(data.Substring(8, 10), "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out _firmwareDate)) { throw new InvalidDataException("Couldn't parse firmware date from hardware configuration data."); } // TODO: what does 18 represent? _terminalType = (TerminalTypes)data[19]; _keyboardType = (KeyboardTypes)data[20]; _displayType = (DisplayTypes)data[21]; _hostSerialParameters = data.Substring(22, 3); byte b; if (!byte.TryParse(data.Substring(25, 1), NumberStyles.None, CultureInfo.InvariantCulture, out b)) { throw new InvalidDataException("Couldn't parse host serial baud rate from hardware configuration data."); } _hostSerialBaudRate = BaudRates.Get(b); _terminalId = Util.CharToTerminalId(data[26]); // TODO: what does 27 represent? Maybe the network card type? if (!byte.TryParse(data.Substring(28, 1), NumberStyles.None, CultureInfo.InvariantCulture, out _fingerprintUnitType)) { throw new InvalidDataException("Couldn't parse fingerprint unit type from hardware configuration data."); } _fingerprintUnitMode = (FingerprintUnitModes)data[29]; if (!int.TryParse(data.Substring(30, 4), NumberStyles.None, CultureInfo.InvariantCulture, out _userDefinedField)) { throw new InvalidDataException("Couldn't parse user defined field from hardware configuration data."); } }
public static ReplyKeyboardMarkup GetKeyboard(KeyboardTypes keyboard) { switch (keyboard) { case KeyboardTypes.MainKeyboard: return(GetMainTypeKeyboard()); case KeyboardTypes.KeyboardSelection: return(GetKeyboardSelection()); default: return(new ReplyKeyboardMarkup()); } }
public static string GetKeyboard(KeyboardTypes keyboard) { switch (keyboard) { case KeyboardTypes.MainKeyboard: return(MainKeyboard); case KeyboardTypes.KeyboardSelection: return(SelectKeyboard); default: return(""); } }
public override async Task SendSimpleMessageAsync(string id, string text, KeyboardTypes keyboardType) { if (ulong.TryParse(id, out var userId) && !string.IsNullOrEmpty(text)) { var sendText = text + DiscordKeyboardBuilder.GetKeyboard(keyboardType); if (client.GetChannel(userId) is ISocketMessageChannel userChannel) { await userChannel.SendMessageAsync(sendText); } } else { throw new ArgumentException("Chat or text is invalid"); } }
public override async Task SendSimpleMessageAsync(string id, string text, KeyboardTypes keyboardType) { if (keyboardType == KeyboardTypes.None) { await client.SendTextMessageAsync(id, text); } else { var keyboard = TelegramKeyboardBuilder.GetKeyboard(keyboardType); await client.SendTextMessageAsync(id, text, replyMarkup : keyboard); } myStopwatch.Stop(); Console.Out.WriteLine("myStopwatch = {0}", myStopwatch.ElapsedMilliseconds);//остановить }
public async override Task SendSimpleMessage(long id, string text, KeyboardTypes keyboardType) { switch (keyboardType) { case KeyboardTypes.MainKeyboard: await client.SendTextMessageAsync(id, text, replyMarkup : KeyboardBuilder.GetMainTypeKeyboard()); break; case KeyboardTypes.KeyboardSelection: await client.SendTextMessageAsync(id, text, replyMarkup : KeyboardBuilder.GetKeyboardSelection()); break; default: await client.SendTextMessageAsync(id, text); break; } }
private HardwareConfiguration(string data) { var subcode = data.Substring(0, 2); if (subcode != "HG") throw new InvalidDataException( string.Format("Expected sub-code of \"{0}\" but got \"{1}\".", "HG", subcode)); if (!int.TryParse(data.Substring(2, 5), NumberStyles.None, CultureInfo.InvariantCulture, out _firmwareVersion)) throw new InvalidDataException("Couldn't parse firmware version from hardware configuration data."); if (!DateTime.TryParseExact(data.Substring(8, 10), "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out _firmwareDate)) throw new InvalidDataException("Couldn't parse firmware date from hardware configuration data."); // TODO: what does 18 represent? _terminalType = (TerminalTypes)data[19]; _keyboardType = (KeyboardTypes)data[20]; _displayType = (DisplayTypes)data[21]; _hostSerialParameters = data.Substring(22, 3); byte b; if (!byte.TryParse(data.Substring(25, 1), NumberStyles.None, CultureInfo.InvariantCulture, out b)) throw new InvalidDataException("Couldn't parse host serial baud rate from hardware configuration data."); _hostSerialBaudRate = BaudRates.Get(b); _terminalId = Util.CharToTerminalId(data[26]); // TODO: what does 27 represent? Maybe the network card type? if (!byte.TryParse(data.Substring(28, 1), NumberStyles.None, CultureInfo.InvariantCulture, out _fingerprintUnitType)) throw new InvalidDataException("Couldn't parse fingerprint unit type from hardware configuration data."); _fingerprintUnitMode = (FingerprintUnitModes)data[29]; if (!int.TryParse(data.Substring(30, 4), NumberStyles.None, CultureInfo.InvariantCulture, out _userDefinedField)) throw new InvalidDataException("Couldn't parse user defined field from hardware configuration data."); }
public void RefreshKeyboard(KeyboardTypes keyboardType) { this.CurrentViewModel = keyboardType == KeyboardTypes.Full ? _fullKeyboardControlVM : _calculatorKeyboardControlVM; }
public abstract Task SendMusicMessage(long id, string text, MusicInfo musicInfo, KeyboardTypes keyboardType);
public abstract Task SendSimpleMessage(long id, string text, KeyboardTypes keyboardType);
protected virtual void RestoreToDefault() { // Restore keyboard to default state _currentRow = 0; _currentKey = 0; _lastColumn = 1; _currentKeyboard = KeyboardTypes.TYPE_ALPHABET; _capsLockTurnedOn = false; _shiftTurnedOn = false; _textEntered = ""; _position = 0; int height = _keyHeight; GUIGraphicsContext.ScaleVertical(ref height); _keyHeightScaled = height; _maxRows = 5; }
public void Reset() { _capsLockTurnedOn = false; _shiftTurnedOn = false; _state = State.STATE_KEYBOARD; _position = 0; _currentKeyboard = KeyboardTypes.TYPE_ALPHABET; _currentRow = 0; _currentKey = 0; _lastColumn = 0; _keyHeightScaled = _keyHeight; _maxRows = 5; _pressedEnter = false; _caretTimer = DateTime.Now; _searchKind = (int)SearchKinds.SEARCH_CONTAINS; // default search Contains _password = false; _textEntered = ""; int height = _keyHeight; GUIGraphicsContext.ScaleVertical(ref height); _keyHeightScaled = height; // Free and reallocate resources to incorporate new keys added to the keyboard. RestoreToDefault(); InitBoard(); }
public override async Task SendMusicMessageAsync(string id, string text, MusicTrack track, KeyboardTypes keyboardType) { var musicVersion = track.MusicVersions.SingleOrDefault(t => t.Extension == "ogg"); var sendText = text + DiscordKeyboardBuilder.GetKeyboard(keyboardType); if (musicVersion == null) { throw new ArgumentNullException($"В базе нет версии ogg трека - {track.Id}"); } if (ulong.TryParse(id, out var userId)) { if (client.GetChannel(userId) is ISocketMessageChannel userChannel) { await userChannel.SendFileAsync(musicVersion.TrackPath, sendText); } } else { throw new ArgumentException("Chat or text is invalid"); } }
public void ShowKeyboard(KeyboardTypes keyboardType = KeyboardTypes.Normal) { }
public static void SetStartupKeyboardType(DependencyObject obj, KeyboardTypes value) { obj.SetValue(StartupKeyboardTypeProperty, value); }
public abstract Task SendMusicMessageAsync(string id, string text, MusicTrack track, KeyboardTypes keyboardType);
public async override Task SendMusicMessage(long id, string text, MusicInfo musicInfo, KeyboardTypes keyboardType) { // FileStream file = new FileStream(@"D:\file4.ogg", FileAccess.Read); Console.WriteLine("SendMusicMessage-1"); Console.WriteLine("SendMusicMessage-2"); Console.WriteLine("SendMusicMessage-3"); switch (keyboardType) { case KeyboardTypes.MainKeyboard: await client.SendTextMessageAsync(id, text, replyMarkup : KeyboardBuilder.GetMainTypeKeyboard()); break; case KeyboardTypes.KeyboardSelection: var stream = new FileStream(musicInfo.fileLocation, FileMode.Open); InputOnlineFile inputFile = new InputOnlineFile(stream); Console.WriteLine("SendMusicMessage-4"); await client.SendVoiceAsync(id, inputFile); Console.WriteLine("SendMusicMessage-5"); await client.SendTextMessageAsync(id, text, replyMarkup : KeyboardBuilder.GetKeyboardSelection()); Console.WriteLine("SendMusicMessage-6"); stream.Close(); break; default: await client.SendTextMessageAsync(id, text); break; } }
public override async Task SendMusicMessageAsync(string id, string text, MusicTrack track, KeyboardTypes keyboardType) { var musicVersion = track.MusicVersions.SingleOrDefault(t => t.Extension == "ogg"); if (musicVersion == null) { throw new ArgumentNullException($"MusicVersion of track {track.Id} is null"); } var keyboard = TelegramKeyboardBuilder.GetKeyboard(keyboardType); const int numberOfRetries = 3; const int delayOnRetry = 1000; for (var i = 0; i < numberOfRetries; i++) { try { var stream = new FileStream(musicVersion.TrackPath, FileMode.Open); var inputFile = new InputOnlineFile(stream); await client.SendVoiceAsync(id, inputFile, caption : text, replyMarkup : keyboard); stream.Close(); break; } catch { if (i <= numberOfRetries) { Console.Out.WriteLine("track is busy = {0}", track.Id); Task.Delay(delayOnRetry); } else { throw new Exception("Music file is invalid"); } } } myStopwatch.Stop(); Console.Out.WriteLine("myStopwatch = {0}", myStopwatch.ElapsedMilliseconds);//остановить }
public override Task SendMusicMessageAsync(string id, string text, MusicTrack track, KeyboardTypes keyboardType) { throw new System.NotImplementedException(); }
protected void Press(Xkey xk) { ClearLabelAsInitialText(); if (xk == Xkey.XK_NULL) // happens in Japanese keyboard (keyboard type) { xk = Xkey.XK_SPACE; } // If the key represents a character, add it to the word if (((uint)xk) < 0x10000 && xk != Xkey.XK_ARROWLEFT && xk != Xkey.XK_ARROWRIGHT) { // Don't add more than the maximum characters, and don't allow // text to exceed the width of the text entry field if (_textEntered.Length < MAX_CHARS) { float fWidth = 0, fHeight = 0; _fontCharKey.GetTextExtent(_textEntered, ref fWidth, ref fHeight); if (fWidth < (GUIGraphicsContext.ScaleHorizontal((int) fTextBoxWidth))) { if (_position >= _textEntered.Length) { _textEntered += GetChar(xk); if (TextChanged != null) { TextChanged(_searchKind, _textEntered); } } else { _textEntered = _textEntered.Insert(_position, GetChar(xk)); if (TextChanged != null) { TextChanged(_searchKind, _textEntered); } } ++_position; // move the caret } } // Unstick the shift key _shiftTurnedOn = false; } // Special cases else { switch (xk) { case Xkey.XK_BACKSPACE: if (_position > 0) { --_position; // move the caret _textEntered = _textEntered.Remove(_position, 1); if (TextChanged != null) { TextChanged(_searchKind, _textEntered); } } break; case Xkey.XK_DELETE: // Used for Japanese only if (_textEntered.Length > 0) { _textEntered = _textEntered.Remove(_position, 1); if (TextChanged != null) { TextChanged(_searchKind, _textEntered); } } break; case Xkey.XK_SHIFT: _shiftTurnedOn = !_shiftTurnedOn; break; case Xkey.XK_CAPSLOCK: _capsLockTurnedOn = !_capsLockTurnedOn; break; case Xkey.XK_ALPHABET: _currentKeyboard = KeyboardTypes.TYPE_ALPHABET; break; case Xkey.XK_SYMBOLS: _currentKeyboard = KeyboardTypes.TYPE_SYMBOLS; break; case Xkey.XK_ACCENTS: _currentKeyboard = KeyboardTypes.TYPE_ACCENTS; break; case Xkey.XK_SMS: //_useSmsStyleTextInsertion = !_useSmsStyleTextInsertion; SmsStyleText = !SmsStyleText; break; case Xkey.XK_ARROWLEFT: if (_position > 0) { --_position; } break; case Xkey.XK_ARROWRIGHT: if (_position < _textEntered.Length) { ++_position; } break; case Xkey.XK_OK: Close(); _pressedEnter = true; break; // added to the original code VirtualKeyboard.cs // by Agree // starts here... case Xkey.XK_SEARCH_IS: _searchKind = (int)SearchKinds.SEARCH_STARTS_WITH; SetSearchKind(); break; case Xkey.XK_SEARCH_CONTAINS: _searchKind = (int)SearchKinds.SEARCH_ENDS_WITH; SetSearchKind(); break; case Xkey.XK_SEARCH_ENDS_WITH: _searchKind = (int)SearchKinds.SEARCH_IS; SetSearchKind(); break; case Xkey.XK_SEARCH_START_WITH: _searchKind = (int)SearchKinds.SEARCH_CONTAINS; SetSearchKind(); break; // code by Agree ends here // case Xkey.XK_SMS0: ProcessSmsInsertion(0); break; case Xkey.XK_SMS1: ProcessSmsInsertion(1); break; case Xkey.XK_SMS2: ProcessSmsInsertion(2); break; case Xkey.XK_SMS3: ProcessSmsInsertion(3); break; case Xkey.XK_SMS4: ProcessSmsInsertion(4); break; case Xkey.XK_SMS5: ProcessSmsInsertion(5); break; case Xkey.XK_SMS6: ProcessSmsInsertion(6); break; case Xkey.XK_SMS7: ProcessSmsInsertion(7); break; case Xkey.XK_SMS8: ProcessSmsInsertion(8); break; case Xkey.XK_SMS9: ProcessSmsInsertion(9); break; } } }