public TileSetRenderLayer(TileSetLayerPresenter model)
     : base(model)
 {
 }
Beispiel #2
0
        private TilePool LoadFile(ITilePoolManager manager)
        {
            if (_fileStream == null) {
                return null;
            }

            if (_fileStream.Position != 0) {
                _fileStream.Position = 0;
            }

            _localManager.Reset();

            TextureResource resource = TextureResourceBitmapExt.CreateTextureResource(_fileStream);
            TilePool.TileImportOptions options = new TilePool.TileImportOptions()
            {
                TileHeight = (int)_numTileHeight.Value,
                TileWidth = (int)_numTileWidth.Value,
                SpaceX = (int)_numXSpacing.Value,
                SpaceY = (int)_numYSpacing.Value,
                MarginX = (int)_numXMargin.Value,
                MarginY = (int)_numYMargin.Value,
                ImportPolicty = TileImportPolicy.SetUnique,
            };

            _previewPool = _localManager.ImportPool(_textName.Text, resource, options);
            _originalResource = _previewPool.TileSource.Crop(_previewPool.TileSource.Bounds);

            if (_useTransColor)
                SetTransparentColor();

            // Update preview window

            if (_previewLayer != null)
                _previewLayer.Dispose();

            Model.TileSetLayer layer = new Model.TileSetLayer(_previewPool.Name, _previewPool);
            _previewLayer = new TileSetLayerPresenter(layer) {
                LevelGeometry = _layerControl.LevelGeometry,
            };

            _rootLayer.Layers.Clear();
            _rootLayer.Layers.Add(_previewLayer);

            // Update stats

            _countTilesHigh.Text = ((_height + (int)_numYSpacing.Value) / ((int)_numTileHeight.Value + (int)_numYSpacing.Value + (int)_numYMargin.Value)).ToString();
            _countTilesWide.Text = ((_width + (int)_numXSpacing.Value) / ((int)_numTileWidth.Value + (int)_numXSpacing.Value + (int)_numXMargin.Value)).ToString();
            _countUniqueTiles.Text = _previewPool.Count.ToString();

            return _previewPool;
        }
        private void InitializeLayerHierarchy()
        {
            _tileLayer = new TileSetLayerPresenter(_tileSet);
            _tileLayer.TileSelected += TileSelected;

            _gridLayer = new GridLayerPresenter() {
                GridSpacingX = _tilePool.TileWidth,
                GridSpacingY = _tilePool.TileHeight,
            };
            _annotLayer = new AnnotationLayerPresenter() {
                Annotations = _annotations,
            };

            _rootLayer = new GroupLayerPresenter();
            _rootLayer.Layers.Add(_tileLayer);
            //_rootLayer.Layers.Add(_gridLayer);
            _rootLayer.Layers.Add(_annotLayer);
        }