using MECF.Framework.UI.Client.CenterViews.Editors.Recipe; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RecipeEditorLib.RecipeModel.Params { public class BoolParam : Param { public delegate void ValueChangedEventHandler(object sender, SetValueEventArgs e); public event ValueChangedEventHandler ValueChangedEvent; public BoolParam() : base() { e.Sender = this; e.PropertyName = Name; } private SetValueEventArgs e = new SetValueEventArgs(); public void OnValueChanged(SetValueEventArgs e) { if (ValueChangedEvent != null) { ValueChangedEvent(this, e); } } private bool _oldValue; public bool OldValue { get => _oldValue; set { _oldValue = value; NotifyOfPropertyChange("OldValue"); } } private bool _value; public bool Value { get { return this._value; } set { this._value = value; if (IsSaved) { OldValue = value; } e.PropertyValue = value.ToString(); if (!IsSaved) OnValueChanged(e); if (this.Feedback != null) this.Feedback(this); this.NotifyOfPropertyChange("Value"); } } public void SetValue(bool value) { OldValue= Value; IsSaved = false; Value = value; } public override bool UndoChanges() { Value = OldValue; IsSaved = true; return true; } } }