public void DefaultForWritingSystem_OldPalasoKeymanKeyboard() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); KeyboardDescription expectedKeyboard; if (Keyboard.Controller.AllAvailableKeyboards.Any(kbd => kbd.Layout == "IPA Unicode 1.1.1")) { expectedKeyboard = Keyboard.Controller.AllAvailableKeyboards.First(kbd => kbd.Layout == "IPA Unicode 1.1.1") as KeyboardDescription; } else { expectedKeyboard = new KeyboardDescription("IPA Unicode 1.1.1 - English (US)", "IPA Unicode 1.1.1", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); } // Palaso sets the keyboard property for Keyman keyboards to <layoutname> var ws = new MockWritingSystemDefinition { Keyboard = "IPA Unicode 1.1.1" }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }
public void GetKeyboard_FromInputLanguage_ExistingKeyboardReturnsKeyboard() { IKeyboardDefinition keyboard = Keyboard.Controller.CreateKeyboard("en-US_foo", KeyboardFormat.Unknown, null); var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); Assert.That(Keyboard.Controller.GetKeyboard(inputLanguage), Is.EqualTo(keyboard)); }
/// <summary> /// Creates and returns a keyboard definition object based on the ID. /// Note that this method is used when we do NOT have a matching available keyboard. /// Therefore we can presume that the created one is NOT available. /// </summary> public KeyboardDescription CreateKeyboardDefinition(string id) { CheckDisposed(); string[] parts = id.Split('_'); string locale = parts[0]; string layout = parts[1]; IInputLanguage inputLanguage; string cultureName; try { var ci = new CultureInfo(locale); cultureName = ci.DisplayName; inputLanguage = new InputLanguageWrapper(ci, IntPtr.Zero, layout); } catch (CultureNotFoundException) { // ignore if we can't find a culture (this can happen e.g. when a language gets // removed that was previously assigned to a WS) - see LT-15333 inputLanguage = null; cultureName = "[Unknown Language]"; } return(new WinKeyboardDescription(id, GetDisplayName(layout, cultureName), layout, locale, false, inputLanguage, this, GetDisplayName(layout, cultureName), new TfInputProcessorProfile())); }
public void GetKeyboard_FromInputLanguage_ExistingKeyboardReturnsKeyboard() { var keyboard = Keyboard.Controller.CreateKeyboardDefinition("foo", "en-US"); KeyboardController.Manager.RegisterKeyboard(keyboard); var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); Assert.That(Keyboard.Controller.GetKeyboard(inputLanguage), Is.EqualTo(keyboard)); }
public void CreateKeyboardDefinition_ExistingKeyboard_ReturnsReference() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); var expectedKeyboard = new KeyboardDescription("foo - English (US)", "foo", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); var keyboard = Keyboard.Controller.CreateKeyboardDefinition("foo", "en-US"); Assert.That(keyboard, Is.SameAs(expectedKeyboard)); Assert.That(keyboard, Is.TypeOf <KeyboardDescription>()); Assert.That((keyboard as KeyboardDescription).InputLanguage, Is.EqualTo(inputLanguage)); }
public void DefaultForWritingSystem_OldPalasoWinIMEKeyboard() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); var expectedKeyboard = new KeyboardDescription("foo - English (US)", "foo", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); // Palaso sets the keyboard property for Windows system keyboards to <layoutname>-<locale> var ws = new MockWritingSystemDefinition { Keyboard = "foo-en-US" }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }
public void DefaultForWritingSystem_OldFwKeymanKeyboard() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); var expectedKeyboard = new KeyboardDescription("IPA Unicode 1.1.1 - English (US)", "IPA Unicode 1.1.1", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); // FieldWorks sets the keyboard property for Keyman keyboards to <layoutname> and WindowsLcid to <lcid> var ws = new MockWritingSystemDefinition { Keyboard = "IPA Unicode 1.1.1", WindowsLcid = 0x409.ToString() }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }
public WinKeyboardDescription(string locale, string layout, IKeyboardAdaptor engine) : base(engine, KeyboardType.System) { InputLanguageWrapper inputLanguage = null; try { inputLanguage = new InputLanguageWrapper(new CultureInfo(locale), IntPtr.Zero, layout); } catch (CultureNotFoundException) { // ignore if we can't find a culture (this can happen e.g. when a language gets // removed that was previously assigned to a WS) - see LT-15333 } Initialize(locale, new WinKeyboardAdaptor.LayoutName(layout), locale, inputLanguage); }
public void DefaultForWritingSystem_OldPalasoIbusKeyboard() { #if __MonoCS__ // For this test on Linux we only use the XkbKeyboardAdaptor and simulate an available // IBus keyboard. This is necessary because otherwise the test might return an // installed Danish IBus keyboard (m17n:da:post) instead of our expected dummy one. KeyboardController.Manager.SetKeyboardAdaptors(new[] { new Palaso.UI.WindowsForms.Keyboarding.Linux.XkbKeyboardAdaptor() }); #endif var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); var expectedKeyboard = new KeyboardDescription("m17n:da:post - English (US)", "m17n:da:post", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); // Palaso sets the keyboard property for Ibus keyboards to <ibus longname> var ws = new MockWritingSystemDefinition { Keyboard = "m17n:da:post" }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }
public static IInputLanguage GetInputLanguage(string locale, string layout, out string cultureName) { IInputLanguage inputLanguage; try { var ci = new CultureInfo(locale); cultureName = ci.DisplayName; inputLanguage = new InputLanguageWrapper(ci, IntPtr.Zero, layout); } catch (CultureNotFoundException) { // ignore if we can't find a culture (this can happen e.g. when a language gets // removed that was previously assigned to a WS) - see LT-15333 inputLanguage = null; cultureName = "[Unknown Language]"; } return(inputLanguage); }
internal static void AddKeyboardForLayout(IDictionary <string, XkbKeyboardDescription> curKeyboards, XklConfigRegistry.LayoutDescription layout, uint iGroup, IKeyboardSwitchingAdaptor engine) { string description = GetDescription(layout); CultureInfo culture = null; try { culture = new CultureInfo(layout.LocaleId); } catch (ArgumentException) { // This can happen if the locale is not supported. // TODO: fix mono's list of supported locales. Doesn't support e.g. de-BE. // See mono/tools/locale-builder. } string id = string.Format("{0}_{1}", layout.LocaleId, layout.LayoutId); var inputLanguage = new InputLanguageWrapper(culture, IntPtr.Zero, layout.Language); XkbKeyboardDescription existingKeyboard; if (curKeyboards.TryGetValue(id, out existingKeyboard)) { if (!existingKeyboard.IsAvailable) { existingKeyboard.SetIsAvailable(true); existingKeyboard.SetName(description); existingKeyboard.SetInputLanguage(inputLanguage); existingKeyboard.GroupIndex = (int)iGroup; } curKeyboards.Remove(id); } else { var keyboard = new XkbKeyboardDescription(id, description, layout.LayoutId, layout.LocaleId, true, inputLanguage, engine, (int)iGroup); if (!KeyboardController.Instance.Keyboards.Contains(keyboard.Id)) { KeyboardController.Instance.Keyboards.Add(keyboard); } } }
internal void AddKeyboardForLayout(XklConfigRegistry.LayoutDescription layout, int iGroup, IKeyboardAdaptor engine) { var description = GetDescription(layout); CultureInfo culture = null; try { culture = new CultureInfo(layout.LocaleId); } catch (ArgumentException) { // This can happen if the locale is not supported. // TODO: fix mono's list of supported locales. Doesn't support e.g. de-BE. // See mono/tools/locale-builder. } var inputLanguage = new InputLanguageWrapper(culture, IntPtr.Zero, layout.Language); var keyboard = new XkbKeyboardDescription(description, layout.LayoutId, layout.LocaleId, inputLanguage, engine, iGroup); KeyboardController.Manager.RegisterKeyboard(keyboard); }
public void DefaultForWritingSystem_OldFwSystemKeyboard() { // 0x001C is Albanian (see http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx). // Make sure it's not installed on current system. if (InputLanguage.InstalledInputLanguages.Cast <InputLanguage>().Any(lang => lang.Culture.LCID == 0x041C)) { Assert.Ignore("Input language 'Albanian (Albania)' is installed on current system. Can't run this test."); } var inputLanguage = new InputLanguageWrapper("sq-AL", IntPtr.Zero, "US"); var expectedKeyboard = new KeyboardDescription("US - Albanian (Albania)", "US", "sq-AL", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); // FieldWorks sets the WindowsLcid property for System keyboards to <lcid> var ws = new MockWritingSystemDefinition { WindowsLcid = 0x041C.ToString() }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }
public void WrapperAndOriginalAreEqual() { var wrapper = new InputLanguageWrapper(InputLanguage.CurrentInputLanguage); Assert.That(wrapper.Equals(InputLanguage.CurrentInputLanguage)); }
public void ImplicitCastToInputLanguageWrapper() { InputLanguageWrapper wrapper = InputLanguage.CurrentInputLanguage; Assert.That(wrapper, Is.Not.Null); }
internal static void AddKeyboardForLayout(IDictionary<string, XkbKeyboardDescription> curKeyboards, XklConfigRegistry.LayoutDescription layout, uint iGroup, IKeyboardSwitchingAdaptor engine) { string description = GetDescription(layout); CultureInfo culture = null; try { culture = new CultureInfo(layout.LocaleId); } catch (ArgumentException) { // This can happen if the locale is not supported. // TODO: fix mono's list of supported locales. Doesn't support e.g. de-BE. // See mono/tools/locale-builder. } string id = string.Format("{0}_{1}", layout.LocaleId, layout.LayoutId); var inputLanguage = new InputLanguageWrapper(culture, IntPtr.Zero, layout.Language); XkbKeyboardDescription existingKeyboard; if (curKeyboards.TryGetValue(id, out existingKeyboard)) { if (!existingKeyboard.IsAvailable) { existingKeyboard.SetIsAvailable(true); existingKeyboard.SetName(description); existingKeyboard.SetInputLanguage(inputLanguage); existingKeyboard.GroupIndex = (int) iGroup; } curKeyboards.Remove(id); } else { var keyboard = new XkbKeyboardDescription(id, description, layout.LayoutId, layout.LocaleId, true, inputLanguage, engine, (int) iGroup); KeyboardController.Instance.Keyboards.Add(keyboard); } }
public void GetKeyboard_FromInputLanguage_NonExistingKeyboard() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); Assert.That(Keyboard.Controller.GetKeyboard(inputLanguage), Is.EqualTo(KeyboardController.NullKeyboard)); }
public void GetKeyboard_FromInputLanguage_NonExistingKeyboard() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); Assert.That(Keyboard.Controller.GetKeyboard(inputLanguage), Is.EqualTo(KeyboardDescription.Zero)); }
/// <summary> /// Creates and returns a keyboard definition object based on the layout and locale. /// </summary> public override IKeyboardDefinition CreateKeyboardDefinition(string layout, string locale) { var inputLanguage = new InputLanguageWrapper(new CultureInfo(locale), IntPtr.Zero, layout); return(new KeyboardDescription(layout, layout, locale, inputLanguage, KeyboardController.Adaptors[0])); }
public MockKeyboardDescription(string id, string locale, string layout) : base(id, id + "mockKbDescription", layout, locale, true, null) { InputLanguage = new InputLanguageWrapper(locale, IntPtr.Zero, layout); }
/// <summary> /// Creates and returns a keyboard definition object based on the ID. /// Note that this method is used when we do NOT have a matching available keyboard. /// Therefore we can presume that the created one is NOT available. /// </summary> public KeyboardDescription CreateKeyboardDefinition(string id) { CheckDisposed(); string[] parts = id.Split('_'); string locale = parts[0]; string layout = parts[1]; IInputLanguage inputLanguage; string cultureName; try { var ci = new CultureInfo(locale); cultureName = ci.DisplayName; inputLanguage = new InputLanguageWrapper(ci, IntPtr.Zero, layout); } catch (CultureNotFoundException) { // ignore if we can't find a culture (this can happen e.g. when a language gets // removed that was previously assigned to a WS) - see LT-15333 inputLanguage = null; cultureName = "[Unknown Language]"; } return new WinKeyboardDescription(id, GetDisplayName(layout, cultureName), layout, locale, false, inputLanguage, this, GetDisplayName(layout, cultureName), new TfInputProcessorProfile()); }