Merge d92d34af05c3d71ffcb7bb644ba9ef95c7ce7cff into 52fc1f6bbc9d20fcd52e3ac6fee86c2a85b628e5

This commit is contained in:
azakhi 2018-08-26 17:24:19 +00:00 committed by GitHub
commit cbf48111cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
90 changed files with 2617 additions and 306 deletions

View File

@ -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

View File

@ -66,6 +66,9 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -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)

View File

@ -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();
}
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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();
}
}
}
}

View File

@ -16,6 +16,6 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string PrefixText => "SetBackgroundColor";
public override int MaximumAllowed => 1;
public override string DisplayHeading => "Background Color";
public override int SortOrder => 18;
public override int SortOrder => 22;
}
}

View File

@ -33,6 +33,6 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override Color SummaryBackgroundColor => Colors.MediumTurquoise;
public override Color SummaryTextColor => Colors.Black;
public override int SortOrder => 16;
public override int SortOrder => 19;
}
}

View File

@ -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;
}
}

View File

@ -16,6 +16,6 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string PrefixText => "SetBorderColor";
public override int MaximumAllowed => 1;
public override string DisplayHeading => "Border Color";
public override int SortOrder => 19;
public override int SortOrder => 23;
}
}

View File

@ -33,6 +33,6 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override Color SummaryBackgroundColor => Colors.MediumSeaGreen;
public override Color SummaryTextColor => Colors.White;
public override int SortOrder => 15;
public override int SortOrder => 18;
}
}

View File

@ -0,0 +1,23 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.ObjectModel.BlockItemTypes
{
public sealed class DisableDropSoundBlockItem : BooleanBlockItem, IAudioVisualBlockItem
{
public DisableDropSoundBlockItem()
{
}
public DisableDropSoundBlockItem(bool booleanValue) : base(booleanValue)
{
}
public override string PrefixText => "DisableDropSound";
public override string DisplayHeading => "Disable Drop Sound";
public override Color SummaryBackgroundColor => Colors.Transparent;
public override Color SummaryTextColor => Colors.Transparent;
public override int SortOrder => 27;
}
}

View File

@ -21,7 +21,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string SummaryText => "Drop Level " + FilterPredicate;
public override Color SummaryBackgroundColor => Colors.DodgerBlue;
public override Color SummaryTextColor => Colors.White;
public override int SortOrder => 13;
public override int SortOrder => 14;
public override int Minimum => 0;
public override int Maximum => 100;
}

View File

@ -0,0 +1,23 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.ObjectModel.BlockItemTypes
{
public sealed class ElderMapBlockItem : BooleanBlockItem
{
public ElderMapBlockItem()
{
}
public ElderMapBlockItem(bool booleanValue) : base(booleanValue)
{
}
public override string PrefixText => "ElderMap";
public override string DisplayHeading => "Elder Map";
public override Color SummaryBackgroundColor => Colors.DarkGoldenrod;
public override Color SummaryTextColor => Colors.White;
public override int SortOrder => 9;
}
}

View File

@ -16,7 +16,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string PrefixText => "SetFontSize";
public override int MaximumAllowed => 1;
public override string DisplayHeading => "Font Size";
public override int SortOrder => 20;
public override int SortOrder => 24;
public override int Minimum => 11;
public override int Maximum => 45;
}

View File

@ -0,0 +1,28 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.BlockItemTypes
{
public class GemLevelBlockItem : NumericFilterPredicateBlockItem
{
public GemLevelBlockItem()
{
}
public GemLevelBlockItem(FilterPredicateOperator predicateOperator, int predicateOperand)
: base(predicateOperator, predicateOperand)
{
}
public override string PrefixText => "GemLevel";
public override int MaximumAllowed => 2;
public override string DisplayHeading => "Gem Level";
public override string SummaryText => "Gem Level " + FilterPredicate;
public override Color SummaryBackgroundColor => Colors.DarkSlateGray;
public override Color SummaryTextColor => Colors.White;
public override int SortOrder => 15;
public override int Minimum => 0;
public override int Maximum => 21;
}
}

View File

@ -0,0 +1,38 @@
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.ObjectModel.BlockItemTypes
{
public class HasExplicitModBlockItem : StringListBlockItem
{
public override string PrefixText => "HasExplicitMod";
public override int MaximumAllowed => 1;
public override string DisplayHeading => "Has Explicit Mod";
public override string SummaryText
{
get
{
if (Items.Count > 0 && Items.Count < 4)
{
return "Item Explicit Mods: " +
Items.Aggregate(string.Empty, (current, i) => current + i + ", ").TrimEnd(' ').TrimEnd(',');
}
if (Items.Count >= 4)
{
var remaining = Items.Count - 3;
return "Item Explicit Mods: " + Items.Take(3)
.Aggregate(string.Empty, (current, i) => current + i + ", ")
.TrimEnd(' ')
.TrimEnd(',') + " (+" + remaining + " more)";
}
return "Item Explicit Mods: (none)";
}
}
public override Color SummaryBackgroundColor => Colors.MidnightBlue;
public override Color SummaryTextColor => Colors.White;
public override int SortOrder => 20;
}
}

