/// <summary> /// Initializes a new instance of the /// <see cref="T:Palaso.UI.WindowsForms.Keyboard.Windows.KeymanKeyboardDescription"/> class. /// </summary> public KeymanKeyboardDescription(string layout, bool isKeyman6, IKeyboardSwitchingAdaptor engine) : base(engine, KeyboardType.OtherIm) { InternalName = layout; Layout = layout; IsKeyman6 = isKeyman6; }
/// <summary> /// Initializes a new instance of the /// <see cref="SIL.Windows.Forms.Keyboarding.Linux.XkbKeyboardDescription"/> class. /// </summary> public XkbKeyboardDescription(string id, string name, string layout, string locale, bool isAvailable, IInputLanguage language, IKeyboardSwitchingAdaptor engine, int groupIndex) : base(id, name, layout, locale, isAvailable, engine) { InputLanguage = language; GroupIndex = groupIndex; }
internal KeyboardDescription(IKeyboardSwitchingAdaptor engine, KeyboardType type) { Engine = engine; Type = type; IsAvailable = true; OperatingSystem = Environment.OSVersion.Platform; }
public void Setup() { var keyboardRetrievingAdaptorDouble = new CombinedIbusKeyboardRetrievingAdaptorDouble(); KeyboardController.Initialize(keyboardRetrievingAdaptorDouble); Adaptor = keyboardRetrievingAdaptorDouble.SwitchingAdaptor; }
internal static XkbKeyboardDescription CreateKeyboardDefinition(string id, IKeyboardSwitchingAdaptor engine) { string layout, locale; KeyboardController.GetLayoutAndLocaleFromLanguageId(id, out layout, out locale); string realLocale = locale; if (locale == "zh") { realLocale = "zh-CN"; // Mono doesn't support bare "zh" until version 3 sometime } else if (locale == "x040F") { realLocale = "is"; // 0x040F is the numeric code for Icelandic. } // Don't crash if the locale is unknown to the system. (It may be that ibus is not running and // this particular locale and layout refer to an ibus keyboard.) Mark the keyboard description // as missing, but create an English (US) keyboard underneath. if (IsLocaleKnown(realLocale)) { return(new XkbKeyboardDescription(id, string.Format("{0} ({1})", locale, layout), layout, locale, false, new InputLanguageWrapper(realLocale, IntPtr.Zero, layout), engine, -1)); } string missingKeyboardFmt = L10NSharp.LocalizationManager.GetString("XkbKeyboardAdaptor.MissingKeyboard", "[Missing] {0} ({1})"); return(new XkbKeyboardDescription(id, String.Format(missingKeyboardFmt, locale, layout), layout, locale, false, new InputLanguageWrapper("en", IntPtr.Zero, "US"), engine, -1)); }
public IbusKeyboardDescription(IKeyboardSwitchingAdaptor engine, IBusEngineDesc ibusKeyboard, uint systemIndex): base(FormatKeyboardIdentifier(ibusKeyboard), ibusKeyboard.LongName, ibusKeyboard.Language, null, engine, KeyboardType.OtherIm) { IBusKeyboardEngine = ibusKeyboard; SystemIndex = systemIndex; }
/// <summary> /// Initializes a new instance of the /// <see cref="T:Palaso.UI.WindowsForms.Keyboard.KeyboardDescription"/> class. /// </summary> internal KeyboardDescription(string name, string layout, string locale, IInputLanguage language, IKeyboardSwitchingAdaptor engine, KeyboardType type = KeyboardType.System) { InternalName = name; Layout = layout; Locale = locale; Engine = engine; Type = type; IsAvailable = true; OperatingSystem = Environment.OSVersion.Platform; InputLanguage = language; }
public WinKeyboardDescription(string locale, string layout, IKeyboardSwitchingAdaptor 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); }
private static IbusKeyboardDescription CreateMockIbusKeyboard(IKeyboardSwitchingAdaptor ibusKeyboardAdapter, string name, string language, string layout) { var engineDescMock = new Mock <IBusEngineDesc>(); engineDescMock.Setup(x => x.Name).Returns(name); engineDescMock.Setup(x => x.Language).Returns(language); engineDescMock.Setup(x => x.Layout).Returns(layout); var keyboard = new IbusKeyboardDescription(string.Format("{0}_{1}", language, name), engineDescMock.Object, ibusKeyboardAdapter) { SystemIndex = 3 }; KeyboardController.Instance.Keyboards.Add(keyboard); return(keyboard); }
public WinKeyboardAdaptor() { try { ProcessorProfiles = new TfInputProcessorProfilesClass(); } catch (InvalidCastException) { ProcessorProfiles = null; return; } // ProfileMgr will be null on Windows XP - the interface got introduced in Vista ProfileManager = ProcessorProfiles as ITfInputProcessorProfileMgr; SwitchingAdaptor = new WindowsKeyboardSwitchingAdapter(this); }
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 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); } }
private WinKeyboardDescription(TfInputProcessorProfile profile, ushort langId, IntPtr hkl, IKeyboardSwitchingAdaptor engine) : base(engine, KeyboardType.System) { var winEngine = engine as WinKeyboardAdaptor; Debug.Assert(winEngine != null); InputProcessorProfile = profile; var culture = new CultureInfo(langId); string locale; string cultureName; try { cultureName = culture.DisplayName; locale = culture.Name; } catch (CultureNotFoundException) { // we get an exception for non-supported cultures, probably because of a // badly applied .NET patch. // http://www.ironspeed.com/Designer/3.2.4/WebHelp/Part_VI/Culture_ID__XXX__is_not_a_supported_culture.htm and others cultureName = "[Unknown Language]"; locale = "en-US"; } WinKeyboardAdaptor.LayoutName layoutName; if (profile.Hkl == IntPtr.Zero && profile.ProfileType != TfProfileType.Illegal) { layoutName = new WinKeyboardAdaptor.LayoutName(winEngine.ProcessorProfiles.GetLanguageProfileDescription( ref profile.ClsId, profile.LangId, ref profile.GuidProfile)); } else layoutName = WinKeyboardAdaptor.GetLayoutNameEx(hkl); Initialize(cultureName, layoutName, locale, new InputLanguageWrapper(culture, hkl, layoutName.Name)); }
public virtual void Initialize() { _adaptor = new XkbKeyboardSwitchingAdaptor(_engine); }
/// <summary> /// Creates and returns a keyboard definition object based on the layout and locale. /// 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> internal static IKeyboardDefinition CreateKeyboardDefinition(string layout, string locale, IKeyboardSwitchingAdaptor adaptor) { var realLocale = locale; if (locale == "zh") { realLocale = "zh-CN"; // Mono doesn't support bare "zh" until version 3 sometime } else if (locale == "x040F") { realLocale = "is"; // 0x040F is the numeric code for Icelandic. } // Don't crash if the locale is unknown to the system. (It may be that ibus is not running and // this particular locale and layout refer to an ibus keyboard.) Mark the keyboard description // as missing, but create an English (US) keyboard underneath. if (IsLocaleKnown(realLocale)) return new XkbKeyboardDescription(string.Format("{0} ({1})", locale, layout), layout, locale, new InputLanguageWrapper(realLocale, IntPtr.Zero, layout), adaptor, -1) {IsAvailable = false}; if (_missingKeyboardFmt == null) { _missingKeyboardFmt = L10NSharp.LocalizationManager.GetString("XkbKeyboardAdaptor.MissingKeyboard", "[Missing] {0} ({1})"); } return new XkbKeyboardDescription(String.Format(_missingKeyboardFmt, locale, layout), layout, locale, new InputLanguageWrapper("en", IntPtr.Zero, "US"), adaptor, -1) {IsAvailable = false}; }
internal void AddKeyboardForLayout(XklConfigRegistry.LayoutDescription layout, uint iGroup, IKeyboardSwitchingAdaptor 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, (int)iGroup); KeyboardController.Manager.RegisterKeyboard(keyboard); }
public IbusXkbKeyboardDescription(string id, IBusEngineDesc ibusKeyboard, IKeyboardSwitchingAdaptor engine) : base(id, ibusKeyboard, engine) { }
public IbusKeyboardDescription(string id, string layout, string locale, IKeyboardSwitchingAdaptor engine) : base (id, FormatKeyboardIdentifier(layout, locale), layout, locale, false, engine) { }
public virtual void Initialize() { SwitchingAdaptor = new XkbKeyboardSwitchingAdaptor(_engine); InitLocales(); }
/// <summary> /// Initialize the installed keyboards /// </summary> public virtual void Initialize() { SwitchingAdaptor = new IbusKeyboardSwitchingAdaptor(_ibusComm); InitKeyboards(); }
private static IbusKeyboardDescription CreateMockIbusKeyboard(IKeyboardSwitchingAdaptor ibusKeyboardAdapter, string name, string language, string layout) { var engineDescMock = new Mock<IBusEngineDesc>(); engineDescMock.Setup(x => x.Name).Returns(name); engineDescMock.Setup(x => x.Language).Returns(language); engineDescMock.Setup(x => x.Layout).Returns(layout); var keyboard = new IbusKeyboardDescription(string.Format("{0}_{1}", language, name), engineDescMock.Object, ibusKeyboardAdapter) {SystemIndex = 3}; KeyboardController.Instance.Keyboards.Add(keyboard); return keyboard; }
/// <summary> /// Initializes a new instance of the /// <see cref="T:Palaso.UI.WindowsForms.Keyboard.Linux.XkbKeyboardDescription"/> class. /// </summary> /// <param name='name'>Display name of the keyboard</param> /// <param name='layout'>Name of the keyboard layout</param> /// <param name='locale'>The locale of the keyboard</param> /// <param name='engine'>The keyboard adaptor that will handle this keyboard</param> /// <param name='groupIndex'>The group index of this xkb keyboard</param> internal XkbKeyboardDescription(string name, string layout, string locale, IInputLanguage language, IKeyboardSwitchingAdaptor engine, int groupIndex) : base(name, layout, locale, language, engine) { GroupIndex = groupIndex; }
private static XkbKeyboardDescription CreateMockXkbKeyboard(string name, string layout, string locale, string layoutName, int group, IKeyboardSwitchingAdaptor adapter) { var keyboard = new XkbKeyboardDescription(name, layout, locale, new InputLanguageWrapper(locale, IntPtr.Zero, layoutName), adapter, group); KeyboardController.Manager.RegisterKeyboard(keyboard); return keyboard; }
private static IbusKeyboardDescription CreateMockIbusKeyboard(IKeyboardSwitchingAdaptor ibusKeyboardAdapter, string name, string language, string layout) { var engineDescMock = new Mock<IBusEngineDesc>(); engineDescMock.Setup(x => x.Name).Returns(name); engineDescMock.Setup(x => x.Language).Returns(language); engineDescMock.Setup(x => x.Layout).Returns(layout); var keyboard = new IbusKeyboardDescription(ibusKeyboardAdapter, engineDescMock.Object, 3); KeyboardController.Manager.RegisterKeyboard(keyboard); return keyboard; }
/// <summary> /// Initializes a new instance of the /// <see cref="T:Palaso.UI.WindowsForms.Keyboard.Windows.WinKeyboardDescription"/> class. /// </summary> public WinKeyboardDescription(TfInputProcessorProfile profile, IKeyboardSwitchingAdaptor engine) : this(profile, profile.LangId, profile.Hkl, engine) { }
public virtual void Close() { _engine.Close(); _engine = null; _adaptor = null; }
internal static XkbKeyboardDescription CreateKeyboardDefinition(string id, IKeyboardSwitchingAdaptor engine) { string[] parts = id.Split('_'); string locale = parts[0]; string layout = parts.Length > 1 ? parts[1] : string.Empty; string realLocale = locale; if (locale == "zh") { realLocale = "zh-CN"; // Mono doesn't support bare "zh" until version 3 sometime } else if (locale == "x040F") { realLocale = "is"; // 0x040F is the numeric code for Icelandic. } // Don't crash if the locale is unknown to the system. (It may be that ibus is not running and // this particular locale and layout refer to an ibus keyboard.) Mark the keyboard description // as missing, but create an English (US) keyboard underneath. if (IsLocaleKnown(realLocale)) return new XkbKeyboardDescription(id, string.Format("{0} ({1})", locale, layout), layout, locale, false, new InputLanguageWrapper(realLocale, IntPtr.Zero, layout), engine, -1); string missingKeyboardFmt = L10NSharp.LocalizationManager.GetString("XkbKeyboardAdaptor.MissingKeyboard", "[Missing] {0} ({1})"); return new XkbKeyboardDescription(id, String.Format(missingKeyboardFmt, locale, layout), layout, locale, false, new InputLanguageWrapper("en", IntPtr.Zero, "US"), engine, -1); }
public IbusKeyboardDescription(string id, string layout, string locale, IKeyboardSwitchingAdaptor engine) : base(id, FormatKeyboardIdentifier(layout, locale), layout, locale, false, engine) { }
public IbusKeyboardDescription(string id, IBusEngineDesc ibusKeyboard, IKeyboardSwitchingAdaptor engine) : base(id, FormatKeyboardIdentifier(ibusKeyboard.Name, ibusKeyboard.Language), ibusKeyboard.LongName, ibusKeyboard.Language, true, engine) { IBusKeyboardEngine = ibusKeyboard; }
public void Initialize() { CheckDisposed(); SwitchingAdaptor = GetKeymanSwitchingAdapter(InstalledKeymanVersion); UpdateAvailableKeyboards(); }
/// <summary> /// Initializes a new instance of the /// <see cref="KeyboardDescription"/> class. /// </summary> public KeyboardDescription(string id, string name, string layout, string locale, bool isAvailable, IKeyboardSwitchingAdaptor engine) : base(id, name, layout, locale, isAvailable) { _engine = engine; }
public WinKeyboardDescription(IntPtr hkl, IKeyboardSwitchingAdaptor engine) : this(new TfInputProcessorProfile(), HklToLangId(hkl), hkl, engine) { }
private static XkbKeyboardDescription CreateMockXkbKeyboard(string name, string layout, string locale, string layoutName, int group, IKeyboardSwitchingAdaptor adapter) { var keyboard = new XkbKeyboardDescription(string.Format("{0}_{1}", layout, locale), name, layout, locale, true, new InputLanguageWrapper(locale, IntPtr.Zero, layoutName), adapter, group); KeyboardController.Instance.Keyboards.Add(keyboard); return(keyboard); }
private static XkbKeyboardDescription CreateMockXkbKeyboard(string name, string layout, string locale, string layoutName, int group, IKeyboardSwitchingAdaptor adapter) { var keyboard = new XkbKeyboardDescription(string.Format("{0}_{1}", layout, locale), name, layout, locale, true, new InputLanguageWrapper(locale, IntPtr.Zero, layoutName), adapter, group); KeyboardController.Instance.Keyboards.Add(keyboard); return keyboard; }