Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string WidgetzInputFolder = "";

            if (WidgetizerFolderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                WidgetzInputFolder = WidgetizerFolderBrowserDialog.SelectedPath + @"\Input";
            }
            else
            {
                return;
            }
            //备份input文件夹
            TransferStatus(true);
            if (Directory.Exists(@"Input_bak"))
            {
                Directory.Delete(@"Input_bak", true);
            }
            FileIO.CopyDirectory(WidgetzInputFolder, @"Input_bak");

            inilist_sw = new StreamWriter("inilist.txt", false, Encoding.UTF8);
            pos        = 0;
            //遍历文件夹
            DirectoryInfo TheFolder = new DirectoryInfo(WidgetzInputFolder);

            FileInfo[] TheFiles = TheFolder.GetFiles();
            //用于设置进度条。
            progressBar1.Minimum = 0;
            progressBar1.Maximum = TheFiles.GetLength(0);
            progressBar1.Step    = 1;
            progressBar1.Value   = 0;
            foreach (FileInfo NextFile in TheFolder.GetFiles())
            {
                //进度条
                progressBar1.PerformStep();
                Application.DoEvents();
                //MessageBox.Show(NextFile.FullName);
                switch (NextFile.Extension)
                {
                case ".slk":        //slk不处理
                    break;

                case ".fdf":        //fdf处理函数
                    MapStringFromFdf(NextFile.FullName);
                    break;

                case ".txt":        //判断是哪种txt
                    MapStringFromIni(NextFile.FullName);
                    break;
                }
            }
            TransferStatus(false);
            //释放句柄
            inilist_sw.Close();
            inilist_sw.Dispose();
            inilist_sw = null;
            refreshfrm();
            MessageBox.Show("Successfully transfered " + pos.ToString() + " strings.", "Finish!");
        }
Exemple #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            //选择inifilelist;
            openFileDialog2.FileName = "inilist.txt";
            if (openFileDialog2.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string inidata = openFileDialog2.FileName;

            openFileDialog2.FileName = "wts_data.txt";
            if (openFileDialog2.ShowDialog() == DialogResult.OK)
            {
                string       wtsdata = openFileDialog2.FileName;
                StreamReader sr      = new StreamReader(inidata);
                string[]     iniss   = sr.ReadToEnd().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                sr.Close();
                StreamReader sr2   = new StreamReader(wtsdata);
                string[]     wtsss = sr2.ReadToEnd().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                sr2.Close();

                if (WidgetizerFolderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    TransferStatus(true);
                    //遍历文件夹
                    DirectoryInfo TheFolder = new DirectoryInfo(WidgetizerFolderBrowserDialog.SelectedPath + @"\Input");
                    FileInfo[]    TheFiles  = TheFolder.GetFiles();
                    //用于设置进度条。
                    progressBar1.Minimum = 0;
                    progressBar1.Maximum = TheFiles.GetLength(0);
                    progressBar1.Step    = 1;
                    progressBar1.Value   = 0;
                    foreach (FileInfo NextFile in TheFolder.GetFiles())
                    {
                        if (NextFile.Extension == ".txt" || NextFile.Extension == ".fdf")
                        {
                            RestoreFileString(NextFile.FullName, iniss, "INI_STRING "); //it also comes with the "GAME_STRING "
                            Application.DoEvents();
                            RestoreFileString(NextFile.FullName, wtsss, "GAME_STRING ");
                            Application.DoEvents();
                        }
                        progressBar1.PerformStep();
                        Application.DoEvents();
                    }
                    TransferStatus(false);
                    refreshfrm();
                    MessageBox.Show("Finish!");
                }
            }
        }