2022-11-14 12:55:53 +03:00
|
|
|
using System;
|
|
|
|
|
2022-11-14 13:01:16 +03:00
|
|
|
namespace Syntriax.Modules.ToggleState
|
2022-11-14 12:55:53 +03:00
|
|
|
{
|
2022-11-14 13:01:16 +03:00
|
|
|
public class ToggleStateMember : IToggleState
|
2022-11-14 12:55:53 +03:00
|
|
|
{
|
2022-11-14 13:58:44 +03:00
|
|
|
private bool _isToggled = true;
|
2022-11-20 18:29:33 +03:00
|
|
|
|
|
|
|
public ToggleStateMember() { }
|
|
|
|
public ToggleStateMember(bool isToggled) => IsToggled = isToggled;
|
|
|
|
|
2022-11-14 13:58:44 +03:00
|
|
|
public bool IsToggled
|
2022-11-14 12:55:53 +03:00
|
|
|
{
|
2022-11-14 13:58:44 +03:00
|
|
|
get => _isToggled;
|
2022-11-14 12:55:53 +03:00
|
|
|
set
|
|
|
|
{
|
2022-11-14 13:58:44 +03:00
|
|
|
bool oldValue = _isToggled;
|
2022-11-14 12:55:53 +03:00
|
|
|
|
2022-11-14 13:58:44 +03:00
|
|
|
_isToggled = value;
|
2022-11-14 12:55:53 +03:00
|
|
|
|
2022-12-02 00:00:45 +03:00
|
|
|
if (oldValue != value)
|
2022-11-14 12:55:53 +03:00
|
|
|
OnToggleStateChanged?.Invoke(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action<bool> OnToggleStateChanged { get; set; } = null;
|
|
|
|
}
|
|
|
|
}
|