예제 #1
0
 private void Form1_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13 && choice)
     {
         if (mousepoz.Count < 2)
         {
             MessageBox.Show("Enter >1 point!", "ERROR");
             return;
         }
         Type[] args = new Type[1];
         args[0] = typeof(Point[]);
         object[]     par  = new object[1];
         List <Point> list = new List <Point>();
         list = mousepoz.GetRange(0, mousepoz.Count);
         mousepoz.Clear();
         par[0] = list.ToArray();
         ConstructorInfo ci = type.GetConstructor(args);
         if (ci != null)
         {
             Shapes.Shapes shape = (Shapes.Shapes)ci.Invoke(par);
             Graphics      g     = this.CreateGraphics();
             shape.draw(g);
         }
     }
 }
예제 #2
0
파일: Form1.cs 프로젝트: LisP94/OOP
 private void rectangleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     points      = new Point[2];
     points[0].X = rand.Next(0, 150);
     points[0].Y = rand.Next(0, 150);
     points[1].X = rand.Next(150, 300);
     points[1].Y = rand.Next(150, 300);
     shape       = new Rectangle.Rectangle(points);
     shape.draw(g);
     list.Add(shape);
 }
예제 #3
0
파일: Form1.cs 프로젝트: LisP94/OOP
 private void rectangleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     points = new Point[2];
     points[0].X = rand.Next(0, 150);
     points[0].Y = rand.Next(0, 150);
     points[1].X = rand.Next(150, 300);
     points[1].Y = rand.Next(150, 300);
     shape = new Rectangle.Rectangle(points);
     shape.draw(g);
     list.Add(shape);
 }
예제 #4
0
파일: Form1.cs 프로젝트: LisP94/OOP
 private void ellipseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     int a,b;
     point.X = rand.Next(120, 170);
     point.Y = rand.Next(0, 300);
     a = rand.Next(2, 80);
     b = rand.Next(2, 80);
     shape = new Ellipse.Ellipse(point, a,b);
     shape.draw(g);
     list.Add(shape);
 }
예제 #5
0
파일: Form1.cs 프로젝트: LisP94/OOP
        private void ellipseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int a, b;

            point.X = rand.Next(120, 170);
            point.Y = rand.Next(0, 300);
            a       = rand.Next(2, 80);
            b       = rand.Next(2, 80);
            shape   = new Ellipse.Ellipse(point, a, b);
            shape.draw(g);
            list.Add(shape);
        }
예제 #6
0
파일: Form1.cs 프로젝트: LisP94/OOP
 private void lineToolStripMenuItem_Click(object sender, EventArgs e)
 {
     points = new Point[2];
     for (i = 0; i <= 1; i++)
     {
         points[i].X = rand.Next(0, 300);
         points[i].Y = rand.Next(0, 300);
     }
     shape = new Line.Line(points);
     shape.draw(g);
     list.Add(shape);
 }
예제 #7
0
파일: Form1.cs 프로젝트: LisP94/OOP
 private void lineToolStripMenuItem_Click(object sender, EventArgs e)
 {
     points = new Point[2];
     for (i = 0; i <= 1; i++)
     {
         points[i].X = rand.Next(0, 300);
         points[i].Y = rand.Next(0, 300);
     }
     shape = new Line.Line(points);
     shape.draw(g);
     list.Add(shape);
 }
예제 #8
0
파일: Form1.cs 프로젝트: LisP94/OOP
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            int count;

            if (polygon)
            {
                if (i > 0)
                {
                    if ((Math.Abs(e.X - cont.ElementAt(0).X) < 5) && (Math.Abs(e.Y - cont.ElementAt(0).Y) < 5))
                    {
                        g.DrawLine(Pens.Red, cont.ElementAt(i - 1), cont.ElementAt(0));
                        polygon = false;
                        points  = new Point[cont.Count];
                        for (count = 0; count < cont.Count; count++)
                        {
                            points[count] = cont.ElementAt(count);
                        }
                        shape = new Polygon.Polygon(points);
                        shape.draw(g);
                        list.Add(shape);
                    }
                    else
                    {
                        point.X = e.X;
                        point.Y = e.Y;
                        g.DrawLine(Pens.Red, point, cont.ElementAt(i - 1));
                        cont.Add(point);
                    }
                }
                else
                {
                    point.X = e.X;
                    point.Y = e.Y;
                    cont.Add(point);
                }
                i++;
            }
        }
예제 #9
0
파일: Form1.cs 프로젝트: LisP94/OOP
 private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
 {
     int count;
     if (polygon)
     {
         if (i > 0)
         {
             if ((Math.Abs(e.X - cont.ElementAt(0).X) < 5) && (Math.Abs(e.Y - cont.ElementAt(0).Y) < 5))
             {
                 g.DrawLine(Pens.Red, cont.ElementAt(i - 1), cont.ElementAt(0));
                 polygon = false;
                 points = new Point[cont.Count];
                 for (count = 0; count < cont.Count; count++)
                 {
                     points[count] = cont.ElementAt(count);
                 }
                 shape = new Polygon.Polygon(points);
                 shape.draw(g);
                 list.Add(shape);
             }
             else
             {
                 point.X = e.X;
                 point.Y = e.Y;
                 g.DrawLine(Pens.Red, point, cont.ElementAt(i - 1));
                 cont.Add(point);
             }
         }
         else
         {
             point.X = e.X;
             point.Y = e.Y;
             cont.Add(point);
         }
         i++;
     }
 }