Пример #1
0
        private void CommandPaste()
        {
            if (CommandCanPaste())
            {
                TileSelectionClipboard clip      = TileSelectionClipboard.CopyFromClipboard();
                TileSelection          selection = clip.GetAsTileSelection(Layer.Level.Project, Layer.TileWidth, Layer.TileHeight);
                if (selection == null)
                {
                    return;
                }

                if (_selection != null)
                {
                    CompoundCommand command = new CompoundCommand();
                    if (_selection.Floating)
                    {
                        command.AddCommand(new DefloatTileSelectionCommand(Layer as MultiTileGridLayer, this));
                    }
                    command.AddCommand(new DeleteTileSelectionCommand(this));

                    LayerContext.History.Execute(command);
                }

                Command pasteCommand = new PasteFloatingSelectionCommand(this, selection, GetCenterTileOffset());
                LayerContext.History.Execute(pasteCommand);

                if (!(_currentTool is TileSelectTool))
                {
                    CommandManager.Perform(CommandKey.TileToolSelect);
                }

                _selection.Activate();
            }
        }
Пример #2
0
        private void ResetSelection(CompoundCommand command)
        {
            if (_selectLayer.HasSelection)
            {
                if (_selectLayer.TileSelection.Floating)
                {
                    command.AddCommand(new DefloatTileSelectionCommand(Layer, _selectLayer));
                }
                command.AddCommand(new DeleteTileSelectionCommand(_selectLayer));
            }

            command.AddCommand(new CreateTileSelectionCommand(_selectLayer));
        }
Пример #3
0
        private void DefloatSelection()
        {
            if (_selectLayer == null || _selectLayer.TileSelection == null)
            {
                return;
            }

            CompoundCommand command = new CompoundCommand();

            if (_selectLayer.TileSelection.Floating)
            {
                command.AddCommand(new DefloatTileSelectionCommand(Layer, _selectLayer));
            }
            command.AddCommand(new DeleteTileSelectionCommand(_selectLayer));
            History.Execute(command);
        }
Пример #4
0
        private void CommandDelete()
        {
            if (CommandCanDelete())
            {
                CompoundCommand command = new CompoundCommand();
                if (!_selection.Floating)
                {
                    command.AddCommand(new FloatTileSelectionCommand(Layer as MultiTileGridLayer, this));
                }
                command.AddCommand(new DeleteTileSelectionCommand(this));

                LayerContext.History.Execute(command);

                CommandManager.Invalidate(CommandKey.Paste);
            }
        }
Пример #5
0
        private void CommandCut()
        {
            if (CommandCanCut())
            {
                TileSelectionClipboard clip = new TileSelectionClipboard(_selection.Tiles);
                clip.CopyToClipboard();

                CompoundCommand command = new CompoundCommand();
                if (!_selection.Floating)
                {
                    command.AddCommand(new FloatTileSelectionCommand(Layer as MultiTileGridLayer, this));
                }
                command.AddCommand(new DeleteTileSelectionCommand(this));

                LayerContext.History.Execute(command);

                CommandManager.Invalidate(CommandKey.Paste);
            }
        }
Пример #6
0
        private void EndDrag(PointerEventInfo info, ILevelGeometry viewport)
        {
            Rectangle selection = ClampSelection(_band.Selection);

            CompoundCommand command = new CompoundCommand();

            if (_mergeAction == MergeAction.New || !_selectLayer.HasSelection || _selectLayer.TileSelection.Floating)
            {
                ResetSelection(command);
            }

            switch (_mergeAction)
            {
            case MergeAction.New:
                ModifyNewTileSelectionCommand newCommand = new ModifyNewTileSelectionCommand(_selectLayer);
                newCommand.AddLocations(TileCoordsFromRegion(selection));
                command.AddCommand(newCommand);
                break;

            case MergeAction.Add:
                ModifyAddTileSelectionCommand addCommand = new ModifyAddTileSelectionCommand(_selectLayer);
                addCommand.AddLocations(TileCoordsFromRegion(selection));
                command.AddCommand(addCommand);
                break;

            case MergeAction.Remove:
                ModifyRemoveTileSelectionCommand removeCommand = new ModifyRemoveTileSelectionCommand(_selectLayer);
                removeCommand.AddLocations(TileCoordsFromRegion(selection));
                command.AddCommand(removeCommand);
                break;
            }

            if (command.Count > 0)
            {
                History.Execute(command);
            }

            _annots.Remove(_selectionAnnot);
            _action = UpdateAction.None;

            EndAutoScroll(info, viewport);
        }
Пример #7
0
        private void CommandDefloat()
        {
            if (CommandCanDefloat())
            {
                CompoundCommand command = new CompoundCommand();
                if (TileSelection.Floating)
                {
                    command.AddCommand(new DefloatTileSelectionCommand(Layer as MultiTileGridLayer, this));
                }
                command.AddCommand(new DeleteTileSelectionCommand(this));

                if (LayerContext != null)
                {
                    LayerContext.History.Execute(command);
                }
                else
                {
                    DefloatSelection();
                }
            }
        }