Ejemplo n.º 1
0
        // image
        private void pictureBoxTileset_Paint(object sender, PaintEventArgs e)
        {
            if (tilesetImage == null)
            {
                return;
            }
            e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
            Rectangle rdst = new Rectangle(0, 0, 256, height);

            if (buttonToggleBG.Checked)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(paletteSet.Palette[16])), rdst);
            }
            e.Graphics.DrawImage(tilesetImage, rdst, 0, 0, 256, height, GraphicsUnit.Pixel);
            if (moving && selection != null)
            {
                Rectangle rsrc = new Rectangle(0, 0, overlay.SelectTS.Width, overlay.SelectTS.Height);
                rdst = new Rectangle(
                    overlay.SelectTS.X * zoom, overlay.SelectTS.Y * zoom,
                    rsrc.Width * zoom, rsrc.Height * zoom);
                e.Graphics.DrawImage(new Bitmap(selection), rdst, rsrc, GraphicsUnit.Pixel);
                Do.DrawString(e.Graphics, new Point(rdst.X, rdst.Y + rdst.Height),
                              "click/drag", Color.White, Color.Black, new Font("Tahoma", 6.75F, FontStyle.Bold));
            }
            float[][] matrixItems =
            {
                new float[] { 1, 0, 0,     0, 0 },
                new float[] { 0, 1, 0,     0, 0 },
                new float[] { 0, 0, 1,     0, 0 },
                new float[] { 0, 0, 0, 0.50F, 0 },
                new float[] { 0, 0, 0,     0, 1 }
            };
            ColorMatrix     cm = new ColorMatrix(matrixItems);
            ImageAttributes ia = new ImageAttributes();

            ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            if (priority1 != null && buttonToggleP1.Checked)
            {
                e.Graphics.DrawImage(priority1, rdst, 0, 0, 256, height, GraphicsUnit.Pixel, ia);
            }
            if (mouseEnter)
            {
                DrawHoverBox(e.Graphics);
            }
            if (Rails)
            {
                overlay.DrawRailProperties(null, 16, 16, e.Graphics, 1);
            }
            if (buttonToggleCartGrid.Checked)
            {
                overlay.DrawTileGrid(e.Graphics, Color.Gray, pictureBox.Size, new Size(16, 16), 1, true);
            }
            if (overlay.SelectTS != null)
            {
                overlay.SelectTS.DrawSelectionBox(e.Graphics, 1);
            }
        }
Ejemplo n.º 2
0
        // Frames
        private void frame_Paint(object sender, PaintEventArgs e)
        {
            var frame = sender as PictureBox;

            // Cancel painting if tag out of bounds
            if ((int)frame.Tag >= sequenceImages.Count)
            {
                return;
            }

            // Fill background with BG color
            if (moldsForm.ShowBG)
            {
                e.Graphics.Clear(Color.FromArgb(animation.PaletteSet.Palette[0]));
            }

            // Draw frame image
            Rectangle dst = new Rectangle(0, 0, frame.Width, frame.Height);
            Rectangle src = new Rectangle(0, 0, width, height);

            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bicubic;
            e.Graphics.DrawImage(sequenceImages[(int)frame.Tag], dst, src, GraphicsUnit.Pixel);

            // Draw invalid alert
            if (sequence.Frames[(int)frame.Tag].Mold >= animation.Molds.Count)
            {
                Font  font  = new Font("Tahoma", 10F, FontStyle.Bold);
                SizeF size  = e.Graphics.MeasureString("(INVALID MOLD INDEX)", font, new PointF(0, 0), StringFormat.GenericDefault);
                Point point = new Point((frame.Width - (int)size.Width) / 2, (frame.Height - (int)size.Height) / 2);
                Do.DrawString(e.Graphics, point, "(INVALID MOLD INDEX)", Color.Black, Color.Red, font);
            }

            // Draw frame border
            if (index == (int)frame.Tag)
            {
                e.Graphics.DrawRectangle(
                    new Pen(new SolidBrush(Color.Red)),
                    new Rectangle(0, 0, frame.Width - 1, frame.Height - 1));
                if (!moldsForm.Picture.Focused)
                {
                    frame.Focus();
                }
            }
            else
            {
                e.Graphics.DrawRectangle(
                    new Pen(new SolidBrush(SystemColors.ControlDark)),
                    new Rectangle(0, 0, frame.Width - 1, frame.Height - 1));
            }
        }
