/// <summary> /// 数据赋值 /// </summary> private void FinalAssessment() { data.name = (txt_Name.Text).Trim(); data.formType = GetType(); if (cmb_slg_Item.SelectedItem == null) { (data as BaseCal_Multi).SetAllMaxValue((double)nud_MaxValue.Value); (data as BaseCal_Multi).SetAllMinValue((double)nud_MinValue.Value); (data as BaseCal_Multi).SetAllK((double)nud_k.Value); } else { (data as BaseCal_Multi).calList[cmb_slg_Item.SelectedIndex].minValue = (double)nud_slg_MinValue.Value; (data as BaseCal_Multi).calList[cmb_slg_Item.SelectedIndex].maxValue = (double)nud_slg_MaxValue.Value; (data as BaseCal_Multi).calList[cmb_slg_Item.SelectedIndex].kCx = (double)nud_slg_k.Value; } if ((data as BaseCal_Multi).baseLine == null || (data as BaseCal_Multi).lines == null) { if ((data as BaseCal_Multi).baseLine == null) { (data as BaseCal_Multi).baseLine = new Line(0, 0, 1, 1); } if ((data as BaseCal_Multi).lines == null) { (data as BaseCal_Multi).lines = new GetSetOfLines(); (data as BaseCal_Multi).lines.AddLine( new GetLineUseThreshold( new Threshold(new Rectangle2(0, 0, 0, 1, 1)))); } 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]; } } } }
private void rdo_LTL_CheckedChanged(object sender, EventArgs e) { if ((sender as RadioButton).Checked && prepared) { calculate = new DisLineToLine(measureManager.k, new Line(0, 0, 1, 1), new Line(0, 0, 1, 1)); data = calculate; unitList1 = measureManager.ListAllLine(); //获取所有线 unitList2 = measureManager.ListAllLine(); //获取所有线 UpdateComboBox(); lab_Item1.Text = "线1"; lab_Item2.Text = "线2"; } }
private void rdo_PTP_CheckedChanged(object sender, EventArgs e) { if ((sender as RadioButton).Checked && prepared) { calculate = new DisPointToPoint(measureManager.k, new Point(0, 0), new Point(0, 0)); data = calculate; unitList1 = measureManager.ListAllPoint(); //获取所有点 unitList2 = measureManager.ListAllPoint(); //获取所有点 UpdateComboBox(); lab_Item1.Text = "点1"; lab_Item2.Text = "点2"; } }
private void Ufrm_Angle_Load(object sender, System.EventArgs e) { hWindow_Final1.HobjectToHimage(ho_Image); if (measureManager == null) { measureManager = form.measureManager; } lines = new List <Line>(); List <MeasuringUnit> units = measureManager.ListAllLine();//获取所有线 foreach (var item in units) { lines.Add(item as Line); cmb_Item1.Items.Add(item.name); cmb_Item2.Items.Add(item.name); } //判断是否编辑模式进入 if (EditMode) { nud_Spacing.Value = data.StringHeight; cbx_AlwaysMinAngel.Visible = false; txt_Name.Text = data.name; //txt_Name.Enabled = false;//编辑模式下不能编辑名字 calculate = data as BaseCal_Single; cmb_Item1.SelectedIndex = Func_System.GetIndex(lines, calculate.unit1 as Line); cmb_Item2.SelectedIndex = Func_System.GetIndex(lines, calculate.unit2 as Line); if (cmb_Item1.SelectedIndex == -1) { calculate.unit1 = new Line(0, 0, 1, 1); } if (cmb_Item2.SelectedIndex == -1) { calculate.unit2 = new Line(0, 0, 1, 1); } nud_MaxValue.Value = (decimal)calculate.maxValue; nud_MinValue.Value = (decimal)calculate.minValue; txt_RealValue.Text = (calculate.hv_RealDistance != null ? calculate.hv_RealDistance.D : 0).ToString("f1"); prepared = true; RunOnce(); } else { calculate = new AngelLineToLine(measureManager.k, new Line(0, 0, 1, 1), new Line(0, 0, 1, 1)); data = calculate; prepared = true; } }
private void Ufrm_Radius_Load(object sender, EventArgs e) { hWindow_Final1.HobjectToHimage(ho_Image); if (measureManager == null) { measureManager = form.measureManager; } circles = new List <Circle>(); measuringUnits = measureManager.ListAllCircle(); foreach (var item in measuringUnits) { circles.Add(item as Circle); cmb_Circles.Items.Add(item.name); } if (EditMode) { //编辑模式 nud_Spacing.Value = data.StringHeight; txt_Name.Text = data.name; // txt_Name.Enabled = false;//编辑模式下不能编辑名字 calculate = data as BaseCal_Single; cmb_Circles.SelectedIndex = Func_System.GetIndex(measuringUnits, calculate.unit1); if (cmb_Circles.SelectedIndex == -1) { calculate.unit1 = new Circle(0, 0, 1); } nud_MaxValue.Value = (decimal)calculate.maxValue; nud_MinValue.Value = (decimal)calculate.minValue; nud_k.Value = (decimal)calculate.kCx.D; nud_RealValue.Value = (decimal)(calculate.hv_RealDistance != null ? calculate.hv_RealDistance.D : 0); prepared = true; RunOnce(); } else { calculate = new CircleRadius(measureManager.k, new Circle(0, 0, 1)); nud_k.Value = (decimal)measureManager.k; data = calculate; prepared = true; } }
private void Ufrm_Distance_Load(object sender, EventArgs e) { hWindow_Final1.HobjectToHimage(ho_Image); if (measureManager == null) { measureManager = form.measureManager; } if (EditMode) { nud_Spacing.Value = data.StringHeight; txt_Name.Text = data.name; // txt_Name.Enabled = false;//编辑模式下不能编辑名字 //编辑模式 calculate = data as BaseCal_Single; if (calculate is DisPointToPoint) { unitList1 = measureManager.ListAllPoint(); //获取所有点 unitList2 = measureManager.ListAllPoint(); //获取所有点 foreach (var item in unitList1) //添加cmb_Item1项 { cmb_Item1.Items.Add(item.name); } foreach (var item in unitList2)//添加cmb_Item2项 { cmb_Item2.Items.Add(item.name); } rdo_PTP.Checked = true; lab_Item1.Text = "点1"; lab_Item2.Text = "点2"; rdo_PTL.Enabled = false; rdo_LTL.Enabled = false; cmb_Item1.SelectedIndex = Func_System.GetIndex(unitList1, calculate.unit1); cmb_Item2.SelectedIndex = Func_System.GetIndex(unitList2, calculate.unit2); if (cmb_Item1.SelectedIndex == -1) { calculate.unit1 = new Point(0, 0); } if (cmb_Item2.SelectedIndex == -1) { calculate.unit2 = new Point(0, 0); } } if (calculate is DisPointToLine) { unitList1 = measureManager.ListAllPoint(); //获取所有点 unitList2 = measureManager.ListAllLine(); //获取所有线 foreach (var item in unitList1) //添加cmb_Item1项 { cmb_Item1.Items.Add(item.name); } foreach (var item in unitList2)//添加cmb_Item2项 { cmb_Item2.Items.Add(item.name); } rdo_PTL.Checked = true; lab_Item1.Text = "点"; lab_Item2.Text = "线"; rdo_PTP.Enabled = false; rdo_LTL.Enabled = false; cmb_Item1.SelectedIndex = Func_System.GetIndex(unitList1, calculate.unit1); cmb_Item2.SelectedIndex = Func_System.GetIndex(unitList2, calculate.unit2); if (cmb_Item1.SelectedIndex == -1) { calculate.unit1 = new Point(0, 0); } if (cmb_Item2.SelectedIndex == -1) { calculate.unit2 = new Line(0, 0, 1, 1); } } if (calculate is DisLineToLine) { unitList1 = measureManager.ListAllLine(); //获取所有线 unitList2 = measureManager.ListAllLine(); //获取所有线 foreach (var item in unitList1) //添加cmb_Item1项 { cmb_Item1.Items.Add(item.name); } foreach (var item in unitList2)//添加cmb_Item2项 { cmb_Item2.Items.Add(item.name); } rdo_LTL.Checked = true; lab_Item1.Text = "线1"; lab_Item2.Text = "线2"; rdo_PTL.Enabled = false; rdo_PTP.Enabled = false; cmb_Item1.SelectedIndex = Func_System.GetIndex(unitList1, calculate.unit1); cmb_Item2.SelectedIndex = Func_System.GetIndex(unitList2, calculate.unit2); if (cmb_Item1.SelectedIndex == -1) { calculate.unit1 = new Line(0, 0, 1, 1); } if (cmb_Item2.SelectedIndex == -1) { calculate.unit2 = new Line(0, 0, 1, 1); } } nud_MaxValue.Value = (decimal)calculate.maxValue; nud_MinValue.Value = (decimal)calculate.minValue; nud_k.Value = (decimal)calculate.kCx.D; nud_RealValue.Value = (decimal)calculate.hv_RealDistance.D; prepared = true; RunOnce(); } else { nud_k.Value = (decimal)measureManager.k; prepared = true; rdo_LTL.Checked = true; //非编辑模式 } }
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]; } } } }