/// OnDisconnected (event)- Jacob Monger /// <summary> /// changes alert button colour to show if there is an alert /// </summary> /// <param name="source"> alert view model </param> /// <param name="e"> data structure - NewAlert = if theres a new alert</param> public void OnAlerted(object source, AlertEventArgs e) { if (e.NewAlert == true) { AlertStatus = "DarkRed"; AlertImage = "Images/ExclamationMarkBlack_64.png"; } else { AlertStatus = "DimGray"; AlertImage = "Images/Exclamation_64.png"; } }
/// OnAlerted (event) - Jacob Monger /// <summary> /// adds or removes flag stating if alert limit was excided /// </summary> /// <param name="source"> alert view model.</param> /// <param name="e"> data structure see alert view model.</param> public void OnAlerted(object source, AlertEventArgs e) { if (e.NewAlert == true) // is there a new alert { for (int ListPosition = 0; ListPosition < AlertList.Count(); ListPosition++) { if (AlertList[ListPosition].AlertName == e.AlertName) // find alert limit { if (e.AlertName.Contains("Max")) { if (e.AlertValue > AlertList[ListPosition].Threshold || AlertList[ListPosition].ThresholdToDisplay == null) // if bigger up date { App.Current.Dispatcher.Invoke((Action) delegate { AlertList.Remove(AlertList[ListPosition]); AlertList.Insert(ListPosition, new AlertListItemModel(e.AlertName, " (Exceeded ", e.AlertValue.ToString("0.00") + ")", e.AlertValue)); }); } } if (e.AlertName.Contains("Min")) { if (e.AlertValue < AlertList[ListPosition].Threshold || AlertList[ListPosition].ThresholdToDisplay == null) // if smaller upadte { App.Current.Dispatcher.Invoke((Action) delegate { AlertList.Remove(AlertList[ListPosition]); AlertList.Insert(ListPosition, new AlertListItemModel(e.AlertName, " (Exceeded ", e.AlertValue.ToString("0.00") + ")", e.AlertValue)); }); } } return; } } } else { for (int ListPosition = 0; ListPosition < AlertList.Count(); ListPosition++) // clear all flags { if (AlertList[ListPosition].Exceeded != null) { string temporyName = AlertList[ListPosition].AlertName; App.Current.Dispatcher.Invoke((Action) delegate { AlertList.Remove(AlertList[ListPosition]); AlertList.Insert(ListPosition, new AlertListItemModel(temporyName)); }); } } } }