Пример #1
0
            public Polygon Copy(int addX = -1, int addY = -1)
            {
                var rtn = new Polygon();

                foreach (Point pt in this.vertices)
                {
                    rtn.vertices.Add(pt);
                }
                if (addX >= 0)
                {
                    rtn.AddVertice(addX, addY);
                }
                return(rtn);
            }
Пример #2
0
 private void picBox_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         img          = poly.ReDraw((Bitmap)img, Color.Black);
         picBox.Image = img;
         polys.Add(poly);
         polist.Items.Add(poly);
         Polygon p = poly.GetClone();
         VP             = p.ViewPort(VP, Color.Black, img.Width, img.Height, VP.Width, VP.Height);
         ViewPort.Image = VP;
         VPs.Add(p);
         polyflag  = false;
         polyfirst = true;
     }
     else
     {
         if (polyflag)
         {
             if (polyfirst)
             {
                 polyfirst = !polyfirst;
                 poly      = new Polygon();
                 poly.AddVertice(e.X, e.Y);
                 point = new Point(e.X, e.Y);
             }
             else
             {
                 img          = DrawLine.DDA((Bitmap)img, point.X, point.Y, e.X, e.Y, Color.Black);
                 picBox.Image = img;
                 poly.AddVertice(e.X, e.Y);
                 point = new Point(e.X, e.Y);
             }
         }
         else
         {
             if (flag == false && polyflag == false)
             {
                 point = new Point(e.X, e.Y);
                 flag  = true;
             }
         }
     }
 }