Cleaned up BlockItem classes, added BlockItemBase and pulled up ILootFilterBlockItem abstract members into it.

Added click toggle for Show/Hide as per suggestion from Antnee
This commit is contained in:
Ben 2015-06-07 15:13:09 +01:00
parent 270645623a
commit 0bab1e7c9a
12 changed files with 71 additions and 151 deletions

View File

@ -107,6 +107,7 @@
<Compile Include="Extensions\EnumHelper.cs" /> <Compile Include="Extensions\EnumHelper.cs" />
<Compile Include="Extensions\HyperlinkExtensions.cs" /> <Compile Include="Extensions\HyperlinkExtensions.cs" />
<Compile Include="Models\BlockItemBaseTypes\ActionBlockItem.cs" /> <Compile Include="Models\BlockItemBaseTypes\ActionBlockItem.cs" />
<Compile Include="Models\BlockItemBaseTypes\BlockItemBase.cs" />
<Compile Include="Models\BlockItemBaseTypes\ColorBlockItem.cs" /> <Compile Include="Models\BlockItemBaseTypes\ColorBlockItem.cs" />
<Compile Include="Models\BlockItemBaseTypes\DualIntegerBlockItem.cs" /> <Compile Include="Models\BlockItemBaseTypes\DualIntegerBlockItem.cs" />
<Compile Include="Models\BlockItemBaseTypes\IntegerBlockItem.cs" /> <Compile Include="Models\BlockItemBaseTypes\IntegerBlockItem.cs" />

View File

@ -1,12 +1,9 @@
using System.ComponentModel; using System.Windows.Media;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using Filtration.Annotations;
using Filtration.Enums; using Filtration.Enums;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.Models.BlockItemBaseTypes
{ {
internal class ActionBlockItem : ILootFilterBlockItem internal class ActionBlockItem : BlockItemBase
{ {
private BlockAction _action; private BlockAction _action;
@ -28,17 +25,17 @@ namespace Filtration.Models.BlockItemBaseTypes
} }
} }
public string PrefixText public override string PrefixText
{ {
get { return string.Empty; } get { return string.Empty; }
} }
public int MaximumAllowed public override int MaximumAllowed
{ {
get { return 1; } get { return 1; }
} }
public string DisplayHeading public override string DisplayHeading
{ {
get get
{ {
@ -46,7 +43,7 @@ namespace Filtration.Models.BlockItemBaseTypes
} }
} }
public string SummaryText public override string SummaryText
{ {
get get
{ {
@ -54,7 +51,7 @@ namespace Filtration.Models.BlockItemBaseTypes
} }
} }
public Color SummaryBackgroundColor public override Color SummaryBackgroundColor
{ {
get get
{ {
@ -62,7 +59,7 @@ namespace Filtration.Models.BlockItemBaseTypes
} }
} }
public Color SummaryTextColor public override Color SummaryTextColor
{ {
get get
{ {
@ -70,15 +67,11 @@ namespace Filtration.Models.BlockItemBaseTypes
} }
} }
public int SortOrder { get { return 0; } } public override int SortOrder { get { return 0; } }
public event PropertyChangedEventHandler PropertyChanged; public void ToggleAction()
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{ {
var handler = PropertyChanged; Action = Action == BlockAction.Show ? BlockAction.Hide : BlockAction.Show;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
} }
} }
} }

View File

@ -1,11 +1,8 @@
using System.ComponentModel; using System.Windows.Media;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using Filtration.Annotations;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.Models.BlockItemBaseTypes
{ {
internal abstract class ColorBlockItem : ILootFilterBlockItem, IAudioVisualBlockItem internal abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem
{ {
private Color _color; private Color _color;
@ -18,19 +15,13 @@ namespace Filtration.Models.BlockItemBaseTypes
Color = color; Color = color;
} }
public abstract string PrefixText { get; } public override string SummaryText
public abstract int MaximumAllowed { get; }
public abstract string DisplayHeading { get; }
public string SummaryText
{ {
get { return string.Empty; } get { return string.Empty; }
} }
public Color SummaryBackgroundColor { get { return Colors.Transparent; } } public override Color SummaryBackgroundColor { get { return Colors.Transparent; } }
public Color SummaryTextColor { get { return Colors.Transparent; } } public override Color SummaryTextColor { get { return Colors.Transparent; } }
public abstract int SortOrder { get; }
public Color Color public Color Color
{ {
@ -41,13 +32,5 @@ namespace Filtration.Models.BlockItemBaseTypes
OnPropertyChanged(); OnPropertyChanged();
} }
} }
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

