public override void updatePreview()
        {
            RailPattern rp = RailPattern.get(currentDirection, currentDirection.opposite);

            using (PreviewDrawer drawer = new PreviewDrawer(preview.Size, new Size(1, 1), 0)) {
                // draw the rail
                for (int i = -5; i < 5; i++)
                {
                    if (currentDirection.isParallelToX)
                    {
                        drawer.draw(rp, i, 0);
                    }
                    else
                    {
                        drawer.draw(rp, 0, i);
                    }
                }

                // draw the signal
                drawer.draw(rp, 0, 0);
                drawer.draw(currentType.getSprite(currentDirection), 0, 0);

                // draw the arrow
                currentDirection.drawArrow(drawer.surface,
                                           drawer.getPoint(-currentDirection.offsetX, -currentDirection.offsetY));

                preview.Image = drawer.createBitmap();
            }
        }
Exemple #2
0
        public PreviewDrawer createPreview(Size pixelSize, int height)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, size, maxHeight /*middle*/);
            int           mh     = height - 2;
            int           z      = 0;

            for (int i = bottoms.Length - 1; i >= 0; i--)
            {
                drawer.draw(bottoms[i], 0, 0, z++);
            }
            if (overlay)
            {
                z--;
                mh++;
            }
            for (int i = 0; i < mh; i++)
            {
                drawer.draw(middle, 0, 0, z++);
            }
            for (int i = tops.Length - 1; i >= 0; i--)
            {
                drawer.draw(tops[i], 0, 0, z++);
            }

            return(drawer);
        }
        public override void updatePreview()
        {
            PreviewDrawer drawer;

            // TODO: locations of the previews are uttely incorrect. fix them

            // direction N
            using (drawer = new PreviewDrawer(pictureN.ClientSize, new Size(2, 4), 0)) {
                drawer.draw(RailPattern.getSlope(Direction.NORTH, 3), 1, -1);
                drawer.draw(RailPattern.getSlope(Direction.NORTH, 2), 1, 0);
                drawer.draw(RailPattern.getSlope(Direction.NORTH, 1), 0, 2);
                drawer.draw(RailPattern.getSlope(Direction.NORTH, 0), 0, 3);
                if (pictureN.Image != null)
                {
                    pictureN.Image.Dispose();
                }
                pictureN.Image = drawer.createBitmap();
            }

            // direction S
            using (drawer = new PreviewDrawer(pictureS.ClientSize, new Size(2, 4), 0)) {
                drawer.draw(RailPattern.getSlope(Direction.SOUTH, 0), 0, 0);
                drawer.draw(RailPattern.getSlope(Direction.SOUTH, 1), 0, 1);
                drawer.draw(RailPattern.getSlope(Direction.SOUTH, 2), 1, 1);
                drawer.draw(RailPattern.getSlope(Direction.SOUTH, 3), 1, 2);
                if (pictureS.Image != null)
                {
                    pictureS.Image.Dispose();
                }
                pictureS.Image = drawer.createBitmap();
            }

            // direction E
            using (drawer = new PreviewDrawer(pictureE.ClientSize, new Size(4, 2), 0)) {
                drawer.draw(RailPattern.getSlope(Direction.EAST, 3), 3, 0);
                drawer.draw(RailPattern.getSlope(Direction.EAST, 2), 2, 0);
                drawer.draw(RailPattern.getSlope(Direction.EAST, 1), 0, 1);
                drawer.draw(RailPattern.getSlope(Direction.EAST, 0), -1, 1);
                if (pictureE.Image != null)
                {
                    pictureE.Image.Dispose();
                }
                pictureE.Image = drawer.createBitmap();
            }

            // direction W
            using (drawer = new PreviewDrawer(pictureW.ClientSize, new Size(4, 2), 0)) {
                drawer.draw(RailPattern.getSlope(Direction.WEST, 3), 1, 0);
                drawer.draw(RailPattern.getSlope(Direction.WEST, 2), 2, 0);
                drawer.draw(RailPattern.getSlope(Direction.WEST, 1), 2, 1);
                drawer.draw(RailPattern.getSlope(Direction.WEST, 0), 3, 1);
                if (pictureW.Image != null)
                {
                    pictureW.Image.Dispose();
                }
                pictureW.Image = drawer.createBitmap();
            }
        }
        /// <summary>
        /// Builds a nice preview of a train.
        /// </summary>
        public PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer pd = new PreviewDrawer(pixelSize, new Size(1, 3), 0);

            // build up rail like
            //
            //     /~~~~~
            //    /
            for (int x = -10; x < 0; x++)
            {
                pd.draw(RailPattern.get(Direction.WEST, Direction.EAST), x, 0);
            }
            pd.draw(RailPattern.get(Direction.WEST, Direction.SOUTHEAST), 0, 0);
            for (int x = 1; x <= 10; x++)
            {
                pd.draw(RailPattern.get(Direction.NORTHWEST, Direction.SOUTHEAST), x, x);
            }

            TrainCarContribution[] cars = create(5);
            if (cars == null)
            {
                for (int i = 6; cars == null && i < 15; i++)
                {
                    cars = create(i);
                }
                for (int i = 4; cars == null && i > 0; i--)
                {
                    cars = create(i);
                }
                if (cars == null)
                {
                    return(pd);                         // no preview
                }
            }

            int[] pos    = new int[] { -2, 0, -1, 0, 0, 0, 1, 1, 2, 2 };
            int[] angle  = new int[] { 12, 12, 13, 14, 14 };
            int[] offset = new int[] { 0, 0, 0, 0, 4, +2, 0, 0, 0, 0 };

            using (DrawContext dc = new DrawContext(pd.surface)) {
                for (int i = 4; i >= 0; i--)
                {
                    if (cars.Length <= i)
                    {
                        continue;                                       // no car
                    }
                    Point pt = pd.getPoint(pos[i * 2], pos[i * 2 + 1]);
                    cars[i].draw(pd.surface,
                                 new Point(pt.X + offset[i * 2], pt.Y + offset[i * 2 + 1] - 9), angle[i]);
                }
            }

            return(pd);
        }
        public override PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, new Size(7, 1), 1);

            drawer.draw(sprites[currentColor][Direction.WEST, PlaceSide.Fore], 3, 1);
            drawer.draw(sprites[currentColor][Direction.EAST, PlaceSide.Back], 2, 0);
            if (hilights != null)
            {
                drawer.draw(hilights[currentHighlight][Direction.WEST, PlaceSide.Fore], 3, 1);
                drawer.draw(hilights[currentHighlight][Direction.EAST, PlaceSide.Back], 2, 0);
            }
            return(drawer);
        }
