|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RestaurantForm
{
public delegate void HealthScoreChangedEventHandler(object sender, HealthScoreChangedEventArgs e);
public class HealthScoreChangedEventArgs : EventArgs
{
private HealthScore _oldvalue;
private String _description;
public HealthScoreChangedEventArgs(HealthScore oldvalue, String description) { _oldvalue = oldvalue.DeepClone(); _description = description; }
public HealthScore OldValue { get { return _oldvalue; } }
public String Description { get { return _description; } set { _description = value; } }
}
[Serializable]
public class HealthScore
{
private int _value;
public event HealthScoreChangedEventHandler Changed;
public HealthScore() { _value = 0; }
public HealthScore(int value) { _value = value; }
public int Value
{
get { return _value; }
set { OnChanged(new HealthScoreChangedEventArgs(this, "Value: " + this.Value + " to " + value.ToString())); _value = value; }
}
public int ValueSilent { set { _value = value; } }
public HealthScore DeepClone()
{
HealthScore clone = new HealthScore();
clone.ValueSilent = this.Value;
return clone;
}
private void OnChanged(HealthScoreChangedEventArgs e) { if (Changed != null) Changed(this, e); }
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.