Exemple #1
0
        public void SaveSettings()
        {
            int i = 0;

            foreach (string cin in m_moduleNames)
            {
                TakaoHelper.DictionaryToFile(m_moduleDictionaries[i], m_moduleXMLFilePaths[i]);
                i++;
            }
        }
Exemple #2
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();
            }
        }