Example #1
0
        private void _b_四种编码生成_Work(object treeToDo)
        {
            Dictionary <string, ArrayList> _treeToDo = (Dictionary <string, ArrayList>)treeToDo;

            fileWorker fW;

            string[] Configs;

            foreach (KeyValuePair <string, ArrayList> obj in _treeToDo)
            {
                fW = new fileWorker(obj.Key.Substring(2));
                foreach (string Config in obj.Value)
                {
                    if (Config[0] != 'C') // 只处理 C 标记
                    {
                        continue;
                    }

                    Configs = Config.Split('|');

                    if (obj.Key[0] == 'P')
                    {
                        if (Configs[3] == "F")
                        {
                            fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]),
                                      "'" + Configs[6].Replace("'", "\\'") + "'");
                        }
                        else
                        {
                            // 因为是原样写回文件,所以只将包含的引号还原
                            // 同时在预处理时对引号进行了反转义,写回时重新转义
                            fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]),
                                      (Configs[4] == "1" ? Configs[3] : "") +
                                      Configs[6].Replace(Configs[3], "\\" + Configs[3]) +
                                      (Configs[5] == "1" ? Configs[3] : ""));
                        }
                    }
                    else
                    {
                        fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]), Configs[6]);
                    }
                }
                fW.Convert();
            }
            Form1.Log("提示: Form1.四种编码生成 正在重新检查文件");
            this.Invoke(new Action(() => { _b_检查文件_Work(new WorkFinishDele(_b_四种编码生成_Finish)); }));
        }
Example #2
0
        private void _b_应用语言文件_Work(object treeToDo)
        {
            Dictionary <string, ArrayList> _treeToDo = (Dictionary <string, ArrayList>)treeToDo;

            fileWorker fW;

            string[] Configs;

            foreach (KeyValuePair <string, ArrayList> obj in _treeToDo)
            {
                if (obj.Key[0] == 'X') // 不处理 XML
                {
                    continue;
                }

                fW = new fileWorker(obj.Key.Substring(2));
                foreach (string Config in obj.Value)
                {
                    if (Config[0] != 'L') // 只处理 L 标记
                    {
                        continue;
                    }

                    Configs = Config.Split('|');

                    // 这个标记的处理出乎意料的简单呢
                    if (obj.Key[0] == 'P')
                    {
                        fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]),
                                  "'" + langDictionary.GetChinese(Configs[3], "P").Replace("'", "\\'") + "'");
                    }
                    else
                    {
                        fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]),
                                  langDictionary.GetChinese(Configs[3], "H"));
                    }
                }
                fW.Do();
            }
            Form1.Log("提示: Form1.应用语言文件 正在重新检查文件");
            this.Invoke(new Action(() => { _b_检查文件_Work(new WorkFinishDele(_b_应用语言文件_Finish)); }));
        }
Example #3
0
        private void _b_提取语言文件_Work(object treeToDo)
        {
            Dictionary <string, ArrayList> _treeToDo = (Dictionary <string, ArrayList>)treeToDo;

            string[] Configs;
            foreach (KeyValuePair <string, ArrayList> obj in _treeToDo)
            {
                if (obj.Key[0] == 'X')  // 不处理 XML
                {
                    continue;
                }

                foreach (string Config in obj.Value)
                {
                    if (Config[0] != 'C') // 只处理 C 标记
                    {
                        continue;
                    }

                    Configs = Config.Split('|');
                    langDictionary.AddNoKey(Configs[6], obj.Key[0] == 'P' ? "P" : "H");
                }
            }

            this.Invoke(new Action(() => { _t_语言包.Items.Clear(); }));
            langDictionary.Update();

            fileWorker fW;

            foreach (KeyValuePair <string, ArrayList> obj in _treeToDo)
            {
                if (obj.Key[0] == 'X')  // 不处理 XML
                {
                    continue;
                }

                fW = new fileWorker(obj.Key.Substring(2));
                foreach (string Config in obj.Value)
                {
                    Configs = Config.Split('|');
                    switch (Configs[0])
                    {
                    case "D":     // 这个还好吧
                        fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]));
                        break;

                    case "L":     // 一般般,后面写过了
                        if (obj.Key[0] == 'P')
                        {
                            fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]),
                                      "lang('plugin/" + iden + "', '" + langDictionary.GetEnglish(Configs[3], "P") + "')");
                        }
                        else
                        {
                            fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]),
                                      "{lang " + iden + ":" + langDictionary.GetEnglish(Configs[3], "H") + "}");
                        }
                        break;

                    case "C":     // 这块处理真心麻烦 ……
                        if (obj.Key[0] == 'P')
                        {
                            //C|起始位置|长度|前(后)缀符号或 F(函数调用)|是否去掉前缀|是否去掉后缀|匹配内容
                            if (Configs[3] == "F")
                            {
                                fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]),
                                          "'" + iden + ":" + langDictionary.AddNoKey(Configs[6], "P") + "'");
                            }
                            else
                            {
                                // 包含的引号说明前(后)面没有需要连接的内容
                                // 所以仅需对不包含引号的增加连接符和引号
                                // 同时在预处理时对引号进行了反转义,写回时重新转义
                                fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]),
                                          (Configs[4] == "1" ? "" : Configs[3] + " . ") +
                                          "lang('plugin/" + iden + "', '" + langDictionary.AddNoKey(Configs[6], "P") + "')" +
                                          (Configs[5] == "1" ? "" : " . " + Configs[3]));
                            }
                        }
                        else
                        {
                            fW.AddJob(Convert.ToInt32(Configs[1]), Convert.ToInt32(Configs[2]),
                                      "{lang " + iden + ":" + langDictionary.AddNoKey(Configs[6], "H") + "}");
                        }
                        break;
                    }
                }
                fW.Do();
            }
            Form1.Log("提示: Form1.提取语言文件 正在重新检查文件");
            this.Invoke(new Action(() => { _b_检查文件_Work(new WorkFinishDele(_b_提取语言文件_Finish)); }));
        }