/// <summary> /// Dessine la selection du tileset si l'état du document est par défaut, sinon dessine l'effet de l'état courant du document /// </summary> /// <param name="state">L'état de dessin</param> /// <param name="e">Les données de dessin</param> private void DrawSelection(bool state, PaintEventArgs e) { if (state) { GameVector2 location = this.GetTilePosition(this.mouseLocation.X + this.mapOrigin.X, this.mouseLocation.Y + this.mapOrigin.Y); if (this.State == GameEditorState.Default) { if (this.texture?.BitmapSelection != null) { ImageAttributes attributes = new ImageAttributes(); attributes.SetOpacity(0.5f); /*************** Affichage uniquement à l'interieur de la carte *****************/ /*int limitX = this.texture.BitmapSelection.Width / GlobalData.TileSize.Width; int limitY = this.texture.BitmapSelection.Height / GlobalData.TileSize.Height; for (int x = 0; x < limitX; x++) { for (int y = 0; y < limitY; y++) { if (location.X + x >= 0 && location.X + x < GlobalData.MapSize.Width && location.Y + y >= 0 && location.Y + y < GlobalData.MapSize.Height) { e.Graphics.DrawImage(this.texture.BitmapSelection, new Rectangle( (location.X + x) * GlobalData.TileSize.Width - this.mapOrigin.X, (location.Y + y) * GlobalData.TileSize.Height - this.mapOrigin.Y, GlobalData.TileSize.Width, GlobalData.TileSize.Height), x * GlobalData.TileSize.Width, y * GlobalData.TileSize.Height, GlobalData.TileSize.Width, GlobalData.TileSize.Height, GraphicsUnit.Pixel, attributes); } } }*/ /*************** Affichage possible à l'exterieur de la carte *****************/ e.Graphics.DrawImage(this.texture.BitmapSelection, new Rectangle( location.X * GlobalData.TileSize.Width - this.mapOrigin.X, location.Y * GlobalData.TileSize.Height - this.mapOrigin.Y, this.texture.BitmapSelection.Width, this.texture.BitmapSelection.Height), 0, 0, this.texture.BitmapSelection.Width, this.texture.BitmapSelection.Height, GraphicsUnit.Pixel, attributes); } } else if (this.State == GameEditorState.Erase && GameMap.InBounds(location)) { e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(100, 255, 45, 45)), location.X * GlobalData.TileSize.Width - this.mapOrigin.X, location.Y * GlobalData.TileSize.Height - this.mapOrigin.Y, GlobalData.TileSize.Width, GlobalData.TileSize.Height); } } }