Added partial support for Advanced BlockGroups
This commit is contained in:
parent
08a193dc6b
commit
08d9cf277b
|
@ -51,5 +51,22 @@ namespace Filtration.Tests.Models
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsFalse(result);
|
Assert.IsFalse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void HasParentInBlockGroupHierarchy_ReturnsCorrectResult()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputRootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null);
|
||||||
|
var testInputSubBlockGroup = new ItemFilterBlockGroup("Sub Block Group", testInputRootBlockGroup);
|
||||||
|
var testInputSubSubBlockGroup = new ItemFilterBlockGroup("Sub Sub Block Group", testInputSubBlockGroup);
|
||||||
|
|
||||||
|
var block = new ItemFilterBlock {BlockGroup = testInputSubSubBlockGroup};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(true, block.HasBlockGroupInParentHierarchy(testInputRootBlockGroup, block.BlockGroup));
|
||||||
|
Assert.AreEqual(true, block.HasBlockGroupInParentHierarchy(testInputSubBlockGroup, block.BlockGroup));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,10 @@ namespace Filtration.Tests.Translators
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var inputString = "Show # TestBlockGroup" + Environment.NewLine;
|
var inputString = "Show # TestBlockGroup" + Environment.NewLine;
|
||||||
|
var inputBlockGroup = new ItemFilterBlockGroup("TestBlockGroup", null);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace Filtration.Converters
|
||||||
|
{
|
||||||
|
internal class BlockGroupAdvancedColorConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
var advanced = (bool) value;
|
||||||
|
|
||||||
|
return advanced ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Black);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -107,6 +107,8 @@
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="Converters\ActiveDocumentConverter.cs" />
|
<Compile Include="Converters\ActiveDocumentConverter.cs" />
|
||||||
|
<Compile Include="Converters\BlockGroupAdvancedColorConverter.cs" />
|
||||||
|
<Compile Include="Converters\BlockGroupVisibilityConverter.cs" />
|
||||||
<Compile Include="Converters\BlockItemTypeToStringConverter.cs" />
|
<Compile Include="Converters\BlockItemTypeToStringConverter.cs" />
|
||||||
<Compile Include="Converters\BooleanInverterConverter.cs" />
|
<Compile Include="Converters\BooleanInverterConverter.cs" />
|
||||||
<Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" />
|
<Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" />
|
||||||
|
@ -372,6 +374,7 @@
|
||||||
<Resource Include="Resources\Icons\block_group_browser_icon.png" />
|
<Resource Include="Resources\Icons\block_group_browser_icon.png" />
|
||||||
<Resource Include="Resources\Icons\clear_filter_icon.png" />
|
<Resource Include="Resources\Icons\clear_filter_icon.png" />
|
||||||
<Resource Include="Resources\Icons\filter_icon.png" />
|
<Resource Include="Resources\Icons\filter_icon.png" />
|
||||||
|
<Resource Include="Resources\Icons\show_advanced_icon.png" />
|
||||||
<Content Include="Resources\ItemBaseTypes.txt">
|
<Content Include="Resources\ItemBaseTypes.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
@ -12,10 +12,11 @@ namespace Filtration.Models
|
||||||
private bool? _isChecked;
|
private bool? _isChecked;
|
||||||
private bool _reentrancyCheck;
|
private bool _reentrancyCheck;
|
||||||
|
|
||||||
public ItemFilterBlockGroup(string groupName, ItemFilterBlockGroup parent)
|
public ItemFilterBlockGroup(string groupName, ItemFilterBlockGroup parent, bool advanced = false)
|
||||||
{
|
{
|
||||||
GroupName = groupName;
|
GroupName = groupName;
|
||||||
ParentGroup = parent;
|
ParentGroup = parent;
|
||||||
|
Advanced = advanced;
|
||||||
ChildGroups = new ObservableCollection<ItemFilterBlockGroup>();
|
ChildGroups = new ObservableCollection<ItemFilterBlockGroup>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +44,8 @@ namespace Filtration.Models
|
||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Advanced { get; private set; }
|
||||||
|
|
||||||
public bool? IsChecked
|
public bool? IsChecked
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -91,7 +94,7 @@ namespace Filtration.Models
|
||||||
|
|
||||||
private void UpdateChildrenCheckState()
|
private void UpdateChildrenCheckState()
|
||||||
{
|
{
|
||||||
foreach (var childGroup in ChildGroups.Where(c => IsChecked != null))
|
foreach (var childGroup in ChildGroups.Where(c => IsChecked != null && !c.Advanced))
|
||||||
{
|
{
|
||||||
childGroup.IsChecked = IsChecked;
|
childGroup.IsChecked = IsChecked;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +117,28 @@ namespace Filtration.Models
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemFilterBlockGroup Search(Func<ItemFilterBlockGroup, bool> predicate)
|
||||||
|
{
|
||||||
|
// if node is a leaf
|
||||||
|
if (ChildGroups == null || ChildGroups.Count == 0)
|
||||||
|
{
|
||||||
|
return predicate(this) ? this : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var results = ChildGroups
|
||||||
|
.Select(i => i.Search(predicate))
|
||||||
|
.Where(i => i != null).ToList();
|
||||||
|
|
||||||
|
if (results.Any())
|
||||||
|
{
|
||||||
|
var result = (ItemFilterBlockGroup)MemberwiseClone();
|
||||||
|
result.ChildGroups = new ObservableCollection<ItemFilterBlockGroup>(results);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
[NotifyPropertyChangedInvocator]
|
[NotifyPropertyChangedInvocator]
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 305 B |
|
@ -33,6 +33,10 @@ namespace Filtration.Translators
|
||||||
{
|
{
|
||||||
var inputGroups = groupStrings.ToList();
|
var inputGroups = groupStrings.ToList();
|
||||||
var firstGroup = inputGroups.First().Trim();
|
var firstGroup = inputGroups.First().Trim();
|
||||||
|
if (firstGroup.StartsWith("~"))
|
||||||
|
{
|
||||||
|
firstGroup = firstGroup.Substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
ItemFilterBlockGroup matchingChildItemGroup = null;
|
ItemFilterBlockGroup matchingChildItemGroup = null;
|
||||||
if (startItemGroup.ChildGroups.Count(g => g.GroupName == firstGroup) > 0)
|
if (startItemGroup.ChildGroups.Count(g => g.GroupName == firstGroup) > 0)
|
||||||
|
@ -42,7 +46,7 @@ namespace Filtration.Translators
|
||||||
|
|
||||||
if (matchingChildItemGroup == null)
|
if (matchingChildItemGroup == null)
|
||||||
{
|
{
|
||||||
var newItemGroup = new ItemFilterBlockGroup(inputGroups.First().Trim(), startItemGroup);
|
var newItemGroup = CreateBlockGroup(inputGroups.First().Trim(), startItemGroup);
|
||||||
startItemGroup.ChildGroups.Add(newItemGroup);
|
startItemGroup.ChildGroups.Add(newItemGroup);
|
||||||
inputGroups = inputGroups.Skip(1).ToList();
|
inputGroups = inputGroups.Skip(1).ToList();
|
||||||
return inputGroups.Count > 0 ? IntegrateStringListIntoBlockGroupHierarchy(inputGroups, newItemGroup) : newItemGroup;
|
return inputGroups.Count > 0 ? IntegrateStringListIntoBlockGroupHierarchy(inputGroups, newItemGroup) : newItemGroup;
|
||||||
|
@ -50,5 +54,23 @@ namespace Filtration.Translators
|
||||||
inputGroups = inputGroups.Skip(1).ToList();
|
inputGroups = inputGroups.Skip(1).ToList();
|
||||||
return inputGroups.Count > 0 ? IntegrateStringListIntoBlockGroupHierarchy(inputGroups, matchingChildItemGroup) : matchingChildItemGroup;
|
return inputGroups.Count > 0 ? IntegrateStringListIntoBlockGroupHierarchy(inputGroups, matchingChildItemGroup) : matchingChildItemGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ItemFilterBlockGroup CreateBlockGroup(string groupNameString, ItemFilterBlockGroup parentGroup)
|
||||||
|
{
|
||||||
|
var advanced = false;
|
||||||
|
|
||||||
|
if (groupNameString.StartsWith("~"))
|
||||||
|
{
|
||||||
|
groupNameString = groupNameString.Substring(1);
|
||||||
|
advanced = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parentGroup.Advanced)
|
||||||
|
{
|
||||||
|
advanced = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ItemFilterBlockGroup(groupNameString, parentGroup, advanced);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ using Filtration.Models;
|
||||||
using Filtration.Services;
|
using Filtration.Services;
|
||||||
using Filtration.Translators;
|
using Filtration.Translators;
|
||||||
using GalaSoft.MvvmLight.CommandWpf;
|
using GalaSoft.MvvmLight.CommandWpf;
|
||||||
|
using GalaSoft.MvvmLight.Messaging;
|
||||||
using Clipboard = System.Windows.Clipboard;
|
using Clipboard = System.Windows.Clipboard;
|
||||||
using MessageBox = System.Windows.MessageBox;
|
using MessageBox = System.Windows.MessageBox;
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ namespace Filtration.ViewModels
|
||||||
IEnumerable<IItemFilterBlockViewModel> ItemFilterSectionViewModels { get; }
|
IEnumerable<IItemFilterBlockViewModel> ItemFilterSectionViewModels { get; }
|
||||||
Predicate<IItemFilterBlockViewModel> BlockFilterPredicate { get; set; }
|
Predicate<IItemFilterBlockViewModel> BlockFilterPredicate { get; set; }
|
||||||
bool IsDirty { get; }
|
bool IsDirty { get; }
|
||||||
|
bool ShowAdvanced { get; }
|
||||||
string Description { get; set; }
|
string Description { get; set; }
|
||||||
string DisplayName { get; }
|
string DisplayName { get; }
|
||||||
|
|
||||||
|
@ -67,6 +69,7 @@ namespace Filtration.ViewModels
|
||||||
_persistenceService = persistenceService;
|
_persistenceService = persistenceService;
|
||||||
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>();
|
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>();
|
||||||
|
|
||||||
|
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
|
||||||
ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
|
ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
|
||||||
CloseCommand = new RelayCommand(OnCloseCommand);
|
CloseCommand = new RelayCommand(OnCloseCommand);
|
||||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null);
|
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null);
|
||||||
|
@ -80,6 +83,7 @@ namespace Filtration.ViewModels
|
||||||
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
|
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RelayCommand<bool> ToggleShowAdvancedCommand { get; private set; }
|
||||||
public RelayCommand ClearFilterCommand { get; private set; }
|
public RelayCommand ClearFilterCommand { get; private set; }
|
||||||
public RelayCommand CloseCommand { get; private set; }
|
public RelayCommand CloseCommand { get; private set; }
|
||||||
public RelayCommand DeleteBlockCommand { get; private set; }
|
public RelayCommand DeleteBlockCommand { get; private set; }
|
||||||
|
@ -150,6 +154,16 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShowAdvanced
|
||||||
|
{
|
||||||
|
get { return _showAdvanced; }
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
_showAdvanced = value;
|
||||||
|
RaisePropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IItemFilterBlockViewModel SelectedBlockViewModel
|
public IItemFilterBlockViewModel SelectedBlockViewModel
|
||||||
{
|
{
|
||||||
get { return _selectedBlockViewModel; }
|
get { return _selectedBlockViewModel; }
|
||||||
|
@ -223,6 +237,7 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _filenameIsFake;
|
private bool _filenameIsFake;
|
||||||
|
private bool _showAdvanced;
|
||||||
|
|
||||||
public void Initialise(ItemFilterScript itemFilterScript, bool newScript)
|
public void Initialise(ItemFilterScript itemFilterScript, bool newScript)
|
||||||
{
|
{
|
||||||
|
@ -384,6 +399,12 @@ namespace Filtration.ViewModels
|
||||||
_avalonDockWorkspaceViewModel.CloseDocument(this);
|
_avalonDockWorkspaceViewModel.CloseDocument(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnToggleShowAdvancedCommand(bool showAdvanced)
|
||||||
|
{
|
||||||
|
ShowAdvanced = !ShowAdvanced;
|
||||||
|
Messenger.Default.Send(new NotificationMessage<bool>(ShowAdvanced, "ShowAdvancedToggled"));
|
||||||
|
}
|
||||||
|
|
||||||
private void OnClearFilterCommand()
|
private void OnClearFilterCommand()
|
||||||
{
|
{
|
||||||
BlockFilterPredicate = null;
|
BlockFilterPredicate = null;
|
||||||
|
|
|
@ -19,4 +19,5 @@
|
||||||
<Image Source="/Filtration;component/Resources/Icons/replace_colors_icon.png" x:Key="ReplaceColorsIcon" x:Shared="false" />
|
<Image Source="/Filtration;component/Resources/Icons/replace_colors_icon.png" x:Key="ReplaceColorsIcon" x:Shared="false" />
|
||||||
<Image Source="/Filtration;component/Resources/Icons/clear_filter_icon.png" x:Key="ClearFilterIcon" x:Shared="False" />
|
<Image Source="/Filtration;component/Resources/Icons/clear_filter_icon.png" x:Key="ClearFilterIcon" x:Shared="False" />
|
||||||
<Image Source="/Filtration;component/Resources/Icons/filter_icon.png" x:Key="FilterIcon" x:Shared="False" />
|
<Image Source="/Filtration;component/Resources/Icons/filter_icon.png" x:Key="FilterIcon" x:Shared="False" />
|
||||||
|
<Image Source="/Filtration;component/Resources/Icons/show_advanced_icon.png" x:Key="ShowAdvancedIcon" x:Shared="False" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
|
@ -61,6 +61,7 @@
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ToolBar>
|
<ToolBar>
|
||||||
<Button ToolTip="Clear Filter" Command="{Binding ClearFilterCommand}" Content="{StaticResource ClearFilterIcon}" />
|
<Button ToolTip="Clear Filter" Command="{Binding ClearFilterCommand}" Content="{StaticResource ClearFilterIcon}" />
|
||||||
|
<!--<ToggleButton ToolTip="Show Advanced Block Groups" Command="{Binding ToggleShowAdvancedCommand}" CommandParameter="{Binding Path=IsChecked, RelativeSource={RelativeSource Self}}" Content="{StaticResource ShowAdvancedIcon}" />-->
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</ToolBarTray>
|
</ToolBarTray>
|
||||||
<userControls:AutoScrollingListBox ItemsSource="{Binding ItemFilterBlockViewModels}"
|
<userControls:AutoScrollingListBox ItemsSource="{Binding ItemFilterBlockViewModels}"
|
||||||
|
|
|
@ -5,13 +5,15 @@
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:models="clr-namespace:Filtration.Models"
|
xmlns:models="clr-namespace:Filtration.Models"
|
||||||
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
|
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
|
||||||
|
xmlns:converters="clr-namespace:Filtration.Converters"
|
||||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||||
xmlns:behaviors="clr-namespace:Filtration.Views.Behaviors"
|
xmlns:behaviors="clr-namespace:Filtration.Views.Behaviors"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance Type=viewModels:BlockGroupBrowserViewModel}"
|
d:DataContext="{d:DesignInstance Type=viewModels:BlockGroupBrowserViewModel}"
|
||||||
d:DesignHeight="300" d:DesignWidth="300">
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
|
<converters:BlockGroupAdvancedColorConverter x:Key="BlockGroupAdvancedColorConverter" />
|
||||||
|
<converters:BlockGroupVisibilityConverter x:Key="BlockGroupVisibilityConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
@ -22,7 +24,7 @@
|
||||||
<Button Height="20" Command="{Binding FilterToSelectedBlockGroupCommand}" Content="{StaticResource FilterIcon}" ToolTip="Filter to Selected Block Group" />
|
<Button Height="20" Command="{Binding FilterToSelectedBlockGroupCommand}" Content="{StaticResource FilterIcon}" ToolTip="Filter to Selected Block Group" />
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
|
|
||||||
<TreeView Grid.Row="1" ItemsSource="{Binding BlockGroups}">
|
<TreeView Grid.Row="1" ItemsSource="{Binding BlockGroups}" Name="TreeView">
|
||||||
<i:Interaction.Behaviors>
|
<i:Interaction.Behaviors>
|
||||||
<behaviors:BindableSelectedItemBehavior SelectedItem="{Binding SelectedBlockGroup, Mode=OneWayToSource}" />
|
<behaviors:BindableSelectedItemBehavior SelectedItem="{Binding SelectedBlockGroup, Mode=OneWayToSource}" />
|
||||||
</i:Interaction.Behaviors>
|
</i:Interaction.Behaviors>
|
||||||
|
@ -30,7 +32,7 @@
|
||||||
<HierarchicalDataTemplate DataType="{x:Type models:ItemFilterBlockGroup}" ItemsSource="{Binding ChildGroups}">
|
<HierarchicalDataTemplate DataType="{x:Type models:ItemFilterBlockGroup}" ItemsSource="{Binding ChildGroups}">
|
||||||
<WrapPanel>
|
<WrapPanel>
|
||||||
<CheckBox IsThreeState="True" IsChecked="{Binding IsChecked}" Click="BlockGroupCheckBox_Clicked" />
|
<CheckBox IsThreeState="True" IsChecked="{Binding IsChecked}" Click="BlockGroupCheckBox_Clicked" />
|
||||||
<TextBlock Text="{Binding GroupName}" />
|
<TextBlock Text="{Binding GroupName}" Foreground="{Binding Advanced, Converter={StaticResource BlockGroupAdvancedColorConverter}}" />
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
</HierarchicalDataTemplate>
|
</HierarchicalDataTemplate>
|
||||||
</TreeView.Resources>
|
</TreeView.Resources>
|
||||||
|
|
Loading…
Reference in New Issue