Example #1
0
        void DrawFigure(FigureName name)
        {
            gr = panel1.CreateGraphics();

            switch (name)
            {
            case FigureName.Rectangle:

                MyFigure rect;
                Calculate(p1x, p1y, p2x, p2y);
                rect = new MyRectangle(p1x, p1y, width, height);
                figs.Add(rect);
                rect.Draw(gr);

                break;

            case FigureName.Circle:

                double   r    = Math.Sqrt(Math.Pow(p2x - p1x, 2) + Math.Pow(p2y - p1y, 2));
                MyFigure circ = new MyCircle(p1x, p1y, r);
                figs.Add(circ);
                circ.Draw(gr);

                break;

            case FigureName.Vagon:

                MyFigure vagon;
                Calculate(p1x, p1y, p2x, p2y);
                vagon = new MyVagon(p1x, p1y, width, height);
                figs.Add(vagon);
                vagon.Draw(gr);

                break;

            case FigureName.Train:

                MyTrain train;
                Calculate(p1x, p1y, p2x, p2y);
                train = new MyTrain(p1x, p1y, width, height, (int)vagcount.Value);
                figs.Add(train);
                train.Draw(gr);

                break;
            }
        }