Exemplo n.º 1
0
        private void StartTeachBtn1_Click(object sender, EventArgs e)
        {
            bool IsTrue = true;

            if (!GrabedImg.IsInitialized())
            {
                MessageBox.Show("图片为空,请先加载一张图片。");
                return;
            }
            if (StartTeachBtn1.Text == "开始示教")
            {
                this.StartTeachBtn1.Text = "保存";
                this.EnableGroupbox(groupBox3, false);
                this.StartTeachBtn1.Enabled = true;
                this.view1.Refresh();
                this.view1.AddImage(GrabedImg);
                HObject RoiContour = new HObject();
                ActionIsDrawingRoi(true);
                this.view1.roiController.reset();
                this.view1.roiController.setROIShape(new ViewROI.ROILine());
            }
            else if (StartTeachBtn1.Text == "保存")
            {
                this.EnableGroupbox(groupBox3, true);
                ViewROI.ROILine myline = new ViewROI.ROILine();
                if (view1.roiController.getActiveROI() is ViewROI.ROILine)
                {
                    StartTeachBtn1.Text = "开始示教";
                    groupBox3.Enabled   = true;
                    myline = (ViewROI.ROILine)view1.roiController.getActiveROI();
                    double row1, col1, row2, col2;
                    myline.GetLine(out row1, out col1, out row2, out col2);
                    LineRow10 = row1;
                    LineCol10 = col1;
                    LineRow20 = row2;
                    LineCol20 = col2;
                    LineRow1  = row1;
                    LineCol1  = col1;
                    LineRow2  = row2;
                    LineCol2  = col2;
                    ActionIsDrawingRoi(false);
                    if (!IsTrue)
                    {
                        StartTeachBtn1.Enabled = true;
                        return;
                    }
                    Thread TeachThd = new Thread(TeachProcess);
                    TeachThd.IsBackground = true;
                    TeachThd.Start();
                    StartTeachBtn1.Enabled = false;
                }
                else
                {
                    MessageBox.Show("请先选中示教直线");
                }
            }
        }
Exemplo n.º 2
0
 private void DrawLineRoi()
 {
     if (!GrabedImg.IsInitialized())
     {
         MessageBox.Show("请先加载图片");
         return;
     }
     if (this.StartTeachBtn1.Text == "开始示教")
     {
         this.StartTeachBtn1.Text = "保存";
         this.EnableGroupbox(groupBox3, false);
         this.StartTeachBtn1.Enabled = true;
         this.myView.ResetWindow();
         this.myView.AddImage(this.GrabedImg);
         HObject RoiContour = new HObject();
         this.ActionIsDrawingRoi(true);
         this.myView.roiController.reset();
         this.myView.SetString(12, 12, "red", "点击显示窗口的位置,绘制直线");
         this.myView.roiController.setROIShape(new ViewROI.ROILine());
     }
     else if (StartTeachBtn1.Text == "保存")
     {
         this.EnableGroupbox(groupBox3, true);
         ViewROI.ROILine myline = new ViewROI.ROILine();
         if (myView.roiController.getActiveROI() is ViewROI.ROILine)
         {
             StartTeachBtn1.Text = "开始示教";
             groupBox3.Enabled   = true;
             myline = (ViewROI.ROILine)myView.roiController.getActiveROI();
             double row1, col1, row2, col2;
             myline.GetLine(out row1, out col1, out row2, out col2);
             LineRow10 = row1;
             LineCol10 = col1;
             LineRow20 = row2;
             LineCol20 = col2;
             LineRow1  = row1;
             LineCol1  = col1;
             LineRow2  = row2;
             LineCol2  = col2;
             ActionIsDrawingRoi(false);
             Thread TeachThd = new Thread(DrawLinesProcess);
             TeachThd.IsBackground = true;
             TeachThd.Start();
             StartTeachBtn1.Enabled = false;
         }
         else
         {
             MessageBox.Show("请先选中示教直线");
         }
     }
 }