/* ----------------------------------------------------------------- */ /// ConvertBackgroundWorker_DoWork /* ----------------------------------------------------------------- */ private void ConvertBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { // GUI の設定を UserSetting に保存する this.SaveSetting(_setting, this.InputPathPanel.Enabled); if (_setting.SaveSetting) { _setting.SaveSetting = false; // 「設定を保存」の項目はレジストリには保存しない. _setting.Save(); } _setting.InputPath = this.InputPathTextBox.Text; // 変換の実行 Converter converter = new Converter(); bool status = converter.Run(_setting); converter.Messages.Add(new Message(Message.Levels.Info, String.Format("CubePDF.Converter.Run: {0}", status.ToString()))); e.Result = converter.Messages; }
/* ----------------------------------------------------------------- */ /// /// ExecConvert /// /// <summary> /// examples に存在する *.ps ファイルに対して Converter.Run /// を実行し,生成されたファイルを results ディレクトリに保存する。 /// </summary> /// /* ----------------------------------------------------------------- */ private void ExecConvert(UserSetting setting, string suffix) { string output = System.Environment.CurrentDirectory + "\\results"; if (!System.IO.Directory.Exists(output)) System.IO.Directory.CreateDirectory(output); foreach (string file in Directory.GetFiles("examples", "*.ps")) { string filename = Path.GetFileNameWithoutExtension(file); string extension = Parameter.Extension((Parameter.FileTypes)setting.FileType); setting.InputPath = Path.GetFullPath(file); setting.OutputPath = output + '\\' + filename + suffix + extension; if (File.Exists(setting.OutputPath) && setting.ExistedFile == Parameter.ExistedFiles.Overwrite) { File.Delete(setting.OutputPath); } var converter = new Converter(); Assert.IsTrue(converter.Run(setting), String.Format("Converter.Run() failed. source file: {0}", file)); bool status = File.Exists(setting.OutputPath); if (!status) { string tmp = String.Format("{0}\\{1}-001{2}", Path.GetDirectoryName(setting.OutputPath), Path.GetFileNameWithoutExtension(setting.OutputPath), Path.GetExtension(setting.OutputPath) ); status = File.Exists(tmp); Assert.IsTrue(status, String.Format("{0}: file not found", setting.OutputPath)); } } }