View File

@ -21,7 +21,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string SummaryText => "Height " + FilterPredicate;
public override Color SummaryBackgroundColor => Colors.LightBlue;
public override Color SummaryTextColor => Colors.Black;
public override int SortOrder => 10;
public override int SortOrder => 11;
public override int Minimum => 0;
public override int Maximum => 6;
}

View File

@ -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;
}
}

View File

@ -20,7 +20,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string SummaryText => "Item Level " + FilterPredicate;
public override Color SummaryBackgroundColor => Colors.DarkSlateGray;
public override Color SummaryTextColor => Colors.White;
public override int SortOrder => 12;
public override int SortOrder => 13;
public override int Minimum => 0;
public override int Maximum => 100;
}

View File

@ -17,6 +17,6 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string PrefixText => "PlayAlertSoundPositional";
public override int MaximumAllowed => 1;
public override string DisplayHeading => "Play Positional Alert Sound";
public override int SortOrder => 22;
public override int SortOrder => 26;
}
}

View File

@ -30,7 +30,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
((ItemRarity) FilterPredicate.PredicateOperand).GetAttributeDescription();
public override Color SummaryBackgroundColor => Colors.LightCoral;
public override Color SummaryTextColor => Colors.White;
public override int SortOrder => 14;
public override int SortOrder => 17;
public override int Minimum => 0;
public override int Maximum => (int)ItemRarity.Unique;
}

View File

@ -39,7 +39,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override Color SummaryBackgroundColor => Colors.GhostWhite;
public override Color SummaryTextColor => Colors.Black;
public override int SortOrder => 9;
public override int SortOrder => 10;
private SocketColor StringToSocketColor(char socketColorString)
{

View File

@ -17,6 +17,6 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string PrefixText => "PlayAlertSound";
public override int MaximumAllowed => 1;
public override string DisplayHeading => "Play Alert Sound";
public override int SortOrder => 21;
public override int SortOrder => 25;
}
}

View File

@ -0,0 +1,28 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.BlockItemTypes
{
public class StackSizeBlockItem : NumericFilterPredicateBlockItem
{
public StackSizeBlockItem()
{
}
public StackSizeBlockItem(FilterPredicateOperator predicateOperator, int predicateOperand)
: base(predicateOperator, predicateOperand)
{
}
public override string PrefixText => "StackSize";
public override int MaximumAllowed => 2;
public override string DisplayHeading => "Stack Size";
public override string SummaryText => "Stack Size " + FilterPredicate;
public override Color SummaryBackgroundColor => Colors.DarkSlateGray;
public override Color SummaryTextColor => Colors.White;
public override int SortOrder => 16;
public override int Minimum => 0;
public override int Maximum => 1000;
}
}

View File

@ -16,6 +16,6 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string PrefixText => "SetTextColor";
public override int MaximumAllowed => 1;
public override string DisplayHeading => "Text Color";
public override int SortOrder => 17;
public override int SortOrder => 21;
}
}

View File

@ -21,7 +21,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
public override string SummaryText => "Width " + FilterPredicate;
public override Color SummaryBackgroundColor => Colors.MediumPurple;
public override Color SummaryTextColor => Colors.White;
public override int SortOrder => 11;
public override int SortOrder => 12;
public override int Minimum => 0;
public override int Maximum => 2;
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -9,6 +9,10 @@ namespace Filtration.ObjectModel.Enums
[Description("Background")]
BackgroundColor,
[Description("Border")]
BorderColor
BorderColor,
[Description("Font Size")]
FontSize,
[Description("Alert Sound")]
AlertSound
}
}

View File

@ -52,15 +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" />
@ -77,16 +85,20 @@
<Compile Include="BlockItemTypes\SocketsBlockItem.cs" />
<Compile Include="BlockItemTypes\PositionalSoundBlockItem.cs" />
<Compile Include="BlockItemTypes\SoundBlockItem.cs" />
<Compile Include="BlockItemTypes\StackSizeBlockItem.cs" />
<Compile Include="BlockItemTypes\TextColorBlockItem.cs" />
<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" />
@ -103,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" />
@ -118,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" />

View File

@ -0,0 +1,9 @@
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ObjectModel
{
public interface IBlockItemWithTheme : IItemFilterBlockItem
{
ThemeComponent ThemeComponent { get; }
}
}

View File

