private void OnDeleteSampling(object sender, SamplingEventArgs e) { switch (e.RecordStatus) { case SamplingRecordStatus.BeginDeleteSampling: lblTitle.Invoke((MethodInvoker) delegate { lblTitle.Text = $"Deleting samplings from {_targetAreaName}"; }); SetupProgressBar(e.RecordCount); break; case SamplingRecordStatus.DeleteSampling: lblDownloadFile.Invoke((MethodInvoker) delegate { lblDownloadFile.Text = $"Deleted {e.ReferenceNumber}"; }); progressBar.Invoke((MethodInvoker) delegate { progressBar.Increment(1); }); break; case SamplingRecordStatus.EndDeleteSampling: btnOk.Invoke((MethodInvoker) delegate { btnOk.Enabled = true; }); progressBar.Invoke((MethodInvoker) delegate { progressBar.Maximum = 100; progressBar.Value = 100; }); lblDownloadFile.Invoke((MethodInvoker) delegate { lblDownloadFile.Text = "Finished deleting samplings"; }); break; } }
private void OnExportSamplingStatus(object sender, SamplingEventArgs e) { bool finishedExport = false; string caption = ""; switch (e.RecordStatus) { //case ExportSamplingStatus.WhereToSaveImport: // _targetAreaName = e.TargetAreaName; // SetupImportLocation(); // break; case SamplingRecordStatus.StartImport: _action = "Importing"; _inImport = true; _titleText = $"Importing {_samplingToFromXML.TargetAreaName}"; _enableOK = false; btnCancel.Invoke((MethodInvoker) delegate { btnCancel.Hide(); }); break; case SamplingRecordStatus.StartExport: _action = "Exporting"; _titleText = $"Exporting { _targetArea.TargetAreaName}"; btnCancel.Invoke((MethodInvoker) delegate { btnCancel.Hide(); }); break; case SamplingRecordStatus.Header: caption = $"{_action} header"; break; case SamplingRecordStatus.Extents: caption = $"{_action} target area extents"; break; case SamplingRecordStatus.Enumerator: caption = $"{_action} enumerators"; break; case SamplingRecordStatus.BeginFishingGears: _processedCount = 0; SetupProgressBar(e.RecordCount); break; case SamplingRecordStatus.FishingGears: caption = $"{_action} fishing gear: {e.GearVariationName}"; _processedCount++; break; case SamplingRecordStatus.LandingSites: caption = $"{_action} landing sites"; break; case SamplingRecordStatus.BeginGearLocalNames: _processedCount = 0; SetupProgressBar(e.RecordCount); break; case SamplingRecordStatus.BeginSamplings: _processedCount = 0; SetupProgressBar(e.RecordCount); //if (e.RecordCount > 0) //{ // progressBar.Invoke((MethodInvoker)delegate // { // progressBar.Value = 1; // progressBar.Minimum = 1; // progressBar.Maximum = e.RecordCount; // }); //} break; case SamplingRecordStatus.Samplings: _processedCount++; caption = $"{_action} sampling ({_processedCount} of {progressBar.Maximum.ToString()}): {e.ReferenceNumber}"; break; case SamplingRecordStatus.Taxa: caption = $"{_action} taxa"; break; case SamplingRecordStatus.BeginCatchNames: _processedCount = 0; SetupProgressBar(e.RecordCount); //if (e.RecordCount > 0) //{ // progressBar.Invoke((MethodInvoker)delegate // { // progressBar.Value = 1; // progressBar.Minimum = 1; // progressBar.Maximum = e.RecordCount; // }); //} _totalCount = e.RecordCount; break; case SamplingRecordStatus.CatchNames: _processedCount++; caption = $"{_action} catch name: {e.CatchName}"; break; case SamplingRecordStatus.EndExport: _enableOK = true; finishedExport = true; caption = "Finished exporting"; break; case SamplingRecordStatus.EndImport: _enableOK = true; caption = "Finished importing"; _inImport = false; break; } btnOk.Invoke((MethodInvoker) delegate { btnOk.Enabled = _enableOK; }); lblDownloadFile.Invoke((MethodInvoker) delegate { lblDownloadFile.Text = caption; }); lblTitle.Invoke((MethodInvoker) delegate { lblTitle.Text = _titleText; }); progressBar.Invoke((MethodInvoker) delegate { if (finishedExport) { progressBar.Maximum = 100; progressBar.Value = 100; } else if (_processedCount > 0) { progressBar.Increment(1); } }); }