private void Ufrm_LineList_Load(object sender, EventArgs e) { hWindow_Final1.HobjectToHimage(ho_Image); if (measureManager == null) { measureManager = form.measureManager; } #region 跟踪 List <MeasuringUnit> translations = measureManager.ListAllTranslation();//所有平移跟踪 verticalPositions = new List <MeasuringUnit>(); horizontalPositions = new List <MeasuringUnit>(); for (int i = translations.Count - 1; i >= 0; i--) { if ((translations[i] as TranslationTracking).line.AxByC0.k == null) { horizontalPositions.Add(translations[i]); cmb_HorizontalTracking.Items.Add(translations[i].name); } else if ((translations[i] as TranslationTracking).line.AxByC0.k.D == 0) //?是水平线 { verticalPositions.Add(translations[i]); //添加垂直定位 cmb_VerticalTracking_L.Items.Add(translations[i].name); //添加垂直跟踪 } } #endregion if (EditMode) { getSetOfLines = data as GetSetOfLines; if (getSetOfLines.position_Horizontal != null) { cmb_HorizontalTracking.SelectedItem = getSetOfLines.position_Horizontal.name; } if (getSetOfLines.position_Vertical_L != null) { cmb_VerticalTracking_L.SelectedItem = getSetOfLines.position_Vertical_L.name; } //nud_MaxGray.Value = trb_MaxGray.Value = (getSetOfLines.LineList[0] as GetLineUseThreshold).parameter.hv_MaxGray; // nud_MinGray.Value = trb_MinGray.Value = (getSetOfLines.LineList[0] as GetLineUseThreshold).parameter.hv_MinGray; if (2 == (getSetOfLines.LineList[0] as GetLineUseThreshold).TPLR) { rdo_DownEdge.Checked = true; } if (3 == (getSetOfLines.LineList[0] as GetLineUseThreshold).TPLR) { rdo_LeftEdge.Checked = true; } if (4 == (getSetOfLines.LineList[0] as GetLineUseThreshold).TPLR) { rdo_RightEdge.Checked = true; } if (5 == (getSetOfLines.LineList[0] as GetLineUseThreshold).TPLR) { radioButton1.Checked = true; } cmb_slg_SelectItem.Items.AddRange(getSetOfLines.GetLinesName());//添加combobox项 txt_Name.Text = getSetOfLines.name; //txt_Name.Enabled = false;//编辑模式下不能编辑名字 prepared = true; RunOnce(); } else { getSetOfLines = new GetSetOfLines(); data = getSetOfLines; } }
private void Ufrm_MultipleDistance_FormClosing(object sender, FormClosingEventArgs e) { if (EditMode) { MeasuringUnit u1 = null; try { u1 = (Line)Func_System.GetUnit(baseLines, (data as BaseCal_Multi).baseLine.iD); } catch (Exception) { } try { if (u1 == null) { u1 = (Line)Func_System.GetUnit(baseLines, (oldData as BaseCal_Multi).baseLine.iD); } } catch (Exception) { } MeasuringUnit u2 = null; try { u2 = (GetSetOfLines)Func_System.GetUnit(lineGroups, (data as BaseCal_Multi).lines.iD); } catch (Exception) { } try { if (u2 == null) { u2 = (GetSetOfLines)Func_System.GetUnit(lineGroups, (oldData as BaseCal_Multi).lines.iD); } } catch (Exception) { } if (u1 == null) { u1 = new Line(0, 0, 1, 1); } if (u2 == null) { u2 = new GetSetOfLines(); (u2 as GetSetOfLines).AddLine( new GetLineUseThreshold( new Threshold(new Rectangle2(0, 0, 0, 1, 1)))); } (data as BaseCal_Multi).baseLine = (Line)u1; (data as BaseCal_Multi).lines = (GetSetOfLines)u2; if (data is MultipleDistance) { for (int i = 0; i < (data as MultipleDistance).calList.Count; i++) { BaseCal_Single item = (data as MultipleDistance).calList[i]; item.unit1 = (data as MultipleDistance).baseLine; item.unit2 = (data as MultipleDistance).lines.LineList[i]; } } if (data is DropDistance) { for (int i = 0; i < (data as DropDistance).calList.Count; i++) { BaseCal_Single item = (data as DropDistance).calList[i]; item.unit1 = (data as DropDistance).baseLine; item.unit2 = (data as DropDistance).lines.LineList[i]; } } if (data is PinDistance) { for (int i = 0; i < (data as PinDistance).calList.Count; i++) { BaseCal_Single item = (data as PinDistance).calList[i]; item.unit1 = (data as PinDistance).lines.LineList[i]; item.unit2 = (data as PinDistance).lines.LineList[i + 1]; } } } }