/// <summary> /// Constructor. /// </summary> /// <param name="dialog">Dialog to attach to the user interface</param> public GenerationDialogUserInterface(GenerationDialog dialog) { this.dialog = dialog; }
public void ProcessProject(bool askConfirmations , bool exitAfterEnd, int LogLevel) { try { // Verify errors: if (lstSourceFiles.Items.Count == 0) { MessageBox.Show(this, "No source file was specified.", "Error"); return; } foreach (string file in lstSourceFiles.Items) { if (!File.Exists(file)) { MessageBox.Show(this, "The file " + file + " does not exist", "Error"); lstSourceFiles.Focus(); lstSourceFiles.SelectedIndices.Clear(); lstSourceFiles.SelectedIndices.Add( lstSourceFiles.Items.IndexOf(file) ); return; } } if (!txtArcCab.Text.Equals("") && !File.Exists(txtArcCab.Text)) { MessageBox.Show(this, "The header file " + txtArcCab.Text + " does not exist"); txtArcCab.Focus(); return; } if (!txtArcPie.Text.Equals("") && !File.Exists(txtArcPie.Text)) { MessageBox.Show(this, "The footer file " + txtArcPie.Text + " does not exist"); txtArcPie.Focus(); return; } if (radCompilar.Checked && txtArchivoAyuda.Text.Trim().Equals("")) { MessageBox.Show(this, "Destination file is mandatory"); txtArchivoAyuda.Focus(); return; } if (chkGenWeb.Checked && !txtHeaderWeb.Text.Trim().Equals("") && !File.Exists(txtHeaderWeb.Text)) { MessageBox.Show(this, "The web header file " + txtHeaderWeb.Text + " does not exist"); txtHeaderWeb.Focus(); return; } if (chkGenWeb.Checked && !txtFooterWeb.Text.Trim().Equals("") && !File.Exists(txtFooterWeb.Text)) { MessageBox.Show(this, "The web footer file " + txtFooterWeb.Text + " does not exist"); txtFooterWeb.Focus(); return; } if (chkGenWeb.Checked && !txtHeadInclude.Text.Trim().Equals("") && !File.Exists(txtHeadInclude.Text.Trim())) { MessageBox.Show(this, "The web <head> include file " + txtHeadInclude.Text + " does not exist"); txtHeadInclude.Focus(); return; } string compilerPath = AppSettings.CompilerPath; if (!File.Exists(compilerPath) && radCompilar.Checked) { MessageBox.Show("The path to the compiler of Microsoft Help Workshop is not set or does not exist. Please, go to the menu File > Settings... and put the path to the compiler. If you dont have it, the link to download it is there."); return; } if (chkJavaHelp.Checked && !File.Exists(AppSettings.JarPath)) { MessageBox.Show("The path to the Sun JDK is not set or does not exist. Please, go to the menu File > Settings... and put the path to the compiler. If you dont have it, the link to download it is there."); return; } if (numNivelCorte.Value > 10) numNivelCorte.Value = 10; else if (numNivelCorte.Value < 0) numNivelCorte.Value = 0; // Confirmar que se quiere procesar: if (radGenerarProyecto.Checked && Directory.Exists(txtDirDst.Text) && askConfirmations) { string msg = "Are you sure you want to create a help project at " + txtDirDst.Text + " ? All files at this directory will be deleted."; if (MessageBox.Show(this, msg, "Generate", MessageBoxButtons.YesNo) == DialogResult.No) return; } if (radCompilar.Checked && File.Exists(txtArchivoAyuda.Text) && askConfirmations ) { string msg = "Are you sure you want to replace the help file " + txtArchivoAyuda.Text + " ?"; if (MessageBox.Show(this, msg, "Generate", MessageBoxButtons.YesNo) == DialogResult.No) return; } if (chkGenWeb.Checked && Directory.Exists(txtDirWeb.Text) && askConfirmations ) { string msg = "Are you sure you want to create a web site at " + txtDirWeb.Text + " ? All files at this directory will be deleted."; if (MessageBox.Show(this, msg, "Generate", MessageBoxButtons.YesNo) == DialogResult.No) return; } if (chkGenPdf.Checked && File.Exists(txtPdf.Text) && askConfirmations) { string msg = "Are you sure you want to replace the PDF file " + txtPdf.Text + " ?"; if (MessageBox.Show(this, msg, "Generate", MessageBoxButtons.YesNo) == DialogResult.No) return; } if (chkGenerateXps.Checked && File.Exists(txtXps.Text) && askConfirmations) { string msg = "Are you sure you want to replace the XPS file " + txtXps.Text + " ?"; if (MessageBox.Show(this, msg, "Generate", MessageBoxButtons.YesNo) == DialogResult.No) return; } if (chkJavaHelp.Checked && File.Exists(txtJavaHelp.Text) && askConfirmations) { string msg = "Are you sure you want to replace the Java Help file " + txtJavaHelp.Text + " ?"; if (MessageBox.Show(this, msg, "Generate", MessageBoxButtons.YesNo) == DialogResult.No) return; } // Check additional files foreach (string file in lstArcAdicionales.Items) { if (!File.Exists(file) && !Directory.Exists(file) && askConfirmations ) { if (MessageBox.Show(this, "The file / directory " + file + " does not exist. Continue with the generation?", "Generate", MessageBoxButtons.YesNo) == DialogResult.No) return; } } this.Cursor = Cursors.WaitCursor; ChmProject project = GetCurrentProject(); GenerationDialog dlg = new GenerationDialog(project, exitAfterEnd, askConfirmations, LogLevel); dlg.ShowDialog(); dlg.Dispose(); } catch (Exception ex) { new ExceptionMessageBox(ex).ShowDialog(); } this.Cursor = Cursors.Default; // Para evitar que quede mucha memoria colgada: GC.Collect(); }