Merge pull request #72 from azakhi/feature/improve-pasting-multiple-blocks
Improve pasting to support different copy sources
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class PasteMultipleBlocksCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly List<IItemFilterBlockBase> _pastedItemFilterBlocks;
|
||||
private readonly IItemFilterBlockBase _addAfterItemFilterBlock;
|
||||
|
||||
public PasteMultipleBlocksCommand(IItemFilterScript itemFilterScript, List<IItemFilterBlockBase> pastedItemFilterBlocks, IItemFilterBlockBase addAfterItemFilterBlock)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_pastedItemFilterBlocks = pastedItemFilterBlocks;
|
||||
_addAfterItemFilterBlock = addAfterItemFilterBlock;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if (_addAfterItemFilterBlock != null)
|
||||
{
|
||||
var lastAddedBlock = _addAfterItemFilterBlock;
|
||||
foreach(var block in _pastedItemFilterBlocks)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_itemFilterScript.ItemFilterBlocks.IndexOf(lastAddedBlock) + 1, block);
|
||||
lastAddedBlock = block;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var block in _pastedItemFilterBlocks)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
foreach (var block in _pastedItemFilterBlocks)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(block);
|
||||
}
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlockDownCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlockUpCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlockToTopCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\PasteSectionCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\PasteMultipleBlocksCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\RemoveSectionCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\SetScriptDescriptionCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\RemoveBlockCommand.cs" />
|
||||
|
||||
@@ -93,5 +93,10 @@ namespace Filtration.ObjectModel.ThemeEditor
|
||||
Items.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
||||
return componentCount > 0;
|
||||
}
|
||||
|
||||
public bool ComponentExists(ThemeComponent themeComponent)
|
||||
{
|
||||
return ComponentExists(themeComponent.ComponentType, themeComponent.ComponentName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user