private void GetNonLocalizableKeyNames() { // These have to be extracted from the keycode XML // as thay aren't available otherwise (they don't change) var kd = new KeyDataXml(); foreach (int code in _nonLocalizableKeys) { _nonLocalizableKeyNames.Add(code, kd.GetKeyNameFromCode(code)); } }
public static void SetLocale(string locale = null) { // Only want to reset locale temporarily so save current value string currentkeyboardlocale = KeyboardHelper.GetCurrentKeyboardLocale(); if (String.IsNullOrEmpty(locale)) { // At startup we need to load the current locale. locale = currentkeyboardlocale; } if ((locale != currentLocale)) { if (customKeyboardLayouts != null && customKeyboardLayouts.ContainsKey(locale)) { KeyboardLayout = (KeyboardLayoutType)customKeyboardLayouts[locale]; } else { // Ask the keydata interface what kind of layout this locale has - US, Euro etc. KeyboardLayout = new KeyDataXml().GetKeyboardLayoutType(locale); } // Load the keyboard layout for the minimum possible time and keep the results: // This can error with some cultures, problems with framework, unhandled thread exception occurs. try { // if (_currentCultureInfo != null) // Console.WriteLine("Setting culture to: LCID: {0}", _currentCultureInfo.LCID); int culture = KeyboardHelper.SetLocale(locale); CurrentCultureInfo = new CultureInfo(culture); _currentLayout = new LocalizedKeySet(); currentLocale = locale; } catch (Exception ex) { Console.WriteLine("Set Locale Exception: {0}", ex); } finally { // Set it back (if different) if (currentLocale != currentkeyboardlocale) { KeyboardHelper.SetLocale(currentkeyboardlocale); } } } }
private static void SaveCustomLayouts() { // Always save, but only if layout actually is custom. // This means next time we only load layouts which are different. // Always overwrite, in case custom layouts have been cleared. string path = Path.Combine(KeyMapperFilePath, "customlayouts.txt"); var kd = new KeyDataXml(); using (var sw = new StreamWriter(path, false)) { foreach (DictionaryEntry de in customKeyboardLayouts) { if ((int)de.Value != (int)kd.GetKeyboardLayoutType(de.Key.ToString())) { sw.WriteLine(de.Key + "=" + (int)de.Value); } } } }
public static void SetLocale(string locale = null) { // Only want to reset locale temporarily so save current value string currentkeyboardlocale = KeyboardHelper.GetCurrentKeyboardLocale(); if (String.IsNullOrEmpty(locale)) { // At startup we need to load the current locale. locale = currentkeyboardlocale; } if ((locale != currentLocale)) { if (customKeyboardLayouts != null && customKeyboardLayouts.ContainsKey(locale)) KeyboardLayout = (KeyboardLayoutType)customKeyboardLayouts[locale]; else { // Ask the keydata interface what kind of layout this locale has - US, Euro etc. KeyboardLayout = new KeyDataXml().GetKeyboardLayoutType(locale); } // Load the keyboard layout for the minimum possible time and keep the results: // This can error with some cultures, problems with framework, unhandled thread exception occurs. try { // if (_currentCultureInfo != null) // Console.WriteLine("Setting culture to: LCID: {0}", _currentCultureInfo.LCID); int culture = KeyboardHelper.SetLocale(locale); CurrentCultureInfo = new CultureInfo(culture); _currentLayout = new LocalizedKeySet(); currentLocale = locale; } catch (Exception ex) { Console.WriteLine("Set Locale Exception: {0}", ex); } finally { // Set it back (if different) if (currentLocale != currentkeyboardlocale) KeyboardHelper.SetLocale(currentkeyboardlocale); } } }
private static void SaveCustomLayouts() { // Always save, but only if layout actually is custom. // This means next time we only load layouts which are different. // Always overwrite, in case custom layouts have been cleared. string path = Path.Combine(KeyMapperFilePath, "customlayouts.txt"); var kd = new KeyDataXml(); using (var sw = new StreamWriter(path, false)) { foreach (DictionaryEntry de in customKeyboardLayouts) if ((int)de.Value != (int)kd.GetKeyboardLayoutType(de.Key.ToString())) sw.WriteLine(de.Key + "=" + (int)de.Value); } }