示例#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;
            }
        }
示例#2
0
        public void CreateTileSelection()
        {
            if (_selection != null)
            {
                DeleteTileSelection();
            }

            _selection = new TileSelection(Layer.TileWidth, Layer.TileHeight);
            if (!(_currentTool is TileSelectTool))
            {
                _selection.Deactivate();
            }

            LayerContext.Annotations.Add(_selection.SelectionAnnotation);

            CommandManager.Invalidate(CommandKey.Cut);
            CommandManager.Invalidate(CommandKey.Copy);
            CommandManager.Invalidate(CommandKey.Delete);
            CommandManager.Invalidate(CommandKey.TileSelectionFloat);
            CommandManager.Invalidate(CommandKey.TileSelectionDefloat);
        }