MultiEditor.MultiEditorComponentList.GetImage C# (CSharp) Method

GetImage() public method

Gets Bitmap of Multi and sets HoverTile
public GetImage ( Graphics gfx, int xoff, int yoff, int maxheight, Point mouseLoc, bool drawFloor, bool forcerefresh ) : void
gfx System.Drawing.Graphics
xoff int
yoff int
maxheight int
mouseLoc Point
drawFloor bool
forcerefresh bool
return void
        public void GetImage(Graphics gfx, int xoff, int yoff, int maxheight, Point mouseLoc, bool drawFloor, bool forcerefresh)
        {
            if (Width == 0 || Height == 0)
                return;

            if (Modified)
                RecalcMinMax();

            xMin = xMinOrg;
            xMax = xMaxOrg;
            yMin = yMinOrg;
            yMax = yMaxOrg;

            if (drawFloor)
            {
                int floorzmod = -Parent.DrawFloorZ << 2 - 44;
                if (yMin > floorzmod)
                    yMin = floorzmod;
                floorzmod = (Width + Height) * 22 - Parent.DrawFloorZ << 2;
                if (yMaxOrg < floorzmod)
                    yMax = floorzmod;
            }
            Parent.HoverTile = GetSelected(mouseLoc, maxheight, drawFloor);

            Rectangle clipBounds = Rectangle.Round(gfx.ClipBounds);
            for (int i = 0; i < Tiles.Count; ++i)
            {
                MultiTile tile = Tiles[i];
                if (!tile.isVirtualFloor)
                    if (tile.Z > maxheight)
                        continue;
                Bitmap bmp = tile.GetBitmap();
                if (bmp == null)
                    continue;
                drawdestRectangle.X = tile.Xmod;
                drawdestRectangle.Y = tile.Ymod;
                drawdestRectangle.X -= xMin + xoff;
                drawdestRectangle.Y -= yMin + yoff;
                drawdestRectangle.Width = bmp.Width;
                drawdestRectangle.Height = bmp.Height;

                if (!clipBounds.IntersectsWith(drawdestRectangle))
                    continue;
                if (tile.isVirtualFloor)
                {
                    if (drawFloor)
                        gfx.DrawImageUnscaled(bmp, drawdestRectangle);
                }
                else
                {
                    if ((Parent.HoverTile != null) && (Parent.HoverTile == tile))
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.HoverColor);
                    else if ((Parent.SelectedTile != null) && (Parent.SelectedTile == tile))
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.SelectedColor);
                    else if (tile.Transparent)
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.TransColor);
                    else if ((Parent.ShowWalkables) && (tile.Walkable))
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.StandableColor);
                    else if ((Parent.ShowDoubleSurface) && (tile.DoubleSurface))
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.StandableColor);
                    else
                        gfx.DrawImageUnscaled(bmp, drawdestRectangle);
                }
            }
        }