Esempio n. 1
0
 private void btnSaveSerach_Click(object sender, EventArgs e)
 {
     if (btnSaveSerach.Text == "新建")
     {
         btnSaveSerach.Text = "保存";
         if (CurrentImage == null || !CurrentImage.IsInitialized())
         {
             MessageBox.Show("请先加载一张图片");
             return;
         }
         ActionIsDrawingRoi(true);
         btnSaveSerach.Enabled = true;
         groupBox2.Enabled     = true;
         view1.roiController.reset();
         view1.roiController.setROIShape(new ViewROI.ROIRectangle1(100));
     }
     else if (btnSaveSerach.Text == "保存")
     {
         SerachRoi = view1.roiController.getActiveROI();
         if (SerachRoi is ViewROI.ROIRectangle1)
         {
             btnSaveSerach.Text = "新建";
             SerachRect1        = (ViewROI.ROIRectangle1)SerachRoi;
             double row11, col11, row21, col21;
             SerachRect1.GetRect1(out row11, out col11, out row21, out col21);
             DialogResult rlt = MessageBox.Show("创建搜索框成功,是否替换原有参数?", "参数覆盖",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (rlt != DialogResult.Yes)
             {
                 return;
             }
             Setting.SearchAreaX  = (int)col11;
             Setting.SearchAreaY  = (int)row11;
             Setting.SearchWidth  = (int)(col21 - col11);
             Setting.SearchHeight = (int)(row21 - row11);
             this.BeginInvoke(new Action(() => {
                 txtSearchX.Text      = Setting.SearchAreaX.ToString();
                 txtSearchY.Text      = Setting.SearchAreaY.ToString();
                 txtSearchWidth.Text  = Setting.SearchWidth.ToString();
                 txtSearchHeight.Text = Setting.SearchHeight.ToString();
                 Logger.Pop("创建搜索框成功");
             }));
         }
         else
         {
             MessageBox.Show("请选中roi");
         }
     }
 }
Esempio n. 2
0
        private void btnSaveSerach_Click(object sender, EventArgs e)
        {
            if (btnSaveSerach.Text == "新建")
            {
                btnSaveSerach.Text = "保存";

                if (GrabedImg == null || !GrabedImg.IsInitialized())
                {
                    MessageBox.Show("请先加载一张图片");
                    return;
                }
                ActionIsDrawingRoi(true);

                btnSaveSerach.Enabled = true;
                groupBox2.Enabled     = true;
                view1.roiController.reset();
                view1.roiController.resetROI();
                view1.roiController.setROIShape(new ViewROI.ROIRectangle1(100));
            }
            else if (btnSaveSerach.Text == "保存")
            {
                SerachRoi = view1.roiController.getActiveROI();
                if (SerachRoi is ViewROI.ROIRectangle1)
                {
                    btnSaveSerach.Text = "新建";
                    SerachRect1        = (ViewROI.ROIRectangle1)SerachRoi;
                    double row11, col11, row21, col21;
                    SerachRect1.GetRect1(out row11, out col11, out row21, out col21);
                    //ActionIsDrawingRoi(false);
                    DialogResult rlt1 = MessageBox.Show("创建搜索框成功,是否替换原有参数?", "参数覆盖",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (rlt1 != DialogResult.Yes)
                    {
                        return;
                    }
                    RectF.X      = (int)col11;
                    RectF.Y      = (int)row11;
                    RectF.Width  = (int)(col21 - col11);
                    RectF.Height = (int)(row21 - row11);

                    this.BeginInvoke(new Action(() =>
                    {
                        txtSearchX.Text      = RectF.X.ToString();
                        txtSearchY.Text      = RectF.Y.ToString();
                        txtSearchWidth.Text  = RectF.Width.ToString();
                        txtSearchHeight.Text = RectF.Height.ToString();
                        Logger.Pop("创建搜索框成功");
                    }));
                }
                else
                {
                    MessageBox.Show("请选中roi");
                }
            }
            #region
            //HTuple row1, row2, column1, column2;
            //view1.SetDraw("red");
            //ActionIsDrawingRoi(true);
            //view1.roiController.reset();
            //view1.roiController.setROIShape(new ViewROI.ROIRectangle1(100));
            //ActionIsDrawingRoi(false);
            //DialogResult rlt = MessageBox.Show("创建搜索框成功,是否替换原有参数?", "参数覆盖", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            //if (rlt != DialogResult.Yes) return;
            //RectF.X= (int)column1.D;
            //RectF.Y = (int)row1.D;
            //RectF.Width = (int)(column2 - column1).D;
            //RectF.Height = (int)(row2 - row1).D;
            //txtSearchX.Text = RectF.X.ToString();
            //txtSearchY.Text = RectF.Y.ToString();
            //txtSearchWidth.Text = RectF.Width.ToString();
            //txtSearchHeight.Text = RectF.Height.ToString();
            //TeachBlobLocaltPara.InspectRois[LineSelectComBox.SelectedIndex] = RectF;
            #endregion
        }