FIL-4 Refactored script parsing to retain isolated comments as a new ItemFilterBlockComment type - UI still needs reworking with new templates and such.
This commit is contained in:
@@ -9,7 +9,7 @@ using Filtration.ObjectModel.Extensions;
|
||||
|
||||
namespace Filtration.ObjectModel
|
||||
{
|
||||
public interface IItemFilterBlock
|
||||
public interface IItemFilterBlock : IItemFilterBlockBase
|
||||
{
|
||||
bool Enabled { get; set; }
|
||||
string Description { get; set; }
|
||||
@@ -21,13 +21,32 @@ namespace Filtration.ObjectModel
|
||||
Color DisplayTextColor { get; }
|
||||
Color DisplayBorderColor { get; }
|
||||
double DisplayFontSize { get; }
|
||||
int BlockCount(Type type);
|
||||
bool AddBlockItemAllowed(Type type);
|
||||
bool HasBlockItemOfType<T>();
|
||||
bool HasBlockGroupInParentHierarchy(ItemFilterBlockGroup targetBlockGroup, ItemFilterBlockGroup startingBlockGroup);
|
||||
}
|
||||
|
||||
public class ItemFilterBlock : IItemFilterBlock
|
||||
public interface IItemFilterBlockBase
|
||||
{
|
||||
}
|
||||
|
||||
public class ItemFilterBlockBase : IItemFilterBlockBase
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public interface IItemFilterCommentBlock : IItemFilterBlockBase
|
||||
{
|
||||
string Comment { get; set; }
|
||||
bool IsSection { get; set; }
|
||||
}
|
||||
|
||||
public class ItemFilterCommentBlock : ItemFilterBlockBase, IItemFilterCommentBlock
|
||||
{
|
||||
public string Comment { get; set; }
|
||||
public bool IsSection { get; set; }
|
||||
}
|
||||
|
||||
public class ItemFilterBlock : ItemFilterBlockBase, IItemFilterBlock
|
||||
{
|
||||
private ItemFilterBlockGroup _blockGroup;
|
||||
|
||||
@@ -43,7 +62,7 @@ namespace Filtration.ObjectModel
|
||||
|
||||
public ItemFilterBlockGroup BlockGroup
|
||||
{
|
||||
get { return _blockGroup; }
|
||||
get => _blockGroup;
|
||||
set
|
||||
{
|
||||
var oldBlockGroup = _blockGroup;
|
||||
@@ -85,15 +104,15 @@ namespace Filtration.ObjectModel
|
||||
|
||||
public ObservableCollection<IItemFilterBlockItem> BlockItems { get; }
|
||||
|
||||
public int BlockCount(Type type)
|
||||
{
|
||||
return BlockItems?.Count(b => b.GetType() == type) ?? 0;
|
||||
}
|
||||
|
||||
public bool AddBlockItemAllowed(Type type)
|
||||
{
|
||||
int BlockCount()
|
||||
{
|
||||
return BlockItems?.Count(b => b.GetType() == type) ?? 0;
|
||||
}
|
||||
|
||||
var blockItem = (IItemFilterBlockItem)Activator.CreateInstance(type);
|
||||
return BlockCount(type) < blockItem.MaximumAllowed;
|
||||
return BlockCount() < blockItem.MaximumAllowed;
|
||||
}
|
||||
|
||||
public bool HasBlockItemOfType<T>()
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
public interface IItemFilterScript
|
||||
{
|
||||
ObservableCollection<IItemFilterBlock> ItemFilterBlocks { get; }
|
||||
ObservableCollection<IItemFilterBlockBase> ItemFilterBlocks { get; }
|
||||
ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; }
|
||||
ThemeComponentCollection ThemeComponents { get; set; }
|
||||
string FilePath { get; set; }
|
||||
@@ -25,7 +25,7 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
public ItemFilterScript()
|
||||
{
|
||||
ItemFilterBlocks = new ObservableCollection<IItemFilterBlock>();
|
||||
ItemFilterBlocks = new ObservableCollection<IItemFilterBlockBase>();
|
||||
ItemFilterBlockGroups = new ObservableCollection<ItemFilterBlockGroup>
|
||||
{
|
||||
new ItemFilterBlockGroup("Root", null)
|
||||
@@ -34,7 +34,7 @@ namespace Filtration.ObjectModel
|
||||
ItemFilterScriptSettings = new ItemFilterScriptSettings(ThemeComponents);
|
||||
}
|
||||
|
||||
public ObservableCollection<IItemFilterBlock> ItemFilterBlocks { get; }
|
||||
public ObservableCollection<IItemFilterBlockBase> ItemFilterBlocks { get; }
|
||||
public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; }
|
||||
|
||||
public ThemeComponentCollection ThemeComponents { get; set; }
|
||||
@@ -59,9 +59,7 @@ namespace Filtration.ObjectModel
|
||||
|
||||
public void ReplaceColors(ReplaceColorsParameterSet replaceColorsParameterSet)
|
||||
{
|
||||
foreach (
|
||||
var block in
|
||||
ItemFilterBlocks.Where(b => BlockIsColorReplacementCandidate(replaceColorsParameterSet, b)))
|
||||
foreach (var block in ItemFilterBlocks.OfType<ItemFilterBlock>().Where(b => BlockIsColorReplacementCandidate(replaceColorsParameterSet, b)))
|
||||
{
|
||||
if (replaceColorsParameterSet.ReplaceTextColor)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user