コード例 #1
0
ファイル: Json.cs プロジェクト: slicks77/chiitrans2
        static Pair <JsObject, int> ParseArray(List <Token> tokens, int pos)
        {
            var  res   = new JsArray();
            bool first = true;

            while (pos < tokens.Count)
            {
                if (tokens[pos].type == TokenType.R_SQUARE)
                {
                    return(new Pair <JsObject, int>(res, pos + 1));
                }
                if (first)
                {
                    first = false;
                }
                else
                {
                    /*if (tokens[pos].type != TokenType.COMMA)
                     *  throw new JsonParseException();
                     * pos += 1;*/
                    if (tokens[pos].type == TokenType.COMMA)
                    {
                        pos += 1;
                    }
                }
                while (pos < tokens.Count && tokens[pos].type == TokenType.COMMA)
                {
                    var cur2 = new JsObject();
                    res.Add(cur2);
                    ++pos;
                }
                if (pos >= tokens.Count)
                {
                    break;
                }
                var cur = ParseObject(tokens, pos);
                pos = cur.second;
                res.Add(cur.first);
            }
            throw new JsonParseException();
        }
コード例 #2
0
ファイル: Options.cs プロジェクト: slicks77/chiitrans2
        public void SaveOptions(string filename)
        {
            JsObject data = new JsObject();
            JsArray  arr  = new JsArray();

            for (int i = 0; i < translators.Count; ++i)
            {
                arr.Add(Json.Parse("{\"id\":" + translators[i].id + ", \"inUse\":" + (translators[i].inUse ? "1" : "0") + "}"));
            }
            data["translators"] = arr;

            foreach (KeyValuePair <string, ColorRecord> kvp in colors)
            {
                data["colors"].num[kvp.Key] = kvp.Value.color.ToArgb();
            }

            saveOpt(data, "wordParseMethod");
            saveOpt(data, "JDicServer");
            saveOpt(data, "alwaysOnTop");
            saveOpt(data, "checkDouble");
            saveOpt(data, "checkRepeatingPhrases");
            saveOpt(data, "checkRepeatingPhrasesAdv");
            saveOpt(data, "replaceSuffixes");
            saveOpt(data, "excludeSpeakers");
            saveOpt(data, "excludeSpeakersPattern");
            saveOpt(data, "messageDelay");
            saveOpt(data, "maxSourceLength");
            data.str["font"]        = new FontConverter().ConvertToString(font);
            data.str["tooltipFont"] = new FontConverter().ConvertToString(tooltipFont);
            saveOpt(data, "translateToOtherLanguage");
            saveOpt(data, "translateLanguage");
            saveOpt(data, "noUseSecondTranslate");
            saveOpt(data, "useCache");
            saveOpt(data, "displayOriginal");
            saveOpt(data, "displayFixed");
            saveOpt(data, "bottomLayerOpacity");
            saveOpt(data, "displayReadings");
            saveOpt(data, "appendBottom");
            saveOpt(data, "dropShadow");
            saveOpt(data, "usePromt");
            saveOpt(data, "furiganaRomaji");
            saveOpt(data, "maxBlocks");
            saveOpt(data, "largeMargins");
            saveOpt(data, "marginSize");
            saveOpt(data, "hivemindServer");
            saveOpt(data, "toolbarVisible");
            saveOpt(data, "monitorNewThreads");
            saveOpt(data, "includeOkurigana");
            saveOpt(data, "clipboardMonitoring");
            saveOpt(data, "clipboardMonitoringJapanese");

            File.WriteAllText(filename, data.Serialize());
        }
コード例 #3
0
        private void SaveAppProfile(string app)
        {
            JsObject data = appProfiles["profiles"][app];

            data.str["keys"] = CurrentAppKeys;
            JsArray mon = new JsArray();

            foreach (KeyValuePair <string, BlockList> kvp in blocks)
            {
                if (kvp.Value.IsMonitored)
                {
                    mon.Add(new JsAtom(kvp.Key));
                }
            }
            data["monitor"]    = mon;
            data.num["manual"] = manualMonitoring ? 1 : 0;
        }