State/ToggleStateMember.cs

25 lines
535 B
C#

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