/// <summary> /// The conversion of a single file is achieved when the user presses the button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btConvertFile_Click(object sender, EventArgs e) { // Verify the parameters if (string.IsNullOrWhiteSpace(tbInputFilePath.Text)) { MessageBox.Show("Please select an input file.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (string.IsNullOrWhiteSpace(tbOutputFilePath.Text)) { MessageBox.Show("Please select an output file.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Run the conversion string errorMessage = "Success"; Cursor.Current = Cursors.WaitCursor; bool bResult = WangTiffToGdPictureTiffConvert.Convert(tbOutputFilePath.Text, ref errorMessage, tbInputFilePath.Text); Cursor.Current = Cursors.Default; if (bResult) { MessageBox.Show("The file " + tbInputFilePath.Text + " with its Wang annotations has been converted to " + tbOutputFilePath.Text, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(errorMessage, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// The conversion is achieved when the user presses the button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btConvertFolder_Click(object sender, EventArgs e) { // Verify the parameters if (string.IsNullOrWhiteSpace(tbInputFolderPath.Text)) { MessageBox.Show("Please select an input folder.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (string.IsNullOrWhiteSpace(tbOutputFolderPath.Text)) { MessageBox.Show("Please select an output folder.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Run the conversion string[] files = Directory.GetFiles(tbInputFolderPath.Text, "*.tif", SearchOption.AllDirectories); foreach (string inputFilePath in files) { // Run the conversion string errorMessage = "Success"; string outputFilePath = tbOutputFolderPath.Text + "\\" + Path.GetFileNameWithoutExtension(inputFilePath) + ".tif"; Cursor.Current = Cursors.WaitCursor; bool bResult = WangTiffToGdPictureTiffConvert.Convert(outputFilePath, ref errorMessage, inputFilePath, _textExtension); Cursor.Current = Cursors.Default; if (!bResult) { if (MessageBox.Show( "An error occurred during the process of file " + inputFilePath + "\n" + errorMessage + "\nContinue?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { break; } } } MessageBox.Show("The files available in folder " + tbInputFolderPath.Text + " with its Wang annotations have been converted.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); }