View File

@ -1,11 +1,8 @@
using System.ComponentModel; using System.Windows.Media;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using Filtration.Annotations;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.Models.BlockItemBaseTypes
{ {
internal abstract class DualIntegerBlockItem : ILootFilterBlockItem, IAudioVisualBlockItem internal abstract class DualIntegerBlockItem : BlockItemBase, IAudioVisualBlockItem
{ {
private int _value; private int _value;
private int _secondValue; private int _secondValue;
@ -20,14 +17,9 @@ namespace Filtration.Models.BlockItemBaseTypes
SecondValue = secondValue; SecondValue = secondValue;
} }
public abstract string PrefixText { get; } public override string SummaryText { get { return string.Empty; } }
public abstract int MaximumAllowed { get; } public override Color SummaryBackgroundColor { get { return Colors.Transparent; } }
public abstract string DisplayHeading { get; } public override Color SummaryTextColor { get { return Colors.Transparent; } }
public string SummaryText { get { return string.Empty; } }
public Color SummaryBackgroundColor { get { return Colors.Transparent; } }
public Color SummaryTextColor { get { return Colors.Transparent; } }
public abstract int SortOrder { get; }
public int Value public int Value
{ {
@ -48,13 +40,5 @@ namespace Filtration.Models.BlockItemBaseTypes
OnPropertyChanged(); OnPropertyChanged();
} }
} }
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

View File

@ -1,11 +1,8 @@
using System.ComponentModel; using System.Windows.Media;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using Filtration.Annotations;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.Models.BlockItemBaseTypes
{ {
internal abstract class IntegerBlockItem : ILootFilterBlockItem, IAudioVisualBlockItem internal abstract class IntegerBlockItem : BlockItemBase, IAudioVisualBlockItem
{ {
private int _value; private int _value;
@ -18,15 +15,9 @@ namespace Filtration.Models.BlockItemBaseTypes
Value = value; Value = value;
} }
public abstract string PrefixText { get; } public override string SummaryText { get { return string.Empty; } }
public abstract int MaximumAllowed { get; } public override Color SummaryBackgroundColor { get { return Colors.Transparent; } }
public override Color SummaryTextColor { get { return Colors.Transparent; } }
public abstract string DisplayHeading { get; }
public string SummaryText { get { return string.Empty; } }
public Color SummaryBackgroundColor { get { return Colors.Transparent; } }
public Color SummaryTextColor { get { return Colors.Transparent; } }
public abstract int SortOrder { get; }
public abstract int Minimum { get; } public abstract int Minimum { get; }
public abstract int Maximum { get; } public abstract int Maximum { get; }
@ -40,13 +31,5 @@ namespace Filtration.Models.BlockItemBaseTypes
OnPropertyChanged(); OnPropertyChanged();
} }
} }
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

View File

@ -1,13 +1,9 @@
using System; using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using Filtration.Annotations;
using Filtration.Enums; using Filtration.Enums;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.Models.BlockItemBaseTypes
{ {
internal abstract class NumericFilterPredicateBlockItem : ILootFilterBlockItem internal abstract class NumericFilterPredicateBlockItem : BlockItemBase
{ {
private NumericFilterPredicate _filterPredicate; private NumericFilterPredicate _filterPredicate;
@ -23,14 +19,6 @@ namespace Filtration.Models.BlockItemBaseTypes
FilterPredicate.PropertyChanged += OnFilterPredicateChanged; FilterPredicate.PropertyChanged += OnFilterPredicateChanged;
} }
public abstract string PrefixText { get; }
public abstract int MaximumAllowed { get; }
public abstract string DisplayHeading { get; }
public abstract string SummaryText { get; }
public abstract Color SummaryBackgroundColor { get; }
public abstract Color SummaryTextColor { get; }
public abstract int SortOrder { get; }
public abstract int Minimum { get; } public abstract int Minimum { get; }
public abstract int Maximum { get; } public abstract int Maximum { get; }
@ -49,13 +37,5 @@ namespace Filtration.Models.BlockItemBaseTypes
OnPropertyChanged("FilterPredicate"); OnPropertyChanged("FilterPredicate");
OnPropertyChanged("SummaryText"); OnPropertyChanged("SummaryText");
} }
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

View File

