Exemplo n.º 1
0
        public static LibraryX.StaticTileBrushX ToXProxy(StaticTileBrush brush)
        {
            if (brush == null)
            {
                return(null);
            }

            List <CommonX.TileStackX> stacks = new List <CommonX.TileStackX>();

            foreach (var kv in brush._tiles)
            {
                List <string> tileIds = new List <string>();
                foreach (Tile tile in kv.Value)
                {
                    tileIds.Add(tile.Uid.ToString());
                }

                stacks.Add(new CommonX.TileStackX()
                {
                    At    = kv.Key.X + "," + kv.Key.Y,
                    Items = String.Join(",", tileIds.ToArray()),
                });
            }

            return(new LibraryX.StaticTileBrushX()
            {
                Uid = brush.Uid,
                Name = brush.Name,
                TileWidth = brush.TileWidth,
                TileHeight = brush.TileHeight,
                Tiles = stacks,
            });
        }
Exemplo n.º 2
0
        public StaticBrushForm(StaticTileBrush brush)
        {
            InitializeForm();

            InitializeBrush(brush);

            _tileSizeList.SelectedIndexChanged += HandleTileSizeChanged;

            _tileSizeList.Enabled = false;

            _validateController.Validate();
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        public static LibraryX.StaticTileBrushX ToXProxy(StaticTileBrush brush)
        {
            if (brush == null)
                return null;

            List<CommonX.TileStackX> stacks = new List<CommonX.TileStackX>();
            foreach (var kv in brush._tiles) {
                List<string> tileIds = new List<string>();
                foreach (Tile tile in kv.Value)
                    tileIds.Add(tile.Uid.ToString());

                stacks.Add(new CommonX.TileStackX() {
                    At = kv.Key.X + "," + kv.Key.Y,
                    Items = String.Join(",", tileIds.ToArray()),
                });
            }

            return new LibraryX.StaticTileBrushX() {
                Uid = brush.Uid,
                Name = brush.Name,
                TileWidth = brush.TileWidth,
                TileHeight = brush.TileHeight,
                Tiles = stacks,
            };
        }
Exemplo n.º 6
0
        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);
        }
        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);
            }
        }