Example #1
0
        public MyTrain(int x, int y, int width, int height, int count)
        {
            for (int i = 0; i < count; i++)
            {
                id = rnd.Next(0, 3);
                MyVagon vagon = new MyVagon(x + (i * width / count), y, width / count - 10, height);

                switch (id)
                {
                case 1:

                    vagon = new MyVagonCoal(x + (i * width / count), y, width / count - 10, height);

                    break;

                case 2:

                    vagon = new MyVagonSand(x + (i * width / count), y, width / count - 10, height);

                    break;
                }

                vagons.Add(vagon);
            }
        }
Example #2
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;
            }
        }