Ejemplo n.º 3
0
        // Picture
        private void picture_Paint(object sender, PaintEventArgs e)
        {
            if (battlefieldImage == null)
            {
                return;
            }
            Rectangle rdst = new Rectangle(0, 0, 512, 512);

            if (toggleBG.Checked)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(paletteSets[palette].Palette[0])), rdst);
            }
            e.Graphics.DrawImage(battlefieldImage, rdst, 0, 0, 512, 512, GraphicsUnit.Pixel);
            if (moving && selection != null)
            {
                Rectangle rsrc = new Rectangle(0, 0, overlay.SelectTS.Width, overlay.SelectTS.Height);
                rdst = new Rectangle(
                    overlay.SelectTS.X * zoom, overlay.SelectTS.Y * zoom,
                    rsrc.Width * zoom, rsrc.Height * zoom);
                e.Graphics.DrawImage(new Bitmap(selection), rdst, rsrc, GraphicsUnit.Pixel);
                Do.DrawString(e.Graphics, new Point(rdst.X, rdst.Y + rdst.Height),
                              "click/drag", Color.White, Color.Black, new Font("Tahoma", 6.75F, FontStyle.Bold));
            }
            float[][] matrixItems =
            {
                new float[] { 1, 0, 0,     0, 0 },
                new float[] { 0, 1, 0,     0, 0 },
                new float[] { 0, 0, 1,     0, 0 },
                new float[] { 0, 0, 0, 0.50F, 0 },
                new float[] { 0, 0, 0,     0, 1 }
            };
            ColorMatrix     cm = new ColorMatrix(matrixItems);
            ImageAttributes ia = new ImageAttributes();

            ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            if (mouseEnter)
            {
                Point location = new Point(mousePosition.X / 16 * 16 * zoom, mousePosition.Y / 16 * 16 * zoom);
                overlay.DrawHoverBox(e.Graphics, location, new Size(16 * zoom, 16 * zoom), zoom, true);
            }
            if (toggleTileGrid.Checked)
            {
                overlay.DrawTileGrid(e.Graphics, Color.Gray, picture.Size, new Size(16, 16), 1, true);
            }
            if (overlay.SelectTS != null)
            {
                overlay.SelectTS.DrawSelectionBox(e.Graphics, 1);
            }
        }
Ejemplo n.º 4
0
 // Picture : Mold
 private void pictureBoxMold_Paint(object sender, PaintEventArgs e)
 {
     e.Graphics.PixelOffsetMode   = PixelOffsetMode.Half;
     e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
     if (toggleBG.Checked)
     {
         e.Graphics.FillRectangle(new SolidBrush(bgcolor), new Rectangle(new Point(0, 0), pictureBoxMold.Size));
     }
     if (tilemapImage != null && e.ClipRectangle.Size != new Size(16, 16))
     {
         Rectangle src = new Rectangle(0, 0, tilemapImage.Width, tilemapImage.Height);
         Rectangle dst = new Rectangle(0, 0, tilemapImage.Width * zoom, tilemapImage.Height * zoom);
         e.Graphics.DrawImage(tilemapImage, dst, src, GraphicsUnit.Pixel);
     }
     if (moving && selection != null && overlay.Select != null)
     {
         Rectangle src = new Rectangle(0, 0, overlay.Select.Width, overlay.Select.Height);
         Rectangle dst = new Rectangle(
             overlay.Select.X * zoom, overlay.Select.Y * zoom,
             src.Width * zoom, src.Height * zoom);
         e.Graphics.DrawImage(new Bitmap(selection), dst, src, GraphicsUnit.Pixel);
         Do.DrawString(e.Graphics, new Point(dst.X, dst.Y + dst.Height),
                       "click/drag", Color.White, Color.Black, new Font("Tahoma", 6.75F, FontStyle.Bold));
     }
     if (mouseEnter && e.ClipRectangle.Size != new Size(16, 16))
     {
         Point location = new Point(mousePosition.X / 16 * 16 * zoom, mousePosition.Y / 16 * 16 * zoom);
         overlay.DrawHoverBox(e.Graphics, location, new Size(16 * zoom, 16 * zoom), zoom, true);
     }
     if (toggleTileGrid.Checked)
     {
         overlay.DrawTileGrid(e.Graphics, Color.Gray, pictureBoxMold.Size, new Size(16, 16), zoom, true);
     }
     if (select.Checked && overlay.Select != null)
     {
         e.Graphics.PixelOffsetMode = PixelOffsetMode.Default;
         overlay.Select.DrawSelectionBox(e.Graphics, zoom);
     }
 }
