public void OnFireEvent(string fireCatagory) { FireEventArgs fe = new FireEventArgs(fireCatagory); if (FireEvent != null) FireEvent(this, fe); }
public void OnFireEvent(string fireCatagory) { FireEventArgs fe = new FireEventArgs(fireCatagory); if (FireEvent != null) { FireEvent(this, fe); } }
// Method public void OnFireEvent(EFireCategory fCat) { // Instantiate the custom event FireEventArgs fe = new FireEventArgs(fCat); // Is null if no methods have been registered if (FireEvent != null) { // Raise the event FireEvent(this, fe); } }
protected override void fireHandler(object sender, FireEventArgs fe) { string message = "Fire is " + fe.FireCatagory + ". "; switch (fe.FireCatagory) { case "Minor": message += "Use an extinguisher"; break; case "Serious": message += "Call the Fire Department"; break; case "Inferno": message += "Evacuate Immediatly!!"; break; } MessageBox.Show(message); }
protected override void fireHandler(object sender, FireEventArgs fe) { int freq = 0; int duration = 1000; switch (fe.FireCatagory) { case "Minor": freq = 800; break; case "Serious": freq = 1600; break; case "Inferno": freq = 3200; break; } Beep(freq, duration); }
//Method public override void FireAlarmHandlerMethod(object fireSubject, FireEventArgs fa) { // Beep duration and frequency int duration = 1000; int frequency = 0; switch (fa.FireCategory) { case EFireCategory.MINOR: frequency = 800; break; case EFireCategory.SERIOUS: frequency = 1200; break; case EFireCategory.INFERNO: frequency = 1600; break; } Beep(frequency, duration); }
//Method public override void FireAlarmHandlerMethod(object fireSubject, FireEventArgs fa) { // Feedback message String message = "Fire category is " + fa.FireCategory.ToString() + "."; // Depending on which enum was picked, a str will be concat'd to the message switch (fa.FireCategory) { case EFireCategory.MINOR: message += " Use a fire extinguisher!"; break; case EFireCategory.SERIOUS: message += " Call the fire department!"; break; case EFireCategory.INFERNO: message += " Evacuate immediately!!"; break; } // Message box will appear MessageBox.Show(message); }
protected abstract void fireHandler(object sender, FireEventArgs fe);
// Method public abstract void FireAlarmHandlerMethod(object fireSubject, FireEventArgs fa);