@ -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 };
}
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -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));
}
}
}

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -318,6 +318,42 @@ namespace Filtration.Parser.Tests.Services
Assert.AreEqual(FilterPredicateOperator.Equal, blockItem.FilterPredicate.PredicateOperator);
}
[Test]
public void TranslateStringToItemFilterBlock_GemLevel_ReturnsCorrectObject()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" GemLevel = 20";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is GemLevelBlockItem));
var blockItem = result.BlockItems.OfType<GemLevelBlockItem>().First();
Assert.AreEqual(20, blockItem.FilterPredicate.PredicateOperand);
Assert.AreEqual(FilterPredicateOperator.Equal, blockItem.FilterPredicate.PredicateOperator);
}
[Test]
public void TranslateStringToItemFilterBlock_StackSize_ReturnsCorrectObject()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" StackSize > 5";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is StackSizeBlockItem));
var blockItem = result.BlockItems.OfType<StackSizeBlockItem>().First();
Assert.AreEqual(5, blockItem.FilterPredicate.PredicateOperand);
Assert.AreEqual(FilterPredicateOperator.GreaterThan, blockItem.FilterPredicate.PredicateOperator);
}
[Test]
public void TranslateStringToItemFilterBlock_Corrupted_ReturnsCorrectObject()
{
@ -386,6 +422,23 @@ namespace Filtration.Parser.Tests.Services
Assert.IsFalse(blockItem.BooleanValue);
}
[Test]
public void TranslateStringToItemFilterBlock_ElderMap_ReturnsCorrectObject()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" ElderMap false";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ElderMapBlockItem));
var blockItem = result.BlockItems.OfType<ElderMapBlockItem>().First();
Assert.IsFalse(blockItem.BooleanValue);
}
[Test]
public void TranslateStringToItemFilterBlock_Identified_ReturnsCorrectObject()
{
@ -494,6 +547,25 @@ namespace Filtration.Parser.Tests.Services
Assert.Contains("Test BaseType 2", blockItem.Items);
}
[Test]
public void TranslateStringToItemFilterBlock_HasExplicitMod_ReturnsCorrectObject()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
@" HasExplicitMod ""Test Mod 1"" ""TestOneWordModInQuotes"" TestOneWordModNotInQuotes ""Test Mod 2""";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is HasExplicitModBlockItem));
var blockItem = result.BlockItems.OfType<HasExplicitModBlockItem>().First();
Assert.Contains("Test Mod 1", blockItem.Items);
Assert.Contains("TestOneWordModInQuotes", blockItem.Items);
Assert.Contains("TestOneWordModNotInQuotes", blockItem.Items);
Assert.Contains("Test Mod 2", blockItem.Items);
}
[Test]
public void TranslateStringToItemFilterBlock_Sockets_ReturnsCorrectObject()
{
@ -701,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
@ -803,6 +875,59 @@ namespace Filtration.Parser.Tests.Services
Assert.AreEqual(95, blockItem.SecondValue);
}
[Test]
public void TranslateStringToItemFilterBlock_DisableDropSound_ReturnsCorrectObject()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" DisableDropSound True";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is DisableDropSoundBlockItem));
var blockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First();
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()
{
@ -813,6 +938,8 @@ namespace Filtration.Parser.Tests.Services
"Show" + Environment.NewLine +
" ItemLevel >= 50" + Environment.NewLine +
" DropLevel < 70" + Environment.NewLine +
" GemLevel = 20" + Environment.NewLine +
" StackSize > 2" + Environment.NewLine +
" Quality = 15" + Environment.NewLine +
" Rarity <= Unique" + Environment.NewLine +
" Identified True" + Environment.NewLine +
@ -820,8 +947,10 @@ namespace Filtration.Parser.Tests.Services
" ElderItem true" + Environment.NewLine +
" ShaperItem False" + Environment.NewLine +
" ShapedMap TRUE" + Environment.NewLine +
" ElderMap False" + Environment.NewLine +
@" Class ""My Item Class"" AnotherClass ""AndAnotherClass""" + Environment.NewLine +
@" BaseType MyBaseType ""Another BaseType""" + Environment.NewLine +
@" HasExplicitMod MyMod ""Another Mod""" + Environment.NewLine +
" JunkLine Let's ignore this one!" + Environment.NewLine +
" #Quality Commented out quality line" + Environment.NewLine +
" Sockets >= 3" + Environment.NewLine +
@ -831,7 +960,10 @@ namespace Filtration.Parser.Tests.Services
" SetBackgroundColor 255 100 5" + Environment.NewLine +
" SetBorderColor 0 0 0" + Environment.NewLine +
" SetFontSize 50" + Environment.NewLine +
" PlayAlertSound 3" + Environment.NewLine;
" PlayAlertSound 3" + 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);
@ -857,10 +989,21 @@ namespace Filtration.Parser.Tests.Services
var shapedMapBlockItem = result.BlockItems.OfType<ShapedMapBlockItem>().First();
Assert.IsTrue(shapedMapBlockItem.BooleanValue);
var elderMapBlockItem = result.BlockItems.OfType<ElderMapBlockItem>().First();
Assert.IsFalse(elderMapBlockItem.BooleanValue);
var dropLevelblockItem = result.BlockItems.OfType<DropLevelBlockItem>().First();
Assert.AreEqual(FilterPredicateOperator.LessThan, dropLevelblockItem.FilterPredicate.PredicateOperator);
Assert.AreEqual(70, dropLevelblockItem.FilterPredicate.PredicateOperand);
var gemLevelBlockItem = result.BlockItems.OfType<GemLevelBlockItem>().First();
Assert.AreEqual(FilterPredicateOperator.Equal, gemLevelBlockItem.FilterPredicate.PredicateOperator);
Assert.AreEqual(20, gemLevelBlockItem.FilterPredicate.PredicateOperand);
var stackSizeBlockItem = result.BlockItems.OfType<StackSizeBlockItem>().First();
Assert.AreEqual(FilterPredicateOperator.GreaterThan, stackSizeBlockItem.FilterPredicate.PredicateOperator);
Assert.AreEqual(2, stackSizeBlockItem.FilterPredicate.PredicateOperand);
var qualityblockItem = result.BlockItems.OfType<QualityBlockItem>().First();
Assert.AreEqual(FilterPredicateOperator.Equal, qualityblockItem.FilterPredicate.PredicateOperator);
Assert.AreEqual(15, qualityblockItem.FilterPredicate.PredicateOperand);
@ -880,6 +1023,11 @@ namespace Filtration.Parser.Tests.Services
Assert.Contains("MyBaseType", baseTypeblockItem.Items);
Assert.Contains("Another BaseType", baseTypeblockItem.Items);
var hasExplicitModBlockItem = result.BlockItems.OfType<HasExplicitModBlockItem>().First();
Assert.AreEqual(2, hasExplicitModBlockItem.Items.Count);
Assert.Contains("MyMod", hasExplicitModBlockItem.Items);
Assert.Contains("Another Mod", hasExplicitModBlockItem.Items);
var socketsblockItem = result.BlockItems.OfType<SocketsBlockItem>().First();
Assert.AreEqual(FilterPredicateOperator.GreaterThanOrEqual, socketsblockItem.FilterPredicate.PredicateOperator);
Assert.AreEqual(3, socketsblockItem.FilterPredicate.PredicateOperand);
@ -917,6 +1065,18 @@ namespace Filtration.Parser.Tests.Services
var soundblockItem = result.BlockItems.OfType<SoundBlockItem>().First();
Assert.AreEqual("3", soundblockItem.Value);
Assert.AreEqual(79, soundblockItem.SecondValue);
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]
@ -1151,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
@ -1168,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);
@ -1183,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);
@ -1334,6 +1500,38 @@ namespace Filtration.Parser.Tests.Services
Assert.AreEqual(expectedResult, result);
}
[Test]
public void TranslateItemFilterBlockToString_GemLevel_ReturnsCorrectString()
{
// Arrange
var expectedResult = "Show" + Environment.NewLine +
" GemLevel <= 15";
_testUtility.TestBlock.BlockItems.Add(new GemLevelBlockItem(FilterPredicateOperator.LessThanOrEqual, 15));
// Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
// Assert
Assert.AreEqual(expectedResult, result);
}
[Test]
public void TranslateItemFilterBlockToString_StackSize_ReturnsCorrectString()
{
// Arrange
var expectedResult = "Show" + Environment.NewLine +
" StackSize = 5";
_testUtility.TestBlock.BlockItems.Add(new StackSizeBlockItem(FilterPredicateOperator.Equal, 5));
// Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
// Assert
Assert.AreEqual(expectedResult, result);
}
[Test]
public void TranslateItemFilterBlockToString_Quality_ReturnsCorrectString()
{
@ -1425,6 +1623,26 @@ namespace Filtration.Parser.Tests.Services
Assert.AreEqual(expectedResult, result);
}
[Test]
public void TranslateItemFilterBlockToString_HasExplicitMod_ReturnsCorrectString()
{
// Arrange
var expectedResult = "Show" + Environment.NewLine +
" HasExplicitMod \"Test Mod\" \"Another Mod\" \"Yet Another Mod\"";
var hasExplicitModBlockItem = new HasExplicitModBlockItem();
hasExplicitModBlockItem.Items.Add("Test Mod");
hasExplicitModBlockItem.Items.Add("Another Mod");
hasExplicitModBlockItem.Items.Add("Yet Another Mod");
_testUtility.TestBlock.BlockItems.Add(hasExplicitModBlockItem);
// Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
// Assert
Assert.AreEqual(expectedResult, result);
}
[Test]
public void TranslateItemFilterBlockToString_Sockets_ReturnsCorrectString()
{
@ -1533,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);
@ -1671,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;
@ -1687,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()
{
@ -1700,20 +1933,27 @@ namespace Filtration.Parser.Tests.Services
" ElderItem True" + Environment.NewLine +
" ShaperItem False" + Environment.NewLine +
" ShapedMap True" + Environment.NewLine +
" ElderMap True" + Environment.NewLine +
" Height <= 6" + Environment.NewLine +
" Height >= 2" + Environment.NewLine +
" Width = 3" + Environment.NewLine +
" ItemLevel > 70" + Environment.NewLine +
" ItemLevel <= 85" + Environment.NewLine +
" DropLevel > 56" + Environment.NewLine +
" GemLevel < 15" + Environment.NewLine +
" StackSize >= 4" + Environment.NewLine +
" Rarity = Unique" + Environment.NewLine +
" Class \"Body Armour\" \"Gloves\" \"Belt\" \"Two Hand Axes\"" + Environment.NewLine +
" BaseType \"Greater Life Flask\" \"Simple Robe\" \"Full Wyrmscale\"" + Environment.NewLine +
" HasExplicitMod \"Guatelitzi's\" \"of Tacati\" \"Tyrannical\"" + Environment.NewLine +
" SetTextColor 255 89 0 56" + Environment.NewLine +
" SetBackgroundColor 0 0 0" + Environment.NewLine +
" SetBorderColor 255 1 254" + Environment.NewLine +
" SetFontSize 50" + Environment.NewLine +
" PlayAlertSound 6 90";
" PlayAlertSound 6 90" + Environment.NewLine +
" 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));
@ -1722,6 +1962,8 @@ namespace Filtration.Parser.Tests.Services
_testUtility.TestBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 70));
_testUtility.TestBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.LessThanOrEqual, 85));
_testUtility.TestBlock.BlockItems.Add(new DropLevelBlockItem(FilterPredicateOperator.GreaterThan, 56));
_testUtility.TestBlock.BlockItems.Add(new GemLevelBlockItem(FilterPredicateOperator.LessThan, 15));
_testUtility.TestBlock.BlockItems.Add(new StackSizeBlockItem(FilterPredicateOperator.GreaterThanOrEqual, 4));
_testUtility.TestBlock.BlockItems.Add(new QualityBlockItem(FilterPredicateOperator.GreaterThan, 2));
_testUtility.TestBlock.BlockItems.Add(new RarityBlockItem(FilterPredicateOperator.Equal, (int)ItemRarity.Unique));
var classItemblockItem = new ClassBlockItem();
@ -1735,6 +1977,11 @@ namespace Filtration.Parser.Tests.Services
baseTypeItemblockItem.Items.Add("Simple Robe");
baseTypeItemblockItem.Items.Add("Full Wyrmscale");
_testUtility.TestBlock.BlockItems.Add(baseTypeItemblockItem);
var hasExplicitModBlockItem = new HasExplicitModBlockItem();
hasExplicitModBlockItem.Items.Add("Guatelitzi's");
hasExplicitModBlockItem.Items.Add("of Tacati");
hasExplicitModBlockItem.Items.Add("Tyrannical");
_testUtility.TestBlock.BlockItems.Add(hasExplicitModBlockItem);
_testUtility.TestBlock.BlockItems.Add(new SocketsBlockItem(FilterPredicateOperator.LessThanOrEqual, 6));
_testUtility.TestBlock.BlockItems.Add(new LinkedSocketsBlockItem(FilterPredicateOperator.GreaterThanOrEqual, 4));
_testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 3));
@ -1748,6 +1995,10 @@ namespace Filtration.Parser.Tests.Services
_testUtility.TestBlock.BlockItems.Add(new ElderItemBlockItem(true));
_testUtility.TestBlock.BlockItems.Add(new ShaperItemBlockItem(false));
_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);

