}//m_bgWorker_DoWork private void StartMerging () { m_Merger = null; string[] listOfDTBFiles = new string[m_lbDTBfiles.Items.Count]; for (int i = 0; i < m_lbDTBfiles.Items.Count; i++) { listOfDTBFiles[i] = m_lbDTBfiles.Items[i].ToString (); } // create temp directory string outputDirTemp = Path.Combine ( m_txtDirectoryPath.Text, "temp" ); if (Directory.Exists ( outputDirTemp )) { Directory.Delete ( outputDirTemp, true ); } Directory.CreateDirectory ( outputDirTemp ); if (m_rdbExistingNumberOfPages.Checked) { m_Merger = new DTBMerger.Merger ( listOfDTBFiles, outputDirTemp, DTBMerger.PageMergeOptions.KeepExisting ); } else if (m_rdbRenumberPages.Checked) { m_Merger = new DTBMerger.Merger ( listOfDTBFiles, outputDirTemp, DTBMerger.PageMergeOptions.Renumber ); } if (daisy3Option == true) { // assign can remove duplicate flag, it is added for precaution due to last minute changes m_Merger.CanRemoveDuplicatePagesInDAISY3 = m_CanRemoveDuplicatePagesInDAISY3; m_Merger.MergeDTDs (); } else if (daisy202option == true) { m_Merger.MergeDAISY2DTDs (); } // apply pretty printer script and remove temp directory string prettyPrinterInputFileName = Path.GetFileName ( listOfDTBFiles[0] ); string dtbPath = Path.Combine ( outputDirTemp, prettyPrinterInputFileName ); string prettyPrinterPath = Path.Combine ( m_PipelineLiteDir, "scripts\\PrettyPrinter.taskScript-hidden" ); if (File.Exists ( prettyPrinterPath )) { DTBMerger.PipelineInterface.ScriptsFunctions.PrettyPrinter ( prettyPrinterPath, dtbPath, m_txtDirectoryPath.Text ); // check if pretty printer has worked well by checking if ncc.html or .opf files are at output string[] filesArray = Directory.GetFiles ( m_txtDirectoryPath.Text, prettyPrinterInputFileName, SearchOption.TopDirectoryOnly ); if (filesArray != null && filesArray.Length > 0) { Directory.Delete ( outputDirTemp, true ); } } }//StartMerging()
public Daisy3MergerForm () { InitializeComponent (); m_bgWorker.DoWork += new System.ComponentModel.DoWorkEventHandler ( m_bgWorker_DoWork ); m_bgWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler ( m_bgWorker_RunWorkerCompleted ); m_bgWorker.WorkerSupportsCancellation = true; m_Merger = null; try { LoadSettings (); } catch (System.Exception ex) { MessageBox.Show ( ex.ToString () ); } }