示例#1
0
        private void B3_Click(object sender, EventArgs e)
        {
            Label l31 = FindControl(panel1, "l31") as Label;
            Label l32 = FindControl(panel1, "l32") as Label;
            Label l33 = FindControl(panel1, "l33") as Label;
            Label l34 = FindControl(panel1, "l34") as Label;
            Label l35 = FindControl(panel1, "l35") as Label;
            int   x1;
            int   y1;
            int   x2;
            int   y2;

            int.TryParse(l31.Text.Split(' ')[1], out x1);
            int.TryParse(l32.Text.Split(' ')[1], out y1);
            int.TryParse(l33.Text.Split(' ')[1], out x2);
            int.TryParse(l34.Text.Split(' ')[1], out y2);
            Figure f2 = new Figure();

            f2.Add(new CustomPoint(x1, y1));
            f2.Add(new CustomPoint(x2, y2));
            var res = Figure.Intersection(f, f2);

            l35.Text = "Result: " + (res.x).ToString("F0") + "; " + (res.y).ToString("F0");
            Graphics g = Graphics.FromImage(pictureBox1.Image);

            Point[] points = new Point[2];
            points[0] = new Point(ToPictureBoxX(x1), ToPictureBoxY(y1));
            points[1] = new Point(ToPictureBoxX(x2), ToPictureBoxY(y2));
            Pen pen = new Pen(Color.Blue);

            g.DrawPolygon(pen, points);
            pictureBox1.Invalidate();
        }