private void drawLevel(Graphics graphics, bool grid) { graphics.InterpolationMode = InterpolationMode.NearestNeighbor; if (level != null && imageList != null) { TilesFondo tilFondo = level.TileFondo; int tilWidth = 32; int tilHeight = 32; Rectangle srcRect = new Rectangle(0, 0, 16, 16); Rectangle destRect = new Rectangle(0, 0, 33, 33); for (int iFila = 0; iFila < 10; iFila++) { for (int iCol = 0; iCol < 12; iCol++) { graphics.DrawImage(this.imageList[version.CPU.ToString() + tilFondo.ToString()], destRect, srcRect, GraphicsUnit.Pixel); destRect.X += tilWidth; } destRect.X = 0; destRect.Y += tilHeight; } drawPlatforms(graphics, tilWidth, tilHeight, ref srcRect, ref destRect); drawCoins(graphics, tilWidth, tilHeight, ref srcRect, ref destRect); drawEnemies(graphics, tilWidth, tilHeight, ref srcRect, ref destRect); if (grid && this.showGrid) { drawGrid(graphics, tilWidth, tilHeight); } } }
void cboTileFondo_DrawItem(object sender, DrawItemEventArgs e) { ComboBox cbo = sender as ComboBox; e.DrawBackground(); if (!this.DesignMode) { if (e.Index != -1) { TilesFondo tile = (TilesFondo)cbo.Items[e.Index]; if (this.imageList != null) { e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor; e.Graphics.DrawImage(this.imageList[this.version.CPU.ToString() + tile.ToString()], e.Bounds.X + 2, e.Bounds.Y + 2, 32, 32); e.Graphics.DrawRectangle(Pens.Black, e.Bounds.X + 1, e.Bounds.Y + 1, 32, 32); } else { SolidBrush textBr; if ((e.State & (DrawItemState.Selected | DrawItemState.HotLight)) != 0) { textBr = new SolidBrush(Color.FromKnownColor(KnownColor.HighlightText)); } else { textBr = new SolidBrush(Color.FromKnownColor(KnownColor.WindowText)); } e.Graphics.DrawString(tile.ToString(), cbo.Font, textBr, e.Bounds.X + 1, e.Bounds.Y + 1); textBr.Dispose(); } } } }