Example #1
0
        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);
                }
            }
        }
		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;
		}
		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);
			}
		}