View File

@ -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())
@ -155,7 +172,7 @@ namespace Filtration.Parser.Tests.Services
script.ItemFilterBlocks.Add(block1);
script.ItemFilterBlocks.Add(block2);
var expectedOutput = "# Script edited with Filtration - https://github.com/ben-wallis/Filtration" + Environment.NewLine +
var expectedOutput = "# Script edited with Filtration - https://github.com/ben-wallis/Filtration" + Environment.NewLine + Environment.NewLine +
"# Test Filter 1" + Environment.NewLine +
"Show" + Environment.NewLine +
" ItemLevel > 5" + Environment.NewLine +

View File

@ -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,14 +275,76 @@ namespace Filtration.Parser.Services
Value = firstValue,
SecondValue = secondValue
};
blockItemValue.ThemeComponent = themeComponent;
block.BlockItems.Add(blockItemValue);
}
}
break;
}
case "GemLevel":
{
AddNumericFilterPredicateItemToBlockItems<GemLevelBlockItem>(block, trimmedLine);
break;
}
case "StackSize":
{
AddNumericFilterPredicateItemToBlockItems<StackSizeBlockItem>(block, trimmedLine);
break;
}
case "HasExplicitMod":
{
AddStringListItemToBlockItems<HasExplicitModBlockItem>(block, trimmedLine);
break;
}
case "ElderMap":
{
AddBooleanItemToBlockItems<ElderMapBlockItem>(block, trimmedLine);
break;
}
case "DisableDropSound":
{
// Only ever use the last DisableDropSound item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<DisableDropSoundBlockItem>(block);
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;
}
@ -284,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)
@ -487,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;
@ -506,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;
@ -532,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;
}