Ejemplo n.º 5
0
        // Picture
        private void picture_Paint(object sender, PaintEventArgs e)
        {
            if (tilesetImage == null)
            {
                return;
            }
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            Rectangle rdst = new Rectangle(0, 0, 256, 256);

            if (toggleLocations.Checked || toggleBanner.Checked)
            {
                double third = 100.0 / 3.0;
                rdst.Y     -= 8;
                rdst.Width  = (int)Do.PercentIncrease(third, 256.0);
                rdst.Height = (int)Do.PercentIncrease(third, 256.0);
                double x = worldMap.X;
                double y = worldMap.Y;
                x  = (int)Do.PercentIncrease(third, x);
                y  = (int)Do.PercentIncrease(third, y);
                x -= Do.PercentDecrease(third, 256) / 4.0;
                y -= Do.PercentDecrease(third, 256) / 4.0;
                rdst.Offset((int)x, (int)y);
            }
            if (toggleBG.Checked)
            {
                e.Graphics.Clear(Color.FromArgb(PaletteSet.Palette[0]));
            }
            if (tilesetImage != null)
            {
                e.Graphics.DrawImage(tilesetImage, rdst, 0, 0, 256, 256, GraphicsUnit.Pixel);
            }
            if (toggleLocations.Checked)
            {
                foreach (Location location in worldMapLocations[Index])
                {
                    if (locationImage == null)
                    {
                        locationImage = Do.PixelsToImage(GetLocationPixels(false), 16, 8);
                    }
                    if (locationImage_S == null)
                    {
                        locationImage_S = Do.PixelsToImage(GetLocationPixels(true), 16, 8);
                    }
                    if (marioImage == null)
                    {
                        marioImage = Do.PixelsToImage(GetMarioPixels(), 16, 32);
                    }
                    if (location.Index == locationsForm.Index)
                    {
                        e.Graphics.DrawImage(locationImage_S, location.X, location.Y);
                    }
                    else
                    {
                        e.Graphics.DrawImage(locationImage, location.X, location.Y);
                    }
                }
            }
            if (toggleBanner.Checked)
            {
                if (logoImage != null)
                {
                    e.Graphics.DrawImage(logoImage, 0, -8);
                }
                if (locationText != null)
                {
                    e.Graphics.DrawImage(locationText, 128 - (locationText.Width / 2), 182);
                }
            }
            if (moving && selection != null)
            {
                Rectangle rsrc = new Rectangle(0, 0, overlay.SelectTS.Width, overlay.SelectTS.Height);
                rdst = new Rectangle(
                    overlay.SelectTS.X * zoom, overlay.SelectTS.Y * zoom,
                    rsrc.Width * zoom, rsrc.Height * zoom);
                e.Graphics.DrawImage(new Bitmap(selection), rdst, rsrc, GraphicsUnit.Pixel);
                Do.DrawString(e.Graphics, new Point(rdst.X, rdst.Y + rdst.Height),
                              "click/drag", Color.White, Color.Black, new Font("Tahoma", 6.75F, FontStyle.Bold));
            }
            float[][] matrixItems =
            {
                new float[] { 1, 0, 0,     0, 0 },
                new float[] { 0, 1, 0,     0, 0 },
                new float[] { 0, 0, 1,     0, 0 },
                new float[] { 0, 0, 0, 0.50F, 0 },
                new float[] { 0, 0, 0,     0, 1 }
            };
            ColorMatrix     cm = new ColorMatrix(matrixItems);
            ImageAttributes ia = new ImageAttributes();

            ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            if (mouseEnter && !toggleLocations.Checked && !toggleBanner.Checked)
            {
                Point location = new Point(mousePosition.X / 16 * 16 * zoom, mousePosition.Y / 16 * 16 * zoom);
                overlay.DrawHoverBox(e.Graphics, location, new Size(16 * zoom, 16 * zoom), zoom, true);
            }
            if (toggleTileGrid.Checked)
            {
                overlay.DrawTileGrid(e.Graphics, Color.Gray, picture.Size, new Size(16, 16), 1, true);
            }
            if (overlay.SelectTS != null)
            {
                overlay.SelectTS.DrawSelectionBox(e.Graphics, 1);
            }
        }