@ -1,44 +1,22 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using Filtration.Annotations;
using Filtration.Enums; using Filtration.Enums;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.Models.BlockItemBaseTypes
{ {
internal abstract class SocketGroupBlockItemBase : ILootFilterBlockItem internal abstract class SocketGroupBlockItemBase : BlockItemBase
{ {
protected SocketGroupBlockItemBase() protected SocketGroupBlockItemBase()
{ {
SocketColorGroups = new ObservableCollection<List<SocketColor>>(); SocketColorGroups = new ObservableCollection<List<SocketColor>>();
SocketColorGroups.CollectionChanged += OnSocketColorGroupsCollectionChanged; SocketColorGroups.CollectionChanged += OnSocketColorGroupsCollectionChanged;
} }
public abstract string PrefixText { get; }
public abstract int MaximumAllowed { get; }
public abstract string DisplayHeading { get; }
public abstract string SummaryText { get; }
public abstract Color SummaryBackgroundColor { get; }
public abstract Color SummaryTextColor { get; }
public abstract int SortOrder { get; }
public ObservableCollection<List<SocketColor>> SocketColorGroups { get; private set; } public ObservableCollection<List<SocketColor>> SocketColorGroups { get; private set; }
private void OnSocketColorGroupsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) private void OnSocketColorGroupsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{ {
OnPropertyChanged("SocketColorGroups"); OnPropertyChanged("SocketColorGroups");
} }
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

View File

@ -1,13 +1,9 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using Filtration.Annotations;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.Models.BlockItemBaseTypes
{ {
internal abstract class StringListBlockItem : ILootFilterBlockItem internal abstract class StringListBlockItem : BlockItemBase
{ {
protected StringListBlockItem() protected StringListBlockItem()
{ {
@ -15,14 +11,6 @@ namespace Filtration.Models.BlockItemBaseTypes
Items.CollectionChanged += OnItemsCollectionChanged; Items.CollectionChanged += OnItemsCollectionChanged;
} }
public abstract string PrefixText { get; }
public abstract int MaximumAllowed { get; }
public abstract string DisplayHeading { get; }
public abstract string SummaryText { get; }
public abstract Color SummaryBackgroundColor { get; }
public abstract Color SummaryTextColor { get; }
public abstract int SortOrder { get; }
public ObservableCollection<string> Items { get; protected set; } public ObservableCollection<string> Items { get; protected set; }
private void OnItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) private void OnItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
@ -30,13 +18,5 @@ namespace Filtration.Models.BlockItemBaseTypes
OnPropertyChanged("Items"); OnPropertyChanged("Items");
OnPropertyChanged("SummaryText"); OnPropertyChanged("SummaryText");
} }
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using Filtration.Models.BlockItemTypes; using Filtration.Models.BlockItemTypes;
using Filtration.ViewModels;
using Filtration.Views;
namespace Filtration.Models namespace Filtration.Models
{ {

View File

@ -3,8 +3,10 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using Filtration.Models; using Filtration.Models;
using Filtration.Models.BlockItemBaseTypes;
using Filtration.Models.BlockItemTypes; using Filtration.Models.BlockItemTypes;
using Filtration.Services; using Filtration.Services;
using Filtration.Views; using Filtration.Views;
@ -44,6 +46,7 @@ namespace Filtration.ViewModels
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand); MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand);
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand); ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand);
AddFilterBlockItemCommand = new RelayCommand<Type>(OnAddFilterBlockItemCommand); AddFilterBlockItemCommand = new RelayCommand<Type>(OnAddFilterBlockItemCommand);
ToggleBlockActionCommand = new RelayCommand(OnToggleBlockActionCommand);
AddAudioVisualBlockItemCommand = new RelayCommand<Type>(OnAddAudioVisualBlockItemCommand); AddAudioVisualBlockItemCommand = new RelayCommand<Type>(OnAddAudioVisualBlockItemCommand);
RemoveFilterBlockItemCommand = new RelayCommand<ILootFilterBlockItem>(OnRemoveFilterBlockItemCommand); RemoveFilterBlockItemCommand = new RelayCommand<ILootFilterBlockItem>(OnRemoveFilterBlockItemCommand);
RemoveAudioVisualBlockItemCommand = new RelayCommand<ILootFilterBlockItem>(OnRemoveAudioVisualBlockItemCommand); RemoveAudioVisualBlockItemCommand = new RelayCommand<ILootFilterBlockItem>(OnRemoveAudioVisualBlockItemCommand);
@ -77,6 +80,7 @@ namespace Filtration.ViewModels
public RelayCommand MoveBlockDownCommand { get; private set; } public RelayCommand MoveBlockDownCommand { get; private set; }
public RelayCommand MoveBlockToTopCommand { get; private set; } public RelayCommand MoveBlockToTopCommand { get; private set; }
public RelayCommand MoveBlockToBottomCommand { get; private set; } public RelayCommand MoveBlockToBottomCommand { get; private set; }
public RelayCommand ToggleBlockActionCommand { get; private set; }
public RelayCommand ReplaceColorsCommand { get; private set; } public RelayCommand ReplaceColorsCommand { get; private set; }
public RelayCommand<Type> AddFilterBlockItemCommand { get; private set; } public RelayCommand<Type> AddFilterBlockItemCommand { get; private set; }
public RelayCommand<Type> AddAudioVisualBlockItemCommand { get; private set; } public RelayCommand<Type> AddAudioVisualBlockItemCommand { get; private set; }
@ -245,6 +249,15 @@ namespace Filtration.ViewModels
get { return Block.HasBlockItemOfType<SoundBlockItem>(); } get { return Block.HasBlockItemOfType<SoundBlockItem>(); }
} }
private void OnToggleBlockActionCommand()
{
var actionBlock = Block.BlockItems.OfType<ActionBlockItem>().First();
if (actionBlock != null)
{
actionBlock.ToggleAction();
}
}
private void OnAddFilterBlockItemCommand(Type blockItemType) private void OnAddFilterBlockItemCommand(Type blockItemType)
{ {
if (!AddBlockItemAllowed(blockItemType)) return; if (!AddBlockItemAllowed(blockItemType)) return;

View File

@ -10,6 +10,7 @@
xmlns:blockItemTypes="clr-namespace:Filtration.Models.BlockItemTypes" xmlns:blockItemTypes="clr-namespace:Filtration.Models.BlockItemTypes"
xmlns:enums="clr-namespace:Filtration.Enums" xmlns:enums="clr-namespace:Filtration.Enums"
xmlns:extensions="clr-namespace:Filtration.Extensions" xmlns:extensions="clr-namespace:Filtration.Extensions"
xmlns:models="clr-namespace:Filtration.Models"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:LootFilterBlockViewModel}" d:DataContext="{d:DesignInstance Type=viewModels:LootFilterBlockViewModel}"
d:DesignHeight="200" d:DesignWidth="800"> d:DesignHeight="200" d:DesignWidth="800">
@ -72,13 +73,24 @@
<WrapPanel /> <WrapPanel />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate> <ItemsControl.Resources>
<DataTemplate>
<DataTemplate DataType="{x:Type blockItemBaseTypes:BlockItemBase}">
<Border BorderBrush="Black" CornerRadius="4" Margin="0,2,2,2" BorderThickness="1" Background="{Binding SummaryBackgroundColor, Converter={StaticResource ColorToSolidColorBrushConverter}}"> <Border BorderBrush="Black" CornerRadius="4" Margin="0,2,2,2" BorderThickness="1" Background="{Binding SummaryBackgroundColor, Converter={StaticResource ColorToSolidColorBrushConverter}}">
<TextBlock Text="{Binding SummaryText}" Margin="5,1,5,1" Foreground="{Binding SummaryTextColor, Converter={StaticResource ColorToSolidColorBrushConverter}}" /> <TextBlock Text="{Binding SummaryText}" Margin="5,1,5,1" Foreground="{Binding SummaryTextColor, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
</Border> </Border>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type blockItemBaseTypes:ActionBlockItem}">
<Button Command="{Binding ElementName=TopLevelGrid, Path=DataContext.ToggleBlockActionCommand}" Style="{StaticResource ChromelessButton}">
<Border BorderBrush="Black" CornerRadius="4" Margin="0,2,2,2" BorderThickness="1" Background="{Binding SummaryBackgroundColor, Converter={StaticResource ColorToSolidColorBrushConverter}}">
<TextBlock Text="{Binding SummaryText}" Margin="5,1,5,1" Foreground="{Binding SummaryTextColor, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
</Border>
</Button>
</DataTemplate>
<!--</ItemsControl.ItemTemplate>-->
</ItemsControl.Resources>
</ItemsControl> </ItemsControl>
</StackPanel> </StackPanel>

View File

@ -21,6 +21,17 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<Style x:Key="ChromelessButton" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" /> <converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" />
<converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" /> <converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
<converters:BoolInverterConverter x:Key="BoolInverterConverter" /> <converters:BoolInverterConverter x:Key="BoolInverterConverter" />