Improve commands & add multiple selection feature
This commit is contained in:
parent
ac6943d73b
commit
32523787d2
|
@ -1,39 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class MoveBlockDownCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly IItemFilterBlockBase _blockToMove;
|
||||
private int _indexMovedFrom;
|
||||
|
||||
public MoveBlockDownCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase blockToMove)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_blockToMove = blockToMove;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
_indexMovedFrom = _itemFilterScript.ItemFilterBlocks.IndexOf(_blockToMove);
|
||||
|
||||
if (_indexMovedFrom >= _itemFilterScript.ItemFilterBlocks.Count)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot move the bottom block down");
|
||||
}
|
||||
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_blockToMove);
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_indexMovedFrom + 1, _blockToMove);
|
||||
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_blockToMove);
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_indexMovedFrom, _blockToMove);
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class MoveBlockToBottomCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly IItemFilterBlockBase _blockToMove;
|
||||
private int _indexMovedFrom;
|
||||
|
||||
public MoveBlockToBottomCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase blockToMove)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_blockToMove = blockToMove;
|
||||
}
|
||||
public void Execute()
|
||||
{
|
||||
_indexMovedFrom = _itemFilterScript.ItemFilterBlocks.IndexOf(_blockToMove);
|
||||
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_blockToMove);
|
||||
_itemFilterScript.ItemFilterBlocks.Add(_blockToMove);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_blockToMove);
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_indexMovedFrom, _blockToMove);
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class MoveBlockToTopCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly IItemFilterBlockBase _blockToMove;
|
||||
private int _indexMovedFrom;
|
||||
|
||||
public MoveBlockToTopCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase blockToMove)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_blockToMove = blockToMove;
|
||||
}
|
||||
public void Execute()
|
||||
{
|
||||
_indexMovedFrom = _itemFilterScript.ItemFilterBlocks.IndexOf(_blockToMove);
|
||||
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_blockToMove);
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(0, _blockToMove);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_blockToMove);
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_indexMovedFrom, _blockToMove);
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class MoveBlockUpCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly IItemFilterBlockBase _blockToMove;
|
||||
private int _indexMovedFrom;
|
||||
|
||||
public MoveBlockUpCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase blockToMove)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_blockToMove = blockToMove;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
_indexMovedFrom = _itemFilterScript.ItemFilterBlocks.IndexOf(_blockToMove);
|
||||
|
||||
if (_indexMovedFrom <= 0)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot move the top block up");
|
||||
}
|
||||
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_blockToMove);
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_indexMovedFrom-1, _blockToMove);
|
||||
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_blockToMove);
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_indexMovedFrom, _blockToMove);
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class MoveBlocksToBottomCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly List<int> _sourceIndexes;
|
||||
|
||||
public MoveBlocksToBottomCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase block)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sourceIndexes = new List<int> { _itemFilterScript.ItemFilterBlocks.IndexOf(block) };
|
||||
}
|
||||
|
||||
public MoveBlocksToBottomCommand(IItemFilterScript itemFilterScript, List<int> sourceIndexes)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sourceIndexes = sourceIndexes;
|
||||
_sourceIndexes.Sort();
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
List<IItemFilterBlockBase> blocksToMove = new List<IItemFilterBlockBase>();
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
blocksToMove.Add(_itemFilterScript.ItemFilterBlocks[_sourceIndexes[i]]);
|
||||
}
|
||||
|
||||
for (var i = _sourceIndexes.Count - 1; i >= 0; i--)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(_sourceIndexes[i]);
|
||||
}
|
||||
|
||||
foreach (var block in blocksToMove)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Add(block);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
List<IItemFilterBlockBase> blocksToMove = new List<IItemFilterBlockBase>();
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
var movedIndex = _itemFilterScript.ItemFilterBlocks.Count - _sourceIndexes.Count;
|
||||
blocksToMove.Add(_itemFilterScript.ItemFilterBlocks[movedIndex]);
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(movedIndex);
|
||||
}
|
||||
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_sourceIndexes[i], blocksToMove[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class MoveBlocksToIndexCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private List<int> _sourceIndexes;
|
||||
private int _targetIndex;
|
||||
|
||||
public MoveBlocksToIndexCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase block, int targetIndex)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sourceIndexes = new List<int> { _itemFilterScript.ItemFilterBlocks.IndexOf(block) };
|
||||
_targetIndex = targetIndex;
|
||||
}
|
||||
|
||||
public MoveBlocksToIndexCommand(IItemFilterScript itemFilterScript, List<int> sourceIndexes, int targetIndex)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sourceIndexes = sourceIndexes;
|
||||
_sourceIndexes.Sort();
|
||||
_targetIndex = targetIndex;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
List<IItemFilterBlockBase> blocksToMove = new List<IItemFilterBlockBase>();
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
blocksToMove.Add(_itemFilterScript.ItemFilterBlocks[_sourceIndexes[i]]);
|
||||
}
|
||||
|
||||
for (var i = _sourceIndexes.Count - 1; i >= 0; i--)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(_sourceIndexes[i]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < blocksToMove.Count; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_targetIndex + i, blocksToMove[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
List<IItemFilterBlockBase> blocksToMove = new List<IItemFilterBlockBase>();
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
blocksToMove.Add(_itemFilterScript.ItemFilterBlocks[_targetIndex]);
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(_targetIndex);
|
||||
}
|
||||
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_sourceIndexes[i], blocksToMove[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class MoveBlocksToTopCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly List<int> _sourceIndexes;
|
||||
|
||||
public MoveBlocksToTopCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase block)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sourceIndexes = new List<int> { _itemFilterScript.ItemFilterBlocks.IndexOf(block) };
|
||||
}
|
||||
|
||||
public MoveBlocksToTopCommand(IItemFilterScript itemFilterScript, List<int> sourceIndexes)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sourceIndexes = sourceIndexes;
|
||||
_sourceIndexes.Sort();
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
List<IItemFilterBlockBase> blocksToMove = new List<IItemFilterBlockBase>();
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
blocksToMove.Add(_itemFilterScript.ItemFilterBlocks[_sourceIndexes[i]]);
|
||||
}
|
||||
|
||||
for (var i = _sourceIndexes.Count - 1; i >= 0; i--)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(_sourceIndexes[i]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(i, blocksToMove[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
List<IItemFilterBlockBase> blocksToMove = new List<IItemFilterBlockBase>();
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
blocksToMove.Add(_itemFilterScript.ItemFilterBlocks[0]);
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(0);
|
||||
}
|
||||
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_sourceIndexes[i], blocksToMove[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class MoveSectionToIndexCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private int _sectionStart;
|
||||
private int _sectionSize;
|
||||
private int _index;
|
||||
|
||||
public MoveSectionToIndexCommand(IItemFilterScript itemFilterScript, int sectionStart, int sectionSize, int index)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sectionStart = sectionStart;
|
||||
_sectionSize = sectionSize;
|
||||
_index = index;
|
||||
}
|
||||
public void Execute()
|
||||
{
|
||||
List<IItemFilterBlockBase> blocksToMove = new List<IItemFilterBlockBase>();
|
||||
for(var i = 0; i < _sectionSize; i++)
|
||||
{
|
||||
blocksToMove.Add(_itemFilterScript.ItemFilterBlocks[_sectionStart]);
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(_sectionStart);
|
||||
}
|
||||
for (var i = 0; i < _sectionSize; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_index + i, blocksToMove[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
List<IItemFilterBlockBase> blocksToMove = new List<IItemFilterBlockBase>();
|
||||
for (var i = 0; i < _sectionSize; i++)
|
||||
{
|
||||
blocksToMove.Add(_itemFilterScript.ItemFilterBlocks[_index]);
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(_index);
|
||||
}
|
||||
for (var i = 0; i < _sectionSize; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_sectionStart + i, blocksToMove[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class PasteBlockCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly IItemFilterBlockBase _pastedItemFilterBlock;
|
||||
private readonly IItemFilterBlockBase _addAfterItemFilterBlock;
|
||||
|
||||
public PasteBlockCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase pastedItemFilterBlock, IItemFilterBlockBase addAfterItemFilterBlock)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_pastedItemFilterBlock = pastedItemFilterBlock;
|
||||
_addAfterItemFilterBlock = addAfterItemFilterBlock;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if (_addAfterItemFilterBlock != null)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_itemFilterScript.ItemFilterBlocks.IndexOf(_addAfterItemFilterBlock) + 1, _pastedItemFilterBlock);
|
||||
}
|
||||
else
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Add(_pastedItemFilterBlock);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_pastedItemFilterBlock);
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -3,13 +3,20 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class PasteMultipleBlocksCommand : IUndoableCommand
|
||||
public class PasteBlocksCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly List<IItemFilterBlockBase> _pastedItemFilterBlocks;
|
||||
private readonly IItemFilterBlockBase _addAfterItemFilterBlock;
|
||||
|
||||
public PasteMultipleBlocksCommand(IItemFilterScript itemFilterScript, List<IItemFilterBlockBase> pastedItemFilterBlocks, IItemFilterBlockBase addAfterItemFilterBlock)
|
||||
public PasteBlocksCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase block, IItemFilterBlockBase addAfterItemFilterBlock)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_pastedItemFilterBlocks = new List<IItemFilterBlockBase> { block };
|
||||
_addAfterItemFilterBlock = addAfterItemFilterBlock;
|
||||
}
|
||||
|
||||
public PasteBlocksCommand(IItemFilterScript itemFilterScript, List<IItemFilterBlockBase> pastedItemFilterBlocks, IItemFilterBlockBase addAfterItemFilterBlock)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_pastedItemFilterBlocks = pastedItemFilterBlocks;
|
|
@ -1,29 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class RemoveBlockCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private IItemFilterBlockBase _removedItemFilterBlock;
|
||||
private int _indexRemovedFrom;
|
||||
|
||||
public RemoveBlockCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase itemFilterBlockBase)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_removedItemFilterBlock = itemFilterBlockBase;
|
||||
}
|
||||
public void Execute()
|
||||
{
|
||||
_indexRemovedFrom = _itemFilterScript.ItemFilterBlocks.IndexOf(_removedItemFilterBlock);
|
||||
_itemFilterScript.ItemFilterBlocks.Remove(_removedItemFilterBlock);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_indexRemovedFrom, _removedItemFilterBlock);
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class RemoveBlocksCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private List<IItemFilterBlockBase> _removedItemFilterBlocks;
|
||||
private List<int> _sourceIndexes;
|
||||
|
||||
public RemoveBlocksCommand(IItemFilterScript itemFilterScript, IItemFilterBlockBase block)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sourceIndexes = new List<int> { _itemFilterScript.ItemFilterBlocks.IndexOf(block) };
|
||||
_removedItemFilterBlocks = new List<IItemFilterBlockBase> { block };
|
||||
}
|
||||
|
||||
public RemoveBlocksCommand(IItemFilterScript itemFilterScript, List<int> sourceIndexes)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sourceIndexes = sourceIndexes;
|
||||
_sourceIndexes.Sort();
|
||||
_removedItemFilterBlocks = new List<IItemFilterBlockBase>();
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
_removedItemFilterBlocks.Add(_itemFilterScript.ItemFilterBlocks[_sourceIndexes[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
for (var i = _sourceIndexes.Count - 1; i >= 0; i--)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(_sourceIndexes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
for (var i = 0; i < _sourceIndexes.Count; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_sourceIndexes[i], _removedItemFilterBlocks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class RemoveSectionCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private List<IItemFilterBlockBase> _removedItemFilterBlocks;
|
||||
private int _sectionStart;
|
||||
private int _sectionSize;
|
||||
|
||||
public RemoveSectionCommand(IItemFilterScript itemFilterScript, int sectionStart, int sectionSize)
|
||||
{
|
||||
_itemFilterScript = itemFilterScript;
|
||||
_sectionStart = sectionStart;
|
||||
_sectionSize = sectionSize;
|
||||
_removedItemFilterBlocks = new List<IItemFilterBlockBase>();
|
||||
for(var i = 0; i < _sectionSize; i++)
|
||||
{
|
||||
_removedItemFilterBlocks.Add(_itemFilterScript.ItemFilterBlocks[_sectionStart + i]);
|
||||
}
|
||||
}
|
||||
public void Execute()
|
||||
{
|
||||
for (var i = 0; i < _sectionSize; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.RemoveAt(_sectionStart);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
for (var i = 0; i < _sectionSize; i++)
|
||||
{
|
||||
_itemFilterScript.ItemFilterBlocks.Insert(_sectionStart + i, _removedItemFilterBlocks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Redo() => Execute();
|
||||
}
|
||||
}
|
|
@ -110,17 +110,13 @@
|
|||
<Compile Include="BlockItemTypes\WidthBlockItem.cs" />
|
||||
<Compile Include="Commands\CommandManager.cs" />
|
||||
<Compile Include="Commands\ICommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveSectionToIndexCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\PasteBlockCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlockToBottomCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlocksToIndexCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlocksToBottomCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\AddCommentBlockCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlockDownCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlockUpCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlockToTopCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\PasteMultipleBlocksCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\RemoveSectionCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\MoveBlocksToTopCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\PasteBlocksCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\RemoveBlocksCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\SetScriptDescriptionCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\RemoveBlockCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\AddBlockCommand.cs" />
|
||||
<Compile Include="Commands\IUndoableCommand.cs" />
|
||||
<Compile Include="Enums\BlockAction.cs" />
|
||||
|
|
|
@ -191,6 +191,7 @@
|
|||
<Compile Include="UserControls\ThemeComponentSelectionControl.xaml.cs">
|
||||
<DependentUpon>ThemeComponentSelectionControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\AttachedProperties\SelectedItemsAttachedProperty.cs" />
|
||||
<Compile Include="Utility\RoutedCommandHandler.cs" />
|
||||
<Compile Include="Utility\RoutedCommandHandlers.cs" />
|
||||
<Compile Include="ViewModels\AvalonDockWorkspaceViewModel.cs" />
|
||||
|
|
|
@ -21,16 +21,6 @@ namespace Filtration.ViewModels
|
|||
|
||||
public ItemFilterBlockViewModelBase()
|
||||
{
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand);
|
||||
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand);
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand);
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand);
|
||||
|
||||
_isVisible = true;
|
||||
}
|
||||
|
||||
|
@ -39,6 +29,16 @@ namespace Filtration.ViewModels
|
|||
{
|
||||
BaseBlock = itemfilterBlock;
|
||||
_parentScriptViewModel = itemFilterScriptViewModel;
|
||||
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand);
|
||||
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand);
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => _parentScriptViewModel.CanModifyBlock(this));
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand);
|
||||
}
|
||||
|
||||
public event EventHandler BlockBecameDirty;
|
||||
|
@ -46,15 +46,15 @@ namespace Filtration.ViewModels
|
|||
public IItemFilterBlockBase BaseBlock { get; protected set; }
|
||||
public IItemFilterScriptViewModel _parentScriptViewModel;
|
||||
|
||||
public RelayCommand CopyBlockCommand { get; }
|
||||
public RelayCommand PasteBlockCommand { get; }
|
||||
public RelayCommand AddBlockCommand { get; }
|
||||
public RelayCommand AddSectionCommand { get; }
|
||||
public RelayCommand DeleteBlockCommand { get; }
|
||||
public RelayCommand MoveBlockUpCommand { get; }
|
||||
public RelayCommand MoveBlockDownCommand { get; }
|
||||
public RelayCommand MoveBlockToTopCommand { get; }
|
||||
public RelayCommand MoveBlockToBottomCommand { get; }
|
||||
public RelayCommand CopyBlockCommand { get; private set; }
|
||||
public RelayCommand PasteBlockCommand { get; private set; }
|
||||
public RelayCommand AddBlockCommand { get; private set; }
|
||||
public RelayCommand AddSectionCommand { get; private set; }
|
||||
public RelayCommand DeleteBlockCommand { get; private set; }
|
||||
public RelayCommand MoveBlockUpCommand { get; private set; }
|
||||
public RelayCommand MoveBlockDownCommand { get; private set; }
|
||||
public RelayCommand MoveBlockToTopCommand { get; private set; }
|
||||
public RelayCommand MoveBlockToBottomCommand { get; private set; }
|
||||
|
||||
public bool IsDirty
|
||||
{
|
||||
|
|
|
@ -10,17 +10,20 @@ namespace Filtration.ViewModels
|
|||
IItemFilterCommentBlock ItemFilterCommentBlock { get; }
|
||||
string Comment { get; }
|
||||
bool IsExpanded { get; set; }
|
||||
bool HasChild { get; set; }
|
||||
bool HasVisibleChild { get; }
|
||||
}
|
||||
|
||||
internal class ItemFilterCommentBlockViewModel : ItemFilterBlockViewModelBase, IItemFilterCommentBlockViewModel
|
||||
{
|
||||
private bool _isExpanded;
|
||||
private bool _hasChild;
|
||||
private int _childCount;
|
||||
private int _visibleChildCount;
|
||||
|
||||
public ItemFilterCommentBlockViewModel()
|
||||
{
|
||||
_isExpanded = true;
|
||||
_childCount = 0;
|
||||
_visibleChildCount = 0;
|
||||
|
||||
ToggleSectionCommand = new RelayCommand(OnToggleSectionCommand);
|
||||
}
|
||||
|
@ -92,16 +95,32 @@ namespace Filtration.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public bool HasChild
|
||||
public int ChildCount
|
||||
{
|
||||
get => _hasChild;
|
||||
get => _childCount;
|
||||
set
|
||||
{
|
||||
_hasChild = value;
|
||||
_childCount = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int VisibleChildCount
|
||||
{
|
||||
get => _visibleChildCount;
|
||||
set
|
||||
{
|
||||
_visibleChildCount = value;
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged(nameof(HasVisibleChild));
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasVisibleChild
|
||||
{
|
||||
get => (_visibleChildCount > 0);
|
||||
}
|
||||
|
||||
private void OnToggleSectionCommand()
|
||||
{
|
||||
_parentScriptViewModel.ToggleSection(this);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -97,18 +97,18 @@ namespace Filtration.ViewModels
|
|||
RedoCommand = new RelayCommand(OnRedoCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSingleSelectedeBlock);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSingleSelectedeBlock);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock && ActiveScriptCanModifySelectedBlocks);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock && ActiveScriptCanModifySelectedBlocks);
|
||||
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
||||
DisableSectionCommand = new RelayCommand(OnDisableSectionCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedCommentBlock);
|
||||
EnableSectionCommand = new RelayCommand(OnEnableSectionCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedCommentBlock);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptCanModifySelectedBlocks);
|
||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock && ActiveScriptCanModifySelectedBlocks);
|
||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock && ActiveScriptCanModifySelectedBlocks);
|
||||
DisableSectionCommand = new RelayCommand(OnDisableSectionCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedCommentBlock && ActiveScriptCanModifySelectedBlocks);
|
||||
EnableSectionCommand = new RelayCommand(OnEnableSectionCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedCommentBlock && ActiveScriptCanModifySelectedBlocks);
|
||||
ExpandSectionCommand = new RelayCommand(OnExpandSectionCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedCommentBlock);
|
||||
CollapseSectionCommand = new RelayCommand(OnCollapseSectionCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedCommentBlock);
|
||||
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
||||
|
@ -329,7 +329,9 @@ namespace Filtration.ViewModels
|
|||
|
||||
public bool ActiveDocumentIsTheme => _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme;
|
||||
|
||||
public bool ActiveScriptHasSelectedBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null;
|
||||
public bool ActiveScriptHasSelectedBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.LastSelectedBlockViewModel != null;
|
||||
|
||||
public bool ActiveScriptHasSingleSelectedeBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModels.Count == 1;
|
||||
|
||||
public bool ActiveScriptHasSelectedEnabledBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedEnabledBlock();
|
||||
|
||||
|
@ -337,6 +339,8 @@ namespace Filtration.ViewModels
|
|||
|
||||
public bool ActiveScriptHasSelectedCommentBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedCommentBlock();
|
||||
|
||||
public bool ActiveScriptCanModifySelectedBlocks => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.CanModifySelectedBlocks();
|
||||
|
||||
|
||||
public bool ActiveThemeIsEditable => AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme;
|
||||
|
||||
|
|
|
@ -30,14 +30,14 @@ namespace Filtration.ViewModels.ToolPanes
|
|||
{
|
||||
switch (message.Notification)
|
||||
{
|
||||
case "SelectedBlockChanged":
|
||||
case "LastSelectedBlockChanged":
|
||||
{
|
||||
OnSelectedBlockChanged(this, EventArgs.Empty);
|
||||
OnLastSelectedBlockChanged(this, EventArgs.Empty);
|
||||
break;
|
||||
}
|
||||
case "ActiveDocumentChanged":
|
||||
{
|
||||
OnSelectedBlockChanged(this, EventArgs.Empty);
|
||||
OnLastSelectedBlockChanged(this, EventArgs.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -62,9 +62,9 @@ namespace Filtration.ViewModels.ToolPanes
|
|||
PreviewText = string.Empty;
|
||||
}
|
||||
|
||||
private void OnSelectedBlockChanged(object sender, EventArgs e)
|
||||
private void OnLastSelectedBlockChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (AvalonDockWorkspaceViewModel.ActiveScriptViewModel?.SelectedBlockViewModel == null)
|
||||
if (AvalonDockWorkspaceViewModel.ActiveScriptViewModel?.LastSelectedBlockViewModel == null)
|
||||
{
|
||||
PreviewText = string.Empty;
|
||||
return;
|
||||
|
@ -72,7 +72,7 @@ namespace Filtration.ViewModels.ToolPanes
|
|||
|
||||
PreviewText =
|
||||
_itemFilterBlockTranslator.TranslateItemFilterBlockBaseToString(
|
||||
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel.BaseBlock);
|
||||
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.LastSelectedBlockViewModel.BaseBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Filtration.Views.AttachedProperties
|
||||
{
|
||||
public static class SelectedItemsAttachedProperty
|
||||
{
|
||||
public static readonly DependencyProperty SelectedItemsProperty =
|
||||
DependencyProperty.RegisterAttached("SelectedItems", typeof(IList), typeof(SelectedItemsAttachedProperty),
|
||||
new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnSelectedItemsChanged)));
|
||||
|
||||
public static IList GetSelectedItems(DependencyObject obj)
|
||||
{
|
||||
return (IList)obj.GetValue(SelectedItemsProperty);
|
||||
}
|
||||
|
||||
public static void SetSelectedItems(DependencyObject obj, IList value)
|
||||
{
|
||||
obj.SetValue(SelectedItemsProperty, value);
|
||||
}
|
||||
|
||||
private static void OnSelectedItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var listbox = d as ListBox;
|
||||
if (listbox != null)
|
||||
{
|
||||
listbox.SelectedItems.Clear();
|
||||
var selectedItems = e.NewValue as IList;
|
||||
if (selectedItems != null)
|
||||
{
|
||||
foreach (var item in selectedItems)
|
||||
{
|
||||
listbox.SelectedItems.Add(item);
|
||||
}
|
||||
|
||||
listbox.SelectionChanged += (s, ev) =>
|
||||
{
|
||||
if (null != ev.RemovedItems)
|
||||
{
|
||||
foreach (var item in ev.RemovedItems)
|
||||
{
|
||||
selectedItems.Remove(item);
|
||||
}
|
||||
}
|
||||
if (null != ev.AddedItems)
|
||||
{
|
||||
foreach (var item in ev.AddedItems)
|
||||
{
|
||||
if (!selectedItems.Contains(item))
|
||||
{
|
||||
selectedItems.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (selectedItems is INotifyCollectionChanged)
|
||||
{
|
||||
(selectedItems as INotifyCollectionChanged).CollectionChanged += (s, ev) =>
|
||||
{
|
||||
// If this is the case, list requires re-adding all
|
||||
if (ev.Action == NotifyCollectionChangedAction.Reset)
|
||||
{
|
||||
listbox.SelectedItems.Clear();
|
||||
}
|
||||
|
||||
if (null != ev.OldItems)
|
||||
{
|
||||
foreach (var item in ev.OldItems)
|
||||
{
|
||||
listbox.SelectedItems.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (null != ev.NewItems)
|
||||
{
|
||||
foreach (var item in ev.NewItems)
|
||||
{
|
||||
if (!listbox.SelectedItems.Contains(item))
|
||||
{
|
||||
listbox.SelectedItems.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -89,7 +89,7 @@
|
|||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Column="0" VerticalAlignment="Center" MinWidth="150" Content="{Binding Header, Mode=OneWay}" />
|
||||
<WrapPanel Grid.Column="1" HorizontalAlignment="Right" Visibility="{Binding HasChild, Converter={StaticResource BooleanVisibilityConverter}}">
|
||||
<WrapPanel Grid.Column="1" HorizontalAlignment="Right" Visibility="{Binding HasVisibleChild, Converter={StaticResource BooleanVisibilityConverter}}">
|
||||
<Button Command="{Binding ToggleSectionCommand}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling"
|
||||
attachedProperties:SelectingItemAttachedProperty.SelectingItem="{Binding CommentBlockBrowserBrowserSelectedBlockViewModel}"
|
||||
SelectedItem="{Binding SelectedBlockViewModel}">
|
||||
SelectionMode="Extended" attachedProperties:SelectedItemsAttachedProperty.SelectedItems="{Binding SelectedBlockViewModels}">
|
||||
<!--ItemTemplateSelector="{StaticResource BlockTemplateSelector}"-->
|
||||
<ListBox.InputBindings>
|
||||
<KeyBinding Key="Delete" Command="{Binding DeleteBlockCommand}" />
|
||||
|
|
Loading…
Reference in New Issue