/// <summary> /// Draws the Map in MainView. /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (MapBase != null) { _graphics = e.Graphics; _graphics.InterpolationMode = InterpolationLocal; _graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; if (_spriteShadeEnabled) { _spriteAttributes.SetGamma(SpriteShadeLocal, ColorAdjustType.Bitmap); } // Image Processing using C# - https://www.codeproject.com/Articles/33838/Image-Processing-using-C // ColorMatrix Guide - https://docs.rainmeter.net/tips/colormatrix-guide/ ControlPaint.DrawBorder3D(_graphics, ClientRectangle, Border3DStyle.Etched); var dragRect = new Rectangle(); if (FirstClick) { var start = GetAbsoluteDragStart(); var end = GetAbsoluteDragEnd(); dragRect = new Rectangle( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1); } for (int lev = MapBase.MapSize.Levs - 1; lev >= MapBase.Level && lev != -1; --lev) { if (_showGrid && lev == MapBase.Level) { DrawGrid(); } for (int row = 0, startY = Origin.Y + (HalfHeight * lev * 3), startX = Origin.X; row != MapBase.MapSize.Rows; ++row, startY += HalfHeight, startX -= HalfWidth) { for (int col = 0, x = startX, y = startY; col != MapBase.MapSize.Cols; ++col, x += HalfWidth, y += HalfHeight) { bool isClicked = FirstClick && //&& Cuboid != null ((col == DragStart.X && row == DragStart.Y) || (col == DragEnd.X && row == DragEnd.Y)); if (isClicked) { Cuboid.DrawCuboid( _graphics, x, y, HalfWidth, HalfHeight, false, lev == MapBase.Level); } if (lev == MapBase.Level || !MapBase[row, col, lev].Occulted) { DrawTile( (XCMapTile)MapBase[row, col, lev], x, y, _graySelection && FirstClick && lev == MapBase.Level && dragRect.Contains(col, row)); } if (isClicked) { Cuboid.DrawCuboid( _graphics, x, y, HalfWidth, HalfHeight, true, lev == MapBase.Level); } else if (Focused && !_suppressTargeter && ClientRectangle.Contains(PointToClient(Cursor.Position)) && col == _colOver && row == _rowOver && lev == MapBase.Level) { Cuboid.DrawTargeter( _graphics, x, y, HalfWidth, HalfHeight); } } } } // if (_drawSelectionBox) // always false. // if (FirstClick && !_graySelection) if (dragRect.Width > 2 || dragRect.Height > 2 || (dragRect.Width > 1 && dragRect.Height > 1)) { DrawSelectionBorder(dragRect); } } }