Exemplo n.º 1
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            if (isStartPointValid)
            {
                rectsROI[idxRect] = rect;

                blnDraw = false;

                using (Graphics g = Graphics.FromHwnd(this.pictureBox1.Handle))
                {
                    foreach (Rectangle _rect in rectsROI)
                    {
                        g.DrawRectangle(new Pen(Color.Red, 4), _rect);
                    }
                }

                RectangleF rectf = RectConverter.ConvertFromDrawRect(rect, idxRect);
                //Rectangle retRect = RectConverter.ConvertToDrawRect(rectf, idxRect);

                Size     size   = RectConverter.GetStepsByRectangleF(rectf);
                PointF[] points = RectConverter.GetAllPointsByRectangleF(rectf);

                Console.WriteLine(points[3].ToString());

                if (RectConverter.frects[idxRect].Contains(points[3]))
                {
                    Console.WriteLine("在里面");
                }
                else
                {
                    Console.WriteLine("不在里面");
                }


                //using (Graphics g = Graphics.FromHwnd(this.pictureBox1.Handle))
                //{
                //    foreach(PointF pt in points)
                //    {
                //        Point ipt = RectConverter.ConvertPointFToPoint(rects[idxRect], rectf, pt);
                //        SolidBrush brush = new SolidBrush(Color.Blue);
                //        Rectangle trect = new Rectangle(ipt, new Size(2, 2));
                //        g.FillRectangle(brush, trect);
                //    }
                //}

                string retfile = RectConverter.GenerateTaskDesc(@".\", "task", rect, rectf, points, size);
            }
        }
Exemplo n.º 2
0
        private void btnStartScan_Click(object sender, EventArgs e)
        {
            if (isSetName)
            {
                if (MessageBox.Show(generateConfirmMessage(), "确认", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                }
                else
                {
                    RectangleF FinalRectF;
                    Rectangle  FinalRect;
                    Size       FinalSize;
                    PointF[]   FinalPoints;

                    for (int i = 0; i < 4; i++)
                    {
                        if (broi[i])
                        {
                            FinalRectF  = RectConverter.ConvertFromDrawRect(rectsROI[i], i);
                            FinalRect   = rectsROI[i];
                            FinalSize   = RectConverter.GetStepsByRectangleF(FinalRectF);
                            FinalPoints = RectConverter.GetAllPointsByRectangleF(FinalRectF);

                            Temp = RectConverter.GenerateTaskDesc(this.filedir, this.filename + "_" + i.ToString(),
                                                                  FinalRect, FinalRectF, FinalPoints, FinalSize);
                        }
                    }

                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("请先设置扫描玻片的名字");
            }
        }