Ejemplo n.º 6
0
        // Picture
        private void pictureBoxScreens_Paint(object sender, PaintEventArgs e)
        {
            if (L1Indexes.Count == 0)
            {
                return;
            }
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bicubic;
            Rectangle dst;
            Rectangle src;

            // Draw screens
            for (int i = 0; i < L1Indexes.Count; i++)
            {
                dst = new Rectangle(i * 256, 0, 256, 256);
                if (L1Indexes[i] < L1Indexes.Count)
                {
                    src = new Rectangle(0, 0, 256, 256);
                    if (screenIndex < screenImages.Count)
                    {
                        if (Index == 3 && i % 2 == 0)
                        {
                            if (ScreenBGImage == null)
                            {
                                int[] BGPixels = Do.TilesetToPixels(BGTileset.Tileset_tiles, 32, 16, 0, false);
                                ScreenBGImage = Do.PixelsToImage(BGPixels, 512, 256);
                            }
                            dst.Width = 512;
                            src.Width = 512;
                            e.Graphics.DrawImage(ScreenBGImage, dst, src, GraphicsUnit.Pixel);
                            dst.Width = 256;
                            src.Width = 256;
                        }
                        e.Graphics.DrawImage(screenImages[i], dst, src, GraphicsUnit.Pixel);
                    }
                }
                else
                {
                    Font  font  = new Font("Tahoma", 10F, FontStyle.Bold);
                    SizeF size  = e.Graphics.MeasureString("(INVALID SCREEN INDEX)", font, new PointF(0, 0), StringFormat.GenericDefault);
                    Point point = new Point(((256 - (int)size.Width) / 2) + (i * 256), (256 - (int)size.Height) / 2);
                    Do.DrawString(e.Graphics, point, "(INVALID SCREEN INDEX)", Color.Black, Color.Red, font);
                }
                if (this.screenIndex == i)
                {
                    Pen pen = new Pen(new SolidBrush(Color.Gray), 2);
                    pen.DashStyle = DashStyle.Dot;
                    e.Graphics.DrawRectangle(pen, new Rectangle(i * 256, 0, 256 - 1, 256 - 1));
                }
            }
            // Draw objects
            for (int i = 0; toggleObjects.Checked && i < MinecartObjects.Count; i++)
            {
                MinecartObject obj = MinecartObjects[i];
                Pen            pen;
                if (objectIndex == i)
                {
                    pen = new Pen(Color.Red, 2);
                }
                else
                {
                    pen = new Pen(Color.Red, 1);
                }
                e.Graphics.DrawRectangle(pen, new Rectangle(obj.X - 1, obj.Y - 1, obj.Count * 32 - 16 + 2, 16 + 2));
                Bitmap image = obj.Type == 1 ? MinecartData.Coin : MinecartData.Mushroom;
                for (int x = 0; x < obj.Count; x++)
                {
                    e.Graphics.DrawImage(image, x * 32 + obj.X, obj.Y, 16, 16);
                }
            }
        }