View File

@ -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("#"))
{
string curLine = Regex.Replace(lines[i].Substring(1), @"\s+", "");
if ((curLine.StartsWith("Show") || curLine.StartsWith("Hide")) && (curLine.Length == 4 || curLine[4] == '#'))
{
inDisabledBlock = true;
linesToRemove.Add(i);
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);
}
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));
}
}
@ -251,8 +239,8 @@ namespace Filtration.Parser.Services
outputString += "# " + line + Environment.NewLine;
}
}
outputString += Environment.NewLine;
}
outputString += Environment.NewLine;
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (var block in script.ItemFilterBlocks)

View File

@ -107,6 +107,9 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -73,6 +73,9 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -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;

View File

@ -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();

View File

@ -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" />

View File

@ -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;
});

View File

@ -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;
}
}
}

View File

@ -0,0 +1,9 @@
using System.Windows.Media;
namespace Filtration.ThemeEditor.ViewModels
{
public class ColorThemeComponentViewModel : ThemeComponentViewModel
{
public Color Color { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace Filtration.ThemeEditor.ViewModels
{
public class IntegerThemeComponentViewModel : ThemeComponentViewModel
{
public int Value { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace Filtration.ThemeEditor.ViewModels
{
public class StrIntThemeComponentViewModel : ThemeComponentViewModel
{
public int Value { get; set; }
public int SecondValue { get; set; }
}
}

View File

@ -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; }
}
}

View File

@ -194,8 +194,21 @@ namespace Filtration.ThemeEditor.ViewModels
private void OnAddThemeComponentCommand(ThemeComponentType themeComponentType)
{
Components.Add(new ThemeComponent(themeComponentType, "Untitled Component",
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)

View File

@ -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>

View File

@ -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>();
});

View File

@ -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;

View File

@ -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();
}
}
}

