상속: TileBrush
예제 #1
0
        public static LibraryX.DynamicTileBrushX ToXProxy(DynamicTileBrush brush)
        {
            if (brush == null)
            {
                return(null);
            }

            List <LibraryX.BrushEntryX> brushEntries = new List <LibraryX.BrushEntryX>();

            for (int i = 0; i < brush.BrushClass.SlotCount; i++)
            {
                Tile tile = brush.GetTile(i);
                if (tile != null)
                {
                    brushEntries.Add(new LibraryX.BrushEntryX()
                    {
                        Slot   = i,
                        TileId = tile.Uid,
                    });
                }
            }

            return(new LibraryX.DynamicTileBrushX()
            {
                Uid = brush.Uid,
                Name = brush.Name,
                Type = brush.BrushClass.ClassName,
                TileWidth = brush.TileWidth,
                TileHeight = brush.TileHeight,
                Entries = brushEntries,
            });
        }
예제 #2
0
        public static DynamicTileBrush FromXProxy(LibraryX.DynamicTileBrushX proxy, TilePoolManager manager, DynamicTileBrushClassRegistry registry)
        {
            if (proxy == null)
                return null;

            DynamicTileBrush brush = new DynamicTileBrush(proxy, manager, registry);
            if (brush._brushClass == null)
                return null;

            return brush;
        }
예제 #3
0
        public DynamicBrushForm(DynamicTileBrush brush)
        {
            InitializeForm();

            InitializeBrush(brush);

            _prototypeList.SelectedIndexChanged += HandlePrototypeChanged;
            _tileSizeList.SelectedIndexChanged += HandleTileSizeChanged;

            _prototypeList.Enabled = false;
            _tileSizeList.Enabled = false;

            _validateController.Validate();
        }
예제 #4
0
        public static DynamicTileBrush FromXProxy(LibraryX.DynamicTileBrushX proxy, TilePoolManager manager, DynamicTileBrushClassRegistry registry)
        {
            if (proxy == null)
            {
                return(null);
            }

            DynamicTileBrush brush = new DynamicTileBrush(proxy, manager, registry);

            if (brush._brushClass == null)
            {
                return(null);
            }

            return(brush);
        }
예제 #5
0
        public static LibraryX.DynamicTileBrushX ToXProxy(DynamicTileBrush brush)
        {
            if (brush == null)
                return null;

            List<LibraryX.BrushEntryX> brushEntries = new List<LibraryX.BrushEntryX>();
            for (int i = 0; i < brush.BrushClass.SlotCount; i++) {
                Tile tile = brush.GetTile(i);
                if (tile != null)
                    brushEntries.Add(new LibraryX.BrushEntryX() {
                        Slot = i,
                        TileId = tile.Uid,
                    });
            }

            return new LibraryX.DynamicTileBrushX() {
                Uid = brush.Uid,
                Name = brush.Name,
                Type = brush.BrushClass.ClassName,
                TileWidth = brush.TileWidth,
                TileHeight = brush.TileHeight,
                Entries = brushEntries,
            };
        }
예제 #6
0
 private void RemoveTileFromBrush(DynamicTileBrush brush, Tile tile)
 {
     if (brush != null) {
         for (int i = 0; i < _brush.BrushClass.SlotCount; i++) {
             if (_brush.GetTile(i) == tile)
                 _brush.SetTile(i, null);
         }
     }
 }
예제 #7
0
        private void InitializeBrush(DynamicTileBrush brush)
        {
            _layerControl.ReferenceWidth = brush.BrushClass.TemplateWidth * brush.TileWidth + 1;
            _layerControl.ReferenceHeight = brush.BrushClass.TemplateHeight * brush.TileHeight + 1;

            _layer = new MultiTileGridLayer("Default", brush.TileWidth, brush.TileHeight, brush.BrushClass.TemplateWidth, brush.BrushClass.TemplateHeight);
            for (int i = 0; i < brush.BrushClass.SlotCount; i++) {
                LocatedTile tile = brush.GetLocatedTile(i);
                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 LocalRenderLayerPresenter(new OverlayRenderCore(this)));
            _rootLayer.Layers.Add(new GridLayerPresenter() {
                GridSpacingX = brush.TileWidth,
                GridSpacingY = brush.TileHeight,
            });

            _nameField.Text = brush.Name;

            _brush = brush;

            SelectCurrentPrototype();
            SelectCurrentTileSize();
        }
        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);
            }
        }