using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using RoboSharp.Results; using RoboSharp.Interfaces; namespace RoboSharp.EventArgObjects { /// /// Interface helper for dealing with Statistic Event Args /// public interface IStatisticPropertyChangedEventArg { /// Statistic.StatType StatType { get; } /// TRUE if of type . Otherwise false. bool Is_StatChangedEventArg { get; } /// TRUE if of type . Otherwise false. bool Is_StatisticPropertyChangedEventArgs { get; } /// string PropertyName { get; } } /// /// EventArgs provided by when any individual property gets modified. /// /// /// Under most circumstances, the 'PropertyName' property will detail which parameter has been updated.
/// When the Statistic object has multiple values change via a method call ( Reset / Add / Subtract methods ), then PropertyName will be String.Empty, indicating multiple values have changed.
/// If this is the case, then the , , and will report the value from the sender's property. ///
public class StatChangedEventArg : PropertyChangedEventArgs, IStatisticPropertyChangedEventArg { private StatChangedEventArg() : base("") { } internal StatChangedEventArg(Statistic stat, long oldValue, long newValue, string PropertyName) : base(PropertyName) { Sender = stat; StatType = stat.Type; OldValue = oldValue; NewValue = newValue; } /// This is a reference to the Statistic that generated the EventArg object public IStatistic Sender { get; } /// public Statistic.StatType StatType { get; } /// Old Value of the object public long OldValue { get; } /// Current Value of the object public long NewValue { get; } /// /// Result of NewValue - OldValue /// public long Difference => NewValue - OldValue; bool IStatisticPropertyChangedEventArg.Is_StatChangedEventArg => true; bool IStatisticPropertyChangedEventArg.Is_StatisticPropertyChangedEventArgs => false; } /// /// EventArgs provided by /// /// /// Under most circumstances, the 'PropertyName' property will detail which parameter has been updated.
/// When the Statistic object has multiple values change via a method call ( Reset / Add / Subtract methods ), then PropertyName will be String.Empty, indicating multiple values have changed.
/// If this is the case, then the , , and will report the value from the sender's property. ///
public class StatisticPropertyChangedEventArgs : PropertyChangedEventArgs, IStatisticPropertyChangedEventArg { private StatisticPropertyChangedEventArgs() : base("") { } internal StatisticPropertyChangedEventArgs(Statistic stat, Statistic oldValue, string PropertyName) : base(PropertyName) { //Sender = stat; StatType = stat.Type; OldValue = oldValue; NewValue = stat.Clone(); Lazydifference = new Lazy(() => Statistic.Subtract(NewValue, OldValue)); } /// public Statistic.StatType StatType { get; } /// Old Value of the object public IStatistic OldValue { get; } /// Current Value of the object public IStatistic NewValue { get; } /// /// Result of NewValue - OldValue /// public IStatistic Difference => Lazydifference.Value; private Lazy Lazydifference; bool IStatisticPropertyChangedEventArg.Is_StatChangedEventArg => false; bool IStatisticPropertyChangedEventArg.Is_StatisticPropertyChangedEventArgs => true; } }