private void simpleRackScanControl1_RackScanned(RackScanResult data) { Invoke((MethodInvoker) delegate { SimpleRackScanControl1_RackScanned(this, data); }); }
private void SimpleRackScanControl1_RackScanned(object sender, RackScanResult e) { this.simpleRackScanControl1.Visible = false; if (e.HasError) { this.cartesianGrid1.Visible = false; this.ShowMessage(e.ErrorDetail, true); return; } this.cartesianGrid1.Visible = true; this.cartesianGrid1.Text = (e.RackBarcode != null && e.RackBarcode != "")? this.txtBarcode.Text + " (" + e.RackBarcode + ")": this.txtBarcode.Text; Dictionary <string, string> currentTubes = new Dictionary <string, string>(); List <Sample> tubes = new List <Sample>(); foreach (var cell in e.Cells) { Sample tube = new Sample(); tube.CurrentCartesianAddress = cell.Address; currentTubes[cell.Address] = cell.Barcode; tube.GridCellLabel = cell.Barcode; tube.GridCellBackColor = (this.listBox1.SelectedIndex == 0) ? this.cartesianGrid1.BackColor : Color.LightGreen; tubes.Add(tube); } this.cartesianGrid1.DataSource = tubes; if (listBox1.SelectedIndex == 0) { _tubes[_CurrentRackCode] = currentTubes; ShowMessage("Rack inventory storage is complete" + System.Environment.NewLine + "Ready for the next rack"); SoundHelper.PlayWaveResource("WorkflowProgress.wav"); } else { bool Error = false; Dictionary <string, string> storedTubes = _tubes[_CurrentRackCode]; foreach (string address in this.cartesianGrid1.GetAddressesInFillOrder()) { if (storedTubes.ContainsKey(address) && currentTubes.ContainsKey(address) && storedTubes[address] != currentTubes[address]) { this.cartesianGrid1.SetOverlay(address, Color.Red, "WRONG TUBE"); Error = true; } if (storedTubes.ContainsKey(address) && !currentTubes.ContainsKey(address)) { this.cartesianGrid1.SetOverlay(address, Color.Red, "MISSING"); Error = true; } if (!storedTubes.ContainsKey(address) && currentTubes.ContainsKey(address)) { this.cartesianGrid1.SetOverlay(address, Color.Red, "EXTRA"); Error = true; } } if (Error) { SoundHelper.PlayWaveResource("MajorError.wav"); ShowMessage("Error detected - Check tubes and try again", true); } else { SoundHelper.PlayWaveResource("WorkflowProgress.wav"); ShowMessage("All tubes match" + System.Environment.NewLine + "Ready for the next rack"); } } }