Merge branch 'improvements'
|
@ -67,6 +67,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Outdated item filter")]
|
||||
public void ProcessItemsAgainstItemFilterScript_IntegrationTest()
|
||||
{
|
||||
//Arrange
|
||||
|
@ -102,6 +103,7 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
|||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Outdated item filter")]
|
||||
public void ProcessItemsAgainstItemFilterScript_IntegrationTest_10Items()
|
||||
{
|
||||
//Arrange
|
||||
|
|
|
@ -4,7 +4,7 @@ using Filtration.ObjectModel.ThemeEditor;
|
|||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
public abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem
|
||||
public abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem, IBlockItemWithTheme
|
||||
{
|
||||
private Color _color;
|
||||
private ThemeComponent _themeComponent;
|
||||
|
@ -63,7 +63,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
|||
|
||||
private void OnThemeComponentUpdated(object sender, EventArgs e)
|
||||
{
|
||||
Color = ((ThemeComponent) sender).Color;
|
||||
Color = ((ColorThemeComponent) sender).Color;
|
||||
}
|
||||
|
||||
private void OnThemeComponentDeleted(object sender, EventArgs e)
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
public abstract class ColorBooleanBlockItem : BlockItemBase, IAudioVisualBlockItem
|
||||
{
|
||||
private Color _color;
|
||||
private bool _booleanValue;
|
||||
|
||||
protected ColorBooleanBlockItem()
|
||||
{
|
||||
}
|
||||
|
||||
protected ColorBooleanBlockItem(Color color, bool booleanValue)
|
||||
{
|
||||
Color = color;
|
||||
BooleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public override string OutputText => PrefixText + " " + +Color.R + " " + Color.G + " "
|
||||
+ Color.B + (Color.A < 255 ? " " + Color.A : string.Empty) +
|
||||
(BooleanValue ? " True" : " False");
|
||||
|
||||
public override string SummaryText => string.Empty;
|
||||
|
||||
public override Color SummaryBackgroundColor => Colors.Transparent;
|
||||
public override Color SummaryTextColor => Colors.Transparent;
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return _color; }
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
IsDirty = true;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool BooleanValue
|
||||
{
|
||||
get { return _booleanValue; }
|
||||
set
|
||||
{
|
||||
_booleanValue = value;
|
||||
IsDirty = true;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
using System.Windows.Media;
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
public abstract class IntegerBlockItem : BlockItemBase, IAudioVisualBlockItem
|
||||
public abstract class IntegerBlockItem : BlockItemBase, IAudioVisualBlockItem, IBlockItemWithTheme
|
||||
{
|
||||
private int _value;
|
||||
private ThemeComponent _themeComponent;
|
||||
|
||||
protected IntegerBlockItem()
|
||||
{
|
||||
|
@ -15,7 +18,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
|||
Value = value;
|
||||
}
|
||||
|
||||
public override string OutputText => PrefixText + " " + Value;
|
||||
public override string OutputText => PrefixText + " " + Value + (ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty);
|
||||
|
||||
public override string SummaryText => string.Empty;
|
||||
public override Color SummaryBackgroundColor => Colors.Transparent;
|
||||
|
@ -24,6 +27,29 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
|||
public abstract int Minimum { get; }
|
||||
public abstract int Maximum { get; }
|
||||
|
||||
public ThemeComponent ThemeComponent
|
||||
{
|
||||
get { return _themeComponent; }
|
||||
set
|
||||
{
|
||||
if (_themeComponent == value) { return; }
|
||||
|
||||
if (_themeComponent != null)
|
||||
{
|
||||
_themeComponent.ThemeComponentUpdated -= OnThemeComponentUpdated;
|
||||
_themeComponent.ThemeComponentDeleted -= OnThemeComponentDeleted;
|
||||
}
|
||||
if (value != null)
|
||||
{
|
||||
value.ThemeComponentUpdated += OnThemeComponentUpdated;
|
||||
value.ThemeComponentDeleted += OnThemeComponentDeleted;
|
||||
}
|
||||
|
||||
_themeComponent = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get { return _value; }
|
||||
|
@ -34,5 +60,15 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
|||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnThemeComponentUpdated(object sender, EventArgs e)
|
||||
{
|
||||
Value = ((IntegerBlockItem)sender).Value;
|
||||
}
|
||||
|
||||
private void OnThemeComponentDeleted(object sender, EventArgs e)
|
||||
{
|
||||
ThemeComponent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
public abstract class StrIntBlockItem : BlockItemBase, IAudioVisualBlockItem, IBlockItemWithTheme
|
||||
{
|
||||
private string _value;
|
||||
private int _secondValue;
|
||||
private ThemeComponent _themeComponent;
|
||||
|
||||
protected StrIntBlockItem()
|
||||
{
|
||||
}
|
||||
|
||||
protected StrIntBlockItem(string value, int secondValue)
|
||||
{
|
||||
Value = value;
|
||||
SecondValue = secondValue;
|
||||
Value = value;
|
||||
SecondValue = secondValue;
|
||||
}
|
||||
|
||||
public override string OutputText => PrefixText + " " + Value + " " + SecondValue + (ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty);
|
||||
|
||||
public override string SummaryText => string.Empty;
|
||||
public override Color SummaryBackgroundColor => Colors.Transparent;
|
||||
public override Color SummaryTextColor => Colors.Transparent;
|
||||
|
||||
public ThemeComponent ThemeComponent
|
||||
{
|
||||
get { return _themeComponent; }
|
||||
set
|
||||
{
|
||||
if (_themeComponent == value) { return; }
|
||||
|
||||
if (_themeComponent != null)
|
||||
{
|
||||
_themeComponent.ThemeComponentUpdated -= OnThemeComponentUpdated;
|
||||
_themeComponent.ThemeComponentDeleted -= OnThemeComponentDeleted;
|
||||
}
|
||||
if (value != null)
|
||||
{
|
||||
value.ThemeComponentUpdated += OnThemeComponentUpdated;
|
||||
value.ThemeComponentDeleted += OnThemeComponentDeleted;
|
||||
}
|
||||
|
||||
_themeComponent = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
_value = value;
|
||||
IsDirty = true;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int SecondValue
|
||||
{
|
||||
get { return _secondValue; }
|
||||
set
|
||||
{
|
||||
_secondValue = value;
|
||||
IsDirty = true;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnThemeComponentUpdated(object sender, EventArgs e)
|
||||
{
|
||||
Value = ((StrIntBlockItem)sender).Value;
|
||||
SecondValue = ((StrIntBlockItem)sender).SecondValue;
|
||||
}
|
||||
|
||||
private void OnThemeComponentDeleted(object sender, EventArgs e)
|
||||
{
|
||||
ThemeComponent = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,24 +2,20 @@
|
|||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
public abstract class StrIntBlockItem : BlockItemBase, IAudioVisualBlockItem
|
||||
public abstract class StringBlockItem : BlockItemBase, IAudioVisualBlockItem
|
||||
{
|
||||
private string _value;
|
||||
private int _secondValue;
|
||||
|
||||
protected StrIntBlockItem()
|
||||
protected StringBlockItem()
|
||||
{
|
||||
}
|
||||
|
||||
protected StrIntBlockItem(string value, int secondValue)
|
||||
protected StringBlockItem(string value)
|
||||
{
|
||||
Value = value;
|
||||
SecondValue = secondValue;
|
||||
Value = value;
|
||||
SecondValue = secondValue;
|
||||
}
|
||||
|
||||
public override string OutputText => PrefixText + " " + Value + " " + SecondValue;
|
||||
public override string OutputText => PrefixText + " " + Value;
|
||||
|
||||
public override string SummaryText => string.Empty;
|
||||
public override Color SummaryBackgroundColor => Colors.Transparent;
|
||||
|
@ -35,16 +31,5 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
|||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int SecondValue
|
||||
{
|
||||
get { return _secondValue; }
|
||||
set
|
||||
{
|
||||
_secondValue = value;
|
||||
IsDirty = true;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
public class BeamBlockItem : ColorBooleanBlockItem
|
||||
{
|
||||
public BeamBlockItem()
|
||||
{
|
||||
}
|
||||
|
||||
public BeamBlockItem(Color color, bool booleanValue) : base(color, booleanValue)
|
||||
{
|
||||
}
|
||||
|
||||
public override string PrefixText => "BeamColor";
|
||||
public override int MaximumAllowed => 1;
|
||||
public override string DisplayHeading => "Beam Color";
|
||||
public override int SortOrder => 29;
|
||||
}
|
||||
}
|
|
@ -23,6 +23,6 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||
public override Color SummaryTextColor => Colors.White;
|
||||
public override int SortOrder => 15;
|
||||
public override int Minimum => 0;
|
||||
public override int Maximum => 40;
|
||||
public override int Maximum => 21;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
public class IconBlockItem : StringBlockItem
|
||||
{
|
||||
public IconBlockItem()
|
||||
{
|
||||
Value = "Icon1";
|
||||
}
|
||||
|
||||
public IconBlockItem(string value) : base(value)
|
||||
{
|
||||
}
|
||||
|
||||
public override string PrefixText => "Icon";
|
||||
public override int MaximumAllowed => 1;
|
||||
public override string DisplayHeading => "Drop Icon";
|
||||
public override int SortOrder => 28;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Filtration.ObjectModel.Commands.ItemFilterScript
|
||||
{
|
||||
public class PasteSectionCommand : IUndoableCommand
|
||||
{
|
||||
private readonly IItemFilterScript _itemFilterScript;
|
||||
private readonly List<IItemFilterBlockBase> _pastedItemFilterBlocks;
|
||||
private readonly IItemFilterBlockBase _addAfterItemFilterBlock;
|
||||
|
||||
public PasteSectionCommand(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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
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();
|
||||
}
|
||||
}
|
|
@ -9,6 +9,10 @@ namespace Filtration.ObjectModel.Enums
|
|||
[Description("Background")]
|
||||
BackgroundColor,
|
||||
[Description("Border")]
|
||||
BorderColor
|
||||
BorderColor,
|
||||
[Description("Font Size")]
|
||||
FontSize,
|
||||
[Description("Alert Sound")]
|
||||
AlertSound
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,19 +52,23 @@
|
|||
<Compile Include="BlockItemBaseTypes\BlockItemBase.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\BooleanBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\ColorBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\ColorBooleanBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\DualIntegerBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\StringIntBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\StringBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\StrIntBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\IntegerBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\NumericFilterPredicateBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\StringListBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\BackgroundColorBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\BaseTypeBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\BeamBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\BorderColorBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\ClassBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\DisableDropSoundBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\ElderMapBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\GemLevelBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\HasExplicitModBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\IconBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\ShapedMapBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\ShaperItemBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\ElderItemBlockItem.cs" />
|
||||
|
@ -86,12 +90,15 @@
|
|||
<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\AddCommentBlockCommand.cs" />
|
||||
<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\RemoveSectionCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\SetScriptDescriptionCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\RemoveBlockCommand.cs" />
|
||||
<Compile Include="Commands\ItemFilterScript\AddBlockCommand.cs" />
|
||||
|
@ -108,6 +115,7 @@
|
|||
<Compile Include="Factories\IItemFilterScriptFactory.cs" />
|
||||
<Compile Include="FilteredItem.cs" />
|
||||
<Compile Include="IAudioVisualBlockItem.cs" />
|
||||
<Compile Include="IBlockItemWithTheme.cs" />
|
||||
<Compile Include="IItemFilterBlockItem.cs" />
|
||||
<Compile Include="Item.cs" />
|
||||
<Compile Include="ItemFilterBlock.cs" />
|
||||
|
@ -123,7 +131,10 @@
|
|||
<Compile Include="ReplaceColorsParameterSet.cs" />
|
||||
<Compile Include="Socket.cs" />
|
||||
<Compile Include="SocketGroup.cs" />
|
||||
<Compile Include="ThemeEditor\StrIntThemeComponent.cs" />
|
||||
<Compile Include="ThemeEditor\IntegerThemeComponent.cs" />
|
||||
<Compile Include="ThemeEditor\Theme.cs" />
|
||||
<Compile Include="ThemeEditor\ColorThemeComponent.cs" />
|
||||
<Compile Include="ThemeEditor\ThemeComponent.cs" />
|
||||
<Compile Include="ThemeEditor\ThemeComponentCollection.cs" />
|
||||
<Compile Include="WindsorInstallers\CommandsInstaller.cs" />
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.ObjectModel
|
||||
{
|
||||
public interface IBlockItemWithTheme : IItemFilterBlockItem
|
||||
{
|
||||
ThemeComponent ThemeComponent { get; }
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
|
@ -22,12 +23,16 @@ namespace Filtration.ObjectModel
|
|||
Color DisplayTextColor { get; }
|
||||
Color DisplayBorderColor { get; }
|
||||
double DisplayFontSize { get; }
|
||||
string DisplayIcon { get; }
|
||||
Color DisplayBeamColor { get; }
|
||||
bool HasBlockItemOfType<T>();
|
||||
bool HasBlockGroupInParentHierarchy(ItemFilterBlockGroup targetBlockGroup, ItemFilterBlockGroup startingBlockGroup);
|
||||
}
|
||||
|
||||
public interface IItemFilterBlockBase
|
||||
{
|
||||
bool IsEdited { get; set; }
|
||||
string OriginalText { get; set; }
|
||||
}
|
||||
|
||||
public abstract class ItemFilterBlockBase : IItemFilterBlockBase
|
||||
|
@ -44,6 +49,8 @@ namespace Filtration.ObjectModel
|
|||
|
||||
public ICommandManager CommandManager { get; }
|
||||
public IItemFilterScript ParentScript { get; set; }
|
||||
public bool IsEdited { get; set; }
|
||||
public string OriginalText { get; set; }
|
||||
}
|
||||
|
||||
public interface IItemFilterCommentBlock : IItemFilterBlockBase
|
||||
|
@ -53,29 +60,60 @@ namespace Filtration.ObjectModel
|
|||
|
||||
public class ItemFilterCommentBlock : ItemFilterBlockBase, IItemFilterCommentBlock
|
||||
{
|
||||
private string _comment;
|
||||
public ItemFilterCommentBlock(IItemFilterScript parentScript) : base(parentScript)
|
||||
{
|
||||
}
|
||||
|
||||
public string Comment { get; set; }
|
||||
public string Comment
|
||||
{
|
||||
get { return _comment; }
|
||||
set
|
||||
{
|
||||
_comment = value;
|
||||
IsEdited = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemFilterBlock : ItemFilterBlockBase, IItemFilterBlock
|
||||
{
|
||||
private ItemFilterBlockGroup _blockGroup;
|
||||
private bool _enabled;
|
||||
private string _description;
|
||||
|
||||
internal ItemFilterBlock()
|
||||
{
|
||||
BlockItems = new ObservableCollection<IItemFilterBlockItem> { ActionBlockItem };
|
||||
BlockItems.CollectionChanged += new NotifyCollectionChangedEventHandler(OnBlockItemsChanged);
|
||||
_enabled = true;
|
||||
}
|
||||
|
||||
public ItemFilterBlock(IItemFilterScript parentScript) : base(parentScript)
|
||||
{
|
||||
BlockItems = new ObservableCollection<IItemFilterBlockItem> { ActionBlockItem };
|
||||
BlockItems.CollectionChanged += new NotifyCollectionChangedEventHandler(OnBlockItemsChanged);
|
||||
_enabled = true;
|
||||
}
|
||||
|
||||
public bool Enabled { get; set; } = true;
|
||||
public string Description { get; set; }
|
||||
public bool Enabled
|
||||
{
|
||||
get { return _enabled; }
|
||||
set
|
||||
{
|
||||
_enabled = value;
|
||||
IsEdited = true;
|
||||
}
|
||||
}
|
||||
public string Description
|
||||
{
|
||||
get { return _description; }
|
||||
set
|
||||
{
|
||||
_description = value;
|
||||
IsEdited = true;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemFilterBlockGroup BlockGroup
|
||||
{
|
||||
|
@ -114,12 +152,17 @@ namespace Filtration.ObjectModel
|
|||
{
|
||||
var actionBlock = BlockItems.OfType<ActionBlockItem>().First();
|
||||
actionBlock.Action = value;
|
||||
IsEdited = true;
|
||||
}
|
||||
}
|
||||
|
||||
public ActionBlockItem ActionBlockItem { get; } = new ActionBlockItem(BlockAction.Show);
|
||||
|
||||
public ObservableCollection<IItemFilterBlockItem> BlockItems { get; }
|
||||
private void OnBlockItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
IsEdited = true;
|
||||
}
|
||||
|
||||
public bool AddBlockItemAllowed(Type type)
|
||||
{
|
||||
|
@ -219,5 +262,23 @@ namespace Filtration.ObjectModel
|
|||
return fontSizeBlockItem?.Value ?? 34;
|
||||
}
|
||||
}
|
||||
|
||||
public string DisplayIcon
|
||||
{
|
||||
get
|
||||
{
|
||||
var displayIcon = BlockItems.OfType<IconBlockItem>().FirstOrDefault();
|
||||
return (displayIcon != null) ? displayIcon.Value : "";
|
||||
}
|
||||
}
|
||||
|
||||
public Color DisplayBeamColor
|
||||
{
|
||||
get
|
||||
{
|
||||
var beamBlockItem = BlockItems.OfType<BeamBlockItem>().FirstOrDefault();
|
||||
return beamBlockItem?.Color ?? new Color { A = 0, R = 0, G = 0, B = 0 };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ObjectModel.ThemeEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class ColorThemeComponent : ThemeComponent
|
||||
{
|
||||
private Color _color;
|
||||
|
||||
public ColorThemeComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
{
|
||||
if (componentName == null || componentColor == null)
|
||||
{
|
||||
throw new ArgumentException("Null parameters not allowed in ColorThemeComponent constructor");
|
||||
}
|
||||
|
||||
ComponentType = componentType;
|
||||
Color = componentColor;
|
||||
ComponentName = componentName;
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return _color; }
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
OnPropertyChanged();
|
||||
_themeComponentUpdatedEventHandler?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ObjectModel.ThemeEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class IntegerThemeComponent : ThemeComponent
|
||||
{
|
||||
private int _value;
|
||||
|
||||
public IntegerThemeComponent(ThemeComponentType componentType, string componentName, int componentValue)
|
||||
{
|
||||
if (componentName == null)
|
||||
{
|
||||
throw new ArgumentException("Null parameters not allowed in IntegerThemeComponent constructor");
|
||||
}
|
||||
|
||||
ComponentType = componentType;
|
||||
Value = componentValue;
|
||||
ComponentName = componentName;
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
_value = value;
|
||||
OnPropertyChanged();
|
||||
_themeComponentUpdatedEventHandler?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ObjectModel.ThemeEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class StrIntThemeComponent : ThemeComponent
|
||||
{
|
||||
private string _value;
|
||||
private int _secondValue;
|
||||
|
||||
public StrIntThemeComponent(ThemeComponentType componentType, string componentName, string componentValue, int componentSecondValue)
|
||||
{
|
||||
if (componentName == null || componentValue == null)
|
||||
{
|
||||
throw new ArgumentException("Null parameters not allowed in StrIntThemeComponent constructor");
|
||||
}
|
||||
|
||||
ComponentType = componentType;
|
||||
Value = componentValue;
|
||||
SecondValue = componentSecondValue;
|
||||
ComponentName = componentName;
|
||||
}
|
||||
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
_value = value;
|
||||
OnPropertyChanged();
|
||||
_themeComponentUpdatedEventHandler?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public int SecondValue
|
||||
{
|
||||
get { return _secondValue; }
|
||||
set
|
||||
{
|
||||
_secondValue = value;
|
||||
OnPropertyChanged();
|
||||
_themeComponentUpdatedEventHandler?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,7 +32,17 @@ namespace Filtration.ObjectModel.ThemeEditor
|
|||
|
||||
public void AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
{
|
||||
_components.Add(new ThemeComponent(componentType, componentName, componentColor));
|
||||
_components.Add(new ColorThemeComponent(componentType, componentName, componentColor));
|
||||
}
|
||||
|
||||
public void AddComponent(ThemeComponentType componentType, string componentName, int componentValue)
|
||||
{
|
||||
_components.Add(new IntegerThemeComponent(componentType, componentName, componentValue));
|
||||
}
|
||||
|
||||
public void AddComponent(ThemeComponentType componentType, string componentName, string componentValue, int componentSecondValue)
|
||||
{
|
||||
_components.Add(new StrIntThemeComponent(componentType, componentName, componentValue, componentSecondValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ namespace Filtration.ObjectModel.ThemeEditor
|
|||
[Serializable]
|
||||
public class ThemeComponent : INotifyPropertyChanged
|
||||
{
|
||||
private Color _color;
|
||||
private EventHandler _themeComponentUpdatedEventHandler;
|
||||
protected EventHandler _themeComponentUpdatedEventHandler;
|
||||
private readonly object _eventLock = new object();
|
||||
|
||||
public ThemeComponent()
|
||||
|
@ -19,18 +18,6 @@ namespace Filtration.ObjectModel.ThemeEditor
|
|||
|
||||
}
|
||||
|
||||
public ThemeComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
{
|
||||
if (componentName == null || componentColor == null)
|
||||
{
|
||||
throw new ArgumentException("Null parameters not allowed in ThemeComponent constructor");
|
||||
}
|
||||
|
||||
ComponentType = componentType;
|
||||
Color = componentColor;
|
||||
ComponentName = componentName;
|
||||
}
|
||||
|
||||
// By implementing a custom event accessor here we can keep the UsageCount up to date.
|
||||
public event EventHandler ThemeComponentUpdated
|
||||
{
|
||||
|
@ -58,17 +45,6 @@ namespace Filtration.ObjectModel.ThemeEditor
|
|||
public string ComponentName { get; set; }
|
||||
public ThemeComponentType ComponentType{ get; set; }
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return _color; }
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
OnPropertyChanged();
|
||||
_themeComponentUpdatedEventHandler?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public int UsageCount
|
||||
{
|
||||
get
|
||||
|
|
|
@ -16,7 +16,33 @@ namespace Filtration.ObjectModel.ThemeEditor
|
|||
return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
|
||||
}
|
||||
|
||||
var component = new ThemeComponent(componentType, componentName, componentColor);
|
||||
var component = new ColorThemeComponent(componentType, componentName, componentColor);
|
||||
Items.Add(component);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, int componentValue)
|
||||
{
|
||||
if (ComponentExists(componentType, componentName))
|
||||
{
|
||||
return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
|
||||
}
|
||||
|
||||
var component = new IntegerThemeComponent(componentType, componentName, componentValue);
|
||||
Items.Add(component);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, string componentValue, int componentSecondValue)
|
||||
{
|
||||
if (ComponentExists(componentType, componentName))
|
||||
{
|
||||
return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
|
||||
}
|
||||
|
||||
var component = new StrIntThemeComponent(componentType, componentName, componentValue, componentSecondValue);
|
||||
Items.Add(component);
|
||||
|
||||
return component;
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace Filtration.Parser.Interface.Services
|
|||
{
|
||||
public interface IItemFilterBlockTranslator
|
||||
{
|
||||
IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IItemFilterScript parentItemFilterScript, bool initialiseBlockGroupHierarchyBuilder = false);
|
||||
IItemFilterCommentBlock TranslateStringToItemFilterCommentBlock(string inputString, IItemFilterScript parentItemFilterScript);
|
||||
IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "", bool initialiseBlockGroupHierarchyBuilder = false);
|
||||
IItemFilterCommentBlock TranslateStringToItemFilterCommentBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "");
|
||||
|
||||
string TranslateItemFilterBlockToString(IItemFilterBlock block);
|
||||
void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
|
||||
|
|
|
@ -773,7 +773,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
// Arrange
|
||||
var inputString = "Show" + Environment.NewLine +
|
||||
" SetTextColor 255 20 100 # Rare Item Text";
|
||||
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100});
|
||||
var testComponent = new ColorThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100});
|
||||
var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent };
|
||||
|
||||
// Act
|
||||
|
@ -892,6 +892,42 @@ namespace Filtration.Parser.Tests.Services
|
|||
Assert.IsTrue(blockItem.BooleanValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_DropIcon_ReturnsCorrectObject()
|
||||
{
|
||||
// Arrange
|
||||
var inputString = "Show" + Environment.NewLine +
|
||||
" Icon Icon1";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
|
||||
|
||||
// Assert
|
||||
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is IconBlockItem));
|
||||
var blockItem = result.BlockItems.OfType<IconBlockItem>().First();
|
||||
Assert.AreEqual("Icon1", blockItem.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_BeamColor_ReturnsCorrectObject()
|
||||
{
|
||||
// Arrange
|
||||
var inputString = "Show" + Environment.NewLine +
|
||||
" BeamColor 255 20 100 True";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BeamBlockItem));
|
||||
var blockItem = result.BlockItems.OfType<BeamBlockItem>().First();
|
||||
Assert.AreEqual(255, blockItem.Color.R);
|
||||
Assert.AreEqual(20, blockItem.Color.G);
|
||||
Assert.AreEqual(100, blockItem.Color.B);
|
||||
Assert.IsTrue(blockItem.BooleanValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_Everything_ReturnsCorrectObject()
|
||||
{
|
||||
|
@ -925,7 +961,9 @@ namespace Filtration.Parser.Tests.Services
|
|||
" SetBorderColor 0 0 0" + Environment.NewLine +
|
||||
" SetFontSize 50" + Environment.NewLine +
|
||||
" PlayAlertSound 3" + Environment.NewLine +
|
||||
" DisableDropSound False" + Environment.NewLine;
|
||||
" DisableDropSound False" + Environment.NewLine +
|
||||
" Icon Icon2" + Environment.NewLine +
|
||||
" BeamColor 255 100 5 false" + Environment.NewLine;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
|
||||
|
@ -1030,6 +1068,15 @@ namespace Filtration.Parser.Tests.Services
|
|||
|
||||
var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First();
|
||||
Assert.IsFalse(disableDropSoundBlockItem.BooleanValue);
|
||||
|
||||
var iconBlockItem = result.BlockItems.OfType<IconBlockItem>().First();
|
||||
Assert.AreEqual("Icon2", iconBlockItem.Value);
|
||||
|
||||
var beamBlockItem = result.BlockItems.OfType<BeamBlockItem>().First();
|
||||
Assert.AreEqual(255, beamBlockItem.Color.R);
|
||||
Assert.AreEqual(100, beamBlockItem.Color.G);
|
||||
Assert.AreEqual(5, beamBlockItem.Color.B);
|
||||
Assert.IsFalse(beamBlockItem.BooleanValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -1264,6 +1311,8 @@ namespace Filtration.Parser.Tests.Services
|
|||
var expectedResult = "Show";
|
||||
|
||||
// Act
|
||||
// TODO: Shouldn't be set to edited this way
|
||||
_testUtility.TestBlock.IsEdited = true;
|
||||
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||
|
||||
// Assert
|
||||
|
@ -1281,6 +1330,8 @@ namespace Filtration.Parser.Tests.Services
|
|||
var child2BlockGroup = new ItemFilterBlockGroup("Child 2 Block Group", child1BlockGroup);
|
||||
_testUtility.TestBlock.BlockGroup = child2BlockGroup;
|
||||
|
||||
// TODO: Shouldn't be set to edited this way
|
||||
_testUtility.TestBlock.IsEdited = true;
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||
|
||||
|
@ -1296,6 +1347,8 @@ namespace Filtration.Parser.Tests.Services
|
|||
var expectedResult = $"Show #{testInputActionBlockComment}";
|
||||
|
||||
_testUtility.TestBlock.BlockItems.OfType<ActionBlockItem>().First().Comment = testInputActionBlockComment;
|
||||
// TODO: Shouldn't be set to edited this way
|
||||
_testUtility.TestBlock.IsEdited = true;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||
|
@ -1698,7 +1751,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
|
||||
var blockItem = new TextColorBlockItem(new Color {A = 255, R = 54, G = 102, B = 255})
|
||||
{
|
||||
ThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Theme Component", new Color())
|
||||
ThemeComponent = new ColorThemeComponent(ThemeComponentType.TextColor, "Test Theme Component", new Color())
|
||||
};
|
||||
|
||||
_testUtility.TestBlock.BlockItems.Add(blockItem);
|
||||
|
@ -1836,10 +1889,8 @@ namespace Filtration.Parser.Tests.Services
|
|||
public void TranslateItemFilterBlockToString_DisabledBlock_ReturnsCorrectString()
|
||||
{
|
||||
// Arrange
|
||||
var expectedResult = "#Disabled Block Start" + Environment.NewLine +
|
||||
"#Show" + Environment.NewLine +
|
||||
"# Width = 4" + Environment.NewLine +
|
||||
"#Disabled Block End";
|
||||
var expectedResult = "#Show" + Environment.NewLine +
|
||||
"# Width = 4";
|
||||
|
||||
|
||||
_testUtility.TestBlock.Enabled = false;
|
||||
|
@ -1852,6 +1903,23 @@ namespace Filtration.Parser.Tests.Services
|
|||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Ignore("Ignore until the new block type is fully implemented")]
|
||||
[Test]
|
||||
public void TranslateItemFilterBlockToString_DropIcon_ReturnsCorrectString()
|
||||
{
|
||||
// Arrange
|
||||
var expectedResult = "Show" + Environment.NewLine +
|
||||
" Icon Icon3";
|
||||
|
||||
_testUtility.TestBlock.BlockItems.Add(new IconBlockItem("Icon3"));
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
|
||||
{
|
||||
|
@ -1883,7 +1951,9 @@ namespace Filtration.Parser.Tests.Services
|
|||
" SetBorderColor 255 1 254" + Environment.NewLine +
|
||||
" SetFontSize 50" + Environment.NewLine +
|
||||
" PlayAlertSound 6 90" + Environment.NewLine +
|
||||
" DisableDropSound True";
|
||||
" DisableDropSound True";/* + Environment.NewLine +
|
||||
" Icon Icon4";
|
||||
" BeamColor 120 130 140 False";*/
|
||||
|
||||
_testUtility.TestBlock.BlockItems.Add(new ActionBlockItem(BlockAction.Show));
|
||||
_testUtility.TestBlock.BlockItems.Add(new IdentifiedBlockItem(true));
|
||||
|
@ -1927,6 +1997,8 @@ namespace Filtration.Parser.Tests.Services
|
|||
_testUtility.TestBlock.BlockItems.Add(new ShapedMapBlockItem(true));
|
||||
_testUtility.TestBlock.BlockItems.Add(new ElderMapBlockItem(true));
|
||||
_testUtility.TestBlock.BlockItems.Add(new DisableDropSoundBlockItem(true));
|
||||
_testUtility.TestBlock.BlockItems.Add(new IconBlockItem("Icon4"));
|
||||
_testUtility.TestBlock.BlockItems.Add(new BeamBlockItem(new Color { A = 255, R = 120, G = 130, B = 140 }, false));
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Outdated item filter")]
|
||||
public void TranslateStringToItemFilterScript_ReturnsScriptWithCorrectNumberOfBlocks()
|
||||
{
|
||||
// Arrange
|
||||
|
@ -40,7 +41,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
|
||||
// Assert
|
||||
Assert.AreEqual(5, script.ItemFilterBlocks.Count);
|
||||
mockItemFilterBlockTranslator.Verify(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<IItemFilterScript>(), false));
|
||||
mockItemFilterBlockTranslator.Verify(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<IItemFilterScript>(), "", false));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -95,13 +96,29 @@ namespace Filtration.Parser.Tests.Services
|
|||
// Assert
|
||||
var expectedResult = Mock.Of<IItemFilterScript>(s => s.ItemFilterBlocks == new ObservableCollection<IItemFilterBlockBase>
|
||||
{
|
||||
Mock.Of<IItemFilterBlock>(c => c.Description == "Blockdescription"),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == " commentymccommentface"),
|
||||
Mock.Of<IItemFilterBlock>(),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == "commment\r\nmorecomment\r\nblah"),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == "anothercomment"),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == "notpartofblockdescription "),
|
||||
Mock.Of<IItemFilterBlock>(c => c.Description == "blockdescription2")
|
||||
Mock.Of<IItemFilterBlock>(c => c.Description == "Blockdescription"
|
||||
&& c.OriginalText == "#Blockdescription" + Environment.NewLine +
|
||||
"Show #Flasks - Endgame - Life/Mana - Divine/Eternal - Q10+ - Normal" + Environment.NewLine +
|
||||
" Class \"Life Flasks\" \"Mana Flasks\"" + Environment.NewLine +
|
||||
" Rarity Normal" + Environment.NewLine +
|
||||
" SetFontSize 28"
|
||||
),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == " commentymccommentface" && c.OriginalText == "# commentymccommentface"),
|
||||
Mock.Of<IItemFilterBlock>(c => c.OriginalText == "Show" + Environment.NewLine +
|
||||
" Class \"Life Flasks\" \"Mana Flasks\"" + Environment.NewLine +
|
||||
" Rarity Normal" + Environment.NewLine +
|
||||
" DropLevel >= 60"
|
||||
),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == "commment\r\nmorecomment\r\nblah"
|
||||
&& c.OriginalText == "#commment" + Environment.NewLine + "#morecomment" + Environment.NewLine + "#blah"),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == "anothercomment" && c.OriginalText == "#anothercomment"),
|
||||
Mock.Of<IItemFilterCommentBlock>(c => c.Comment == "notpartofblockdescription " && c.OriginalText == "#notpartofblockdescription "),
|
||||
Mock.Of<IItemFilterBlock>(c => c.Description == "blockdescription2"
|
||||
&& c.OriginalText == "#blockdescription2" + Environment.NewLine +
|
||||
"Show #TestBlock" + Environment.NewLine +
|
||||
" Class \"Life Flasks\" \"Mana Flasks\"" + Environment.NewLine +
|
||||
" Rarity Normal "
|
||||
)
|
||||
} && s.ItemFilterBlockGroups == new ObservableCollection<ItemFilterBlockGroup> { new ItemFilterBlockGroup("Root", null, false) }
|
||||
&& s.ThemeComponents == new ThemeComponentCollection()
|
||||
&& s.ItemFilterScriptSettings == new ItemFilterScriptSettings(new ThemeComponentCollection())
|
||||
|
|
|
@ -30,9 +30,10 @@ namespace Filtration.Parser.Services
|
|||
}
|
||||
|
||||
// Converts a string into an ItemFilterCommentBlock maintaining newlines and spaces but removing # characters
|
||||
public IItemFilterCommentBlock TranslateStringToItemFilterCommentBlock(string inputString, IItemFilterScript parentItemFilterScript)
|
||||
public IItemFilterCommentBlock TranslateStringToItemFilterCommentBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "")
|
||||
{
|
||||
var itemFilterCommentBlock = new ItemFilterCommentBlock(parentItemFilterScript);
|
||||
itemFilterCommentBlock.OriginalText = originalString;
|
||||
|
||||
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
||||
{
|
||||
|
@ -42,12 +43,13 @@ namespace Filtration.Parser.Services
|
|||
|
||||
itemFilterCommentBlock.Comment = itemFilterCommentBlock.Comment.TrimEnd('\r', '\n');
|
||||
|
||||
itemFilterCommentBlock.IsEdited = false;
|
||||
return itemFilterCommentBlock;
|
||||
}
|
||||
|
||||
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
||||
// and reading ItemFilterScripts from a file.
|
||||
public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IItemFilterScript parentItemFilterScript, bool initialiseBlockGroupHierarchyBuilder = false)
|
||||
public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "", bool initialiseBlockGroupHierarchyBuilder = false)
|
||||
{
|
||||
if (initialiseBlockGroupHierarchyBuilder)
|
||||
{
|
||||
|
@ -57,6 +59,7 @@ namespace Filtration.Parser.Services
|
|||
_masterComponentCollection = parentItemFilterScript.ItemFilterScriptSettings.ThemeComponentCollection;
|
||||
var block = new ItemFilterBlock(parentItemFilterScript);
|
||||
var showHideFound = false;
|
||||
block.OriginalText = originalString;
|
||||
|
||||
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
||||
{
|
||||
|
@ -214,11 +217,15 @@ namespace Filtration.Parser.Services
|
|||
// Only ever use the last SetFontSize item encountered as multiples aren't valid.
|
||||
RemoveExistingBlockItemsOfType<FontSizeBlockItem>(block);
|
||||
|
||||
var match = Regex.Match(trimmedLine, @"\s+(\d+)");
|
||||
if (match.Success)
|
||||
var match = Regex.Matches(trimmedLine, @"(\s+(\d+)\s*)([#]?)(.*)");
|
||||
if (match.Count > 0)
|
||||
{
|
||||
var blockItemValue = new FontSizeBlockItem(Convert.ToInt16(match.Value));
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
var blockItem = new FontSizeBlockItem(Convert.ToInt16(match[0].Groups[2].Value));
|
||||
if(match[0].Groups[3].Value == "#" && !string.IsNullOrWhiteSpace(match[0].Groups[4].Value))
|
||||
{
|
||||
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize, match[0].Groups[4].Value.Trim(), blockItem.Value);
|
||||
}
|
||||
block.BlockItems.Add(blockItem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -229,7 +236,7 @@ namespace Filtration.Parser.Services
|
|||
RemoveExistingBlockItemsOfType<SoundBlockItem>(block);
|
||||
RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block);
|
||||
|
||||
var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?");
|
||||
var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?\s*([#]?)(.*)");
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
|
@ -245,6 +252,12 @@ namespace Filtration.Parser.Services
|
|||
secondValue = 79;
|
||||
}
|
||||
|
||||
ThemeComponent themeComponent = null;
|
||||
if(match.Groups[3].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[4].Value))
|
||||
{
|
||||
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, match.Groups[4].Value.Trim(), firstValue, secondValue);
|
||||
}
|
||||
|
||||
if (lineOption == "PlayAlertSound")
|
||||
{
|
||||
var blockItemValue = new SoundBlockItem
|
||||
|
@ -252,6 +265,7 @@ namespace Filtration.Parser.Services
|
|||
Value = firstValue,
|
||||
SecondValue = secondValue
|
||||
};
|
||||
blockItemValue.ThemeComponent = themeComponent;
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
}
|
||||
else
|
||||
|
@ -261,6 +275,7 @@ namespace Filtration.Parser.Services
|
|||
Value = firstValue,
|
||||
SecondValue = secondValue
|
||||
};
|
||||
blockItemValue.ThemeComponent = themeComponent;
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
}
|
||||
}
|
||||
|
@ -294,9 +309,42 @@ namespace Filtration.Parser.Services
|
|||
AddBooleanItemToBlockItems<DisableDropSoundBlockItem>(block, trimmedLine);
|
||||
break;
|
||||
}
|
||||
case "Icon":
|
||||
{
|
||||
// Only ever use the last Icon item encountered as multiples aren't valid.
|
||||
RemoveExistingBlockItemsOfType<IconBlockItem>(block);
|
||||
|
||||
var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)");
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
var blockItemValue = new IconBlockItem
|
||||
{
|
||||
Value = match.Groups[1].Value
|
||||
};
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "BeamColor":
|
||||
{
|
||||
// Only ever use the last BeamColor item encountered as multiples aren't valid.
|
||||
RemoveExistingBlockItemsOfType<BeamBlockItem>(block);
|
||||
|
||||
var result = Regex.Matches(trimmedLine, @"([\w\s]*)(True|False)[#]?(.*)", RegexOptions.IgnoreCase);
|
||||
var color = GetColorFromString(result[0].Groups[1].Value);
|
||||
var beamBlockItem = new BeamBlockItem
|
||||
{
|
||||
Color = GetColorFromString(result[0].Groups[1].Value),
|
||||
BooleanValue = result[0].Groups[2].Value.Trim().ToLowerInvariant() == "true"
|
||||
};
|
||||
block.BlockItems.Add(beamBlockItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
block.IsEdited = false;
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -312,6 +360,7 @@ namespace Filtration.Parser.Services
|
|||
|
||||
private static void AddBooleanItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : BooleanBlockItem
|
||||
{
|
||||
inputString = Regex.Replace(inputString, @"\s+", " ");
|
||||
var blockItem = Activator.CreateInstance<T>();
|
||||
var splitString = inputString.Split(' ');
|
||||
if (splitString.Length == 2)
|
||||
|
@ -515,6 +564,11 @@ namespace Filtration.Parser.Services
|
|||
// TODO: Private
|
||||
public string TranslateItemFilterCommentBlockToString(IItemFilterCommentBlock itemFilterCommentBlock)
|
||||
{
|
||||
if (!itemFilterCommentBlock.IsEdited)
|
||||
{
|
||||
return itemFilterCommentBlock.OriginalText;
|
||||
}
|
||||
|
||||
// TODO: Tests
|
||||
// TODO: # Section: text?
|
||||
var commentWithHashes = string.Empty;
|
||||
|
@ -534,13 +588,13 @@ namespace Filtration.Parser.Services
|
|||
// TODO: Private
|
||||
public string TranslateItemFilterBlockToString(IItemFilterBlock block)
|
||||
{
|
||||
var outputString = string.Empty;
|
||||
|
||||
if (!block.Enabled)
|
||||
if(!block.IsEdited)
|
||||
{
|
||||
outputString += "#Disabled Block Start" + Environment.NewLine;
|
||||
return block.OriginalText;
|
||||
}
|
||||
|
||||
var outputString = string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(block.Description))
|
||||
{
|
||||
outputString += "# " + block.Description + Environment.NewLine;
|
||||
|
@ -560,16 +614,23 @@ namespace Filtration.Parser.Services
|
|||
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||
foreach (var blockItem in block.BlockItems.Where(b => b.GetType() != typeof(ActionBlockItem)).OrderBy(b => b.SortOrder))
|
||||
{
|
||||
// Do not save temporary blocks until the new features are fully implemented
|
||||
if (blockItem is IconBlockItem || blockItem is BeamBlockItem)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockItem.OutputText != string.Empty)
|
||||
{
|
||||
outputString += (!block.Enabled ? _disabledNewLine : _newLine) + blockItem.OutputText;
|
||||
}
|
||||
}
|
||||
|
||||
if (!block.Enabled)
|
||||
{
|
||||
outputString += Environment.NewLine + "#Disabled Block End";
|
||||
}
|
||||
//TODO: Disabled for the time being. A better solution is needed.
|
||||
// Replace 'Maelström' to prevent encoding problems in other editors
|
||||
//outputString.Replace("Maelström Staff", "Maelstr");
|
||||
//outputString.Replace("Maelström of Chaos", "Maelstr");
|
||||
//outputString.Replace("Maelström", "Maelstr");
|
||||
|
||||
return outputString;
|
||||
}
|
||||
|
|
|
@ -51,60 +51,35 @@ namespace Filtration.Parser.Services
|
|||
public static string PreprocessDisabledBlocks(string inputString)
|
||||
{
|
||||
bool inDisabledBlock = false;
|
||||
var showHideFound = false;
|
||||
|
||||
var lines = Regex.Split(inputString, "\r\n|\r|\n").ToList();
|
||||
var linesToRemove = new List<int>();
|
||||
|
||||
for (var i = 0; i < lines.Count; i++)
|
||||
{
|
||||
if (lines[i].StartsWith("#Disabled Block Start"))
|
||||
if (!inDisabledBlock && lines[i].StartsWith("#"))
|
||||
{
|
||||
inDisabledBlock = true;
|
||||
linesToRemove.Add(i);
|
||||
continue;
|
||||
string curLine = Regex.Replace(lines[i].Substring(1), @"\s+", "");
|
||||
if ((curLine.StartsWith("Show") || curLine.StartsWith("Hide")) && (curLine.Length == 4 || curLine[4] == '#'))
|
||||
{
|
||||
inDisabledBlock = true;
|
||||
lines[i] = lines[i].Substring(1).TrimStart(' ');
|
||||
lines[i] = lines[i].Substring(0, 4) + "Disabled" + lines[i].Substring(4);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (inDisabledBlock)
|
||||
{
|
||||
if (lines[i].StartsWith("#Disabled Block End"))
|
||||
if (!lines[i].StartsWith("#"))
|
||||
{
|
||||
inDisabledBlock = false;
|
||||
showHideFound = false;
|
||||
linesToRemove.Add(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
lines[i] = lines[i].TrimStart('#');
|
||||
lines[i] = lines[i].Replace("#", " # ");
|
||||
var spaceOrEndOfLinePos = lines[i].IndexOf(" ", StringComparison.Ordinal) > 0 ? lines[i].IndexOf(" ", StringComparison.Ordinal) : lines[i].Length;
|
||||
var lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
|
||||
|
||||
// If we haven't found a Show or Hide line yet, then this is probably the block comment.
|
||||
// Put its # back on and skip to the next line.
|
||||
if (lineOption != "Show" && lineOption != "Hide" && showHideFound == false)
|
||||
else
|
||||
{
|
||||
lines[i] = "#" + lines[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lineOption == "Show")
|
||||
{
|
||||
lines[i] = lines[i].Replace("Show", "ShowDisabled");
|
||||
showHideFound = true;
|
||||
}
|
||||
else if (lineOption == "Hide")
|
||||
{
|
||||
lines[i] = lines[i].Replace("Hide", "HideDisabled");
|
||||
showHideFound = true;
|
||||
lines[i] = lines[i].Substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = linesToRemove.Count - 1; i >= 0; i--)
|
||||
{
|
||||
lines.RemoveAt(linesToRemove[i]);
|
||||
}
|
||||
|
||||
return lines.Aggregate((c, n) => c + Environment.NewLine + n);
|
||||
}
|
||||
|
||||
|
@ -113,11 +88,14 @@ namespace Filtration.Parser.Services
|
|||
var script = _itemFilterScriptFactory.Create();
|
||||
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
|
||||
|
||||
//Remove old disabled tags
|
||||
inputString = Regex.Replace(inputString, @"#Disabled\sBlock\s(Start|End).*?\n", "");
|
||||
inputString = (inputString.EndsWith("\n#Disabled Block End")) ? inputString.Substring(0, inputString.Length - 19) : inputString;
|
||||
|
||||
var originalLines = Regex.Split(inputString, "\r\n|\r|\n");
|
||||
|
||||
inputString = inputString.Replace("\t", "");
|
||||
if (inputString.Contains("#Disabled Block Start"))
|
||||
{
|
||||
inputString = PreprocessDisabledBlocks(inputString);
|
||||
}
|
||||
inputString = PreprocessDisabledBlocks(inputString);
|
||||
|
||||
var conditionBoundaries = IdentifyBlockBoundaries(inputString);
|
||||
|
||||
|
@ -155,14 +133,24 @@ namespace Filtration.Parser.Services
|
|||
var block = new string[end - begin];
|
||||
Array.Copy(lines, begin, block, 0, end - begin);
|
||||
var blockString = string.Join("\r\n", block);
|
||||
Array.Copy(originalLines, begin, block, 0, end - begin);
|
||||
var originalString = "";
|
||||
for (var i = block.Length - 1; i >= 0; i--)
|
||||
{
|
||||
if(block[i].Replace(" ", "").Replace("\t", "").Length > 0)
|
||||
{
|
||||
originalString = string.Join("\r\n", block, 0, i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (boundary.Value.BoundaryType == ItemFilterBlockBoundaryType.ItemFilterBlock)
|
||||
{
|
||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString, script));
|
||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString, script, originalString));
|
||||
}
|
||||
else
|
||||
{
|
||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterCommentBlock(blockString, script));
|
||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterCommentBlock(blockString, script, originalString));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Filtration.ThemeEditor.Tests.Services
|
|||
|
||||
var testInputTheme = new Theme();
|
||||
var testInputThemeComponentColor = new Color{ R = 255, G = 0, B = 1 };
|
||||
var testInputThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
|
||||
var testInputThemeComponent = new ColorThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
|
||||
testInputTheme.Components.Add(testInputThemeComponent);
|
||||
testInputBlockItem.ThemeComponent = testInputThemeComponent;
|
||||
var mockMessageBoxService = new Mock<IMessageBoxService>();
|
||||
|
@ -53,8 +53,8 @@ namespace Filtration.ThemeEditor.Tests.Services
|
|||
|
||||
var testInputTheme = new Theme();
|
||||
var testInputThemeComponentColor = new Color { R = 255, G = 0, B = 1 };
|
||||
var testInputThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
|
||||
var testInputBlockItemThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Different Component", testInputThemeComponentColor);
|
||||
var testInputThemeComponent = new ColorThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
|
||||
var testInputBlockItemThemeComponent = new ColorThemeComponent(ThemeComponentType.TextColor, "Different Component", testInputThemeComponentColor);
|
||||
testInputTheme.Components.Add(testInputThemeComponent);
|
||||
testInputBlockItem.ThemeComponent = testInputBlockItemThemeComponent;
|
||||
|
||||
|
|
|
@ -31,6 +31,14 @@ namespace Filtration.ThemeEditor.Converters
|
|||
{
|
||||
return "Background Color Theme Components";
|
||||
}
|
||||
case "Font Size":
|
||||
{
|
||||
return "Font Size Theme Components";
|
||||
}
|
||||
case "Alert Sound":
|
||||
{
|
||||
return "Alert Sound Theme Components";
|
||||
}
|
||||
}
|
||||
|
||||
return type.GetAttributeDescription();
|
||||
|
|
|
@ -108,6 +108,9 @@
|
|||
<Compile Include="Providers\ThemeProvider.cs" />
|
||||
<Compile Include="Services\ThemePersistenceService.cs" />
|
||||
<Compile Include="Services\ThemeService.cs" />
|
||||
<Compile Include="ViewModels\ColorThemeComponentViewModel.cs" />
|
||||
<Compile Include="ViewModels\StrIntThemeComponentViewModel.cs" />
|
||||
<Compile Include="ViewModels\IntegerThemeComponentViewModel.cs" />
|
||||
<Compile Include="ViewModels\IThemeViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\ThemeComponentViewModel.cs" />
|
||||
<Compile Include="ViewModels\ThemeEditorViewModel.cs" />
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
using Filtration.ThemeEditor.Services;
|
||||
using Filtration.ThemeEditor.ViewModels;
|
||||
|
@ -34,7 +35,20 @@ namespace Filtration.ThemeEditor.Providers
|
|||
var themeComponentCollection = script.ThemeComponents.Aggregate(new ThemeComponentCollection(),
|
||||
(c, component) =>
|
||||
{
|
||||
c.Add(new ThemeComponent(component.ComponentType, component.ComponentName, component.Color));
|
||||
switch(component.ComponentType)
|
||||
{
|
||||
case ThemeComponentType.BackgroundColor:
|
||||
case ThemeComponentType.BorderColor:
|
||||
case ThemeComponentType.TextColor:
|
||||
c.Add(new ColorThemeComponent(component.ComponentType, component.ComponentName, ((ColorThemeComponent)component).Color));
|
||||
break;
|
||||
case ThemeComponentType.FontSize:
|
||||
c.Add(new IntegerThemeComponent(component.ComponentType, component.ComponentName, ((IntegerThemeComponent)component).Value));
|
||||
break;
|
||||
case ThemeComponentType.AlertSound:
|
||||
c.Add(new StrIntThemeComponent(component.ComponentType, component.ComponentName, ((StrIntThemeComponent)component).Value, ((StrIntThemeComponent)component).SecondValue));
|
||||
break;
|
||||
}
|
||||
return c;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Filtration.Common.Services;
|
||||
|
@ -29,38 +30,25 @@ namespace Filtration.ThemeEditor.Services
|
|||
var mismatchedComponents = false;
|
||||
foreach (var component in theme.Components)
|
||||
{
|
||||
var componentMatched = false;
|
||||
Type targetType = null;
|
||||
var blocks = script.ItemFilterBlocks.OfType<ItemFilterBlock>();
|
||||
switch (component.ComponentType)
|
||||
{
|
||||
case ThemeComponentType.BackgroundColor:
|
||||
targetType = typeof (BackgroundColorBlockItem);
|
||||
mismatchedComponents = ApplyColorTheme(blocks, typeof(BackgroundColorBlockItem), component);
|
||||
break;
|
||||
case ThemeComponentType.TextColor:
|
||||
targetType = typeof (TextColorBlockItem);
|
||||
mismatchedComponents = ApplyColorTheme(blocks, typeof(TextColorBlockItem), component);
|
||||
break;
|
||||
case ThemeComponentType.BorderColor:
|
||||
targetType = typeof (BorderColorBlockItem);
|
||||
mismatchedComponents = ApplyColorTheme(blocks, typeof(BorderColorBlockItem), component);
|
||||
break;
|
||||
case ThemeComponentType.FontSize:
|
||||
mismatchedComponents = ApplyIntegerTheme(blocks, typeof(FontSizeBlockItem), component);
|
||||
break;
|
||||
case ThemeComponentType.AlertSound:
|
||||
mismatchedComponents = ApplyStrIntTheme(blocks, typeof(SoundBlockItem), component);
|
||||
mismatchedComponents = ApplyStrIntTheme(blocks, typeof(PositionalSoundBlockItem), component);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var block in script.ItemFilterBlocks.OfType<ItemFilterBlock>())
|
||||
{
|
||||
foreach (var blockItem in block.BlockItems.Where(i => i.GetType() == targetType))
|
||||
{
|
||||
var colorBlockItem = (ColorBlockItem) blockItem;
|
||||
if (colorBlockItem.ThemeComponent != null &&
|
||||
colorBlockItem.ThemeComponent.ComponentName == component.ComponentName)
|
||||
{
|
||||
colorBlockItem.Color = component.Color;
|
||||
componentMatched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!componentMatched)
|
||||
{
|
||||
mismatchedComponents = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,5 +59,66 @@ namespace Filtration.ThemeEditor.Services
|
|||
MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ApplyColorTheme(IEnumerable<ItemFilterBlock> blocks, Type type, ThemeComponent component)
|
||||
{
|
||||
var componentMatched = false;
|
||||
foreach (var block in blocks)
|
||||
{
|
||||
foreach (var blockItem in block.BlockItems.Where(i => i.GetType() == type))
|
||||
{
|
||||
var colorBlockItem = (ColorBlockItem)blockItem;
|
||||
if (colorBlockItem.ThemeComponent != null &&
|
||||
colorBlockItem.ThemeComponent.ComponentName == component.ComponentName)
|
||||
{
|
||||
colorBlockItem.Color = ((ColorThemeComponent)component).Color;
|
||||
componentMatched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !componentMatched;
|
||||
}
|
||||
|
||||
private bool ApplyIntegerTheme(IEnumerable<ItemFilterBlock> blocks, Type type, ThemeComponent component)
|
||||
{
|
||||
var componentMatched = false;
|
||||
foreach (var block in blocks)
|
||||
{
|
||||
foreach (var blockItem in block.BlockItems.Where(i => i.GetType() == type))
|
||||
{
|
||||
var colorBlockItem = (IntegerBlockItem)blockItem;
|
||||
if (colorBlockItem.ThemeComponent != null &&
|
||||
colorBlockItem.ThemeComponent.ComponentName == component.ComponentName)
|
||||
{
|
||||
colorBlockItem.Value = ((IntegerThemeComponent)component).Value;
|
||||
componentMatched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !componentMatched;
|
||||
}
|
||||
|
||||
private bool ApplyStrIntTheme(IEnumerable<ItemFilterBlock> blocks, Type type, ThemeComponent component)
|
||||
{
|
||||
var componentMatched = false;
|
||||
foreach (var block in blocks)
|
||||
{
|
||||
foreach (var blockItem in block.BlockItems.Where(i => i.GetType() == type))
|
||||
{
|
||||
var colorBlockItem = (StrIntBlockItem)blockItem;
|
||||
if (colorBlockItem.ThemeComponent != null &&
|
||||
colorBlockItem.ThemeComponent.ComponentName == component.ComponentName)
|
||||
{
|
||||
colorBlockItem.Value = ((StrIntThemeComponent)component).Value;
|
||||
colorBlockItem.SecondValue = ((StrIntThemeComponent)component).SecondValue;
|
||||
componentMatched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !componentMatched;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
using System.Windows.Media;
|
||||
|
||||
namespace Filtration.ThemeEditor.ViewModels
|
||||
{
|
||||
public class ColorThemeComponentViewModel : ThemeComponentViewModel
|
||||
{
|
||||
public Color Color { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Filtration.ThemeEditor.ViewModels
|
||||
{
|
||||
public class IntegerThemeComponentViewModel : ThemeComponentViewModel
|
||||
{
|
||||
public int Value { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
namespace Filtration.ThemeEditor.ViewModels
|
||||
{
|
||||
public class StrIntThemeComponentViewModel : ThemeComponentViewModel
|
||||
{
|
||||
public int Value { get; set; }
|
||||
public int SecondValue { get; set; }
|
||||
}
|
||||
}
|
|
@ -7,13 +7,11 @@ namespace Filtration.ThemeEditor.ViewModels
|
|||
{
|
||||
string ComponentName { get; set; }
|
||||
ThemeComponentType ComponentType { get; set; }
|
||||
Color Color { get; set; }
|
||||
}
|
||||
|
||||
public class ThemeComponentViewModel : IThemeComponentViewModel
|
||||
{
|
||||
public string ComponentName { get; set; }
|
||||
public ThemeComponentType ComponentType { get; set; }
|
||||
public Color Color { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,8 +194,21 @@ namespace Filtration.ThemeEditor.ViewModels
|
|||
|
||||
private void OnAddThemeComponentCommand(ThemeComponentType themeComponentType)
|
||||
{
|
||||
Components.Add(new ThemeComponent(themeComponentType, "Untitled Component",
|
||||
new Color {A = 255, R = 255, G = 255, B = 255}));
|
||||
switch (themeComponentType)
|
||||
{
|
||||
case ThemeComponentType.BackgroundColor:
|
||||
case ThemeComponentType.BorderColor:
|
||||
case ThemeComponentType.TextColor:
|
||||
Components.Add(new ColorThemeComponent(themeComponentType, "Untitled Component",
|
||||
new Color { A = 255, R = 255, G = 255, B = 255 }));
|
||||
break;
|
||||
case ThemeComponentType.FontSize:
|
||||
Components.Add(new IntegerThemeComponent(themeComponentType, "Untitled Component", 35));
|
||||
break;
|
||||
case ThemeComponentType.AlertSound:
|
||||
Components.Add(new StrIntThemeComponent(themeComponentType, "Untitled Component", "1", 100));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDeleteThemeComponentCommand(ThemeComponent themeComponent)
|
||||
|
|
|
@ -58,6 +58,30 @@
|
|||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
<xctk:ColorPicker Grid.Row="2" SelectedColor="{Binding Color}" />
|
||||
<ContentControl Grid.Row="2" Content="{Binding Mode=OneWay}">
|
||||
<ContentControl.Resources>
|
||||
<!-- Color Theme Template -->
|
||||
<DataTemplate DataType="{x:Type themeEditor:ColorThemeComponent}">
|
||||
<xctk:ColorPicker SelectedColor="{Binding Color}" />
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Integer Theme Template -->
|
||||
<DataTemplate DataType="{x:Type themeEditor:IntegerThemeComponent}">
|
||||
<xctk:ShortUpDown Value="{Binding Value}" />
|
||||
</DataTemplate>
|
||||
|
||||
<!-- String Integer Theme Template -->
|
||||
<DataTemplate DataType="{x:Type themeEditor:StrIntThemeComponent}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column="0" Text="{Binding Value}" Height="25" Padding="2,-15,0,0" />
|
||||
<xctk:ShortUpDown Grid.Column="1" Value="{Binding SecondValue}" HorizontalAlignment="Right"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ContentControl.Resources>
|
||||
</ContentControl>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -46,6 +46,9 @@ namespace Filtration
|
|||
cfg.ConstructServicesUsing(_container.Resolve);
|
||||
cfg.CreateMap<Theme, IThemeEditorViewModel>().ConstructUsingServiceLocator();
|
||||
cfg.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap();
|
||||
cfg.CreateMap<ColorThemeComponent, ColorThemeComponentViewModel>().ReverseMap();
|
||||
cfg.CreateMap<IntegerThemeComponent, IntegerThemeComponentViewModel>().ReverseMap();
|
||||
cfg.CreateMap<StrIntThemeComponent, StrIntThemeComponentViewModel>().ReverseMap();
|
||||
cfg.CreateMap<IThemeEditorViewModel, Theme>();
|
||||
});
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Filtration.Converters
|
|||
var themeComponentsList = values[0] as ThemeComponentCollection;
|
||||
if (themeComponentsList == null || themeComponentsList.Count == 0) return null;
|
||||
|
||||
var blockItem = values[1] as ColorBlockItem;
|
||||
var blockItem = values[1] as BlockItemBase;
|
||||
if (blockItem == null) return null;
|
||||
|
||||
ThemeComponentType themeComponentType;
|
||||
|
@ -33,6 +33,14 @@ namespace Filtration.Converters
|
|||
{
|
||||
themeComponentType = ThemeComponentType.BorderColor;
|
||||
}
|
||||
else if (blockItem.GetType() == typeof(FontSizeBlockItem))
|
||||
{
|
||||
themeComponentType = ThemeComponentType.FontSize;
|
||||
}
|
||||
else if (blockItem.GetType() == typeof(SoundBlockItem) || blockItem.GetType() == typeof(PositionalSoundBlockItem))
|
||||
{
|
||||
themeComponentType = ThemeComponentType.AlertSound;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Filtration.Converters
|
||||
{
|
||||
internal class DropIconConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var iconString = (string)value;
|
||||
switch(iconString)
|
||||
{
|
||||
case "Icon1":
|
||||
return "/Filtration;component/Resources/DropIcons/Icon1.png";
|
||||
case "Icon2":
|
||||
return "/Filtration;component/Resources/DropIcons/Icon2.png";
|
||||
case "Icon3":
|
||||
return "/Filtration;component/Resources/DropIcons/Icon3.png";
|
||||
case "Icon4":
|
||||
return "/Filtration;component/Resources/DropIcons/Icon4.png";
|
||||
case "Icon5":
|
||||
return "/Filtration;component/Resources/DropIcons/Icon5.png";
|
||||
case "Icon6":
|
||||
return "/Filtration;component/Resources/DropIcons/Icon6.png";
|
||||
}
|
||||
|
||||
return "/Filtration;component/Resources/DropIcons/NoIcon.png";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -167,6 +167,7 @@
|
|||
<Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToBlockActionConverter.cs" />
|
||||
<Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\DropIconConverter.cs" />
|
||||
<Compile Include="Converters\HashSignRemovalConverter.cs" />
|
||||
<Compile Include="Converters\ItemRarityConverter.cs" />
|
||||
<Compile Include="Converters\TreeViewMarginConverter.cs" />
|
||||
|
@ -190,6 +191,9 @@
|
|||
<Compile Include="UserControls\EditableListBoxControl.xaml.cs">
|
||||
<DependentUpon>EditableListBoxControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControls\ImageComboBoxControl.xaml.cs">
|
||||
<DependentUpon>ImageComboBoxControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControls\ItemPreviewControl.xaml.cs">
|
||||
<DependentUpon>ItemPreviewControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -230,6 +234,10 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControls\ImageComboBoxControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControls\ThemeComponentSelectionControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -538,6 +546,13 @@
|
|||
</None>
|
||||
<Resource Include="Resources\Icons\redo_icon.png" />
|
||||
<Resource Include="Resources\Icons\undo_icon.png" />
|
||||
<Resource Include="Resources\DropIcons\Icon1.png" />
|
||||
<Resource Include="Resources\DropIcons\Icon2.png" />
|
||||
<Resource Include="Resources\DropIcons\Icon3.png" />
|
||||
<Resource Include="Resources\DropIcons\Icon4.png" />
|
||||
<Resource Include="Resources\DropIcons\Icon5.png" />
|
||||
<Resource Include="Resources\DropIcons\Icon6.png" />
|
||||
<Resource Include="Resources\DropIcons\NoIcon.png" />
|
||||
<Content Include="Resources\ItemBaseTypes.txt" />
|
||||
<Content Include="Resources\ItemClasses.txt" />
|
||||
</ItemGroup>
|
||||
|
|
After Width: | Height: | Size: 9.2 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 2.7 KiB |
|
@ -86,6 +86,17 @@
|
|||
<userControls:EditableListBoxControl Margin="5,5,5,5" ItemsSource="{Binding Items}" />
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Beam Block Template -->
|
||||
<DataTemplate DataType="{x:Type blockItemTypes:BeamBlockItem}">
|
||||
<StackPanel>
|
||||
<WrapPanel VerticalAlignment="Center" Margin="5,5,5,5">
|
||||
<RadioButton IsChecked="{Binding BooleanValue}" Margin="0,0,10,0">Permanent</RadioButton>
|
||||
<RadioButton IsChecked="{Binding BooleanValue, Converter={StaticResource BoolInverterConverter}}" >Temporary</RadioButton>
|
||||
</WrapPanel>
|
||||
<xctk:ColorPicker SelectedColor="{Binding Color}" AvailableColors="{Binding ElementName=BlockItemContentControl, Path=DataContext.AvailableColors }" ShowAvailableColors="True" AvailableColorsHeader="Path of Exile Colors"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Color Template -->
|
||||
<DataTemplate DataType="{x:Type blockItemBaseTypes:ColorBlockItem}">
|
||||
<StackPanel>
|
||||
|
@ -105,9 +116,21 @@
|
|||
|
||||
<!-- Font Size Template -->
|
||||
<DataTemplate DataType="{x:Type blockItemTypes:FontSizeBlockItem}">
|
||||
<WrapPanel HorizontalAlignment="Left">
|
||||
<xctk:ShortUpDown Value="{Binding Value}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Width="50" />
|
||||
</WrapPanel>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<xctk:ShortUpDown Grid.Column="0" Value="{Binding Value}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Margin="0,0,10,0" />
|
||||
<userControls:ThemeComponentSelectionControl Grid.Column="1" ThemeComponent="{Binding ThemeComponent}">
|
||||
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
|
||||
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
|
||||
<Binding Path="." />
|
||||
</MultiBinding>
|
||||
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||
</userControls:ThemeComponentSelectionControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Sound Template -->
|
||||
|
@ -118,6 +141,14 @@
|
|||
</Button>
|
||||
<ComboBox ItemsSource="{Binding ElementName=BlockItemContentControl, Path=DataContext.SoundsAvailable}" SelectedValue="{Binding Value}" Style="{StaticResource MetroComboBox}" />
|
||||
<xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="300" HorizontalAlignment="Right" ToolTip="Volume"/>
|
||||
<userControls:ThemeComponentSelectionControl ThemeComponent="{Binding ThemeComponent}" Margin="0,2,0,0">
|
||||
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
|
||||
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
|
||||
<Binding Path="." />
|
||||
</MultiBinding>
|
||||
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||
</userControls:ThemeComponentSelectionControl>
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
|
||||
|
@ -129,6 +160,21 @@
|
|||
</Button>
|
||||
<ComboBox ItemsSource="{Binding ElementName=BlockItemContentControl, Path=DataContext.SoundsAvailable}" SelectedValue="{Binding Value}" Style="{StaticResource MetroComboBox}" />
|
||||
<xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="300" HorizontalAlignment="Right" ToolTip="Volume"/>
|
||||
<userControls:ThemeComponentSelectionControl ThemeComponent="{Binding ThemeComponent}" Margin="0,2,0,0">
|
||||
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
|
||||
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
|
||||
<Binding Path="." />
|
||||
</MultiBinding>
|
||||
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||
</userControls:ThemeComponentSelectionControl>
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Drop Icon Template -->
|
||||
<DataTemplate DataType="{x:Type blockItemTypes:IconBlockItem}">
|
||||
<WrapPanel HorizontalAlignment="Left">
|
||||
<userControls:ImageComboBoxControl/>
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ContentControl.Resources>
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Windows;
|
|||
using Filtration.Annotations;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
using Filtration.Views;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using Xceed.Wpf.Toolkit;
|
||||
|
@ -20,10 +22,10 @@ namespace Filtration.UserControls
|
|||
// ReSharper disable once PossibleNullReferenceException
|
||||
(Content as FrameworkElement).DataContext = this;
|
||||
|
||||
SetBlockColorCommand = new RelayCommand(OnSetBlockColorCommmand);
|
||||
SetBlockValueCommand = new RelayCommand(OnSetBlockValueCommmand);
|
||||
}
|
||||
|
||||
public RelayCommand SetBlockColorCommand { get; private set; }
|
||||
public RelayCommand SetBlockValueCommand { get; private set; }
|
||||
|
||||
public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register(
|
||||
"BlockItem",
|
||||
|
@ -88,12 +90,34 @@ namespace Filtration.UserControls
|
|||
"ShFusing", "ShRegal", "ShVaal"
|
||||
};
|
||||
|
||||
private void OnSetBlockColorCommmand()
|
||||
{
|
||||
var blockItem = BlockItem as ColorBlockItem;
|
||||
if (blockItem?.ThemeComponent == null) return;
|
||||
public List<string> IconsAvailable => new List<string> {
|
||||
"Icon1", "Icon2", "Icon3", "Icon4", "Icon5", "Icon6"
|
||||
};
|
||||
|
||||
blockItem.Color = blockItem.ThemeComponent.Color;
|
||||
private void OnSetBlockValueCommmand()
|
||||
{
|
||||
var blockItemWithTheme = BlockItem as IBlockItemWithTheme;
|
||||
if (blockItemWithTheme?.ThemeComponent == null) return;
|
||||
|
||||
var componentType = ((IBlockItemWithTheme)BlockItem).ThemeComponent.ComponentType;
|
||||
switch(componentType)
|
||||
{
|
||||
case ThemeComponentType.BackgroundColor:
|
||||
case ThemeComponentType.BorderColor:
|
||||
case ThemeComponentType.TextColor:
|
||||
var colorBlockItem = BlockItem as ColorBlockItem;
|
||||
colorBlockItem.Color = ((ColorThemeComponent)colorBlockItem.ThemeComponent).Color;
|
||||
break;
|
||||
case ThemeComponentType.FontSize:
|
||||
var integerBlockItem = BlockItem as IntegerBlockItem;
|
||||
integerBlockItem.Value = ((IntegerThemeComponent)integerBlockItem.ThemeComponent).Value;
|
||||
break;
|
||||
case ThemeComponentType.AlertSound:
|
||||
var strIntBlockItem = BlockItem as StrIntBlockItem;
|
||||
strIntBlockItem.Value = ((StrIntThemeComponent)strIntBlockItem.ThemeComponent).Value;
|
||||
strIntBlockItem.SecondValue = ((StrIntThemeComponent)strIntBlockItem.ThemeComponent).SecondValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<UserControl
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Filtration.UserControls"
|
||||
xmlns:Converters="clr-namespace:Filtration.Converters" x:Class="Filtration.UserControls.ImageComboBoxControl"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<Converters:DropIconConverter x:Key="DropIconConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<ComboBox ItemsSource="{Binding DataContext.IconsAvailable, ElementName=BlockItemContentControl}" SelectedValue="{Binding Value}" Style="{StaticResource MetroComboBox}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image MaxWidth="20" MaxHeight="20" Source="{Binding Converter={StaticResource DropIconConverter}, Mode=OneWay}" />
|
||||
<Label Content="{Binding}" VerticalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Filtration.UserControls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ImageComboBoxControl.xaml
|
||||
/// </summary>
|
||||
public partial class ImageComboBoxControl : UserControl
|
||||
{
|
||||
public ImageComboBoxControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:userControls="clr-namespace:Filtration.UserControls"
|
||||
xmlns:themeEditor="clr-namespace:Filtration.ObjectModel.ThemeEditor;assembly=Filtration.ObjectModel"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=userControls:ThemeComponentSelectionControl}"
|
||||
|
@ -21,7 +22,7 @@
|
|||
<Setter Property="MinHeight" Value="0" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<Grid.ColumnDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
@ -32,44 +33,47 @@
|
|||
Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<i:InvokeCommandAction Command="{Binding SetBlockColorCommand, RelativeSource={RelativeSource AncestorType=userControls:BlockItemControl}}" />
|
||||
<i:InvokeCommandAction Command="{Binding SetBlockValueCommand, RelativeSource={RelativeSource AncestorType=userControls:BlockItemControl}}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate >
|
||||
<ContentControl Content="{Binding}">
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition SharedSizeGroup="ComponentNameColumn" Width="Auto" />
|
||||
<ColumnDefinition SharedSizeGroup="ComponentColorColumn" Width="20" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding ComponentName}" Margin="0,0,2,0" />
|
||||
<Border Grid.Column="1" Background="{Binding Color, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ComboBoxItem}}" Value="{x:Null}">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding ComponentName}" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate >
|
||||
<ContentControl Content="{Binding}">
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition SharedSizeGroup="ComponentNameColumn" Width="Auto" />
|
||||
<ColumnDefinition SharedSizeGroup="ComponentValueColumn" Width="20" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding ComponentName}" Margin="0,0,2,0" />
|
||||
<ContentControl Content="{Binding Mode=OneWay}" Grid.Column="1">
|
||||
<ContentControl.Resources>
|
||||
<DataTemplate DataType="{x:Type themeEditor:ColorThemeComponent}">
|
||||
<Border Background="{Binding Color, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type themeEditor:IntegerThemeComponent}">
|
||||
<TextBlock Text="{Binding Value}" FontWeight="Bold" />
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type themeEditor:StrIntThemeComponent}">
|
||||
<!--TODO: How to show theese?-->
|
||||
</DataTemplate>
|
||||
</ContentControl.Resources>
|
||||
</ContentControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<userControls:CrossButton Grid.Column="1" Height="12" Command="{Binding RemoveThemeComponentCommand}" VerticalAlignment="Top" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<TextBlock Grid.Column="0" Grid.ColumnSpan="2" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource InverseBooleanVisibilityConverter}}" VerticalAlignment="Center">
|
||||
|
|
|
@ -174,7 +174,9 @@ namespace Filtration.ViewModels
|
|||
typeof (FontSizeBlockItem),
|
||||
typeof (SoundBlockItem),
|
||||
typeof (PositionalSoundBlockItem),
|
||||
typeof (DisableDropSoundBlockItem)
|
||||
typeof (DisableDropSoundBlockItem),
|
||||
typeof (IconBlockItem),
|
||||
typeof (BeamBlockItem)
|
||||
};
|
||||
|
||||
public bool BlockEnabled
|
||||
|
@ -214,6 +216,8 @@ namespace Filtration.ViewModels
|
|||
public Color DisplayBackgroundColor => Block.DisplayBackgroundColor;
|
||||
public Color DisplayBorderColor => Block.DisplayBorderColor;
|
||||
public double DisplayFontSize => Block.DisplayFontSize/1.8;
|
||||
public string DisplayIcon => Block.DisplayIcon;
|
||||
public Color DisplayBeamColor => Block.DisplayBeamColor;
|
||||
|
||||
public bool HasSound => Block.HasBlockItemOfType<SoundBlockItem>();
|
||||
public bool HasPositionalSound => Block.HasBlockItemOfType<PositionalSoundBlockItem>();
|
||||
|
@ -424,7 +428,7 @@ namespace Filtration.ViewModels
|
|||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
Block.IsEdited = true;
|
||||
//if (sender is IAudioVisualBlockItem)
|
||||
//{
|
||||
RefreshBlockPreview();
|
||||
|
@ -437,6 +441,8 @@ namespace Filtration.ViewModels
|
|||
RaisePropertyChanged(nameof(DisplayBackgroundColor));
|
||||
RaisePropertyChanged(nameof(DisplayBorderColor));
|
||||
RaisePropertyChanged(nameof(DisplayFontSize));
|
||||
RaisePropertyChanged(nameof(DisplayIcon));
|
||||
RaisePropertyChanged(nameof(DisplayBeamColor));
|
||||
RaisePropertyChanged(nameof(HasSound));
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,14 @@ namespace Filtration.ViewModels
|
|||
void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel);
|
||||
IItemFilterBlockBase BaseBlock { get; }
|
||||
bool IsDirty { get; set; }
|
||||
bool IsVisible { get; set; }
|
||||
event EventHandler BlockBecameDirty;
|
||||
}
|
||||
|
||||
internal abstract class ItemFilterBlockViewModelBase : ViewModelBase, IItemFilterBlockViewModelBase
|
||||
{
|
||||
private bool _isDirty;
|
||||
private bool _isVisible;
|
||||
|
||||
public ItemFilterBlockViewModelBase()
|
||||
{
|
||||
|
@ -28,6 +30,8 @@ namespace Filtration.ViewModels
|
|||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand);
|
||||
|
||||
_isVisible = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,6 +70,16 @@ namespace Filtration.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get => _isVisible;
|
||||
set
|
||||
{
|
||||
_isVisible = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCopyBlockCommand()
|
||||
{
|
||||
_parentScriptViewModel.CopyBlock(this);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Filtration.ObjectModel;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using System;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
{
|
||||
|
@ -6,10 +8,22 @@ namespace Filtration.ViewModels
|
|||
{
|
||||
IItemFilterCommentBlock ItemFilterCommentBlock { get; }
|
||||
string Comment { get; }
|
||||
bool IsExpanded { get; set; }
|
||||
bool HasChild { get; set; }
|
||||
}
|
||||
|
||||
internal class ItemFilterCommentBlockViewModel : ItemFilterBlockViewModelBase, IItemFilterCommentBlockViewModel
|
||||
{
|
||||
private bool _isExpanded;
|
||||
private bool _hasChild;
|
||||
|
||||
public ItemFilterCommentBlockViewModel()
|
||||
{
|
||||
_isExpanded = true;
|
||||
|
||||
ToggleSectionCommand = new RelayCommand(OnToggleSectionCommand);
|
||||
}
|
||||
|
||||
public override void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
|
||||
{
|
||||
_parentScriptViewModel = itemFilterScriptViewModel;
|
||||
|
@ -19,6 +33,8 @@ namespace Filtration.ViewModels
|
|||
base.Initialise(itemfilterBlock, itemFilterScriptViewModel);
|
||||
}
|
||||
|
||||
public RelayCommand ToggleSectionCommand { get; }
|
||||
|
||||
public IItemFilterCommentBlock ItemFilterCommentBlock { get; private set; }
|
||||
|
||||
public string Comment
|
||||
|
@ -34,8 +50,60 @@ namespace Filtration.ViewModels
|
|||
ItemFilterCommentBlock.Comment = value;
|
||||
IsDirty = true;
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged("Header");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Header
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] commentLines = ItemFilterCommentBlock.Comment.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
||||
var titleOffset = 1;
|
||||
if (commentLines.Length > 1 && (commentLines[0].TrimStart(' ').StartsWith(@"============") || commentLines[0].TrimStart(' ').StartsWith(@"------------")))
|
||||
{
|
||||
titleOffset = 3;
|
||||
commentLines[0] = commentLines[1];
|
||||
}
|
||||
|
||||
commentLines[0] = commentLines[0].TrimStart(' ');
|
||||
if (commentLines[0].Length > 80)
|
||||
{
|
||||
commentLines[0] = commentLines[0].Substring(0, 80) + " (...)";
|
||||
}
|
||||
else if (commentLines.Length > titleOffset)
|
||||
{
|
||||
commentLines[0] = commentLines[0] + " (...)";
|
||||
}
|
||||
|
||||
return commentLines[0];
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get => _isExpanded;
|
||||
set
|
||||
{
|
||||
_isExpanded = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasChild
|
||||
{
|
||||
get => _hasChild;
|
||||
set
|
||||
{
|
||||
_hasChild = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnToggleSectionCommand()
|
||||
{
|
||||
_parentScriptViewModel.ToggleSection(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ using System.ComponentModel;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
@ -44,11 +45,16 @@ namespace Filtration.ViewModels
|
|||
void SetDirtyFlag();
|
||||
bool HasSelectedEnabledBlock();
|
||||
bool HasSelectedDisabledBlock();
|
||||
bool HasSelectedCommentBlock();
|
||||
|
||||
RelayCommand AddBlockCommand { get; }
|
||||
RelayCommand AddSectionCommand { get; }
|
||||
RelayCommand DisableBlockCommand { get; }
|
||||
RelayCommand EnableBlockCommand { get; }
|
||||
RelayCommand DisableSectionCommand { get; }
|
||||
RelayCommand EnableSectionCommand { get; }
|
||||
RelayCommand ExpandSectionCommand { get; }
|
||||
RelayCommand CollapseSectionCommand { get; }
|
||||
RelayCommand DeleteBlockCommand { get; }
|
||||
RelayCommand MoveBlockUpCommand { get; }
|
||||
RelayCommand MoveBlockDownCommand { get; }
|
||||
|
@ -60,6 +66,8 @@ namespace Filtration.ViewModels
|
|||
RelayCommand PasteBlockStyleCommand { get; }
|
||||
RelayCommand ExpandAllBlocksCommand { get; }
|
||||
RelayCommand CollapseAllBlocksCommand { get; }
|
||||
RelayCommand ExpandAllSectionsCommand { get; }
|
||||
RelayCommand CollapseAllSectionsCommand { get; }
|
||||
RelayCommand<bool> ToggleShowAdvancedCommand { get; }
|
||||
RelayCommand ClearFilterCommand { get; }
|
||||
|
||||
|
@ -74,6 +82,7 @@ namespace Filtration.ViewModels
|
|||
void MoveBlockUp(IItemFilterBlockViewModelBase targetBlockViewModelBase);
|
||||
void MoveBlockDown(IItemFilterBlockViewModelBase targetBlockViewModelBase);
|
||||
void MoveBlockToBottom(IItemFilterBlockViewModelBase targetBlockViewModelBase);
|
||||
void ToggleSection(IItemFilterCommentBlockViewModel targetCommentBlockViewModelBase, bool updateViewModels = true);
|
||||
}
|
||||
|
||||
internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel
|
||||
|
@ -92,6 +101,7 @@ namespace Filtration.ViewModels
|
|||
private IItemFilterBlockViewModelBase _selectedBlockViewModel;
|
||||
private IItemFilterCommentBlockViewModel _sectionBrowserSelectedBlockViewModel;
|
||||
private readonly ObservableCollection<IItemFilterBlockViewModelBase> _itemFilterBlockViewModels;
|
||||
private ObservableCollection<IItemFilterBlockViewModelBase> _viewItemFilterBlockViewModels;
|
||||
private ICollectionView _itemFilterBlockViewModelsCollectionView;
|
||||
private Predicate<IItemFilterBlockViewModel> _blockFilterPredicate;
|
||||
private ICommandManager _scriptCommandManager;
|
||||
|
@ -131,18 +141,26 @@ namespace Filtration.ViewModels
|
|||
AddSectionCommand = new RelayCommand(OnAddCommentBlockCommand, () => SelectedBlockViewModel != null);
|
||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, HasSelectedEnabledBlock);
|
||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, HasSelectedDisabledBlock);
|
||||
DisableSectionCommand = new RelayCommand(OnDisableSectionCommand, HasSelectedCommentBlock);
|
||||
EnableSectionCommand = new RelayCommand(OnEnableSectionCommand, HasSelectedCommentBlock);
|
||||
ExpandSectionCommand = new RelayCommand(OnExpandSectionCommand, HasSelectedCommentBlock);
|
||||
CollapseSectionCommand = new RelayCommand(OnCollapseSectionCommand, HasSelectedCommentBlock);
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
|
||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null);
|
||||
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
|
||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => SelectedBlockViewModel != null);
|
||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand);
|
||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand);
|
||||
ExpandAllSectionsCommand = new RelayCommand(ExpandAllSections);
|
||||
CollapseAllSectionsCommand = new RelayCommand(CollapseAllSections);
|
||||
|
||||
var icon = new BitmapImage();
|
||||
icon.BeginInit();
|
||||
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/script_icon.png");
|
||||
icon.EndInit();
|
||||
IconSource = icon;
|
||||
|
||||
_viewItemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
|
||||
}
|
||||
|
||||
public void Initialise(IItemFilterScript itemFilterScript, bool newScript)
|
||||
|
@ -164,6 +182,9 @@ namespace Filtration.ViewModels
|
|||
|
||||
Title = Filename;
|
||||
ContentId = "ScriptContentId";
|
||||
|
||||
CollapseAllSections();
|
||||
UpdateBlockModelsForView();
|
||||
}
|
||||
|
||||
private void ItemFilterBlocksOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
|
||||
|
@ -186,6 +207,8 @@ namespace Filtration.ViewModels
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateBlockModelsForView();
|
||||
}
|
||||
|
||||
private void AddItemFilterBlockViewModels(IEnumerable<IItemFilterBlockBase> itemFilterBlocks, int addAtIndex)
|
||||
|
@ -245,12 +268,18 @@ namespace Filtration.ViewModels
|
|||
public RelayCommand AddSectionCommand { get; }
|
||||
public RelayCommand EnableBlockCommand { get; }
|
||||
public RelayCommand DisableBlockCommand { get; }
|
||||
public RelayCommand DisableSectionCommand { get; }
|
||||
public RelayCommand EnableSectionCommand { get; }
|
||||
public RelayCommand ExpandSectionCommand { get; }
|
||||
public RelayCommand CollapseSectionCommand { get; }
|
||||
public RelayCommand CopyBlockCommand { get; }
|
||||
public RelayCommand CopyBlockStyleCommand { get; }
|
||||
public RelayCommand PasteBlockCommand { get; }
|
||||
public RelayCommand PasteBlockStyleCommand { get; }
|
||||
public RelayCommand ExpandAllBlocksCommand { get; }
|
||||
public RelayCommand CollapseAllBlocksCommand { get; }
|
||||
public RelayCommand ExpandAllSectionsCommand { get; }
|
||||
public RelayCommand CollapseAllSectionsCommand { get; }
|
||||
|
||||
public bool IsActiveDocument
|
||||
{
|
||||
|
@ -264,6 +293,19 @@ namespace Filtration.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<IItemFilterBlockViewModelBase> ViewItemFilterBlockViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return _viewItemFilterBlockViewModels;
|
||||
}
|
||||
set
|
||||
{
|
||||
_viewItemFilterBlockViewModels = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<IItemFilterBlockViewModelBase> ItemFilterBlockViewModels
|
||||
{
|
||||
get
|
||||
|
@ -359,6 +401,13 @@ namespace Filtration.ViewModels
|
|||
return SelectedBlockViewModel != null;
|
||||
}
|
||||
|
||||
public bool HasSelectedCommentBlock()
|
||||
{
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
|
||||
return selectedBlockViewModel != null;
|
||||
}
|
||||
|
||||
public IItemFilterBlockViewModelBase SelectedBlockViewModel
|
||||
{
|
||||
get => _selectedBlockViewModel;
|
||||
|
@ -514,7 +563,7 @@ namespace Filtration.ViewModels
|
|||
Script.ThemeComponents.Where(
|
||||
t =>
|
||||
Script.ItemFilterBlocks.OfType<ItemFilterBlock>().Count(
|
||||
b => b.BlockItems.OfType<ColorBlockItem>().Count(i => i.ThemeComponent == t) > 0) == 0).ToList();
|
||||
b => b.BlockItems.OfType<IBlockItemWithTheme>().Count(i => i.ThemeComponent == t) > 0) == 0).ToList();
|
||||
|
||||
if (unusedThemeComponents.Count <= 0) return true;
|
||||
|
||||
|
@ -634,7 +683,15 @@ namespace Filtration.ViewModels
|
|||
|
||||
private void OnCopyBlockCommand()
|
||||
{
|
||||
CopyBlock(SelectedBlockViewModel);
|
||||
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
|
||||
{
|
||||
CopyBlock(SelectedBlockViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
CopySection(commentBlockViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyBlock(IItemFilterBlockViewModelBase targetBlockViewModel)
|
||||
|
@ -649,6 +706,26 @@ namespace Filtration.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void CopySection(IItemFilterCommentBlockViewModel targetCommentBlockViewModel)
|
||||
{
|
||||
var sectionStart = ItemFilterBlockViewModels.IndexOf(targetCommentBlockViewModel) + 1;
|
||||
var copyText = _blockTranslator.TranslateItemFilterBlockBaseToString(targetCommentBlockViewModel.BaseBlock);
|
||||
while (sectionStart < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionStart] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
copyText += Environment.NewLine + "##CopySection##" + Environment.NewLine + _blockTranslator.TranslateItemFilterBlockBaseToString(ItemFilterBlockViewModels[sectionStart].BaseBlock);
|
||||
sectionStart++;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_clipboardService.SetClipboardText(copyText);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCopyBlockStyleCommand()
|
||||
{
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterBlockViewModel;
|
||||
|
@ -709,15 +786,65 @@ namespace Filtration.ViewModels
|
|||
|
||||
public void PasteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
var commentBlock = targetBlockViewModelBase as IItemFilterCommentBlockViewModel;
|
||||
if(commentBlock != null && !commentBlock.IsExpanded)
|
||||
{
|
||||
var blockIndex = ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase) + 1;
|
||||
while (blockIndex < ItemFilterBlockViewModels.Count && (ItemFilterBlockViewModels[blockIndex] as IItemFilterCommentBlockViewModel) == null)
|
||||
{
|
||||
blockIndex++;
|
||||
}
|
||||
targetBlockViewModelBase = ItemFilterBlockViewModels[blockIndex - 1];
|
||||
}
|
||||
try
|
||||
{
|
||||
var clipboardText = _clipboardService.GetClipboardText();
|
||||
if (string.IsNullOrEmpty(clipboardText)) return;
|
||||
|
||||
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script, true); // TODO: Doesn't handle pasting comment blocks?
|
||||
if (translatedBlock == null) return;
|
||||
string[] blockTexts = clipboardText.Split(new string[] { Environment.NewLine + "##CopySection##" + Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
_scriptCommandManager.ExecuteCommand(new PasteBlockCommand(Script, translatedBlock, targetBlockViewModelBase.BaseBlock));
|
||||
List<IItemFilterBlockBase> blocksToPaste = new List<IItemFilterBlockBase>();
|
||||
foreach (var curBlock in blockTexts)
|
||||
{
|
||||
IItemFilterBlockBase translatedBlock;
|
||||
var preparedString = PrepareBlockForParsing(curBlock);
|
||||
var isCommentBlock = true;
|
||||
string[] textLines = preparedString.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
||||
foreach(var line in textLines)
|
||||
{
|
||||
if(!line.StartsWith(@"#"))
|
||||
{
|
||||
isCommentBlock = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isCommentBlock)
|
||||
{
|
||||
translatedBlock = _blockTranslator.TranslateStringToItemFilterCommentBlock(preparedString, Script, curBlock);
|
||||
}
|
||||
else
|
||||
{
|
||||
translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(preparedString, Script, curBlock, true);
|
||||
}
|
||||
|
||||
if (translatedBlock == null) continue;
|
||||
|
||||
blocksToPaste.Add(translatedBlock);
|
||||
}
|
||||
|
||||
if (blocksToPaste.Count < 1)
|
||||
return;
|
||||
|
||||
var blockIndex = ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase) + 1;
|
||||
_scriptCommandManager.ExecuteCommand(new PasteSectionCommand(Script, blocksToPaste, targetBlockViewModelBase.BaseBlock));
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels[blockIndex];
|
||||
RaisePropertyChanged("SelectedBlockViewModel");
|
||||
var firstBlockAsComment = blocksToPaste[0] as IItemFilterCommentBlock;
|
||||
if (firstBlockAsComment != null)
|
||||
{
|
||||
OnCollapseSectionCommand();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -728,39 +855,250 @@ namespace Filtration.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private string PrepareBlockForParsing(string inputString)
|
||||
{
|
||||
inputString = inputString.Replace("\t", "");
|
||||
var lines = Regex.Split(inputString, "\r\n|\r|\n").ToList();
|
||||
for (var i = 0; i < lines.Count; i++)
|
||||
{
|
||||
if (lines[i].Length == 0)
|
||||
{
|
||||
lines.RemoveAt(i--);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
for (var i = lines.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (lines[i].Length == 0)
|
||||
{
|
||||
lines.RemoveAt(i++);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
var allCommented = true;
|
||||
for (var i = 0; i < lines.Count; i++)
|
||||
{
|
||||
lines[i] = Regex.Replace(lines[i], @"\s+", " ");
|
||||
if(lines[i][0] == '#')
|
||||
{
|
||||
if (lines[i].Length > 1 && lines[i][1] != ' ')
|
||||
{
|
||||
lines[i] = "# " + lines[i].Substring(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
allCommented = false;
|
||||
}
|
||||
}
|
||||
|
||||
var disabledBlock = -1;
|
||||
if (allCommented)
|
||||
{
|
||||
for (var i = 0; i < lines.Count; i++)
|
||||
{
|
||||
if (lines[i].StartsWith("#"))
|
||||
{
|
||||
string curLine = Regex.Replace(lines[i].Substring(1), @"\s+", "");
|
||||
if ((curLine.StartsWith("Show") || curLine.StartsWith("Hide")) && (curLine.Length == 4 || curLine[4] == '#'))
|
||||
{
|
||||
lines[i] = lines[i].Substring(0, 6) + "Disabled" + lines[i].Substring(6);
|
||||
disabledBlock = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(disabledBlock >= 0)
|
||||
{
|
||||
for (var i = disabledBlock; i < lines.Count; i++)
|
||||
{
|
||||
lines[i] = lines[i].Substring(2);
|
||||
}
|
||||
}
|
||||
|
||||
return string.Join(Environment.NewLine, lines);
|
||||
}
|
||||
|
||||
private void OnMoveBlockToTopCommand()
|
||||
{
|
||||
MoveBlockToTop(SelectedBlockViewModel);
|
||||
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
|
||||
{
|
||||
MoveBlockToTop(SelectedBlockViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveSectionToTop(commentBlockViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMoveBlockUpCommand()
|
||||
{
|
||||
MoveBlockUp(SelectedBlockViewModel);
|
||||
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if(commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
|
||||
{
|
||||
MoveBlockUp(SelectedBlockViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveSectionUp(commentBlockViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveBlockUp(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new MoveBlockUpCommand(Script, targetBlockViewModelBase?.BaseBlock));
|
||||
var blockIndex = ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase);
|
||||
if (ItemFilterBlockViewModels[blockIndex - 1].IsVisible)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new MoveBlockUpCommand(Script, targetBlockViewModelBase?.BaseBlock));
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels[blockIndex - 1];
|
||||
RaisePropertyChanged("SelectedBlockViewModel");
|
||||
}
|
||||
else
|
||||
{
|
||||
var aboveSectionStart = blockIndex - 1;
|
||||
while(ItemFilterBlockViewModels[aboveSectionStart] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
aboveSectionStart--;
|
||||
}
|
||||
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, blockIndex, 1, aboveSectionStart));
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels[aboveSectionStart];
|
||||
RaisePropertyChanged("SelectedBlockViewModel");
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveSectionUp(IItemFilterCommentBlockViewModel targetCommentBlockViewModel)
|
||||
{
|
||||
var sectionStart = ItemFilterBlockViewModels.IndexOf(targetCommentBlockViewModel);
|
||||
var sectionEnd = sectionStart + 1;
|
||||
while(sectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
sectionEnd++;
|
||||
}
|
||||
|
||||
var newLocation = sectionStart - 1;
|
||||
if (ItemFilterBlockViewModels[newLocation].IsVisible)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, sectionStart, sectionEnd - sectionStart, newLocation));
|
||||
}
|
||||
else
|
||||
{
|
||||
while (ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
newLocation--;
|
||||
}
|
||||
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, sectionStart, sectionEnd - sectionStart, newLocation));
|
||||
}
|
||||
|
||||
ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel);
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation];
|
||||
RaisePropertyChanged("SelectedBlockViewModel");
|
||||
}
|
||||
|
||||
private void OnMoveBlockDownCommand()
|
||||
{
|
||||
MoveBlockDown(SelectedBlockViewModel);
|
||||
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
|
||||
{
|
||||
MoveBlockDown(SelectedBlockViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveSectionDown(commentBlockViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveBlockDown(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new MoveBlockDownCommand(Script, targetBlockViewModelBase?.BaseBlock));
|
||||
var blockIndex = ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase);
|
||||
var beloveBlockAsComment = ItemFilterBlockViewModels[blockIndex + 1] as IItemFilterCommentBlockViewModel;
|
||||
if (beloveBlockAsComment == null || beloveBlockAsComment.IsExpanded)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new MoveBlockDownCommand(Script, targetBlockViewModelBase?.BaseBlock));
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels[blockIndex + 1];
|
||||
RaisePropertyChanged("SelectedBlockViewModel");
|
||||
}
|
||||
else
|
||||
{
|
||||
var beloveSectionEnd = blockIndex + 2;
|
||||
while (beloveSectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[beloveSectionEnd] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
beloveSectionEnd++;
|
||||
}
|
||||
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, blockIndex, 1, beloveSectionEnd - 1));
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels[beloveSectionEnd - 1];
|
||||
RaisePropertyChanged("SelectedBlockViewModel");
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveSectionDown(IItemFilterCommentBlockViewModel targetCommentBlockViewModel)
|
||||
{
|
||||
var sectionStart = ItemFilterBlockViewModels.IndexOf(targetCommentBlockViewModel);
|
||||
var sectionEnd = sectionStart + 1;
|
||||
while (sectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
sectionEnd++;
|
||||
}
|
||||
|
||||
if (sectionEnd >= ItemFilterBlockViewModels.Count)
|
||||
return;
|
||||
|
||||
var sectionSize = sectionEnd - sectionStart;
|
||||
|
||||
var newLocation = sectionStart + 1;
|
||||
var beloveBlockAsComment = ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel;
|
||||
if (beloveBlockAsComment == null || beloveBlockAsComment.IsExpanded)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, sectionStart, sectionSize, newLocation));
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((newLocation + sectionSize) < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[newLocation + sectionSize] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
newLocation++;
|
||||
}
|
||||
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, sectionStart, sectionEnd - sectionStart, newLocation));
|
||||
}
|
||||
|
||||
ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel);
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation];
|
||||
RaisePropertyChanged("SelectedBlockViewModel");
|
||||
}
|
||||
|
||||
private void OnMoveBlockToBottomCommand()
|
||||
{
|
||||
MoveBlockToBottom(SelectedBlockViewModel);
|
||||
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
|
||||
{
|
||||
MoveBlockToBottom(SelectedBlockViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveSectionToBottom(commentBlockViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAddBlockCommand()
|
||||
{
|
||||
AddBlock(SelectedBlockViewModel);
|
||||
var selectedBlockAsCommentBlock = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if(selectedBlockAsCommentBlock == null || selectedBlockAsCommentBlock.IsExpanded)
|
||||
{
|
||||
AddBlock(SelectedBlockViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
var sectionStart = ItemFilterBlockViewModels.IndexOf(selectedBlockAsCommentBlock);
|
||||
var sectionEnd = sectionStart + 1;
|
||||
while (sectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
sectionEnd++;
|
||||
}
|
||||
AddBlock(ItemFilterBlockViewModels[sectionEnd - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
|
@ -776,7 +1114,22 @@ namespace Filtration.ViewModels
|
|||
|
||||
public void DeleteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new RemoveBlockCommand(Script, targetBlockViewModelBase.BaseBlock));
|
||||
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new RemoveBlockCommand(Script, targetBlockViewModelBase.BaseBlock));
|
||||
}
|
||||
else
|
||||
{
|
||||
var sectionStart = ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase);
|
||||
var sectionEnd = sectionStart + 1;
|
||||
while (sectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
sectionEnd++;
|
||||
}
|
||||
|
||||
_scriptCommandManager.ExecuteCommand(new RemoveSectionCommand(Script, sectionStart, sectionEnd - sectionStart));
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveBlockToBottom(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
|
@ -784,11 +1137,43 @@ namespace Filtration.ViewModels
|
|||
_scriptCommandManager.ExecuteCommand(new MoveBlockToBottomCommand(Script, targetBlockViewModelBase.BaseBlock));
|
||||
}
|
||||
|
||||
public void MoveSectionToBottom(IItemFilterCommentBlockViewModel targetCommentBlockViewModel)
|
||||
{
|
||||
var sectionStart = ItemFilterBlockViewModels.IndexOf(targetCommentBlockViewModel);
|
||||
var sectionEnd = sectionStart + 1;
|
||||
while (sectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
sectionEnd++;
|
||||
}
|
||||
|
||||
var newLocation = ItemFilterBlockViewModels.Count - (sectionEnd - sectionStart);
|
||||
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, sectionStart, sectionEnd - sectionStart, newLocation));
|
||||
|
||||
ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel);
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation];
|
||||
}
|
||||
|
||||
public void MoveBlockToTop(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new MoveBlockToTopCommand(Script, targetBlockViewModelBase.BaseBlock));
|
||||
}
|
||||
|
||||
public void MoveSectionToTop(IItemFilterCommentBlockViewModel targetCommentBlockViewModel)
|
||||
{
|
||||
var sectionStart = ItemFilterBlockViewModels.IndexOf(targetCommentBlockViewModel);
|
||||
var sectionEnd = sectionStart + 1;
|
||||
while (sectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
sectionEnd++;
|
||||
}
|
||||
|
||||
var newLocation = 0;
|
||||
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, sectionStart, sectionEnd - sectionStart, newLocation));
|
||||
|
||||
ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel);
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation];
|
||||
}
|
||||
|
||||
private void OnBlockBecameDirty(object sender, EventArgs e)
|
||||
{
|
||||
SetDirtyFlag();
|
||||
|
@ -796,7 +1181,21 @@ namespace Filtration.ViewModels
|
|||
|
||||
private void OnAddCommentBlockCommand()
|
||||
{
|
||||
AddCommentBlock(SelectedBlockViewModel);
|
||||
var selectedBlockAsCommentBlock = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (selectedBlockAsCommentBlock == null || selectedBlockAsCommentBlock.IsExpanded)
|
||||
{
|
||||
AddCommentBlock(SelectedBlockViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
var sectionStart = ItemFilterBlockViewModels.IndexOf(selectedBlockAsCommentBlock);
|
||||
var sectionEnd = sectionStart + 1;
|
||||
while (sectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel == null)
|
||||
{
|
||||
sectionEnd++;
|
||||
}
|
||||
AddCommentBlock(ItemFilterBlockViewModels[sectionEnd - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExpandAllBlocksCommand()
|
||||
|
@ -837,5 +1236,181 @@ namespace Filtration.ViewModels
|
|||
selectedBlockViewModel.BlockEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisableSectionCommand()
|
||||
{
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (selectedBlockViewModel != null)
|
||||
{
|
||||
var sectionIndex = ItemFilterBlockViewModels.IndexOf(selectedBlockViewModel);
|
||||
for (int i = sectionIndex + 1; i < ItemFilterBlockViewModels.Count; i++)
|
||||
{
|
||||
var block = ItemFilterBlockViewModels[i] as IItemFilterBlockViewModel;
|
||||
if (block != null)
|
||||
{
|
||||
block.BlockEnabled = false;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnableSectionCommand()
|
||||
{
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (selectedBlockViewModel != null)
|
||||
{
|
||||
var sectionIndex = ItemFilterBlockViewModels.IndexOf(selectedBlockViewModel);
|
||||
for (int i = sectionIndex + 1; i < ItemFilterBlockViewModels.Count; i++)
|
||||
{
|
||||
var block = ItemFilterBlockViewModels[i] as IItemFilterBlockViewModel;
|
||||
if (block != null)
|
||||
{
|
||||
block.BlockEnabled = true;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExpandSectionCommand()
|
||||
{
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (selectedBlockViewModel != null && !selectedBlockViewModel.IsExpanded)
|
||||
{
|
||||
ToggleSection(selectedBlockViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollapseSectionCommand()
|
||||
{
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
|
||||
if (selectedBlockViewModel != null && selectedBlockViewModel.IsExpanded)
|
||||
{
|
||||
ToggleSection(selectedBlockViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleSection(IItemFilterCommentBlockViewModel targetCommentBlockViewModelBase, bool updateViewModels = true)
|
||||
{
|
||||
var newState = !targetCommentBlockViewModelBase.IsExpanded;
|
||||
targetCommentBlockViewModelBase.IsExpanded = newState;
|
||||
var sectionIndex = ItemFilterBlockViewModels.IndexOf(targetCommentBlockViewModelBase);
|
||||
var viewIndex = ViewItemFilterBlockViewModels.IndexOf(targetCommentBlockViewModelBase);
|
||||
for (int i = sectionIndex + 1; i < ItemFilterBlockViewModels.Count; i++)
|
||||
{
|
||||
var block = ItemFilterBlockViewModels[i] as IItemFilterBlockViewModel;
|
||||
if (block != null)
|
||||
{
|
||||
if (newState)
|
||||
viewIndex++;
|
||||
|
||||
if (newState == block.IsVisible)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(updateViewModels)
|
||||
{
|
||||
if(newState)
|
||||
{
|
||||
if(viewIndex < ViewItemFilterBlockViewModels.Count)
|
||||
{
|
||||
ViewItemFilterBlockViewModels.Insert(viewIndex, block);
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewItemFilterBlockViewModels.Add(block);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewItemFilterBlockViewModels.RemoveAt(viewIndex + 1);
|
||||
}
|
||||
}
|
||||
block.IsVisible = newState;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateBlockModelsForView()
|
||||
{
|
||||
ObservableCollection<IItemFilterBlockViewModelBase> blocksForView = new ObservableCollection<IItemFilterBlockViewModelBase>();
|
||||
for (var i = 0; i < ItemFilterBlockViewModels.Count; i++)
|
||||
{
|
||||
var block = ItemFilterBlockViewModels[i];
|
||||
if (block.IsVisible)
|
||||
{
|
||||
blocksForView.Add(block);
|
||||
|
||||
var blockAsComment = block as IItemFilterCommentBlockViewModel;
|
||||
if(blockAsComment != null && i < (ItemFilterBlockViewModels.Count - 1))
|
||||
{
|
||||
var followingBlock = ItemFilterBlockViewModels[i + 1] as IItemFilterBlockViewModel;
|
||||
if(followingBlock != null)
|
||||
{
|
||||
blockAsComment.HasChild = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
blockAsComment.HasChild = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ViewItemFilterBlockViewModels = blocksForView;
|
||||
}
|
||||
|
||||
private void CollapseAllSections()
|
||||
{
|
||||
ObservableCollection<IItemFilterBlockViewModelBase> blocksForView = new ObservableCollection<IItemFilterBlockViewModelBase>();
|
||||
for (int i = 0; i < ItemFilterBlockViewModels.Count; i++)
|
||||
{
|
||||
var block = ItemFilterBlockViewModels[i] as IItemFilterCommentBlockViewModel;
|
||||
if (block != null)
|
||||
{
|
||||
blocksForView.Add(block);
|
||||
|
||||
if(block.IsExpanded)
|
||||
{
|
||||
ToggleSection(block, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectedBlockViewModel == null && blocksForView.Count > 0)
|
||||
{
|
||||
SelectedBlockViewModel = blocksForView[0];
|
||||
}
|
||||
|
||||
ViewItemFilterBlockViewModels = blocksForView;
|
||||
}
|
||||
|
||||
private void ExpandAllSections()
|
||||
{
|
||||
ObservableCollection<IItemFilterBlockViewModelBase> blocksForView = new ObservableCollection<IItemFilterBlockViewModelBase>();
|
||||
for (int i = 0; i < ItemFilterBlockViewModels.Count; i++)
|
||||
{
|
||||
blocksForView.Add(ItemFilterBlockViewModels[i]);
|
||||
|
||||
var block = ItemFilterBlockViewModels[i] as IItemFilterCommentBlockViewModel;
|
||||
if (block != null && !block.IsExpanded)
|
||||
{
|
||||
ToggleSection(block, false);
|
||||
}
|
||||
}
|
||||
|
||||
if(SelectedBlockViewModel == null && blocksForView.Count > 0)
|
||||
{
|
||||
SelectedBlockViewModel = blocksForView[0];
|
||||
}
|
||||
|
||||
ViewItemFilterBlockViewModels = blocksForView;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,6 +100,10 @@ namespace Filtration.ViewModels
|
|||
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);
|
||||
ExpandSectionCommand = new RelayCommand(OnExpandSectionCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedCommentBlock);
|
||||
CollapseSectionCommand = new RelayCommand(OnCollapseSectionCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedCommentBlock);
|
||||
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
|
@ -110,11 +114,16 @@ namespace Filtration.ViewModels
|
|||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddFontSizeThemeComponentCommand = new RelayCommand(OnAddFontSizeThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddAlertSoundThemeComponentCommand = new RelayCommand(OnAddAlertSoundThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable && _avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
||||
|
||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
ExpandAllSectionsCommand = new RelayCommand(OnExpandAllSectionsCommand, () => ActiveDocumentIsScript);
|
||||
CollapseAllSectionsCommand = new RelayCommand(OnCollapseAllSectionsCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript);
|
||||
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
|
@ -206,6 +215,8 @@ namespace Filtration.ViewModels
|
|||
public RelayCommand AddTextColorThemeComponentCommand { get; }
|
||||
public RelayCommand AddBackgroundColorThemeComponentCommand { get; }
|
||||
public RelayCommand AddBorderColorThemeComponentCommand { get; }
|
||||
public RelayCommand AddFontSizeThemeComponentCommand { get; }
|
||||
public RelayCommand AddAlertSoundThemeComponentCommand { get; }
|
||||
public RelayCommand DeleteThemeComponentCommand { get; }
|
||||
|
||||
public RelayCommand AddBlockCommand { get; }
|
||||
|
@ -213,6 +224,10 @@ namespace Filtration.ViewModels
|
|||
public RelayCommand DeleteBlockCommand { get; }
|
||||
public RelayCommand DisableBlockCommand { get; }
|
||||
public RelayCommand EnableBlockCommand { get; }
|
||||
public RelayCommand DisableSectionCommand { get; }
|
||||
public RelayCommand EnableSectionCommand { get; }
|
||||
public RelayCommand ExpandSectionCommand { get; }
|
||||
public RelayCommand CollapseSectionCommand { get; }
|
||||
|
||||
public RelayCommand MoveBlockUpCommand { get; }
|
||||
public RelayCommand MoveBlockDownCommand { get; }
|
||||
|
@ -222,6 +237,9 @@ namespace Filtration.ViewModels
|
|||
public RelayCommand ExpandAllBlocksCommand { get; }
|
||||
public RelayCommand CollapseAllBlocksCommand { get; }
|
||||
|
||||
public RelayCommand ExpandAllSectionsCommand { get; }
|
||||
public RelayCommand CollapseAllSectionsCommand { get; }
|
||||
|
||||
public RelayCommand<bool> ToggleShowAdvancedCommand { get; }
|
||||
public RelayCommand ClearFiltersCommand { get; }
|
||||
|
||||
|
@ -260,6 +278,9 @@ namespace Filtration.ViewModels
|
|||
|
||||
public bool ActiveScriptHasSelectedDisabledBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedDisabledBlock();
|
||||
|
||||
public bool ActiveScriptHasSelectedCommentBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedCommentBlock();
|
||||
|
||||
|
||||
public bool ActiveThemeIsEditable => AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme;
|
||||
|
||||
private bool ActiveDocumentIsEditable()
|
||||
|
@ -595,6 +616,26 @@ namespace Filtration.ViewModels
|
|||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.EnableBlockCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnDisableSectionCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DisableSectionCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnEnableSectionCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.EnableSectionCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnExpandSectionCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandSectionCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnCollapseSectionCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.CollapseSectionCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnExpandAllBlocksCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null);
|
||||
|
@ -605,6 +646,16 @@ namespace Filtration.ViewModels
|
|||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.CollapseAllBlocksCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnExpandAllSectionsCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllSectionsCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnCollapseAllSectionsCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.CollapseAllSectionsCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnToggleShowAdvancedCommand(bool showAdvanced)
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ToggleShowAdvancedCommand.Execute(showAdvanced);
|
||||
|
@ -630,6 +681,16 @@ namespace Filtration.ViewModels
|
|||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.BorderColor);
|
||||
}
|
||||
|
||||
private void OnAddFontSizeThemeComponentCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.FontSize);
|
||||
}
|
||||
|
||||
private void OnAddAlertSoundThemeComponentCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.AlertSound);
|
||||
}
|
||||
|
||||
private void OnDeleteThemeComponentCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute(
|
||||
|
|
|
@ -28,6 +28,9 @@ namespace Filtration.ViewModels.ToolPanes
|
|||
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/block_group_browser_icon.png");
|
||||
icon.EndInit();
|
||||
IconSource = icon;
|
||||
|
||||
IsVisible = false;
|
||||
|
||||
Messenger.Default.Register<NotificationMessage<bool>>(this, message =>
|
||||
{
|
||||
switch (message.Notification)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media.Imaging;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
|
||||
|
@ -15,6 +17,8 @@ namespace Filtration.ViewModels.ToolPanes
|
|||
{
|
||||
private IEnumerable<IItemFilterCommentBlockViewModel> _itemFilterCommentBlockViewModels;
|
||||
private IItemFilterCommentBlockViewModel _selectedItemFilterCommentBlockViewModel;
|
||||
private CollectionView _commentBlocksView;
|
||||
private string _searchText;
|
||||
|
||||
public CommentBlockBrowserViewModel() : base("Section Browser")
|
||||
{
|
||||
|
@ -24,6 +28,8 @@ namespace Filtration.ViewModels.ToolPanes
|
|||
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/add_section_icon.png");
|
||||
icon.EndInit();
|
||||
IconSource = icon;
|
||||
_searchText = "";
|
||||
_commentBlocksView = (CollectionView)CollectionViewSource.GetDefaultView(new List<IItemFilterCommentBlockViewModel>());
|
||||
|
||||
Messenger.Default.Register<NotificationMessage>(this, message =>
|
||||
{
|
||||
|
@ -46,7 +52,23 @@ namespace Filtration.ViewModels.ToolPanes
|
|||
private set
|
||||
{
|
||||
_itemFilterCommentBlockViewModels = value;
|
||||
RaisePropertyChanged();
|
||||
|
||||
_commentBlocksView = _itemFilterCommentBlockViewModels != null ?
|
||||
(CollectionView)CollectionViewSource.GetDefaultView(_itemFilterCommentBlockViewModels)
|
||||
: (CollectionView)CollectionViewSource.GetDefaultView(new List<IItemFilterCommentBlockViewModel>());
|
||||
|
||||
_commentBlocksView.Filter = SearchFilter;
|
||||
_commentBlocksView.Refresh();
|
||||
RaisePropertyChanged("CommentBlocksView");
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionView CommentBlocksView
|
||||
{
|
||||
get => _commentBlocksView;
|
||||
private set
|
||||
{
|
||||
_commentBlocksView = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,6 +86,18 @@ namespace Filtration.ViewModels.ToolPanes
|
|||
}
|
||||
}
|
||||
|
||||
public string SearchText
|
||||
{
|
||||
get => _searchText;
|
||||
set
|
||||
{
|
||||
_searchText = value;
|
||||
_commentBlocksView.Refresh();
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged("CommentBlocksView");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnActiveDocumentChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (AvalonDockWorkspaceViewModel.ActiveScriptViewModel != null && AvalonDockWorkspaceViewModel.ActiveDocument.IsScript)
|
||||
|
@ -81,5 +115,24 @@ namespace Filtration.ViewModels.ToolPanes
|
|||
ItemFilterCommentBlockViewModels = null;
|
||||
SelectedItemFilterCommentBlockViewModel = null;
|
||||
}
|
||||
|
||||
private bool SearchFilter(object obj)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_searchText))
|
||||
return true;
|
||||
|
||||
var block = obj as IItemFilterCommentBlockViewModel;
|
||||
var searchWords = Regex.Split(_searchText, @"\s+");
|
||||
foreach(var word in searchWords)
|
||||
{
|
||||
if (string.IsNullOrEmpty(word))
|
||||
continue;
|
||||
|
||||
if (block.Comment.IndexOf(word, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
|
||||
<xcad:LayoutRoot>
|
||||
<xcad:LayoutPanel Orientation="Horizontal">
|
||||
<xcad:LayoutAnchorablePane Name="SectionBrowserPane" DockWidth="150" />
|
||||
<xcad:LayoutAnchorablePane Name="SectionBrowserPane" DockWidth="200" />
|
||||
<xcad:LayoutPanel Orientation="Vertical">
|
||||
<xcad:LayoutDocumentPane />
|
||||
</xcad:LayoutPanel>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<ResourceDictionary>
|
||||
<views:BindingProxy x:Key="Proxy" Data="{Binding}" />
|
||||
<converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" />
|
||||
<converters:DropIconConverter x:Key="DropIconConverter"/>
|
||||
<Style TargetType="{x:Type ContentPresenter}" x:Key="BlockItemFadeInStyle">
|
||||
<Setter Property="LayoutTransform">
|
||||
<Setter.Value>
|
||||
|
@ -94,6 +95,7 @@
|
|||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- BlockItems Summary Panel -->
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">
|
||||
|
@ -129,6 +131,12 @@
|
|||
|
||||
<!-- Item Preview Box -->
|
||||
<WrapPanel Grid.Row="0" Grid.Column="2" VerticalAlignment="Center">
|
||||
<Image Source="{Binding DisplayIcon, Converter={StaticResource DropIconConverter}, Mode=OneWay}" Width="30" Height="30" Margin="0,0,10,0" />
|
||||
<Line Y2="41" StrokeThickness="2" Stroke="{Binding DisplayBeamColor, Converter={StaticResource ColorToSolidColorBrushConverter}, Mode=OneWay}" Margin="0,2,10,0" >
|
||||
<Line.Effect>
|
||||
<DropShadowEffect BlurRadius="5" ShadowDepth="0" Color="{Binding DisplayBeamColor, Mode=OneWay}" Direction="0"/>
|
||||
</Line.Effect>
|
||||
</Line>
|
||||
<Button Command="{Binding PlaySoundCommand}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
|
|
|
@ -76,7 +76,51 @@
|
|||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column ="0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/>
|
||||
|
||||
<Expander Grid.Column="1"
|
||||
Style="{StaticResource ExpanderRightAlignStyle}"
|
||||
x:Name="BlockExpander">
|
||||
|
||||
<Expander.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</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}}">
|
||||
<Button Command="{Binding ToggleSectionCommand}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,3,0"
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
ToolTip="Expand Section" Visibility="{Binding IsExpanded, Converter={StaticResource InverseBooleanVisibilityConverter}}">
|
||||
<Image Source="/Filtration;component/Resources/Icons/expand_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||
</Button>
|
||||
<Button Command="{Binding ToggleSectionCommand}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,3,0"
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
ToolTip="Collapse Section" Visibility="{Binding IsExpanded, Converter={StaticResource BooleanVisibilityConverter}}">
|
||||
<Image Source="/Filtration;component/Resources/Icons/collapse_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||
</Button>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Expander.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column ="0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/>
|
||||
</Grid>
|
||||
</Expander>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
</Border>
|
||||
<Border Grid.Row="1" BorderThickness="1" BorderBrush="DarkGray" Margin="5,5,5,5">
|
||||
<DockPanel LastChildFill="True">
|
||||
<userControls:AutoScrollingListBox ItemsSource="{Binding ItemFilterBlockViewModels}"
|
||||
<userControls:AutoScrollingListBox ItemsSource="{Binding ViewItemFilterBlockViewModels}"
|
||||
Padding="5"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
BorderThickness="0"
|
||||
|
|
|
@ -102,6 +102,13 @@
|
|||
<fluent:Button Header="Enable Block" Command="{Binding EnableBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyEnabledIcon}" />
|
||||
<fluent:Button Header="Disable Block" Command="{Binding DisableBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyDisabledIcon}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
<fluent:RibbonGroupBox Header="Sections">
|
||||
<fluent:Button Header="Enable Section" Command="{Binding EnableSectionCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyEnabledIcon}" />
|
||||
<fluent:Button Header="Disable Section" Command="{Binding DisableSectionCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyDisabledIcon}" />
|
||||
<fluent:Button Header="" SizeDefinition="Middle" IsEnabled="False" />
|
||||
<fluent:Button Header="Expand All Sections" Command="{Binding ExpandAllSectionsCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" />
|
||||
<fluent:Button Header="Collapse All Sections" Command="{Binding CollapseAllSectionsCommand}" SizeDefinition="Middle" Icon="{StaticResource CollapseIcon}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
<fluent:RibbonGroupBox Header="Expand / Collapse">
|
||||
<fluent:Button Header="Expand All" Command="{Binding ExpandAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" />
|
||||
<fluent:Button Header="Collapse All" Command="{Binding CollapseAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource CollapseIcon}" />
|
||||
|
@ -122,6 +129,8 @@
|
|||
<fluent:Button SizeDefinition="Middle" Header="Add Text Color" Icon="{StaticResource AddIcon}" Command="{Binding AddTextColorThemeComponentCommand}" />
|
||||
<fluent:Button SizeDefinition="Middle" Header="Add Background Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBackgroundColorThemeComponentCommand}" />
|
||||
<fluent:Button SizeDefinition="Middle" Header="Add Border Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBorderColorThemeComponentCommand}" />
|
||||
<fluent:Button SizeDefinition="Middle" Header="Add Font Size" Icon="{StaticResource AddIcon}" Command="{Binding AddFontSizeThemeComponentCommand}" />
|
||||
<fluent:Button SizeDefinition="Middle" Header="Add Alert Sound" Icon="{StaticResource AddIcon}" Command="{Binding AddAlertSoundThemeComponentCommand}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
<fluent:RibbonGroupBox Header="Delete">
|
||||
<fluent:Button Header="Delete Theme Component" Icon="{StaticResource ThemeComponentDeleteIcon}" LargeIcon="{StaticResource ThemeComponentDeleteIcon}" Command="{Binding DeleteThemeComponentCommand}" />
|
||||
|
|
|
@ -13,7 +13,12 @@
|
|||
<converters:HashSignRemovalConverter x:Key="HashSignRemovalConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<ListBox ItemsSource="{Binding ItemFilterCommentBlockViewModels}"
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Grid.Row="0" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" Height="30" Padding="0,-10,0,0" />
|
||||
<ListBox Grid.Row="1" ItemsSource="{Binding CommentBlocksView}"
|
||||
SelectedItem="{Binding SelectedItemFilterCommentBlockViewModel}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Hidden"><!--SelectionChanged="SectionBrowserListBox_OnSelectionChanged"-->
|
||||
<ListBox.Resources>
|
||||
|
@ -21,7 +26,7 @@
|
|||
</ListBox.Resources>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="viewModels:ItemFilterCommentBlockViewModel">
|
||||
<TextBlock Text="{Binding Comment, Converter={StaticResource HashSignRemovalConverter}}" ToolTip="{Binding Comment}" />
|
||||
<TextBlock Text="{Binding Header, Converter={StaticResource HashSignRemovalConverter}}" ToolTip="{Binding Comment}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
|