Exemple #6
0
        /// <summary>
        /// Creates the preview image of the land builder.
        /// </summary>
        public override PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, new Size(3, 3), 0);

            for (int x = 0; x <= 3; x++)
            {
                drawer.draw(sprites[Direction.NORTH.index / 2], x, 0);
                drawer.draw(sprites[Direction.SOUTH.index / 2], x, 3);
            }
            for (int y = 0; y <= 3; y++)
            {
                drawer.draw(sprites[Direction.WEST.index / 2], 0, y);
                drawer.draw(sprites[Direction.EAST.index / 2], 3, y);
            }

            return(drawer);
        }
        public override PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, new Size(10, 1), 0);

            for (int x = 9; x >= 0; x--)
            {
                if (x == 5)
                {
                    drawer.draw(sprites[0, 0], x, 0);
                }
                drawer.draw(RailPattern.get(Direction.EAST, Direction.WEST), x, 0);
                if (x == 5)
                {
                    drawer.draw(sprites[0, 1], x, 0);
                }
            }
            return(drawer);
        }
Exemple #8
0
        public override PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, size, tops.Length + bottoms.Length + 1 /*middle*/);

            int z = 0;

            for (int i = bottoms.Length - 1; i >= 0; i--)
            {
                drawer.draw(bottoms[i], 0, 0, z++);
            }
            if (overlay)
            {
                drawer.draw(middle, 0, 0, z - 1);
            }
            drawer.draw(middle, 0, 0, z++);
            for (int i = tops.Length - 1; i >= 0; i--)
            {
                drawer.draw(tops[i], 0, 0, z++);
            }

            return(drawer);
        }
