private void btnDatCreator_BuildDat_Click(object sender, EventArgs e) { base.initializeProcessing(); if (checkDatafileCreatorInputs()) { toolStripStatusLabel1.Text = ConfigurationManager.AppSettings["Form_AuditDatafileCreator_MessageBegin"]; DatafileCreatorWorker.GetGameParamsStruct vGetGameParamsStruct = new DatafileCreatorWorker.GetGameParamsStruct(); vGetGameParamsStruct.pDir = tbDatCreator_SourceFolder.Text; vGetGameParamsStruct.pOutputMessage = ""; vGetGameParamsStruct.totalFiles = Directory.GetFiles(tbDatCreator_SourceFolder.Text, "*.*", SearchOption.AllDirectories).Length; vGetGameParamsStruct.UseNormalChecksums = this.cbUseNormalChecksum.Checked; vGetGameParamsStruct.AddMd5Sha1 = this.cbMd5Sha1.Checked; datCreator = new DatafileCreatorWorker(); datCreator.ProgressChanged += backgroundWorker_ReportProgress; datCreator.RunWorkerCompleted += datafileCreatorWorker_WorkComplete; datCreator.RunWorkerAsync(vGetGameParamsStruct); } }
private void datafileCreatorWorker_WorkComplete(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { toolStripStatusLabel1.Text = ConfigurationManager.AppSettings["Form_AuditDatafileCreator_MessageCancel"]; tbOutput.Text += ConfigurationManager.AppSettings["Form_Global_OperationCancelled"]; } else { lblProgressLabel.Text = String.Empty; datafile dataFile = new datafile(); dataFile.header = DatafileCreatorWorker.buildHeader(tbDatCreator_Author.Text, tbDatCreator_Category.Text, tbDatCreator_Comment.Text, tbDatCreator_Date.Text, tbDatCreator_Description.Text, tbDatCreator_Email.Text, tbDatCreator_Homepage.Text, tbDatCreator_Name.Text, tbDatCreator_Url.Text, tbDatCreator_Version.Text); dataFile.game = (VGMToolbox.format.auditing.game[])e.Result; XmlSerializer serializer = new XmlSerializer(dataFile.GetType()); TextWriter textWriter = new StreamWriter(tbDatCreator_OutputDat.Text); serializer.Serialize(textWriter, dataFile); textWriter.Close(); textWriter.Dispose(); toolStripStatusLabel1.Text = ConfigurationManager.AppSettings["Form_AuditDatafileCreator_MessageComplete"]; } // update node color setNodeAsComplete(); }