private void InitializeBrush(StaticTileBrush brush) { int tilesW = brush.TilesWide + 12; int tilesH = brush.TilesHigh + 12; _layerControl.ReferenceWidth = tilesW * brush.TileWidth + 1; _layerControl.ReferenceHeight = tilesH * brush.TileHeight + 1; _layer = new MultiTileGridLayer("Default", brush.TileWidth, brush.TileHeight, tilesW, tilesH); foreach (LocatedTile tile in brush.Tiles) { if (tile.Tile != null) { _layer.AddTile(tile.X, tile.Y, tile.Tile); } } _rootLayer.Layers.Clear(); _rootLayer.Layers.Add(new TileGridLayerPresenter(_layerContext, _layer)); _rootLayer.Layers.Add(new GridLayerPresenter() { GridSpacingX = brush.TileWidth, GridSpacingY = brush.TileHeight, }); _nameField.Text = brush.Name; _brush = brush; SelectCurrentTileSize(); }
public StaticBrushForm(StaticTileBrush brush) { InitializeForm(); InitializeBrush(brush); _tileSizeList.SelectedIndexChanged += HandleTileSizeChanged; _tileSizeList.Enabled = false; _validateController.Validate(); }
private void RemoveTileFromBrush(StaticTileBrush brush, Tile tile) { if (brush != null) { List <LocatedTile> removeQueue = new List <LocatedTile>(); foreach (LocatedTile brushTile in brush.Tiles) { if (brushTile.Tile == tile) { removeQueue.Add(brushTile); } } foreach (LocatedTile brushTile in removeQueue) { brush.RemoveTile(brushTile.Location, brushTile.Tile); } } }
private void CommandCloneBrush() { if (CommandCanCloneBrush()) { string name = FindCloneBrushName(SelectedBrush.Name); Guid newBrushId = Guid.Empty; if (SelectedBrush is DynamicTileBrush) { DynamicTileBrush oldBrush = SelectedBrush as DynamicTileBrush; DynamicTileBrush newBrush = new DynamicTileBrush(name, oldBrush.TileWidth, oldBrush.TileHeight, oldBrush.BrushClass); for (int i = 0; i < oldBrush.BrushClass.SlotCount; i++) { newBrush.SetTile(i, oldBrush.GetTile(i)); } TileBrushManager.DefaultDynamicBrushCollection.Brushes.Add(newBrush); newBrushId = newBrush.Uid; } else if (SelectedBrush is StaticTileBrush) { StaticTileBrush oldBrush = SelectedBrush as StaticTileBrush; StaticTileBrush newBrush = new StaticTileBrush(name, oldBrush.TileWidth, oldBrush.TileHeight); foreach (LocatedTile tile in oldBrush.Tiles) { newBrush.AddTile(tile.Location, tile.Tile); } newBrush.Normalize(); TileBrushManager.DefaultStaticBrushCollection.Brushes.Add(newBrush); newBrushId = newBrush.Uid; } else { return; } OnSyncTileBrushCollection(EventArgs.Empty); SelectBrush(newBrushId); OnTileBrushSelected(EventArgs.Empty); } }
private void EndDrag(PointerEventInfo info, ILevelGeometry viewport) { Rectangle selection = ClampSelection(_band.Selection); StaticTileBrush anonBrush = new StaticTileBrush("User Selected", Layer.TileWidth, Layer.TileHeight); foreach (LocatedTile tile in Layer.TilesAt(_band.Selection)) { anonBrush.AddTile(new TileCoord(tile.X - _band.Selection.Left, tile.Y - _band.Selection.Top), tile.Tile); } anonBrush.Normalize(); _activeBrush = anonBrush; _annots.Remove(_selectionAnnot); _selectionAnnot = null; //EndAutoScroll(info, viewport); }