Esempio n. 1
0
        // TODO: MultiTileGridLayer stuff should move into appropriate class
        public void SetTool(TileTool tool)
        {
            if (LayerContext == null)
            {
                return;
            }

            if (_selection != null && tool == TileTool.Select)
            {
                _selection.Activate();
            }
            else if (_selection != null)
            {
                _selection.Deactivate();
            }

            if (_currentTool != null)
            {
                _currentTool.Dispose();
            }

            switch (tool)
            {
            case TileTool.Select:
                _currentTool = new TileSelectTool(LayerContext.History, Layer as MultiTileGridLayer, LayerContext.Annotations, this);
                break;

            case TileTool.Draw:
                TileDrawTool drawTool = new TileDrawTool(LayerContext.History, Layer as MultiTileGridLayer, LayerContext.Annotations);
                drawTool.Info = Info;
                drawTool.BindTilePoolController(_tilePoolController);
                drawTool.BindTileBrushManager(_tileBrushController);
                _currentTool = drawTool;
                break;

            case TileTool.Erase:
                _currentTool = new TileEraseTool(LayerContext.History, Layer as MultiTileGridLayer, LayerContext.Annotations);
                break;

            case TileTool.Fill:
                TileFillTool fillTool = new TileFillTool(LayerContext.History, Layer as MultiTileGridLayer, _sourceType);
                fillTool.BindTilePoolController(_tilePoolController);
                fillTool.BindTileBrushManager(_tileBrushController);
                _currentTool = fillTool;
                break;

            default:
                _currentTool = null;
                break;
            }
        }