View File

@ -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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -114,6 +114,7 @@ Bear Trap
Behemoth Mace
Belfry Map
Bestel's Manuscript
Bestiary Orb
Beyond Leaguestone
Binding Shard
Birth of the Three
@ -131,6 +132,7 @@ Blast Rain
Blessed Orb
Blessing of Chayula
Blessing of Esh
Blessing of God
Blessing of Tul
Blessing of Uul-Netol
Blessing of Xoph
@ -244,6 +246,7 @@ Chaos Orb
Chaos Shard
Chaotic Disposition
Charged Dash
Charged Traps Support
Chateau Map
Chayula's Breachstone
Chest Splitter
@ -492,6 +495,7 @@ Exalted Orb
Exalted Shard
Excavation Map
Explosive Arrow
Explosive Trap
Exquisite Blade
Exquisite Leather
Eye Gouger
@ -531,8 +535,10 @@ Flame Dash
Flame Surge
Flame Totem
Flameblast
Flamethrower Trap
Flammability
Flanged Mace
Flashpowder Keg
Flaying Knife
Flesh Offering
Fleshripper
@ -540,6 +546,7 @@ Flicker Strike
Flooded Mine Map
Fluted Bascinet
Footman Sword
Forbidden Power
Forge of the Phoenix Map
Fork Support
Fortify Support
@ -654,6 +661,7 @@ Harbinger's Orb
Harbinger's Shard
Harlequin Mask
Harmonic Spirit Shield
Harmony of Souls
Harpy Rapier
Haste
Hatred
@ -705,6 +713,7 @@ Ignite Proliferation Support
Imbued Wand
Immolate Support
Immortal Call
Immortal Resolve
Imp Dagger
Imperial Bow
Imperial Buckler
@ -712,6 +721,7 @@ Imperial Claw
Imperial Maul
Imperial Skean
Imperial Staff
Imprinted Bestiary Orb
Incinerate
Increased Area of Effect Support
Increased Critical Damage Support
@ -813,6 +823,7 @@ Light Quiver
Lighthouse Map
Lightning Arrow
Lightning Penetration Support
Lightning Spire Trap
Lightning Strike
Lightning Tendrils
Lightning Trap
@ -923,6 +934,7 @@ Muttering Essence of Woe
Nailed Fist
Necromancer Circlet
Necromancer Silks
Necromancy Net
Necropolis Map
Nemesis Leaguestone
Nightmare Bascinet
@ -983,6 +995,7 @@ Penetrating Arrow Quiver
Peninsula Map
Perandus Coin
Perandus Leaguestone
Perfection
Pernarch
Petrified Club
Phantasmagoria Map
@ -1082,7 +1095,10 @@ Regal Orb
Regal Shard
Regicide Mask
Reinforced Greaves
Reinforced Iron Net
Reinforced Kite Shield
Reinforced Rope Net
Reinforced Steel Net
Reinforced Tower Shield
Rejuvenation Totem
Relic Chambers Map
@ -1185,6 +1201,7 @@ Scroll of Wisdom
Searching Eye Jewel
Searing Bond
Secutor Helm
Seismic Trap
Sekhem
Sekhema Feather
Sentinel Jacket
@ -1264,8 +1281,12 @@ Silver Coin
Silver Flask
Silver Key
Silver Locket
Simple Iron Net
Simple Robe
Simple Rope Net
Simple Steel Net
Sinner Tricorne
Siphoning Trap
Skean
Skinning Knife
Slaughter Knife
@ -1292,6 +1313,7 @@ Sovereign Spiked Shield
Spark
Sparkling Claw
Spectral Axe
Spectral Shield Throw
Spectral Sword
Spectral Throw
Spell Cascade Support
@ -1341,6 +1363,7 @@ Stibnite Flask
Stiletto
Stone Axe
Stone Hammer
Stone of Passage
Storm Barrier Support
Storm Blade
Storm Burst
@ -1349,6 +1372,9 @@ Strand Map
Strapped Boots
Strapped Leather
Strapped Mitts
Strong Iron Net
Strong Rope Net
Strong Steel Net
Struck by Lightning
Studded Belt
Studded Round Shield
@ -1361,6 +1387,7 @@ Summon Chaos Golem
Summon Flame Golem
Summon Ice Golem
Summon Lightning Golem
Summon Phantasm on Kill Support
Summon Raging Spirit
Summon Skeleton
Summon Stone Golem
@ -1377,6 +1404,7 @@ Talisman Leaguestone
Talon Axe
Tarnished Spirit Shield
Teak Round Shield
Tectonic Slam
Tempered Foil
Tempest Leaguestone
Tempest Shield
@ -1386,17 +1414,22 @@ Tenderizer
Terrace Map
Terror Claw
Terror Maul
Thaumaturgical Net
Thaumetic Emblem
Thaumetic Sulphite
The Admirer
The Aesthete
The Arena Champion
The Army of Blood
The Artist
The Avenger
The Battle Born
The Beast
The Betrayal
The Black Flag
The Blazing Fire
The Body
The Breach
The Brittle Emperor
The Calling
The Carrion Crow
@ -1404,18 +1437,23 @@ The Cartographer
The Cataclysm
The Catalyst
The Celestial Justicar
The Celestial Stone
The Chains that Bind
The Coming Storm
The Conduit
The Cursed King
The Dapper Prodigy
The Dark Mage
The Darkest Dream
The Deceiver
The Demoness
The Devastator
The Doctor
The Doppelganger
The Dragon
The Dragon's Heart
The Dreamer
The Dreamland
The Drunken Aristocrat
The Encroaching Darkness
The Endurance
@ -1425,6 +1463,7 @@ The Explorer
The Eye of Desire
The Eye of Fury
The Eye of the Dragon
The Fathomless Depths
The Feast
The Fiend
The Fletcher
@ -1437,6 +1476,7 @@ The Garish Power
The Gemcutter
The Gentleman
The Gladiator
The Hale Heart
The Harvester
The Hermit
The Hoarder
@ -1444,8 +1484,11 @@ The Hunger
The Immortal
The Incantation
The Inoculated
The Insatiable
The Inventor
The Iron Bard
The Jester
The Jeweller's Boon
The King's Blade
The King's Heart
The Last One Standing
@ -1454,9 +1497,12 @@ The Lion
The Lord in Black
The Lover
The Lunaris Priestess
The Master
The Mayor
The Mercenary
The Metalsmith's Gift
The Oath
The Obscured
The Offering
The One With All
The Opulent
@ -1466,17 +1512,22 @@ The Penitent
The Poet
The Polymath
The Porcupine
The Professor
The Puzzle
The Queen
The Rabid Rhoa
The Realm
The Risk
The Rite of Elements
The Road to Power
The Ruthless Ceinture
The Saint's Treasure
The Samurai's Eye
The Scarred Meadow
The Scavenger
The Scholar
The Sephirot
The Shaper's Key
The Sigil
The Siren
The Soul
@ -1490,6 +1541,7 @@ The Sun
The Surgeon
The Surveyor
The Survivalist
The Sword King's Salute
The Teardrop
The Thaumaturgist
The Throne
@ -1498,6 +1550,8 @@ The Traitor
The Trial
The Twins
The Tyrant
The Undaunted
The Undisputed
The Union
The Valkyrie
The Valley of Steel Boxes
@ -1509,10 +1563,12 @@ The Warlord
The Watcher
The Web
The Wind
The Witch
The Wolf
The Wolf's Shadow
The Wolven King's Bite
The Wolverine
The World Eater
The Wrath
The Wretched
Thicket Bow
@ -1523,6 +1579,7 @@ Thorn Rapier
Three Faces in the Dark
Three Hands Talisman
Three Rat Talisman
Three Voices
Thresher Claw
Throat Stabber
Thunderous Skies
@ -1590,6 +1647,8 @@ Uul-Netol's Breachstone
Vaal Arc
Vaal Axe
Vaal Blade
Vaal Blade Vortex
Vaal Blight
Vaal Breach
Vaal Buckler
Vaal Burning Arrow
@ -1600,6 +1659,7 @@ Vaal Cyclone
Vaal Detonate Dead
Vaal Discipline
Vaal Double Strike
Vaal Earthquake
Vaal Fireball
Vaal Flameblast
Vaal Gauntlets
@ -1612,6 +1672,9 @@ Vaal Haste
Vaal Hatchet
Vaal Ice Nova
Vaal Immortal Call
Vaal Impurity of Fire
Vaal Impurity of Ice
Vaal Impurity of Lightning
Vaal Lightning Strike
Vaal Lightning Trap
Vaal Lightning Warp
@ -1640,7 +1703,16 @@ Vault Map
Velvet Gloves
Velvet Slippers
Vengeance
Vial of Awakening
Vial of Consequence
Vial of Dominance
Vial of Fate
Vial Of Power
Vial of Sacrifice
Vial of Summoning
Vial of the Ghost
Vial of the Ritual
Vial of Transcendence
Vigilant Strike
Vile Staff
Vile Toxins Support