Exemple #9
0
        /// <summary>
        /// Creates the preview image of the land builder.
        /// </summary>
        public override PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, new Size(1, 8), 0);

            Sprite sp = getSprite(Dir.N | Dir.S);

            for (int y = -4; y <= 4; y++)
            {
                drawer.draw(sp, 0, y);
            }

            return(drawer);
        }
        /// <summary>
        /// Creates the preview image of the land builder.
        /// </summary>
        public override PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, new Size(10, 10), 0);

            for (int y = 0; y < 10; y++)
            {
                for (int x = 0; x < 10; x++)
                {
                    drawer.draw(getLand().sprite, x, y);
                }
            }

            return(drawer);
        }
Exemple #11
0
        /// <summary>
        /// Creates the preview image of the land builder.
        /// </summary>
        public override PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, new Size(3, 3), 0);

            for (int y = 0; y < 3; y++)
            {
                for (int x = 2; x >= 0; x--)
                {
                    drawer.draw(sprites[getSpriteIndex(x, y, 0, 2, 0, 2)], x, y);
                }
            }

            return(drawer);
        }
        /// <summary>
        /// Creates the preview image of the land builder.
        /// </summary>
        public override PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, new Size(3, 3), 0);

            for (int y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    drawer.draw(sprites[getIndex(0, x, 2), getIndex(0, y, 2)], x, y);
                }
            }

            return(drawer);
        }
Exemple #13
0
        public override PreviewDrawer createPreview(Size pixelSize)
        {
            PreviewDrawer drawer = new PreviewDrawer(pixelSize, new Size(10, 1), 0);

            for (int x = 9; x >= 0; x--)
            {
                if (x == 5)
                {
                    drawer.draw(sprites[currentColor, 0], x, 0);
                }
                //drawer.draw( RoadPattern.get((byte)Direction.EAST), x,0 );
            }
            return(drawer);
        }
 public override void updatePreview()
 {
     using (PreviewDrawer drawer = new PreviewDrawer(picture.Size, new Size(1, 10), 0))
     {
         for (int i = 0; i < 10; i++)
         {
             drawer.draw(RailPattern.get(Direction.NORTH, Direction.SOUTH), 0, i);
         }
         if (picture.Image != null)
         {
             picture.Image.Dispose();
         }
         picture.Image = drawer.createBitmap();
     }
 }
 public override void updatePreview()
 {
     using (PreviewDrawer drawer = new PreviewDrawer(preview.Size, new Size(3, 3), 0))
     {
         for (int x = 0; x < 3; x++)
         {
             for (int y = 0; y < 3; y++)
             {
                 drawer.draw(LandPropertyVoxel.sprite, x, y);
             }
         }
         if (preview.Image != null)
         {
             preview.Image.Dispose();
         }
         preview.Image = drawer.createBitmap();
     }
 }
Exemple #16
0
        /// <summary>
        /// Called when a selection of the structure has changed.
        /// </summary>
        protected virtual void updatePreview(DummyCarContribution builder)
        {
            //DummyCarContribution builder = (DummyCarContribution)typeBox.SelectedItem;
            using (PreviewDrawer drawer = new PreviewDrawer(preview.Size, new Size(10, 1), 0)) {
                drawer.draw(builder.getSprites(), 5, 0);

                if (previewBitmap != null)
                {
                    previewBitmap.Dispose();
                }
                preview.Image = previewBitmap = drawer.createBitmap();
            }
            if (isPlacing)
            {
                currentController = builder.createBuilder(this.siteImpl);
            }
            else
            {
                currentController = builder.createRemover(this.siteImpl);
            }
        }