29 lines
651 B
C#
29 lines
651 B
C#
using System;
|
|
|
|
namespace Syntriax.Modules.ToggleState
|
|
{
|
|
public class ToggleStateMember : IToggleState
|
|
{
|
|
private bool _isToggled = true;
|
|
|
|
public ToggleStateMember() { }
|
|
public ToggleStateMember(bool isToggled) => IsToggled = isToggled;
|
|
|
|
public bool IsToggled
|
|
{
|
|
get => _isToggled;
|
|
set
|
|
{
|
|
bool oldValue = _isToggled;
|
|
|
|
_isToggled = value;
|
|
|
|
if (oldValue = !value)
|
|
OnToggleStateChanged?.Invoke(value);
|
|
}
|
|
}
|
|
|
|
public Action<bool> OnToggleStateChanged { get; set; } = null;
|
|
}
|
|
}
|