Add enable/disable checkbox to group browser

This commit is contained in:
azakhi
2018-09-06 09:59:09 +03:00
parent ae38197052
commit 1f6cbeec86
7 changed files with 150 additions and 43 deletions

View File

@@ -14,6 +14,7 @@ namespace Filtration.ObjectModel
public interface IItemFilterBlock : IItemFilterBlockBase
{
bool Enabled { get; set; }
event EventHandler EnabledStatusChanged;
string Description { get; set; }
ItemFilterBlockGroup BlockGroup { get; set; }
BlockAction Action { get; set; }
@@ -105,8 +106,12 @@ namespace Filtration.ObjectModel
{
_enabled = value;
IsEdited = true;
EnabledStatusChanged?.Invoke(null, null);
}
}
public event EventHandler EnabledStatusChanged;
public string Description
{
get { return _description; }
@@ -198,14 +203,23 @@ namespace Filtration.ObjectModel
private void OnBlockGroupStatusChanged(object sender, EventArgs e)
{
if (BlockGroup.IsChecked == false && Action == BlockAction.Show)
if (BlockGroup.IsShowChecked == false && Action == BlockAction.Show)
{
Action = BlockAction.Hide;
}
else if (BlockGroup.IsChecked && Action == BlockAction.Hide)
else if (BlockGroup.IsShowChecked && Action == BlockAction.Hide)
{
Action = BlockAction.Show;
}
if (BlockGroup.IsEnableChecked == false && Enabled)
{
Enabled = false;
}
else if (BlockGroup.IsEnableChecked && !Enabled)
{
Enabled = true;
}
}
public Color DisplayTextColor

View File

@@ -5,7 +5,8 @@ namespace Filtration.ObjectModel
{
public class ItemFilterBlockGroup
{
private bool _isChecked;
private bool _isShowChecked;
private bool _isEnableChecked;
public ItemFilterBlockGroup(string groupName, ItemFilterBlockGroup parent, bool advanced = false)
{
@@ -22,14 +23,14 @@ namespace Filtration.ObjectModel
public List<ItemFilterBlockGroup> ChildGroups { get; }
public bool Advanced { get; }
public bool IsChecked
public bool IsShowChecked
{
get { return _isChecked; }
get { return _isShowChecked; }
set
{
if (value != _isChecked)
if (value != _isShowChecked)
{
_isChecked = value;
_isShowChecked = value;
// 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.
BlockGroupStatusChanged?.Invoke(null, null);
@@ -37,6 +38,21 @@ namespace Filtration.ObjectModel
}
}
public bool IsEnableChecked
{
get { return _isEnableChecked; }
set
{
if (value != _isEnableChecked)
{
_isEnableChecked = value;
// Raise an event to let blocks that have this block group assigned that
// they might need to change their Enabled due to the block group status changing.
BlockGroupStatusChanged?.Invoke(null, null);
}
}
}
public override string ToString()
{
var currentBlockGroup = this;