Improve parent group status logic
This commit is contained in:
@@ -89,6 +89,7 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
BlockItems = new ObservableCollection<IItemFilterBlockItem> { ActionBlockItem };
|
||||
BlockItems.CollectionChanged += new NotifyCollectionChangedEventHandler(OnBlockItemsChanged);
|
||||
ActionBlockItem.PropertyChanged += OnActionBlockItemChanged;
|
||||
_enabled = true;
|
||||
}
|
||||
|
||||
@@ -96,6 +97,7 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
BlockItems = new ObservableCollection<IItemFilterBlockItem> { ActionBlockItem };
|
||||
BlockItems.CollectionChanged += new NotifyCollectionChangedEventHandler(OnBlockItemsChanged);
|
||||
ActionBlockItem.PropertyChanged += OnActionBlockItemChanged;
|
||||
_enabled = true;
|
||||
}
|
||||
|
||||
@@ -107,6 +109,10 @@ namespace Filtration.ObjectModel
|
||||
_enabled = value;
|
||||
IsEdited = true;
|
||||
EnabledStatusChanged?.Invoke(null, null);
|
||||
if(BlockGroup != null && BlockGroup.IsEnableChecked != value)
|
||||
{
|
||||
BlockGroup.IsEnableChecked = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +176,13 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
IsEdited = true;
|
||||
}
|
||||
private void OnActionBlockItemChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (BlockGroup != null && BlockGroup.IsShowChecked != (Action == BlockAction.Show))
|
||||
{
|
||||
BlockGroup.IsShowChecked = (Action == BlockAction.Show);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddBlockItemAllowed(Type type)
|
||||
{
|
||||
@@ -207,7 +220,7 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
Action = BlockAction.Hide;
|
||||
}
|
||||
else if (BlockGroup.IsShowChecked && Action == BlockAction.Hide)
|
||||
else if (BlockGroup.IsShowChecked == true && Action == BlockAction.Hide)
|
||||
{
|
||||
Action = BlockAction.Show;
|
||||
}
|
||||
@@ -216,7 +229,7 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
Enabled = false;
|
||||
}
|
||||
else if (BlockGroup.IsEnableChecked && !Enabled)
|
||||
else if (BlockGroup.IsEnableChecked == true && !Enabled)
|
||||
{
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
@@ -5,15 +5,16 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
public class ItemFilterBlockGroup
|
||||
{
|
||||
private bool _isShowChecked;
|
||||
private bool _isEnableChecked;
|
||||
private bool? _isShowChecked;
|
||||
private bool? _isEnableChecked;
|
||||
|
||||
public ItemFilterBlockGroup(string groupName, ItemFilterBlockGroup parent, bool advanced = false)
|
||||
public ItemFilterBlockGroup(string groupName, ItemFilterBlockGroup parent, bool advanced = false, bool isLeafNode = false)
|
||||
{
|
||||
GroupName = groupName;
|
||||
ParentGroup = parent;
|
||||
Advanced = advanced;
|
||||
ChildGroups = new List<ItemFilterBlockGroup>();
|
||||
IsLeafNode = isLeafNode;
|
||||
}
|
||||
|
||||
public event EventHandler BlockGroupStatusChanged;
|
||||
@@ -22,8 +23,9 @@ namespace Filtration.ObjectModel
|
||||
public ItemFilterBlockGroup ParentGroup { get; }
|
||||
public List<ItemFilterBlockGroup> ChildGroups { get; }
|
||||
public bool Advanced { get; }
|
||||
public bool IsLeafNode { get; }
|
||||
|
||||
public bool IsShowChecked
|
||||
public bool? IsShowChecked
|
||||
{
|
||||
get { return _isShowChecked; }
|
||||
set
|
||||
@@ -38,7 +40,7 @@ namespace Filtration.ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnableChecked
|
||||
public bool? IsEnableChecked
|
||||
{
|
||||
get { return _isEnableChecked; }
|
||||
set
|
||||
|
||||
Reference in New Issue
Block a user