private utilLaunchParams GatherParameters() { utilLaunchParams myParams = new utilLaunchParams(); System.IO.FileInfo myInFileInfo = new System.IO.FileInfo(txtInPath.Text); System.IO.DirectoryInfo myInDirInfo = new System.IO.DirectoryInfo(txtInPath.Text); //Validate input path if (myInFileInfo.Exists || myInDirInfo.Exists) { myParams.inputPath = txtInPath.Text; } else { throw new Exception("Input path doesn't exist!"); } //Validate output path System.IO.DirectoryInfo parentOutDir = System.IO.Directory.GetParent(txtOutPath.Text); if (!parentOutDir.Exists) { throw new Exception("Output path parent directory doesn't exist!"); } else { myParams.outputPath = txtOutPath.Text; } //Get nb of slots if necessary if (chkNbSlots.Checked) { myParams.nbslots = Decimal.ToUInt32(numNbSlots.Value); } else { myParams.nbslots = 0; } //Get output image type if (optRaw.Checked) { myParams.outimgt = utilLaunchParams.outImgTy.RAW; } else if (optBMP.Checked) { myParams.outimgt = utilLaunchParams.outImgTy.BMP; } else { myParams.outimgt = utilLaunchParams.outImgTy.PNG; } return(myParams); }
private void DoExecuteUtility() { SetStatusWorking(); EnableDisableEditableControls(false); try { utilLaunchParams execparams = GatherParameters(); string args = "\"" + execparams.inputPath + "\" \"" + execparams.outputPath + "\""; if (execparams.nbslots != 0) { args = "-n " + execparams.nbslots + " " + args; } if (execparams.outimgt == utilLaunchParams.outImgTy.BMP) { args = "-bmp " + args; } else if (execparams.outimgt == utilLaunchParams.outImgTy.RAW) { args = "-raw " + args; } // FrontendCommon.UtilityLauncher myUtility = new FrontendCommon.UtilityLauncher(this, KAOMADO_EXE); if (myUtility.StartUtil(args)) { myUtility.WaitUntilFinished(); } if (myUtility.GetReturnCode() == 0) { SetStatusSuccess(); } else { SetStatusFailure(); } } catch (Exception e) { MessageBox.Show(this, e.Message, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Error); SetStatusFailure(); } EnableDisableEditableControls(true); timerResetStatus.Start(); }