View File

@ -16,6 +16,7 @@ Gems
Gloves
Helmets
Hybrid Flasks
Incursion Item
Jewel
Labyrinth Item
Labyrinth Map Item

View File

@ -76,11 +76,27 @@
<userControls:EditableListBoxControl Margin="5,5,5,5" ItemsSource="{Binding Items}" AutoCompleteItemsSource="{Binding ElementName=TopLevelGrid, Path=DataContext.AutoCompleteItemBaseTypes}" />
</DataTemplate>
<!-- Explicit Mods Template -->
<DataTemplate DataType="{x:Type blockItemTypes:HasExplicitModBlockItem}">
<userControls:EditableListBoxControl Margin="5,5,5,5" ItemsSource="{Binding Items}" />
</DataTemplate>
<!-- Socket Groups Template -->
<DataTemplate DataType="{x:Type blockItemTypes:SocketGroupBlockItem}">
<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>
@ -100,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 -->
@ -113,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>
@ -124,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>

View File

@ -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;

View File

@ -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>

View File

@ -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();
}
}
}

View File

@ -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}"
@ -32,7 +33,7 @@
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>
@ -46,25 +47,28 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="ComponentNameColumn" Width="Auto" />
<ColumnDefinition SharedSizeGroup="ComponentColorColumn" Width="20" />
<ColumnDefinition SharedSizeGroup="ComponentValueColumn" 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}}" />
<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.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>

