private void 二維量測EllipseToolStripMenuItem_Click(object sender, EventArgs e) { //控制項目前cell位置 CurrencyManager cm = (CurrencyManager)this.BindingContext[ProcedureTable.DataSource]; //設定Procedure_Table顯示字串 Procedure_Table p = new Procedure_Table(); Object_Table O = new Object_Table(); p.ProcedureName = "Measure_2D_Eillpse"; p.Setornot = false; p.ProcedureMethod = (int)procedure_M.Measure_2D_Ellipse; p.SettingForm = new Measure_2D_Ellipse(); Camera.Procedure.Insert(cm.Position + 1, p); Camera.Object.Insert(cm.Position + 1, O); //重新排序Procedure編號 remarkProcedure(0); //更新表格 if (cm != null) { cm.Refresh(); ProcedureTable.ClearSelection(); if (ProcedureTable.RowCount < cm.Position + 1) { ProcedureTable.Rows[cm.Position + 1].Selected = true; } else { ProcedureTable.Rows[cm.Position].Selected = true; } } setProcedurecolor(); }
int clk = 0;//載入圖片序數 private void 載入圖片ToolStripMenuItem_Click(object sender, EventArgs e) { //控制項目前cell位置 CurrencyManager cm = (CurrencyManager)this.BindingContext[ProcedureTable.DataSource]; //設定Procedure_Table顯示字串 Procedure_Table p = new Procedure_Table(); Object_Table O = new Object_Table(); p.ProcedureName = "載入圖片" + clk; p.Setornot = false; p.ProcedureMethod = (int)procedure_M.readimage; O.ImageName = "載入圖片" + clk; Camera.Procedure.Insert(cm.Position + 1, p); Camera.Object.Insert(cm.Position + 1, O); clk++; //重新排序Procedure編號 remarkProcedure(0); //更新表格 if (cm != null) { //更新表單(會將所有設定清除....) cm.Refresh(); //新增之後將cm移至新增的項目上 ProcedureTable.ClearSelection(); if (ProcedureTable.RowCount < cm.Position + 1) { ProcedureTable.Rows[cm.Position + 1].Selected = true; } else { ProcedureTable.Rows[cm.Position].Selected = true; } } //設定Procedurecolor 依照是否已經設定好參數 setProcedurecolor(); }
private void ProcedureTable_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { CurrencyManager cm = (CurrencyManager)this.BindingContext[ProcedureTable.DataSource]; Procedure_Table p = new Procedure_Table(); switch (Camera.Procedure[cm.Position].ProcedureMethod) { case (int)procedure_M.readimage: //載入圖片函式 AccessImage readthefuckingimage = new AccessImage(); //由檔案載入圖片 readthefuckingimage.ImagefromFile(); //設定顯示視窗 //readthefuckingimage.setwindow(MainWindow.HalconWindow); if (readthefuckingimage.getimagebase().GetImage != null) { p.procedurefunction.doprocedurefunction += readthefuckingimage.show; Camera.Object[cm.Position].Image = readthefuckingimage.getimagebase().GetImage; Camera.Procedure[cm.Position].Setornot = true; } break; case (int)procedure_M.Measure_1D: Measure_1D M1_temp = (Measure_1D)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { M1_temp.MeasureImage = Camera.Object[cm.Position - 1].Image; //暫時使用前一個程序的圖片(載入圖片) M1_temp.O_T = Camera.Object; } M1_temp.ShowDialog(); Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += M1_temp.run; Camera.Procedure[cm.Position].SettingForm = M1_temp; Camera.Procedure[cm.Position].Setornot = M1_temp.setornot; break; case (int)procedure_M.Measure_2D_Circle: Measure_2D_Circle M2DC_temp = (Measure_2D_Circle)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { M2DC_temp.MeasureImage = Camera.Object[cm.Position - 1].Image; //暫時使用前一個程序的圖片(載入圖片) } M2DC_temp.ShowDialog(); Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += M2DC_temp.run; Camera.Procedure[cm.Position].SettingForm = M2DC_temp; Camera.Procedure[cm.Position].Setornot = M2DC_temp.setornot; break; case (int)procedure_M.Measure_2D_Ellipse: Measure_2D_Ellipse M2DE_temp = (Measure_2D_Ellipse)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { M2DE_temp.MeasureImage = Camera.Object[cm.Position - 1].Image; //暫時使用前一個程序的圖片(載入圖片) } M2DE_temp.ShowDialog(); Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += M2DE_temp.run; Camera.Procedure[cm.Position].SettingForm = M2DE_temp; Camera.Procedure[cm.Position].Setornot = M2DE_temp.setornot; break; case (int)procedure_M.Measure_2D_Line: Measure_2D_Line M2DL_temp = (Measure_2D_Line)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { M2DL_temp.MeasureImage = Camera.Object[cm.Position - 1].Image; //暫時使用前一個程序的圖片(載入圖片) } M2DL_temp.ShowDialog(); Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += M2DL_temp.run; Camera.Procedure[cm.Position].SettingForm = M2DL_temp; Camera.Procedure[cm.Position].Setornot = M2DL_temp.setornot; break; case (int)procedure_M.CreateMatchingModel: CreateMatchingModel CMM_temp = (CreateMatchingModel)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { CMM_temp.TemplateImage = Camera.Object[cm.Position - 1].Image; } CMM_temp.ShowDialog(); Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += CMM_temp.run; Camera.Procedure[cm.Position].SettingForm = CMM_temp; Camera.Procedure[cm.Position].Setornot = CMM_temp.setornot; break; } setProcedurecolor(); }
private void ProcedureTable_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { CurrencyManager cm = (CurrencyManager)this.BindingContext[ProcedureTable.DataSource]; Procedure_Table p = new Procedure_Table(); //載入圖片函式 switch (Camera.Procedure[cm.Position].ProcedureMethod) { case (int)PROCEDURE.readimage: AccessImage readthefuckingimage = new AccessImage(); //由檔案載入圖片 readthefuckingimage.ImagefromFile(); if (readthefuckingimage.getimagebase().GetImage != null) { p.procedurefunction.doprocedurefunction += readthefuckingimage.show; string temp = "(procedure_" + cm.Position + ",Image_" + Camera.Object[cm.Position].OImage.Count + ")"; if (readthefuckingimage.getimagebase().GetImage != null) { Camera.Object[cm.Position].OImage.Clear(); Camera.Object[cm.Position].OImageName.Clear(); } Camera.Object[cm.Position].OImage.Add(readthefuckingimage.getimagebase().GetImage); Camera.Object[cm.Position].OImageName.Add(temp); Camera.Procedure[cm.Position].Setornot = true; } break; case (int)PROCEDURE.ImageFromCamera: ImageFromCamera IFC_temp = (ImageFromCamera)Camera.Procedure[cm.Position].SettingForm; IFC_temp.ShowDialog(); if (IFC_temp.setornot == true) { if (IFC_temp.dstImage != null) { Camera.Object[cm.Position].OImage.Clear(); Camera.Object[cm.Position].OImageName.Clear(); } Camera.Object[cm.Position].OImage.Add(IFC_temp.dstImage); Camera.Object[cm.Position].OImageName.Add("(procedure_" + cm.Position + ",Image_" + Camera.Object[cm.Position].OImage.Count + ")"); } Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += IFC_temp.run; Camera.Procedure[cm.Position].SettingForm = IFC_temp; Camera.Procedure[cm.Position].Setornot = IFC_temp.setornot; break; case (int)PROCEDURE.Measure_1D: Measure_1D M1_temp = (Measure_1D)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { M1_temp.M1DP_in.O_T = Camera.Object; } M1_temp.ShowDialog(); if (M1_temp.M1DP_form.setornot == true) { Camera.Object[cm.Position].OPoint.Clear(); Camera.Object[cm.Position].OPointName.Clear(); if (M1_temp.M1DP_out.dstfirstpoint != null) { for (int i = 0; i < M1_temp.M1DP_out.dstfirstpoint.Count; i++) { Camera.Object[cm.Position].OPoint.Add(M1_temp.M1DP_out.dstfirstpoint[i]); Camera.Object[cm.Position].OPointName.Add("dstfirstpoint" + i); } } if (M1_temp.M1DP_out.dstsecondpoint != null) { for (int i = 0; i < M1_temp.M1DP_out.dstsecondpoint.Count; i++) { Camera.Object[cm.Position].OPoint.Add(M1_temp.M1DP_out.dstsecondpoint[i]); Camera.Object[cm.Position].OPointName.Add("dstsecondpoint" + i); } } } Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += M1_temp.run; Camera.Procedure[cm.Position].SettingForm = M1_temp; Camera.Procedure[cm.Position].Setornot = M1_temp.M1DP_form.setornot; break; case (int)PROCEDURE.Measure_2D_Circle: Measure_2D_Circle M2DC_temp = (Measure_2D_Circle)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { M2DC_temp.M2DCP_in.O_T = Camera.Object; //暫時使用前一個程序的圖片(載入圖片) } M2DC_temp.ShowDialog(); if (M2DC_temp.M2DCP_out.setornot == true) { Camera.Object[cm.Position].OCircle.Clear(); Camera.Object[cm.Position].OCircleName.Clear(); if (M2DC_temp.M2DCP_out.dst_circle != null) { Camera.Object[cm.Position].OCircle.Add(M2DC_temp.M2DCP_out.dst_circle); Camera.Object[cm.Position].OCircleName.Add("testcircle"); } } Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += M2DC_temp.run; Camera.Procedure[cm.Position].SettingForm = M2DC_temp; Camera.Procedure[cm.Position].Setornot = M2DC_temp.M2DCP_out.setornot; break; case (int)PROCEDURE.Measure_2D_Line: Measure_2D_Line M2DL_temp = (Measure_2D_Line)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { M2DL_temp.M2DLP_in.O_T = Camera.Object; //暫時使用前一個程序的圖片(載入圖片) } M2DL_temp.ShowDialog(); if (M2DL_temp.M2DLP_out.setornot == true) { Camera.Object[cm.Position].OLine.Clear(); Camera.Object[cm.Position].OLineName.Clear(); if (M2DL_temp.M2DLP_out.dst_line != null) { Camera.Object[cm.Position].OLine.Add(M2DL_temp.M2DLP_out.dst_line); Camera.Object[cm.Position].OLineName.Add("TheVerticalLine"); } } Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += M2DL_temp.run; Camera.Procedure[cm.Position].SettingForm = M2DL_temp; Camera.Procedure[cm.Position].Setornot = M2DL_temp.M2DLP_out.setornot; break; case (int)PROCEDURE.CreateMatchingModel: CreateMatchingModel CMM_temp = (CreateMatchingModel)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { CMM_temp.CMMP_in.O_T = Camera.Object; } CMM_temp.ShowDialog(); if (CMM_temp.CMMP_out.setornot ==true) { Camera.Object[cm.Position].OImage.Clear(); Camera.Object[cm.Position].OImageName.Clear(); if (CMM_temp.CMMP_out.dst_Image.GetImage != null) { Camera.Object[cm.Position].OImage.Add(CMM_temp.CMMP_out.dst_Image.GetImage); Camera.Object[cm.Position].OImageName.Add("CreateMatchingModel"); } } Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += CMM_temp.run; Camera.Procedure[cm.Position].SettingForm = CMM_temp; Camera.Procedure[cm.Position].Setornot = CMM_temp.CMMP_out.setornot; break; case (int)PROCEDURE.TheVerticalLine: TheVerticalLine TVL_temp = (TheVerticalLine)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { TVL_temp.TVL_in.O_T = Camera.Object; } TVL_temp.ShowDialog(); if (TVL_temp.TVL_out.setornot == true) { Camera.Object[cm.Position].OLine.Clear(); Camera.Object[cm.Position].OLineName.Clear(); if (TVL_temp.TVL_out.dst_Line != null) { Camera.Object[cm.Position].OLine.Add(TVL_temp.TVL_out.dst_Line); Camera.Object[cm.Position].OLineName.Add("TheVerticalLine"); } } Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += TVL_temp.run; Camera.Procedure[cm.Position].SettingForm = TVL_temp; Camera.Procedure[cm.Position].Setornot = TVL_temp.TVL_out.setornot; break; case (int)PROCEDURE.PL_distance: PL_distance PLD_temp = (PL_distance)Camera.Procedure[cm.Position].SettingForm; if (cm.Position != 0) { PLD_temp.O_T = Camera.Object; } PLD_temp.ShowDialog(); Camera.Procedure[cm.Position].procedurefunction.doprocedurefunction += PLD_temp.run; Camera.Procedure[cm.Position].SettingForm = PLD_temp; Camera.Procedure[cm.Position].Setornot = PLD_temp.setornot; break; } setProcedurecolor(); }