2015-06-04 13:15:54 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.ObjectModel;
|
2018-08-20 13:12:45 -04:00
|
|
|
|
using System.Collections.Specialized;
|
2015-06-04 13:15:54 -04:00
|
|
|
|
using System.Linq;
|
2016-01-31 05:51:53 -05:00
|
|
|
|
using System.Windows.Media;
|
2015-06-24 14:57:16 -04:00
|
|
|
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
2016-01-31 05:51:53 -05:00
|
|
|
|
using Filtration.ObjectModel.BlockItemTypes;
|
2017-12-07 13:14:47 -05:00
|
|
|
|
using Filtration.ObjectModel.Commands;
|
2015-06-24 14:57:16 -04:00
|
|
|
|
using Filtration.ObjectModel.Enums;
|
2016-01-31 05:51:53 -05:00
|
|
|
|
using Filtration.ObjectModel.Extensions;
|
2015-06-04 13:15:54 -04:00
|
|
|
|
|
2015-06-24 14:57:16 -04:00
|
|
|
|
namespace Filtration.ObjectModel
|
2015-06-04 13:15:54 -04:00
|
|
|
|
{
|
2017-05-20 13:14:28 -04:00
|
|
|
|
public interface IItemFilterBlock : IItemFilterBlockBase
|
2015-12-28 12:30:34 -05:00
|
|
|
|
{
|
|
|
|
|
bool Enabled { get; set; }
|
2018-09-06 02:59:09 -04:00
|
|
|
|
event EventHandler EnabledStatusChanged;
|
2015-12-28 12:30:34 -05:00
|
|
|
|
string Description { get; set; }
|
|
|
|
|
ItemFilterBlockGroup BlockGroup { get; set; }
|
|
|
|
|
BlockAction Action { get; set; }
|
2017-05-14 09:10:54 -04:00
|
|
|
|
ActionBlockItem ActionBlockItem { get; }
|
2015-12-28 12:30:34 -05:00
|
|
|
|
ObservableCollection<IItemFilterBlockItem> BlockItems { get; }
|
2016-01-31 05:51:53 -05:00
|
|
|
|
Color DisplayBackgroundColor { get; }
|
|
|
|
|
Color DisplayTextColor { get; }
|
|
|
|
|
Color DisplayBorderColor { get; }
|
|
|
|
|
double DisplayFontSize { get; }
|
2018-08-29 13:12:02 -04:00
|
|
|
|
int DisplayIconSize { get; }
|
|
|
|
|
int DisplayIconColor { get; }
|
|
|
|
|
int DisplayIconShape { get; }
|
|
|
|
|
Color DisplayEffectColor { get; }
|
2015-12-28 12:30:34 -05:00
|
|
|
|
bool HasBlockItemOfType<T>();
|
|
|
|
|
bool HasBlockGroupInParentHierarchy(ItemFilterBlockGroup targetBlockGroup, ItemFilterBlockGroup startingBlockGroup);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-20 13:14:28 -04:00
|
|
|
|
public interface IItemFilterBlockBase
|
|
|
|
|
{
|
2018-08-20 13:12:45 -04:00
|
|
|
|
bool IsEdited { get; set; }
|
|
|
|
|
string OriginalText { get; set; }
|
2017-05-20 13:14:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-07 13:14:47 -05:00
|
|
|
|
public abstract class ItemFilterBlockBase : IItemFilterBlockBase
|
2017-05-20 13:14:28 -04:00
|
|
|
|
{
|
2017-12-07 13:14:47 -05:00
|
|
|
|
protected ItemFilterBlockBase()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected ItemFilterBlockBase(IItemFilterScript parentScript)
|
|
|
|
|
{
|
|
|
|
|
CommandManager = parentScript.CommandManager;
|
|
|
|
|
ParentScript = parentScript;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ICommandManager CommandManager { get; }
|
|
|
|
|
public IItemFilterScript ParentScript { get; set; }
|
2018-08-20 13:12:45 -04:00
|
|
|
|
public bool IsEdited { get; set; }
|
|
|
|
|
public string OriginalText { get; set; }
|
2017-05-20 13:14:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IItemFilterCommentBlock : IItemFilterBlockBase
|
|
|
|
|
{
|
|
|
|
|
string Comment { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ItemFilterCommentBlock : ItemFilterBlockBase, IItemFilterCommentBlock
|
|
|
|
|
{
|
2018-08-20 13:12:45 -04:00
|
|
|
|
private string _comment;
|
2017-12-07 13:14:47 -05:00
|
|
|
|
public ItemFilterCommentBlock(IItemFilterScript parentScript) : base(parentScript)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-20 13:12:45 -04:00
|
|
|
|
public string Comment
|
|
|
|
|
{
|
|
|
|
|
get { return _comment; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_comment = value;
|
|
|
|
|
IsEdited = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-20 13:14:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ItemFilterBlock : ItemFilterBlockBase, IItemFilterBlock
|
2015-06-04 13:15:54 -04:00
|
|
|
|
{
|
2015-06-11 17:01:52 -04:00
|
|
|
|
private ItemFilterBlockGroup _blockGroup;
|
2018-08-20 13:12:45 -04:00
|
|
|
|
private bool _enabled;
|
|
|
|
|
private string _description;
|
2015-06-11 17:01:52 -04:00
|
|
|
|
|
2017-12-07 13:14:47 -05:00
|
|
|
|
internal ItemFilterBlock()
|
|
|
|
|
{
|
|
|
|
|
BlockItems = new ObservableCollection<IItemFilterBlockItem> { ActionBlockItem };
|
2018-08-20 13:12:45 -04:00
|
|
|
|
BlockItems.CollectionChanged += new NotifyCollectionChangedEventHandler(OnBlockItemsChanged);
|
|
|
|
|
_enabled = true;
|
2017-12-07 13:14:47 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ItemFilterBlock(IItemFilterScript parentScript) : base(parentScript)
|
2015-06-04 13:15:54 -04:00
|
|
|
|
{
|
2017-12-07 13:14:47 -05:00
|
|
|
|
BlockItems = new ObservableCollection<IItemFilterBlockItem> { ActionBlockItem };
|
2018-08-20 13:12:45 -04:00
|
|
|
|
BlockItems.CollectionChanged += new NotifyCollectionChangedEventHandler(OnBlockItemsChanged);
|
|
|
|
|
_enabled = true;
|
2015-06-04 13:15:54 -04:00
|
|
|
|
}
|
2015-07-06 13:19:05 -04:00
|
|
|
|
|
2018-08-20 13:12:45 -04:00
|
|
|
|
public bool Enabled
|
|
|
|
|
{
|
|
|
|
|
get { return _enabled; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enabled = value;
|
|
|
|
|
IsEdited = true;
|
2018-09-06 02:59:09 -04:00
|
|
|
|
EnabledStatusChanged?.Invoke(null, null);
|
2018-08-20 13:12:45 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-06 02:59:09 -04:00
|
|
|
|
|
|
|
|
|
public event EventHandler EnabledStatusChanged;
|
|
|
|
|
|
2018-08-20 13:12:45 -04:00
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get { return _description; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_description = value;
|
|
|
|
|
IsEdited = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-11 17:01:52 -04:00
|
|
|
|
|
|
|
|
|
public ItemFilterBlockGroup BlockGroup
|
|
|
|
|
{
|
2017-05-20 13:14:28 -04:00
|
|
|
|
get => _blockGroup;
|
2015-06-11 17:01:52 -04:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
var oldBlockGroup = _blockGroup;
|
|
|
|
|
_blockGroup = value;
|
|
|
|
|
|
|
|
|
|
if (_blockGroup != null)
|
|
|
|
|
{
|
|
|
|
|
_blockGroup.BlockGroupStatusChanged += OnBlockGroupStatusChanged;
|
|
|
|
|
if (oldBlockGroup != null)
|
|
|
|
|
{
|
|
|
|
|
oldBlockGroup.BlockGroupStatusChanged -= OnBlockGroupStatusChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (oldBlockGroup != null)
|
|
|
|
|
{
|
|
|
|
|
oldBlockGroup.BlockGroupStatusChanged -= OnBlockGroupStatusChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-04 13:15:54 -04:00
|
|
|
|
|
|
|
|
|
public BlockAction Action
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var actionBlock = BlockItems.OfType<ActionBlockItem>().First();
|
|
|
|
|
return actionBlock.Action;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
var actionBlock = BlockItems.OfType<ActionBlockItem>().First();
|
|
|
|
|
actionBlock.Action = value;
|
2018-08-20 13:12:45 -04:00
|
|
|
|
IsEdited = true;
|
2015-06-04 13:15:54 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-07 13:14:47 -05:00
|
|
|
|
public ActionBlockItem ActionBlockItem { get; } = new ActionBlockItem(BlockAction.Show);
|
2017-05-14 09:10:54 -04:00
|
|
|
|
|
2015-12-13 15:17:15 -05:00
|
|
|
|
public ObservableCollection<IItemFilterBlockItem> BlockItems { get; }
|
2018-08-20 13:12:45 -04:00
|
|
|
|
private void OnBlockItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
IsEdited = true;
|
|
|
|
|
}
|
2015-06-04 13:15:54 -04:00
|
|
|
|
|
|
|
|
|
public bool AddBlockItemAllowed(Type type)
|
|
|
|
|
{
|
2017-05-20 13:14:28 -04:00
|
|
|
|
int BlockCount()
|
|
|
|
|
{
|
|
|
|
|
return BlockItems?.Count(b => b.GetType() == type) ?? 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-08 15:17:34 -04:00
|
|
|
|
var blockItem = (IItemFilterBlockItem)Activator.CreateInstance(type);
|
2017-05-20 13:14:28 -04:00
|
|
|
|
return BlockCount() < blockItem.MaximumAllowed;
|
2015-06-04 13:15:54 -04:00
|
|
|
|
}
|
2015-06-06 15:44:38 -04:00
|
|
|
|
|
|
|
|
|
public bool HasBlockItemOfType<T>()
|
|
|
|
|
{
|
|
|
|
|
return BlockItems.Count(b => b is T) > 0;
|
|
|
|
|
}
|
2015-06-11 17:01:52 -04:00
|
|
|
|
|
2015-06-14 11:50:08 -04:00
|
|
|
|
public bool HasBlockGroupInParentHierarchy(ItemFilterBlockGroup targetBlockGroup, ItemFilterBlockGroup startingBlockGroup)
|
|
|
|
|
{
|
|
|
|
|
if (startingBlockGroup == targetBlockGroup)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (BlockGroup == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-19 18:02:32 -05:00
|
|
|
|
return startingBlockGroup.ParentGroup != null && HasBlockGroupInParentHierarchy(targetBlockGroup, startingBlockGroup.ParentGroup);
|
2015-06-14 11:50:08 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-11 17:01:52 -04:00
|
|
|
|
private void OnBlockGroupStatusChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2018-09-06 02:59:09 -04:00
|
|
|
|
if (BlockGroup.IsShowChecked == false && Action == BlockAction.Show)
|
2015-06-11 17:01:52 -04:00
|
|
|
|
{
|
|
|
|
|
Action = BlockAction.Hide;
|
|
|
|
|
}
|
2018-09-06 02:59:09 -04:00
|
|
|
|
else if (BlockGroup.IsShowChecked && Action == BlockAction.Hide)
|
2015-06-11 17:01:52 -04:00
|
|
|
|
{
|
|
|
|
|
Action = BlockAction.Show;
|
|
|
|
|
}
|
2018-09-06 02:59:09 -04:00
|
|
|
|
|
|
|
|
|
if (BlockGroup.IsEnableChecked == false && Enabled)
|
|
|
|
|
{
|
|
|
|
|
Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
else if (BlockGroup.IsEnableChecked && !Enabled)
|
|
|
|
|
{
|
|
|
|
|
Enabled = true;
|
|
|
|
|
}
|
2015-06-11 17:01:52 -04:00
|
|
|
|
}
|
2016-01-31 05:51:53 -05:00
|
|
|
|
|
|
|
|
|
public Color DisplayTextColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var textColorBlockItem = BlockItems.OfType<TextColorBlockItem>().FirstOrDefault();
|
|
|
|
|
if (textColorBlockItem != null)
|
|
|
|
|
{
|
|
|
|
|
return textColorBlockItem.Color;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-31 09:11:30 -05:00
|
|
|
|
var itemClassBlockItem = BlockItems.OfType<ClassBlockItem>().FirstOrDefault();
|
|
|
|
|
if (itemClassBlockItem != null)
|
|
|
|
|
{
|
|
|
|
|
if (itemClassBlockItem.Items.All(i => i.Contains("Gems")))
|
|
|
|
|
{
|
|
|
|
|
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.GemItem];
|
|
|
|
|
}
|
|
|
|
|
if (itemClassBlockItem.Items.All(i => i.Contains("Quest")))
|
|
|
|
|
{
|
|
|
|
|
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.QuestItem];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-31 05:51:53 -05:00
|
|
|
|
var rarityBlockItem = BlockItems.OfType<RarityBlockItem>().FirstOrDefault();
|
|
|
|
|
return rarityBlockItem != null
|
|
|
|
|
? ((ItemRarity) rarityBlockItem.FilterPredicate.PredicateOperand).DefaultRarityTextColor()
|
|
|
|
|
: PathOfExileNamedColors.Colors[PathOfExileNamedColor.WhiteItem];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color DisplayBackgroundColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var backgroundColorBlockItem = BlockItems.OfType<BackgroundColorBlockItem>().FirstOrDefault();
|
2018-09-03 08:37:10 -04:00
|
|
|
|
return backgroundColorBlockItem?.Color ?? new Color { A = 240, R = 0, G = 0, B = 0 };
|
2016-01-31 05:51:53 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color DisplayBorderColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var borderColorBlockItem = BlockItems.OfType<BorderColorBlockItem>().FirstOrDefault();
|
2018-09-03 08:37:10 -04:00
|
|
|
|
return borderColorBlockItem?.Color ?? new Color { A = 240, R = 0, G = 0, B = 0 };
|
2016-01-31 05:51:53 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double DisplayFontSize
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var fontSizeBlockItem = BlockItems.OfType<FontSizeBlockItem>().FirstOrDefault();
|
|
|
|
|
return fontSizeBlockItem?.Value ?? 34;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-21 10:03:42 -04:00
|
|
|
|
|
2018-08-29 13:12:02 -04:00
|
|
|
|
public int DisplayIconSize
|
2018-08-21 10:03:42 -04:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2018-08-29 13:12:02 -04:00
|
|
|
|
var mapIconBlockItem = BlockItems.OfType<MapIconBlockItem>().FirstOrDefault();
|
|
|
|
|
if (mapIconBlockItem != null)
|
|
|
|
|
return (int)mapIconBlockItem.Size;
|
|
|
|
|
|
|
|
|
|
return -1;
|
2018-08-21 10:03:42 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-22 06:15:50 -04:00
|
|
|
|
|
2018-08-29 13:12:02 -04:00
|
|
|
|
public int DisplayIconColor
|
2018-08-22 06:15:50 -04:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2018-08-29 13:12:02 -04:00
|
|
|
|
var mapIconBlockItem = BlockItems.OfType<MapIconBlockItem>().FirstOrDefault();
|
|
|
|
|
if (mapIconBlockItem != null)
|
|
|
|
|
return (int)mapIconBlockItem.Color;
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int DisplayIconShape
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var mapIconBlockItem = BlockItems.OfType<MapIconBlockItem>().FirstOrDefault();
|
|
|
|
|
if (mapIconBlockItem != null)
|
|
|
|
|
return (int)mapIconBlockItem.Shape;
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color DisplayEffectColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var beamBlockItem = BlockItems.OfType<PlayEffectBlockItem>().FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (beamBlockItem != null)
|
|
|
|
|
{
|
|
|
|
|
switch (beamBlockItem.Color)
|
|
|
|
|
{
|
|
|
|
|
case EffectColor.Red:
|
|
|
|
|
return Colors.Red;
|
|
|
|
|
case EffectColor.Green:
|
|
|
|
|
return Colors.Green;
|
|
|
|
|
case EffectColor.Blue:
|
|
|
|
|
return Colors.Blue;
|
|
|
|
|
case EffectColor.Brown:
|
|
|
|
|
return Colors.Brown;
|
|
|
|
|
case EffectColor.White:
|
|
|
|
|
return Colors.White;
|
|
|
|
|
case EffectColor.Yellow:
|
|
|
|
|
return Colors.Yellow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Colors.Transparent;
|
2018-08-22 06:15:50 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-04 13:15:54 -04:00
|
|
|
|
}
|
|
|
|
|
}
|