private void LoadSettings() { this.m_moduleNames = new string[this.m_genericInputMethods.Count]; this.m_moduleXMLFilePaths = new string[this.m_genericInputMethods.Count]; this.m_moduleDictionaries = new Dictionary <string, string> [this.m_genericInputMethods.Count]; int i = 0; foreach (KeyValuePair <string, string> kvp in m_genericInputMethods) { string cin = kvp.Key; this.m_moduleNames[i] = cin; this.m_moduleXMLFilePaths[i] = TakaoHelper.GetXMLFullPath(m_venderIdentifer + "." + cin + ".plist"); this.m_moduleDictionaries[i] = TakaoHelper.DictionaryFromFile(m_moduleXMLFilePaths[i]); try { // The default values; this.m_moduleDictionaries[i].Add("MaximumRadicalLength", "20"); this.m_moduleDictionaries[i].Add("ShouldCommitAtMaximumRadicalLength", "false"); this.m_moduleDictionaries[i].Add("ClearReadingBufferAtCompositionError", "false"); this.m_moduleDictionaries[i].Add("MatchOneChar", "?"); this.m_moduleDictionaries[i].Add("MatchZeroOrMoreChar", "*"); this.m_moduleDictionaries[i].Add("UseDynamicFrequency", "false"); } catch { } this.u_modulesListBox.Items.Add(kvp.Value); PanelGenericSettings setting = new PanelGenericSettings(cin, kvp.Value, m_moduleDictionaries[i], u_applyButton); this.AddPanel(setting, cin); i++; } this.u_modulesListBox.SelectedIndex = 0; }
/// <summary> /// Write preference into XML files. /// </summary> private void SaveSettings() { #region Avoid keykey.plist changes by UI during setting preference. Dictionary <string, string> currenGeneralDictionary = TakaoHelper.DictionaryFromFile(m_generalXMLpath); if (currenGeneralDictionary.Count > 0) { string ActivatedAroundFiltersStirng; currenGeneralDictionary.TryGetValue("ActivatedAroundFilters", out ActivatedAroundFiltersStirng); try { if (ActivatedAroundFiltersStirng == null || ActivatedAroundFiltersStirng.Length == 0) { ActivatedAroundFiltersStirng = "ARRAY:"; } else { string stringToExplode = ActivatedAroundFiltersStirng.Remove(0, 6); string[] aroundFilters = stringToExplode.Split(", ".ToCharArray()); ActivatedAroundFiltersStirng = "ARRAY:"; int count = 0; foreach (string aroundFilter in aroundFilters) { if (aroundFilter.StartsWith("ReverseLookup-")) { continue; } ActivatedAroundFiltersStirng += aroundFilter; if (count < aroundFilters.Length - 1) { ActivatedAroundFiltersStirng += ", "; } count++; } } } catch { } try { // If lookup is enabled; if (this.u_panelGeneral.ReverseLookupMethod.Length > 0) { if (ActivatedAroundFiltersStirng == "ARRAY:") { ActivatedAroundFiltersStirng = "ARRAY:" + this.u_panelGeneral.ReverseLookupMethod; } else { ActivatedAroundFiltersStirng += ", " + this.u_panelGeneral.ReverseLookupMethod; } } } catch { } string ActivatedOutputFiltersString; currenGeneralDictionary.TryGetValue("ActivatedOutputFilters", out ActivatedOutputFiltersString); try { if (ActivatedOutputFiltersString == null || ActivatedOutputFiltersString.Length == 0) { ActivatedOutputFiltersString = "ARRAY:"; } } catch { } string PrimaryInputMethod; currenGeneralDictionary.TryGetValue("PrimaryInputMethod", out PrimaryInputMethod); try { m_generalDictionary.Remove("ActivatedAroundFilters"); m_generalDictionary.Remove("ActivatedOutputFilters"); m_generalDictionary.Remove("PrimaryInputMethod"); m_generalDictionary.Add("ActivatedAroundFilters", ActivatedAroundFiltersStirng); m_generalDictionary.Add("ActivatedOutputFilters", ActivatedOutputFiltersString); m_generalDictionary.Add("PrimaryInputMethod", PrimaryInputMethod); } catch { } } #endregion TakaoHelper.DictionaryToFile(m_generalDictionary, m_generalXMLpath); TakaoHelper.DictionaryToFile(m_traditionalPhoneticDictionary, m_traditionalPhoneticXMLpath); TakaoHelper.DictionaryToFile(m_smartPhoneticDictionary, m_smartPhoneticXMLpath); TakaoHelper.DictionaryToFile(m_cangjieDictionary, m_cangjieXMLpath); TakaoHelper.DictionaryToFile(m_simplexDictionary, m_simplexXMLpath); TakaoHelper.DictionaryToFile(m_searchDictionary, m_oneKeyXMLpath); if (this.m_hasGenericInputMethods) { this.u_panelGeneric.SaveSettings(); } }
/// <summary> /// Initializing configurations from saved XML files. /// </summary> private void LoadSettings() { #region Loading properties // Load the settings from the XML files into Dictionary objects. this.m_generalDictionary = TakaoHelper.DictionaryFromFile(m_generalXMLpath); this.m_traditionalPhoneticDictionary = TakaoHelper.DictionaryFromFile(m_traditionalPhoneticXMLpath); this.m_smartPhoneticDictionary = TakaoHelper.DictionaryFromFile(m_smartPhoneticXMLpath); this.m_cangjieDictionary = TakaoHelper.DictionaryFromFile(m_cangjieXMLpath); this.m_simplexDictionary = TakaoHelper.DictionaryFromFile(m_simplexXMLpath); this.m_searchDictionary = TakaoHelper.DictionaryFromFile(m_oneKeyXMLpath); // If some important settings do not exist in the XML files, we add them here with the default value. try { // The default general settings this.TryAddValueInDictionary(this.m_generalDictionary, "ShouldUseNotifyWindow", "true"); this.TryAddValueInDictionary(this.m_generalDictionary, "ShouldUseTransparentStatusBar", "false"); this.TryAddValueInDictionary(this.m_generalDictionary, "ShouldPlaySoundOnTypingError", "true"); this.TryAddValueInDictionary(this.m_generalDictionary, "SoundFilename", "Default"); this.TryAddValueInDictionary(this.m_generalDictionary, "ShouldCheckUpdateOnLaunch", "true"); this.TryAddValueInDictionary(this.m_generalDictionary, "IgnoreShiftAsAlphanumericModeToggleKey", "false"); this.TryAddValueInDictionary(this.m_generalDictionary, "EnablesCapsLockAsAlphanumericModeToggle", "false"); this.TryAddValueInDictionary(this.m_generalDictionary, "ToggleInputMethodWithControlBackslash", "true"); this.TryAddValueInDictionary(this.m_generalDictionary, "HighlightColor", "Purple"); this.TryAddValueInDictionary(this.m_generalDictionary, "BackgroundColor", "Black"); this.TryAddValueInDictionary(this.m_generalDictionary, "TextColor", "White"); this.TryAddValueInDictionary(this.m_generalDictionary, "BackgroundPattern", "false"); this.TryAddValueInDictionary(this.m_generalDictionary, "ShouldUseSystemTray", "false"); this.TryAddValueInDictionary(this.m_generalDictionary, "ChineseConverterToggleKey", "s"); this.TryAddValueInDictionary(this.m_generalDictionary, "RepeatLastCommitTextKey", "g"); this.TryAddValueInDictionary(this.m_generalDictionary, "KeyboardFormShouldFollowCursor", "false"); this.TryAddValueInDictionary(this.m_generalDictionary, "ModulesSuppressedFromUI", "ARRAY:"); // The default settings for the Traditional Phonetic Input Method this.TryAddValueInDictionary(this.m_traditionalPhoneticDictionary, "KeyboardLayout", "Standard"); this.TryAddValueInDictionary(this.m_traditionalPhoneticDictionary, "UseCharactersSupportedByEncoding", ""); // The default settings for the Smart Phonetic Input Method this.TryAddValueInDictionary(this.m_smartPhoneticDictionary, "KeyboardLayout", "Standard"); this.TryAddValueInDictionary(this.m_smartPhoneticDictionary, "UseCharactersSupportedByEncoding", ""); this.TryAddValueInDictionary(this.m_smartPhoneticDictionary, "ClearComposingTextWithEsc", "false"); this.TryAddValueInDictionary(this.m_smartPhoneticDictionary, "ShowCandidateListWithSpace", "false"); this.TryAddValueInDictionary(this.m_smartPhoneticDictionary, "UseCharactersSupportedByEncoding", ""); this.TryAddValueInDictionary(this.m_smartPhoneticDictionary, "CandidateCursorAtEndOfTargetBlock", "false"); this.TryAddValueInDictionary(this.m_smartPhoneticDictionary, "ComposingTextBufferSize", "10"); // The default settings for CangJie Input Method this.TryAddValueInDictionary(this.m_cangjieDictionary, "ShouldCommitAtMaximumRadicalLength", "false"); this.TryAddValueInDictionary(this.m_cangjieDictionary, "UseDynamicFrequency", "false"); this.TryAddValueInDictionary(this.m_cangjieDictionary, "ClearReadingBufferAtCompositionError", "true"); this.TryAddValueInDictionary(this.m_cangjieDictionary, "ComposeWhileTyping", "false"); this.TryAddValueInDictionary(this.m_cangjieDictionary, "UseOverrideTable", "Punctuations-punctuations-cin"); this.TryAddValueInDictionary(this.m_cangjieDictionary, "UseCharactersSupportedByEncoding", ""); // The default settings for Simplex Input Method this.TryAddValueInDictionary(this.m_simplexDictionary, "ClearReadingBufferAtCompositionError", "true"); this.TryAddValueInDictionary(this.m_simplexDictionary, "ComposeWhileTyping", "false"); this.TryAddValueInDictionary(this.m_simplexDictionary, "UseCharactersSupportedByEncoding", ""); this.TryAddValueInDictionary(this.m_searchDictionary, "ShortcutKey", "`"); } catch (ArgumentException) { // @zonble // If some keys are already there, the Add() method will raise exceptions. // However, we ignore these exceptions. } #endregion }