Beispiel #1
0
 public CCircle(CCircle c)
 {
     center = new PointF((float)c.X, (float)c.Y);
     r      = c.R;
     _color = c.color;
 }
Beispiel #2
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            treeClicked = false;

            if (shapeIndex == 0)
            {
                PointF p = new PointF(e.X, e.Y);
                shapes.Set_current_first();
                for (bool cond = !shapes.Is_empty(); cond;
                     cond = shapes.Step_forward())
                {
                    if (shapes.Current.Shape.Contains(p))
                    {
                        if (s != null)
                        {
                            s.Draw(g, w);
                        }
                        s = shapes.Current.Shape;
                        s.Draw(g, w, 4);
                        UpdateTB();
                        return;
                    }
                }
            }

            if (shapeIndex == 1)
            {
                if (s != null)
                {
                    s.Draw(g, w);
                }
                s = new CCircle(e.X, e.Y, 100);
                s.Draw(g, w, 4);
                shapes.Push_back(s);
            }

            if (shapeIndex == 2)
            {
                if (a == default(PointF))
                {
                    a = new PointF(e.X, e.Y);
                }
                else
                {
                    b = new PointF(e.X, e.Y);
                }
                if (b != default(PointF))
                {
                    if (s != null)
                    {
                        s.Draw(g, w);
                    }
                    s = new CSegment(a, b);
                    a = default(PointF);
                    b = default(PointF);
                    s.Draw(g, w, 4);
                    shapes.Push_back(s);
                }
            }

            if (shapeIndex == 3)
            {
                PointF cur = new PointF(e.X, e.Y);
                curver = new CCircle(cur, 5);
                curver.Draw(g, w);
                if (first == null)
                {
                    first = new CCircle(cur, 5);
                    first.Chng_clr(3);
                    first.Draw(g, w);
                }
                if (first.Contains(cur) && cur != first.Center)
                {
                    if (s != null)
                    {
                        s.Draw(g, w);
                    }
                    cur   = default(PointF);
                    first = null;
                    s     = new Polygon(v);
                    Draw_all_shapes();
                    s.Draw(g, w, 4);
                    shapes.Push_back(s);
                    v.Clear();
                }
                else
                {
                    v.Add(cur);
                }
            }

            if (shapeIndex == 4)
            {
                PointF p = new PointF(e.X, e.Y);
                shapes.Set_current_first();
                for (bool cond = !shapes.Is_empty(); cond;)
                {
                    if (shapes.Current.Shape.Contains(p))
                    {
                        gr.Add(shapes.Current.Shape);
                        shapes.Current.Shape.Draw(g, w, 3);
                        if (shapes.Current.Shape != shapes.Head.Shape)
                        {
                            shapes.Delete_current();
                            cond = shapes.Step_forward();
                        }
                        else
                        {
                            shapes.Delete_current();
                            cond = !shapes.Is_empty();
                        }
                    }
                    else
                    {
                        cond = shapes.Step_forward();
                    }
                }
            }
            UpdateTB();
        }