/// <summary> /// Binding Related Controls to Plate /// </summary> /// <param name="dg"></param> /// <param name="plate"></param> private void BindRelatedControls(DataGrid dg, PlateBase plate) { for (int i = 0; i < dg.Items.Count; i++) { string strName = (dg.Columns[0].GetCellContent(dg.Items[i]) as TextBlock).Text; if (strName == plate.ChineseName) { List <object> list = new List <object>(); list.Add(dg.Columns[0].GetCellContent(dg.Items[i]) as TextBlock); list.Add(dg.Columns[1].GetCellContent(dg.Items[i]) as TextBlock); list.Add((dg.Columns[3] as DataGridTemplateColumn).CellTemplate.FindName("txtAddVolume", dg.Columns[3].GetCellContent(dg.Items[i])) as TextBox); plate.RelatedControls = list; break; } } }
/// <summary> /// Get Plane from planar objects like - plate, grating, slab or isolated footing /// </summary> /// <param name="steelObject"> Advance Steel element</param> /// <returns name="plane"> returns a plane from plannar objects - plate, slab, footing isolated or grating</returns> public static Autodesk.DesignScript.Geometry.Plane GetPlane(AdvanceSteel.Nodes.SteelDbObject steelObject) { Autodesk.DesignScript.Geometry.Plane ret = null; using (var ctx = new SteelServices.DocContext()) { if (steelObject != null) { FilerObject filerObj = Utils.GetObject(steelObject.Handle); if (filerObj != null) { if (filerObj.IsKindOf(FilerObject.eObjectType.kPlate) || filerObj.IsKindOf(FilerObject.eObjectType.kSlab) || filerObj.IsKindOf(FilerObject.eObjectType.kFootingIsolated) || filerObj.IsKindOf(FilerObject.eObjectType.kGrating)) { PlateBase selectedObj = filerObj as PlateBase; Plane plane = selectedObj.DefinitionPlane; ret = Utils.ToDynPlane(plane, true); } else { throw new System.Exception("Wrong type of Steel Object found, must be a Plate, Grating, Slab or Footing Isolated - Planner Object"); } } else { throw new System.Exception("No Object found via registered handle"); } } else { throw new System.Exception("No Steel Object found"); } } return(ret); }
private void Scan_Click(object sender, RoutedEventArgs e) { LoadFrom loadFrom = new LoadFrom(); BackgroundWorker worker = new BackgroundWorker(); worker.WorkerReportsProgress = true; worker.WorkerSupportsCancellation = true; bool WaitFalg = true; string ErrMsg = ""; worker.DoWork += delegate(object s, DoWorkEventArgs args) { DateTime fileBeforeCreatedTime = WanTai.Controller.EVO.ProcessorFactory.GetDateTimeNow(); Services.DeskTopService desktopService = new Services.DeskTopService(); try { desktopService.CallScanScript(); } catch (Exception ex) { MessageBox.Show("扫描错误!", "系统提示"); return; } //get data from scan files, check plates ,and update scan volume of reagents foreach (ReagentAndSuppliesConfiguration reagent in reagentAndSupplies) { reagent.FirstAddVolume = 0; } foreach (PlateBase plate in ViewPlates) { plate.FirstAddVolume = 0; } DataTable dtScan = GetScanResult(fileBeforeCreatedTime); DataTable dtDitiScan = GetDitiScanResult(fileBeforeCreatedTime); DataTable dtHeaterScan = GetHeaterScanResult(fileBeforeCreatedTime); CheckByScanResult(dtScan); CheckDitiByScanResult(dtDitiScan); CheckHeaterScanResult(dtHeaterScan); GetDetectedLiquid(fileBeforeCreatedTime); //if any plate of a reagent is incorrect this reagent is incorrect foreach (ReagentAndSuppliesConfiguration reagent in reagentAndSupplies) { List <PlateBase> plates = ViewPlates.FindAll(P => (P.ChineseName == reagent.DisplayName && P.ItemType == reagent.ItemType)); reagent.Correct = !plates.Exists(P => !P.Correct); //只更新第一個Plate的值 if (reagent.ItemType >= 100 && reagent.ItemType < 200) { PlateBase firstPlate = ViewPlates.FirstOrDefault(P => (P.ChineseName == reagent.DisplayName && P.ItemType == reagent.ItemType)); if (firstPlate != null) { firstPlate.FirstAddVolume = reagent.FirstAddVolume; } } } worker.ReportProgress(1, ErrMsg); while (WaitFalg) { Thread.Sleep(1000); } }; worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args) { //to show the last column which contains confirm buttons foreach (DataGrid dg in dataGridDictionary.Values) { dg.Columns[5].Visibility = Visibility.Visible; } //incorrect plates and corresponding reagents will shine BindRelatedControls(); UpdatePlates(); foreach (UIElement uiElement in DeskTopWithGrid.Children) { if (uiElement is CarrierBase) { ((CarrierBase)uiElement).ShiningStop(); ((CarrierBase)uiElement).Scan(); } } loadFrom.Close(); btnSave.IsEnabled = reagentAndSupplies.FirstOrDefault(P => P.Correct == false) == null; }; worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { }; worker.RunWorkerAsync(); loadFrom.ShowDialog(); /******************************************* * //call script and generate scan files * System.Windows.Input.Cursor currentCurson = this.Cursor; * this.Cursor = Cursors.Wait; * //call script and generate scan files * DateTime fileBeforeCreatedTime = WanTai.Controller.EVO.ProcessorFactory.GetDateTimeNow(); * Services.DeskTopService desktopService = new Services.DeskTopService(); * try * { * desktopService.CallScanScript(); * } * catch (Exception ex) * { * MessageBox.Show("扫描错误!"); * } * * //get data from scan files, check plates ,and update scan volume of reagents * foreach (ReagentAndSuppliesConfiguration reagent in reagentAndSupplies) * { * reagent.FirstAddVolume = 0; * } * foreach (PlateBase plate in ViewPlates) * { * plate.FirstAddVolume = 0; * } * DataTable dtScan = GetScanResult(fileBeforeCreatedTime); * DataTable dtDitiScan = GetDitiScanResult(fileBeforeCreatedTime); * DataTable dtHeaterScan = GetHeaterScanResult(fileBeforeCreatedTime); * * CheckByScanResult(dtScan); * CheckDitiByScanResult(dtDitiScan); * CheckHeaterScanResult(dtHeaterScan); * GetDetectedLiquid(fileBeforeCreatedTime); * * //if any plate of a reagent is incorrect this reagent is incorrect * foreach (ReagentAndSuppliesConfiguration reagent in reagentAndSupplies) * { * List<PlateBase> plates = ViewPlates.FindAll(P => (P.ChineseName == reagent.DisplayName && P.ItemType == reagent.ItemType)); * reagent.Correct = !plates.Exists(P => !P.Correct); * } * * //to show the last column which contains confirm buttons * foreach (DataGrid dg in dataGridDictionary.Values) * { * dg.Columns[5].Visibility = Visibility.Visible; * } * * //incorrect plates and corresponding reagents will shine * BindRelatedControls(); * UpdatePlates(); * foreach (UIElement uiElement in DeskTopWithGrid.Children) * { * if (uiElement is CarrierBase) * { * ((CarrierBase)uiElement).Scan(); * } * } * * Cursor = currentCurson; * btnSave.IsEnabled = reagentAndSupplies.FirstOrDefault(P => P.Correct == false) == null; ****************************************************************************************************/ }
/// <summary> /// Check DitiPlate by Scan Result,and Update Volume(Plate Count) to DataGrid /// </summary> /// <param name="dtScan"></param> private void CheckDitiByScanResult(DataTable dtScan) { int Diti1000 = 0; int Diti200 = 0; string Diti1000BarcodePrefix = new ReagentSuppliesConfigurationController().GetBarcodePrefix(DiTiType.DiTi1000); string Diti200BarcodePrefix = new ReagentSuppliesConfigurationController().GetBarcodePrefix(DiTiType.DiTi200); PlateBase plate = null; for (int i = 0; i < dtScan.Rows.Count; i++) { if (Diti1000BarcodePrefix != null && dtScan.Rows[i]["Barcode"].ToString().StartsWith(Diti1000BarcodePrefix) && dtScan.Rows[i]["TypeName"].ToString() == "DiTi 1000ul") { switch (Diti1000) { case 0: plate = ViewPlates.FirstOrDefault( P => (P.ContainerName == "005" && P.Position == 1)); break; case 1: plate = ViewPlates.FirstOrDefault( P => (P.ContainerName == "005" && P.Position == 2)); break; default: plate = ViewPlates.FirstOrDefault( P => (P.ContainerName == "006" && P.Position == Diti1000)); break; } Diti1000++; } else if (Diti200BarcodePrefix != null && dtScan.Rows[i]["Barcode"].ToString().StartsWith(Diti200BarcodePrefix) && dtScan.Rows[i]["TypeName"].ToString() == "DiTi 200 ul") { switch (Diti200) { case 0: plate = ViewPlates.FirstOrDefault( P => (P.ContainerName == "005" && P.Position == 3)); break; default: plate = ViewPlates.FirstOrDefault( P => (P.ContainerName == "007" && P.Position == Diti200 + 1)); break; } Diti200++; } else { continue; } if (plate != null) { plate.Correct = true; plate.Barcode = dtScan.Rows[i]["Barcode"].ToString(); plate.FirstAddVolume = 0; } foreach (ReagentAndSuppliesConfiguration reagent in reagentAndSupplies) { if (dtScan.Rows[i]["Barcode"].ToString().StartsWith(reagent.BarcodePrefix)) { reagent.FirstAddVolume += (double)dtScan.Rows[i]["Volume"]; break; } } } }