/// <summary> /// Convert the project /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnConvert_Click(object sender, EventArgs e) { ConvertToMSBuildFormat converter; string project, folder; bool isValid = true; epErrors.Clear(); epErrors.SetIconPadding(txtProjectFile, btnSelectNewFolder.Width + 5); epErrors.SetIconPadding(txtNewProjectFolder, btnSelectNewFolder.Width + 5); project = txtProjectFile.Text.Trim(); folder = txtNewProjectFolder.Text.Trim(); if(project.Length == 0) { epErrors.SetError(txtProjectFile, "A project file must " + "be specified"); isValid = false; } else if(!File.Exists(project)) { epErrors.SetError(txtProjectFile, "The specified " + "project file does not exist"); isValid = false; } if(folder.Length == 0) { epErrors.SetError(txtNewProjectFolder, "An output folder for " + "the converted project must be specified"); isValid = false; } if(isValid) { project = Path.GetFullPath(project); folder = Path.GetFullPath(folder); if(FolderPath.TerminatePath(Path.GetDirectoryName(project)) == FolderPath.TerminatePath(folder)) { epErrors.SetError(txtNewProjectFolder, "The output " + "folder cannot match the folder of the original project"); isValid = false; } } if(!isValid) return; try { this.Cursor = Cursors.WaitCursor; switch(cboProjectFormat.SelectedIndex) { case 1: converter = new ConvertFromNDoc(txtProjectFile.Text, txtNewProjectFolder.Text); break; case 2: converter = new ConvertFromDocProject( txtProjectFile.Text, txtNewProjectFolder.Text); break; case 3: converter = new ConvertFromSandcastleGui( txtProjectFile.Text, txtNewProjectFolder.Text); break; case 4: converter = new ConvertFromMSExampleGui( txtProjectFile.Text, txtNewProjectFolder.Text); break; default: converter = new ConvertFromShfbFile(txtProjectFile.Text, txtNewProjectFolder.Text); break; } newProjectFilename = converter.ConvertProject(); MessageBox.Show("The project has been converted successfully", Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } catch(Exception ex) { System.Diagnostics.Debug.WriteLine(ex); BuilderException bex = ex as BuilderException; if(bex != null) MessageBox.Show("Unable to convert project. " + "Reason: Error " + bex.ErrorCode + ":" + bex.Message, Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else MessageBox.Show("Unable to convert project. " + "Reason: " + ex.Message, Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { this.Cursor = Cursors.Default; } }