internal static int LayoutToInt(VirtualKeyboardLayout layout) { var members = typeof(VirtualKeyboardLayout).GetMember(layout.ToString()); if (members.Length == 0) { throw new NotSupportedException(string.Format("Unknown keyboard layout: {0}", layout)); } Util.ThrowIfUnsupported(members[0], string.Format("The keyboard layout, {0}, is not supported.", layout)); return((int)layout); }
public static void SetOptions(VirtualKeyboardLayout layout, VirtualKeyboardEnter enter, bool noHelp = true) { if (Util.IsCapableOfRunning(10, 3)) { virtualkeyboard_change_options_v2(LayoutToInt(layout), EnterKeyToInt(enter), noHelp); } else { virtualkeyboard_change_options(LayoutToInt(layout), EnterKeyToInt(enter)); } }
private void SetLayoutByLanguage(Language currentAppLanguage) { // 1. letters IVirtualKeyboardLayoutProvider lettersLayoutProvider; switch (currentAppLanguage.LanguageTag) { case "ru": lettersLayoutProvider = new RussianLettersProvider(); break; case "uk": lettersLayoutProvider = new UkrainianLettersProvider(); break; case "en": default: lettersLayoutProvider = new UsLettersProvider(); break; } lettersLayoutProvider.InitLayout(currentAppLanguage); var lettersLayout = lettersLayoutProvider.Layout; var lettersRows = lettersLayout.Rows; // 2. space and backspace var spaceRow = new VirtualKeyboardLayoutRow { CreatePlaceholder(), CreatePlaceholder(), new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Space, }, CreatePlaceholder(), new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Backspace, }, }; var layout = new VirtualKeyboardLayout(); layout.Rows.AddRange(lettersRows); layout.Rows.Add(spaceRow); Layout = layout; }
private void SetLayoutByLanguage(Language language) { // 1. numbers and backspace var numberSymbols = "1234567890"; var numbersRow = new VirtualKeyboardLayoutRow(); numbersRow.AddRange(numberSymbols .Select(x => new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = x.ToString(), })); numbersRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Backspace, }); // 2. letters var lettersLayoutProvider = new UsLettersProvider(); lettersLayoutProvider.InitLayout(language); var lettersLayout = lettersLayoutProvider.Layout; var lettersRows = lettersLayout.Rows; // confirm var lastRow = lettersRows.Last(); lastRow.Insert(0, CreatePlaceholder()); lastRow.Insert(0, CreatePlaceholder()); lastRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Control, Value = LanguageManager.Current.GetLocalizedString("VirtualKeyboard_SearchKey_Text"), ControlCommand = CommonControlCommands.Confirm, Icon = KeyboardIcons.Search, } ); var layout = new VirtualKeyboardLayout(); layout.Rows.Add(numbersRow); layout.Rows.AddRange(lettersRows); Layout = layout; }
private void UpdateLayout() { var layout = new VirtualKeyboardLayout(); var symbols = @"123 456 789 0"; var symbolsLines = symbols.Split('\n') .Select(x => x.Trim()) .ToArray(); for (var i = 0; i < symbolsLines.Length; i++) { var symbolsLine = symbolsLines[i]; var row = new VirtualKeyboardLayoutRow( symbolsLine .Select(x => new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = x.ToString(), })); // add backspace to the last row if (i == symbolsLines.Length - 1) { row.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Backspace, }); } layout.Rows.Add(row); } Layout = layout; }
private void UpdateLayout() { var symbols = GetSymbolsString(); var symbolsLines = symbols.Split('\n') .Select(x => x.Trim()) .ToArray(); var layout = new VirtualKeyboardLayout(); foreach (var symbolsLine in symbolsLines) { var row = new VirtualKeyboardLayoutRow( symbolsLine .Select(x => new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = x.ToString(), })); layout.Rows.Add(row); } Layout = layout; }
private void SetLayoutByLanguage(Language language) { _selectedAppLanguage = language; // 1. numbers and backspace var numberSymbols = "1234567890"; var numbersRow = new VirtualKeyboardLayoutRow(); numbersRow.AddRange(numberSymbols .Select(x => new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = x.ToString(), })); numbersRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Backspace, }); // 2. letters IVirtualKeyboardLayoutProvider lettersLayoutProvider; switch (language.LanguageTag) { case "ru": lettersLayoutProvider = new RussianLettersProvider(); break; case "uk": lettersLayoutProvider = new UkrainianLettersProvider(); break; case "en": default: lettersLayoutProvider = new UsLettersProvider(); break; } lettersLayoutProvider.InitLayout(_currentAppLanguage); var lettersLayout = lettersLayoutProvider.Layout; var lettersRows = lettersLayout.Rows; // additional text symbols var _2ndLetterRow = lettersRows[1]; _2ndLetterRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = "-", }); var _3rdLetterRow = lettersRows[2]; _3rdLetterRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = "/", }); _3rdLetterRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = ".", }); // 3. space and languages var lastRow = new VirtualKeyboardLayoutRow { new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Space, }, new VirtualKey() { Type = VirtualKeyTypeEnum.Control, Value = language.NativeName.ToUpper().FirstNSymbols(3), ControlCommand = CommonControlCommands.SwitchLanguage, }, }; if (ShowConfirmCommand) { // confirm lastRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Control, Value = LanguageManager.Current.GetLocalizedString("VirtualKeyboard_SearchKey_Text"), ControlCommand = CommonControlCommands.Confirm, Icon = KeyboardIcons.Search, }); } else { // 1 placeholder between space and language switch lastRow.Insert(1, CreatePlaceholder()); // 3 placeholder at the start lastRow.Insert(0, CreatePlaceholder()); lastRow.Insert(0, CreatePlaceholder()); } var layout = new VirtualKeyboardLayout(); layout.Rows.Add(numbersRow); layout.Rows.AddRange(lettersRows); layout.Rows.Add(new VirtualKeyboardLayoutRow(lastRow)); Layout = layout; }
private void SetLayoutByLanguage(Language currentAppLanguage) { // 1. numbers and backspace var numberSymbols = "1234567890"; var numbersRow = new VirtualKeyboardLayoutRow(); numbersRow.AddRange(numberSymbols .Select(x => new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = x.ToString(), })); numbersRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Backspace, }); // 2. letters IVirtualKeyboardLayoutProvider lettersLayoutProvider; switch (currentAppLanguage.LanguageTag) { case "ru": lettersLayoutProvider = new RussianLettersProvider(); break; case "uk": lettersLayoutProvider = new UkrainianLettersProvider(); break; case "en": default: lettersLayoutProvider = new UsLettersProvider(); break; } lettersLayoutProvider.InitLayout(currentAppLanguage); var lettersLayout = lettersLayoutProvider.Layout; var lettersRows = lettersLayout.Rows; // additional text symbols var _2ndLetterRow = lettersRows[1]; _2ndLetterRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = "-", }); var _3rdLetterRow = lettersRows[2]; _3rdLetterRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = ",", }); _3rdLetterRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = ".", }); // 3. space var spaceRow = new VirtualKeyboardLayoutRow { new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Space, }, }; var layout = new VirtualKeyboardLayout(); layout.Rows.Add(numbersRow); layout.Rows.AddRange(lettersRows); layout.Rows.Add(spaceRow); Layout = layout; }
internal static int LayoutToInt(VirtualKeyboardLayout layout) { var members = typeof(VirtualKeyboardLayout).GetMember(layout.ToString()); if (members.Length == 0) { throw new NotSupportedException(string.Format("Unknown keyboard layout: {0}", layout)); } Util.ThrowIfUnsupported(members[0], string.Format("The keyboard layout, {0}, is not supported.", layout)); return (int)layout; }
public static void SetOptions(VirtualKeyboardLayout layout, VirtualKeyboardEnter enter, bool noHelp = true) { if (Util.IsCapableOfRunning(10, 3)) { virtualkeyboard_change_options_v2(LayoutToInt(layout), EnterKeyToInt(enter), noHelp); } else { virtualkeyboard_change_options(LayoutToInt(layout), EnterKeyToInt(enter)); } }
private void SetLayoutByLanguage(Language language) { _selectedAppLanguage = language; // 1. numbers and backspace var numberSymbols = "1234567890"; var numbersRow = new VirtualKeyboardLayoutRow(); numbersRow.AddRange(numberSymbols .Select(x => new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = x.ToString(), })); numbersRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Backspace, }); // 2. letters IVirtualKeyboardLayoutProvider lettersLayoutProvider; switch (language.LanguageTag) { case "ru": lettersLayoutProvider = new RussianLettersProvider(); break; case "uk": lettersLayoutProvider = new UkrainianLettersProvider(); break; case "en": default: lettersLayoutProvider = new UsLettersProvider(); break; } lettersLayoutProvider.InitLayout(_currentAppLanguage); var lettersLayout = lettersLayoutProvider.Layout; var lettersRows = lettersLayout.Rows; // extra symbols if (language.LanguageTag == "en") { var _2ndLettersRow = lettersRows[1]; _2ndLettersRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = "-", }); var _3rdLettersRow = lettersRows[2]; _3rdLettersRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = "+", }); _3rdLettersRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = "/", }); _3rdLettersRow.Add(new VirtualKey() { Type = VirtualKeyTypeEnum.Text, Value = ".", }); } // 3. space, languages and confirm var lastRow = new VirtualKeyboardLayoutRow { new VirtualKey() { Type = VirtualKeyTypeEnum.Special, SpecialKeyType = VirtualSpecialKeyTypeEnum.Space, }, new VirtualKey() { Type = VirtualKeyTypeEnum.Control, Value = language.NativeName.ToUpper().FirstNSymbols(3), ControlCommand = CommonControlCommands.SwitchLanguage, }, new VirtualKey() { Type = VirtualKeyTypeEnum.Control, Value = LanguageManager.Current.GetLocalizedString("VirtualKeyboard_SearchKey_Text"), ControlCommand = CommonControlCommands.Confirm, Icon = KeyboardIcons.Search, } }; var layout = new VirtualKeyboardLayout(); layout.Rows.Add(numbersRow); layout.Rows.AddRange(lettersRows); layout.Rows.Add(lastRow); Layout = layout; }