void ConvertAddingPrefix_Click(object sender, EventArgs e) { // この前に開いているタブのセーブの確認 if (preConvertSave() == false) { return; } // conv\Arcanum\の中身があれば掃除する // tempとかconv指定じゃダメなん? IOController.deleteDirectory(Path.Data.TemporaryDirectory + Path.Data.BaseDirectory); IOController.deleteDirectory(Path.Data.ConvertedDirectory + Path.Data.BaseDirectory); setStatus("コンバート開始..."); // prefix // editorのタブの表示は変更したくないから開き直す // 一旦tempに出力 // tempからconvに // 分けないと、通常コンバート時にファイルがたまるな… // あるいはコンバート前に一旦convを掃除するか // あと重いので諸々が更新されない そろそろプログレスバーを検討。できればマルチスレッドでもいいが System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); initializeProgressBar(IOController.getNumFiles(Path.Data.BaseDirectory) + IOController.getNumFiles(Path.Data.ModifiedDirectory)); Convert.convertPrefixOriginal(Path.Data.BaseDirectory); Convert.convertPrefix(Path.Data.ModifiedDirectory); watch.Stop(); completeProgressBar(); addStatus("完了" + " (" + watch.ElapsedMilliseconds + "ms)"); // ゴミ処理 IOController.deleteDirectory(Path.Data.TemporaryDirectory); }
void Convert_Click(object sender, EventArgs e) { if (preConvertSave() == false) { return; } // conv\Arcanum\の中身があれば掃除する // convで消さないのはなんで? IOController.deleteDirectory(Path.Data.ConvertedDirectory + Path.Data.BaseDirectory); setStatus("コンバート開始..."); System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); initializeProgressBar(IOController.getNumFiles(Path.Data.ModifiedDirectory)); Convert.convert(Path.Data.ModifiedDirectory); watch.Stop(); completeProgressBar(); addStatus("完了" + " (" + watch.ElapsedMilliseconds + "ms)"); }
void Progress_Click(object sender, EventArgs e) { initializeProgressBar(IOController.getNumFiles(@"Arcanum\")); setStatus("翻訳進捗率の算出中..."); System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); // addでlistにでも情報詰めて集計は後にした方が楽かなー string prog = Path.Xml.ProgressFile; ProgressFile pf = new ProgressFile(); if (System.IO.File.Exists(prog)) { pf = xml.Xml.Read <ProgressFile>(prog); } // listのオーダーが気になるけど書いてないので念のためhashにするよ System.Collections.Hashtable ignore = new System.Collections.Hashtable(); foreach (string f in pf.Ignore) { ignore.Add(f, 0); } foreach (string f in pf.Pending) { ignore.Add(f, 0); } List <ProgressCount> progress = new List <ProgressCount>(); calcProgress(Path.Data.BaseDirectory, progress, ignore); string buff = @""; int num = 0; int total = 0; foreach (ProgressCount count in progress) { if (count.Exist) { buff += @"*"; } if (count.Translated < count.Total) { } else { buff += @"+"; } float rate = 0; if (count.Total > 0) { rate = ( float )count.Translated / count.Total; } buff += count.Name + ": " + count.Translated + " / " + count.Total + " (" + rate.ToString("P0") + ")\r\n"; num += count.Translated; total += count.Total; } if (total > 0) { float totalrate = ( float )num / total; buff = "TOTAL: " + num + " / " + total + " (" + totalrate.ToString("P0") + ")\r\n" + buff; string output = @"progress.txt"; using (System.IO.StreamWriter writer = new System.IO.StreamWriter(output, false, System.Text.Encoding.GetEncoding("shift_jis"))) { //writer.AutoFlush = true; // 即時書き込み writer.Write(buff); runEditor(output); } } completeProgressBar(); watch.Stop(); addStatus("完了: progress.txt" + " (" + watch.ElapsedMilliseconds + "ms)"); // 本とかのチェックにひっかかってるなあ // prefix用とは別関数用意しないと }