private void TilesetView_MouseMove(object sender, MouseEventArgs e) { Size tileSize = this.TilesetView.DisplayedTileSize; Point tilePos = this.TilesetView.GetTileIndexLocation(this.TilesetView.HoveredTileIndex); Point posOnTile = new Point(e.X - tilePos.X, e.Y - tilePos.Y); Size centerSize = new Size( tileSize.Width - TilemapsResCache.TilesetCollisionVertical.Width * 2 - 2, tileSize.Height - TilemapsResCache.TilesetCollisionHorizontal.Height * 2 - 2); // Determine the hovered tile hotspot for user interaction TileHotSpot lastHoveredArea = this.hoveredArea; if (posOnTile.X > (tileSize.Width - centerSize.Width) / 2 && posOnTile.Y > (tileSize.Height - centerSize.Height) / 2 && posOnTile.X < (tileSize.Width + centerSize.Width) / 2 && posOnTile.Y < (tileSize.Height + centerSize.Height) / 2) { this.hoveredArea = TileHotSpot.Center; } else { float angle = MathF.Angle(tileSize.Width / 2, tileSize.Height / 2, posOnTile.X, posOnTile.Y); if (MathF.CircularDist(angle, 0.0f) < MathF.RadAngle45) { this.hoveredArea = TileHotSpot.Top; } else if (MathF.CircularDist(angle, MathF.RadAngle90) < MathF.RadAngle45) { this.hoveredArea = TileHotSpot.Right; } else if (MathF.CircularDist(angle, MathF.RadAngle180) < MathF.RadAngle45) { this.hoveredArea = TileHotSpot.Bottom; } else { this.hoveredArea = TileHotSpot.Left; } } // If the user is in the process of setting or clearing bits, perform the drawing operation if (this.isUserDrawing) { this.PerformUserDrawAction(); } if (lastHoveredArea != this.hoveredArea) { this.TilesetView.InvalidateTile(this.TilesetView.HoveredTileIndex, 0); } }
private void TilesetView_MouseMove(object sender, MouseEventArgs e) { Size tileSize = this.TilesetView.DisplayedTileSize; Point tilePos = this.TilesetView.GetTileIndexLocation(this.TilesetView.HoveredTileIndex); Point posOnTile = new Point(e.X - tilePos.X, e.Y - tilePos.Y); Size centerSize = new Size( tileSize.Width - TilemapsResCache.TilesetCollisionVertical.Width * 2 - 2, tileSize.Height - TilemapsResCache.TilesetCollisionHorizontal.Height * 2 - 2); // Determine the hovered tile hotspot for user interaction TileHotSpot lastHoveredArea = this.hoveredArea; if (posOnTile.X > (tileSize.Width - centerSize.Width) / 2 && posOnTile.Y > (tileSize.Height - centerSize.Height) / 2 && posOnTile.X < (tileSize.Width + centerSize.Width) / 2 && posOnTile.Y < (tileSize.Height + centerSize.Height) / 2) { this.hoveredArea = TileHotSpot.Center; } else { float angle = MathF.Angle(tileSize.Width / 2, tileSize.Height / 2, posOnTile.X, posOnTile.Y); if (MathF.CircularDist(angle, 0.0f ) < MathF.RadAngle45) this.hoveredArea = TileHotSpot.Top; else if (MathF.CircularDist(angle, MathF.RadAngle90 ) < MathF.RadAngle45) this.hoveredArea = TileHotSpot.Right; else if (MathF.CircularDist(angle, MathF.RadAngle180) < MathF.RadAngle45) this.hoveredArea = TileHotSpot.Bottom; else this.hoveredArea = TileHotSpot.Left; } // If the user is in the process of setting or clearing bits, perform the drawing operation if (this.isUserDrawing) this.PerformUserDrawAction(); if (lastHoveredArea != this.hoveredArea) this.TilesetView.InvalidateTile(this.TilesetView.HoveredTileIndex, 0); }