View File

@ -159,7 +159,11 @@ namespace Filtration.ViewModels
typeof (CorruptedBlockItem),
typeof (ElderItemBlockItem),
typeof (ShaperItemBlockItem),
typeof (ShapedMapBlockItem)
typeof (ShapedMapBlockItem),
typeof (ElderMapBlockItem),
typeof (GemLevelBlockItem),
typeof (StackSizeBlockItem),
typeof (HasExplicitModBlockItem)
};
public List<Type> AudioVisualBlockItemTypesAvailable => new List<Type>
@ -169,7 +173,10 @@ namespace Filtration.ViewModels
typeof (BorderColorBlockItem),
typeof (FontSizeBlockItem),
typeof (SoundBlockItem),
typeof (PositionalSoundBlockItem)
typeof (PositionalSoundBlockItem),
typeof (DisableDropSoundBlockItem),
typeof (IconBlockItem),
typeof (BeamBlockItem)
};
public bool BlockEnabled
@ -209,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>();
@ -419,7 +428,7 @@ namespace Filtration.ViewModels
{
IsDirty = true;
}
Block.IsEdited = true;
//if (sender is IAudioVisualBlockItem)
//{
RefreshBlockPreview();
@ -432,6 +441,8 @@ namespace Filtration.ViewModels
RaisePropertyChanged(nameof(DisplayBackgroundColor));
RaisePropertyChanged(nameof(DisplayBorderColor));
RaisePropertyChanged(nameof(DisplayFontSize));
RaisePropertyChanged(nameof(DisplayIcon));
RaisePropertyChanged(nameof(DisplayBeamColor));
RaisePropertyChanged(nameof(HasSound));
}

View File

@ -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);

View File

@ -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);
}
}
}

View File

@ -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;
@ -633,9 +682,17 @@ namespace Filtration.ViewModels
}
private void OnCopyBlockCommand()
{
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,40 +855,251 @@ 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()
{
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
if (commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
{
MoveBlockToTop(SelectedBlockViewModel);
}
else
{
MoveSectionToTop(commentBlockViewModel);
}
}
private void OnMoveBlockUpCommand()
{
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
if(commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
{
MoveBlockUp(SelectedBlockViewModel);
}
else
{
MoveSectionUp(commentBlockViewModel);
}
}
public void MoveBlockUp(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{
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()
{
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
if (commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
{
MoveBlockDown(SelectedBlockViewModel);
}
else
{
MoveSectionDown(commentBlockViewModel);
}
}
public void MoveBlockDown(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{
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()
{
var commentBlockViewModel = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
if (commentBlockViewModel == null || commentBlockViewModel.IsExpanded)
{
MoveBlockToBottom(SelectedBlockViewModel);
}
else
{
MoveSectionToBottom(commentBlockViewModel);
}
}
private void OnAddBlockCommand()
{
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)
{
@ -775,29 +1113,90 @@ namespace Filtration.ViewModels
}
public void DeleteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{
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)
{
_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();
}
private void OnAddCommentBlockCommand()
{
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;
}
}
}

View File

@ -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(

View File

@ -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)

View File

@ -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;
}
}
}

View File

@ -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>

View File

@ -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"

View File

@ -71,6 +71,48 @@
</Grid.ColumnDefinitions>
<Border Width="7" Grid.Column="0" BorderBrush="Gray" Background="Gray" CornerRadius="2,0,0,2" />
<Border Grid.Column =" 1" BorderThickness="1" BorderBrush="SlateGray" Background="Gainsboro" CornerRadius="0,2,2,0" Padding="3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<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" />
@ -78,6 +120,8 @@
</Grid.ColumnDefinitions>
<TextBox Grid.Column ="0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/>
</Grid>
</Expander>
</Grid>
</Border>
</Grid>
</UserControl>

View File

@ -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"

View File

@ -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}" />

View File

@ -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>