Added Show/Hide functionality to the checkboxes in the Block Group Browser
This commit is contained in:
parent
3ee7e1cc2a
commit
aa433ad685
|
@ -54,6 +54,36 @@ namespace Filtration.Tests.Translators
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify();
|
_testUtility.MockBlockGroupHierarchyBuilder.Verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TranslateStringToItemFilterBlock_ShowBlock_SetsBlockGroupIsCheckedCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var inputString = "Show # TestBlockGroup" + Environment.NewLine;
|
||||||
|
var inputBlockGroup = new ItemFilterBlockGroup("TestBlockGroup", null);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||||
|
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(true, inputBlockGroup.IsChecked);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TranslateStringToItemFilterBlock_HideBlock_SetsBlockGroupIsCheckedCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var inputString = "Hide # TestBlockGroup" + Environment.NewLine;
|
||||||
|
var inputBlockGroup = new ItemFilterBlockGroup("TestBlockGroup", null);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||||
|
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(false, inputBlockGroup.IsChecked);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TranslateStringToItemFilterBlock_NoBlockGroupComment_CallsBlockGroupHierarchyBuilder()
|
public void TranslateStringToItemFilterBlock_NoBlockGroupComment_CallsBlockGroupHierarchyBuilder()
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.ObjectModel" />
|
<Reference Include="System.ObjectModel" />
|
||||||
|
<Reference Include="System.Runtime" />
|
||||||
<Reference Include="System.Windows.Controls.Input.Toolkit">
|
<Reference Include="System.Windows.Controls.Input.Toolkit">
|
||||||
<HintPath>..\packages\WPFToolkit.3.5.50211.1\lib\System.Windows.Controls.Input.Toolkit.dll</HintPath>
|
<HintPath>..\packages\WPFToolkit.3.5.50211.1\lib\System.Windows.Controls.Input.Toolkit.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -8,13 +8,40 @@ namespace Filtration.Models
|
||||||
{
|
{
|
||||||
internal class ItemFilterBlock
|
internal class ItemFilterBlock
|
||||||
{
|
{
|
||||||
|
private ItemFilterBlockGroup _blockGroup;
|
||||||
|
|
||||||
public ItemFilterBlock()
|
public ItemFilterBlock()
|
||||||
{
|
{
|
||||||
BlockItems = new ObservableCollection<IItemFilterBlockItem> {new ActionBlockItem(BlockAction.Show)};
|
BlockItems = new ObservableCollection<IItemFilterBlockItem> {new ActionBlockItem(BlockAction.Show)};
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public ItemFilterBlockGroup BlockGroup { get; set; }
|
|
||||||
|
public ItemFilterBlockGroup BlockGroup
|
||||||
|
{
|
||||||
|
get { return _blockGroup; }
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BlockAction Action
|
public BlockAction Action
|
||||||
{
|
{
|
||||||
|
@ -47,5 +74,17 @@ namespace Filtration.Models
|
||||||
{
|
{
|
||||||
return BlockItems.Count(b => b is T) > 0;
|
return BlockItems.Count(b => b is T) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnBlockGroupStatusChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (BlockGroup.IsChecked == false && Action == BlockAction.Show)
|
||||||
|
{
|
||||||
|
Action = BlockAction.Hide;
|
||||||
|
}
|
||||||
|
else if (BlockGroup.IsChecked == true && Action == BlockAction.Hide)
|
||||||
|
{
|
||||||
|
Action = BlockAction.Show;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.ObjectModel;
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
@ -18,6 +19,11 @@ namespace Filtration.Models
|
||||||
ChildGroups = new ObservableCollection<ItemFilterBlockGroup>();
|
ChildGroups = new ObservableCollection<ItemFilterBlockGroup>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public event EventHandler BlockGroupStatusChanged;
|
||||||
|
public string GroupName { get; private set; }
|
||||||
|
public ItemFilterBlockGroup ParentGroup { get; private set; }
|
||||||
|
public ObservableCollection<ItemFilterBlockGroup> ChildGroups { get; private set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var currentBlockGroup = this;
|
var currentBlockGroup = this;
|
||||||
|
@ -37,10 +43,6 @@ namespace Filtration.Models
|
||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GroupName { get; private set; }
|
|
||||||
public ItemFilterBlockGroup ParentGroup { get; private set; }
|
|
||||||
public ObservableCollection<ItemFilterBlockGroup> ChildGroups { get; private set; }
|
|
||||||
|
|
||||||
public bool? IsChecked
|
public bool? IsChecked
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -59,6 +61,13 @@ namespace Filtration.Models
|
||||||
_isChecked = value;
|
_isChecked = value;
|
||||||
UpdateCheckState();
|
UpdateCheckState();
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
|
|
||||||
|
// Raise an event to let blocks that have this block group assigned that
|
||||||
|
// they might need to change their Action due to the block group status changing.
|
||||||
|
if (BlockGroupStatusChanged != null)
|
||||||
|
{
|
||||||
|
BlockGroupStatusChanged.Invoke(null, null);
|
||||||
|
}
|
||||||
_reentrancyCheck = false;
|
_reentrancyCheck = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,6 +274,7 @@ namespace Filtration.Translators
|
||||||
if (blockGroups.Count(b => !string.IsNullOrEmpty(b.Trim())) > 0)
|
if (blockGroups.Count(b => !string.IsNullOrEmpty(b.Trim())) > 0)
|
||||||
{
|
{
|
||||||
block.BlockGroup = _blockGroupHierarchyBuilder.IntegrateStringListIntoBlockGroupHierarchy(blockGroups);
|
block.BlockGroup = _blockGroupHierarchyBuilder.IntegrateStringListIntoBlockGroupHierarchy(blockGroups);
|
||||||
|
block.BlockGroup.IsChecked = block.Action == BlockAction.Show;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,7 @@ namespace Filtration.ViewModels
|
||||||
if (document.IsScript)
|
if (document.IsScript)
|
||||||
{
|
{
|
||||||
_sectionBrowserViewModel.ClearDown();
|
_sectionBrowserViewModel.ClearDown();
|
||||||
|
_blockGroupBrowserViewModel.ClearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenDocuments.Remove(document);
|
OpenDocuments.Remove(document);
|
||||||
|
|
Loading…
Reference in New Issue