Ejemplo n.º 1
0
        public void LoadOptions(string filename)
        {
            SetDefault();
            JsObject data = Json.Parse(File.ReadAllText(filename));

            JsArray tr = (JsArray)data["translators"];

            if (tr.length == Translation.Translators.Length)
            {
                translators = new List <TranslatorRecord>();
                for (int i = 0; i < tr.length; ++i)
                {
                    translators.Add(new TranslatorRecord(tr[i].num["id"], tr[i].num["inUse"] != 0));
                }
            }

            if (data.dict.ContainsKey("colors"))
            {
                foreach (string key in data["colors"].dict.Keys)
                {
                    if (colors.ContainsKey(key))
                    {
                        colors[key].color = Color.FromArgb(data["colors"].num[key]);
                    }
                }
            }

            loadOpt(data, "wordParseMethod");
            loadOpt(data, "JDicServer");
            if (JDicServer.EndsWith("?9U"))
            {
                JDicServer = JDicServer.Substring(0, JDicServer.Length - 3);
            }
            loadOpt(data, "alwaysOnTop");
            loadOpt(data, "checkDouble");
            loadOpt(data, "checkRepeatingPhrases");
            loadOpt(data, "checkRepeatingPhrasesAdv");
            loadOpt(data, "replaceSuffixes");
            loadOpt(data, "excludeSpeakers");
            loadOpt(data, "excludeSpeakersPattern");
            loadOpt(data, "messageDelay");
            loadOpt(data, "maxSourceLength");
            try
            {
                font = (Font)(new FontConverter().ConvertFromString(data.str["font"]));
            }
            catch (Exception)
            {
            }
            try
            {
                tooltipFont = (Font)(new FontConverter().ConvertFromString(data.str["tooltipFont"]));
            }
            catch (Exception)
            {
            }
            loadOpt(data, "translateToOtherLanguage");
            loadOpt(data, "translateLanguage");
            loadOpt(data, "useCache");
            loadOpt(data, "displayOriginal");
            loadOpt(data, "displayFixed");
            loadOpt(data, "bottomLayerOpacity");
            loadOpt(data, "displayReadings");
            loadOpt(data, "appendBottom");
            loadOpt(data, "dropShadow");
            loadOpt(data, "usePromt");
            loadOpt(data, "furiganaRomaji");
            loadOpt(data, "maxBlocks");
            loadOpt(data, "largeMargins");
            loadOpt(data, "marginSize");
            loadOpt(data, "hivemindServer");
            loadOpt(data, "toolbarVisible");
            loadOpt(data, "monitorNewThreads");
            loadOpt(data, "includeOkurigana");
            loadOpt(data, "clipboardMonitoring");
            loadOpt(data, "clipboardMonitoringJapanese");
        }