Esempio n. 1
0
        private void roundButton_Save_Click(object sender, EventArgs e)
        {
            //    VisionMgr.GetInstance().Save();
            if (indexSelVisionSel == -1)
            {
                return;
            }
            if (dataGridViewProcessItem.Rows[indexSelVisionSel].Cells[1].Value == null ||
                dataGridViewProcessItem.Rows[indexSelVisionSel].Cells[1].Value.ToString() == "")
            {
                return;
            }
            string strItem = dataGridViewProcessItem.Rows[indexSelVisionSel].Cells[1].Value.ToString();

            //判断视觉Item是否填写完整
            if (!IstemOK(indexSelVisionSel))
            {
                return;
            }
            string strVisionType = dataGridViewProcessItem.Rows[indexSelVisionSel].Cells[2].Value.ToString();
            double dExposure     = dataGridViewProcessItem.Rows[indexSelVisionSel].Cells[4].Value.ToString().ToDouble();
            double dGain         = dataGridViewProcessItem.Rows[indexSelVisionSel].Cells[5].Value.ToString().ToDouble();
            string strCamName    = dataGridViewProcessItem.Rows[indexSelVisionSel].Cells[3].Value.ToString();

            switch (strVisionType)
            {
            case "模板匹配":
                Vision_MatchSetCtr1.SaveParm(VisionMgr.GetInstance().GetItem(strItem));
                break;

            case "二维码":
                vision_2dCodeSetCtr1.SaveParm(VisionMgr.GetInstance().GetItem(strItem));
                break;

            case "一维码":
                vision_1BarCodeSetCtr1.SaveParm(VisionMgr.GetInstance().GetItem(strItem));
                break;

            case "找圆":
                vision_FindCircleCtr1.SaveParm(VisionMgr.GetInstance().GetItem(strItem));
                break;
            }

            CreateAndSaveItem(strItem, strVisionType, strCamName, dExposure, dGain);
        }
Esempio n. 2
0
        private void dataGridViewProcessItem_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dataGridViewProcessItem.Rows[e.RowIndex].Cells[e.ColumnIndex].GetType() != typeof(DataGridViewCheckBoxCell))
            {
                return;
            }
            if (this.dataGridViewProcessItem.Rows[e.RowIndex].Cells[e.ColumnIndex].GetType() == typeof(DataGridViewCheckBoxCell))
            {
                for (int i = 0; i < this.dataGridViewProcessItem.RowCount; i++)
                {
                    this.dataGridViewProcessItem.Rows[i].Cells[e.ColumnIndex].Value = false;
                }
                //this.dataGridViewProcessItem.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = true;
                indexSelVisionSel = e.RowIndex;
            }
            DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)this.dataGridViewProcessItem.Rows[e.RowIndex].Cells[e.ColumnIndex];

            if ((bool)checkCell.EditedFormattedValue == true)
            {
                indexSelVisionSel = e.RowIndex;
            }
            else
            {
                indexSelVisionSel = -1;
            }
            foreach (var temp in panel_VisionCtrls.Controls)
            {
                ((Control)temp).Hide();
            }

            if (indexSelVisionSel == -1)
            {
                dataGridViewProcessItem.Columns[2].ReadOnly = true;
                return;
            }

            dataGridViewProcessItem.Columns[2].ReadOnly = false;
            //if (!IstemOK(e.RowIndex)) return;
            string ItemName = "";

            ItemName = dataGridViewProcessItem.Rows[e.RowIndex].Cells[1].Value.ToString();
            VisionSetpBase visionSetpBase = VisionMgr.GetInstance().GetItem(ItemName);

            if (dataGridViewProcessItem.Rows[e.RowIndex].Cells[2].Value.ToString() != visionSetpBase.PrTyppeItem.ToString())
            {
                string       str          = visionSetpBase.m_strStepName + " 当前的视觉类型为:" + visionSetpBase.PrTyppeItem.ToString() + "是否切换到视觉类型:" + dataGridViewProcessItem.Rows[e.RowIndex].Cells[2].Value.ToString();
                DialogResult dialogResult = MessageBox.Show(str, "Err", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (dialogResult == DialogResult.Yes)
                {
                    visionSetpBase.Disopose();


                    string camname  = visionSetpBase.m_camparam.m_strCamName;
                    double exposure = visionSetpBase.m_camparam.m_dExposureTime;
                    double dGain    = visionSetpBase.m_camparam.m_dGain;
                    VisionMgr.GetInstance().DelItem(ItemName);
                    visionSetpBase = null;
                    string strtype = dataGridViewProcessItem.Rows[e.RowIndex].Cells[2].Value.ToString();
                    CreateAndSaveItem(ItemName, strtype,
                                      camname, exposure, dGain);
                    visionSetpBase = VisionMgr.GetInstance().GetItem(ItemName);
                }
                else
                {
                    return;
                }
            }
            switch (dataGridViewProcessItem.Rows[e.RowIndex].Cells[2].Value.ToString())
            {
            case "模板匹配":
                Vision_MatchSetCtr1.Show();
                Vision_MatchSetCtr1.FlushToDlg(visionSetpBase, visionControl1);
                roundButton_ShapeROIAdd.Show();
                roundButton_ShapeROISub.Show();
                break;

            case "二维码":
                vision_2dCodeSetCtr1.Show();
                vision_2dCodeSetCtr1.FlushToDlg(visionSetpBase, visionControl1);
                break;

            case "一维码":
                vision_1BarCodeSetCtr1.Show();
                vision_1BarCodeSetCtr1.FlushToDlg(visionSetpBase, visionControl1);
                break;

            case "找圆":
                vision_FindCircleCtr1.Show();
                vision_FindCircleCtr1.FlushToDlg(visionSetpBase, visionControl1);
                break;
            }
            roundButton_SeachArea.Show();
            // roundButton_DrawRect1.Show();
            roundButton_Test.Show();
        }