Ejemplo n.º 1
0
        private void _b_载入语言文件_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Status = Status | _StatusEnum.Working;
                Form1.Log("进程: Form1.载入语言文件 开始执行");

                _t_语言包.Items.Clear();
                langDictionary.Clear();

                XmlDocument doc = new XmlDocument();
                doc.Load(openFileDialog1.FileName);

                Encoding    gbk       = Encoding.GetEncoding("GBK");
                Encoding    iso       = Encoding.GetEncoding("ISO-8859-1");
                XmlNodeList listNodes = null;

                listNodes = doc.SelectNodes("/root/item[@id='Data']/item[@id='language']/item[@id='scriptlang']/item");
                foreach (XmlNode node in listNodes)
                {
                    langDictionary.Add(node.Attributes["id"].Value, gbk.GetString(iso.GetBytes(node.InnerText)), "P");
                }

                listNodes = doc.SelectNodes("/root/item[@id='Data']/item[@id='language']/item[@id='templatelang']/item");
                foreach (XmlNode node in listNodes)
                {
                    langDictionary.Add(node.Attributes["id"].Value, gbk.GetString(iso.GetBytes(node.InnerText)), "H");
                }

                Form1.Log("进程: Form1.载入语言文件 执行完毕");
                Status = Status & (~_StatusEnum.Working);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 读取选择项目
        /// </summary>
        /// <param name="CheckedItems">Dictionary 文件类型|文件位置, 选中项 Tag</param>
        /// <returns>是否继续执行</returns>
        private bool treeChecked(out Dictionary <string, ArrayList> CheckedItems)
        {
            if ((Status & _StatusEnum.Working) != 0)
            {
                MessageBox.Show("有其它任务正在执行");
            }
            else if ((Status & _StatusEnum.Checked) == 0 || _t_树形图.Nodes.Count == 0)
            {
                MessageBox.Show("文件检查未完成或检查结果为空");
            }
            else
            {
                Status       = Status | _StatusEnum.Working;
                CheckedItems = treeChecked(_t_树形图.Nodes);
                if (CheckedItems.Count == 0)
                {
                    Status = Status & (~_StatusEnum.Working);
                    MessageBox.Show("您没有选中任何项目");
                }
                else
                {
                    return(true);
                }
            }

            CheckedItems = null;
            return(false);
        }
Ejemplo n.º 3
0
        private void _b_指定应用目录_Click(object sender, EventArgs e)
        {
            if ((Status & _StatusEnum.Working) != 0)
            {
                MessageBox.Show("有其它任务正在执行");
                return;
            }

            Status = Status | _StatusEnum.Working;
            if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _l_应用目录.Text = openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory = folderBrowserDialog1.SelectedPath;

                _t_树形图.Nodes.Clear();
                _t_语言包.Items.Clear();
                langDictionary.Clear();

                Form1.Log("提示: 已将应用目录指定为: " + _l_应用目录.Text);
                Form1.Log("提示: Form1.指定应用目录 正在检查文件");
                _b_检查文件_Work(new WorkFinishDele(_b_指定应用目录_Finish));
            }
            else
            {
                Status = Status & (~_StatusEnum.Working);
            }
        }
Ejemplo n.º 4
0
        public Form1()
        {
            InitializeComponent();

            langDictionary.AddLanguage = new AddLanguageDele(AddLanguage);
            _LogDelegate = new LogDelegate(_Log);

            Status = 0;
        }
Ejemplo n.º 5
0
 private void _b_应用语言文件_Finish()
 {
     if (this.InvokeRequired == false)
     {
         _t_树形图.Nodes[0].Remove();
         Form1.Log("进程: Form1.应用语言文件 执行完毕");
         Status = Status & (~_StatusEnum.Working);
     }
     else
     {
         WorkFinishDele workFinish = new WorkFinishDele(_b_应用语言文件_Finish);
         this.Invoke(workFinish);
     }
 }
Ejemplo n.º 6
0
 private void _b_检查文件_Finish()
 {
     if (this.InvokeRequired == false)
     {
         _t_树形图.Nodes[0].Remove();
         Form1.Log("进程: Form1.检查文件 执行完毕");
         Form1.Log("提示: 如果应用已经进行过语言包提取,请先导入原语言包!");
         Status = (Status & (~_StatusEnum.Working)) | _StatusEnum.Checked;
     }
     else
     {
         WorkFinishDele workFinish = new WorkFinishDele(_b_检查文件_Finish);
         this.Invoke(workFinish);
     }
 }
Ejemplo n.º 7
0
 private void _b_检查文件_Click(object sender, EventArgs e)
 {
     if ((Status & _StatusEnum.Working) != 0)
     {
         MessageBox.Show("有其它任务正在执行");
         return;
     }
     else if (_l_应用目录.Text == "")
     {
         MessageBox.Show("请指定应用目录");
         return;
     }
     else
     {
         Status = Status | _StatusEnum.Working;
         Form1.Log("进程: Form1.检查文件 开始执行");
         _b_检查文件_Work(new WorkFinishDele(_b_检查文件_Finish));
     }
 }
Ejemplo n.º 8
0
        private void _b_导出语言文件_Click(object sender, EventArgs e)
        {
            if ((Status & _StatusEnum.Working) != 0)
            {
                MessageBox.Show("有其它任务正在执行");
            }
            else if ((Status & _StatusEnum.Checked) == 0 || _t_树形图.Nodes.Count == 0)
            {
                MessageBox.Show("文件检查未完成或检查结果为空");
            }
            else if (_t_语言包.Items.Count == 0)
            {
                MessageBox.Show("请先导入或提取语言包");
            }
            else if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Status = Status | _StatusEnum.Working;
                Form1.Log("进程: Form1.导出语言文件 开始执行");

                Dictionary <string, string> _P, _H;
                langDictionary.Export(out _P, out _H);

                FileStream   fs = new FileStream(saveFileDialog1.FileName, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("GBK"));
                sw.Write("<?php\n\n$scriptlang['" + iden + "'] = array(\n");
                foreach (KeyValuePair <string, string> obj in _P)
                {
                    sw.Write("    '" + obj.Key + "' => '" + obj.Value.Replace("'", "\\'") + "',\n");
                }
                sw.Write(");\n\n$templatelang['" + iden + "'] = array(\n");
                foreach (KeyValuePair <string, string> obj in _H)
                {
                    sw.Write("    '" + obj.Key + "' => '" + obj.Value.Replace("'", "\\'") + "',\n");
                }
                sw.Write(");\n\n$installlang['" + iden + "'] = array(\n    // Install Lang Here\n);");
                sw.Close();
                fs.Close();

                Form1.Log("进程: Form1.导出语言文件 执行完毕");
                Status = Status & (~_StatusEnum.Working);
            }
        }