/// <summary> /// Processes a Publish repsonse from the server. /// </summary> void MonitoredItem_Notification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e) { if (InvokeRequired) { BeginInvoke(m_MonitoredItemNotification, monitoredItem, e); return; } else if (!IsHandleCreated) { return; } try { // ignore notifications for other monitored items. if (!Object.ReferenceEquals(m_monitoredItem, monitoredItem)) { return; } // notify controls of the change. EventsCTRL.NotificationReceived(e); DataChangesCTRL.NotificationReceived(e); LatestValueCTRL.ShowValue(monitoredItem, true); // update item status. UpdateStatus(); } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
/// <summary> /// Displays the dialog. /// </summary> public void Show(MonitoredItem monitoredItem) { if (monitoredItem == null) { throw new ArgumentNullException("monitoredItem"); } Show(); BringToFront(); // remove previous subscription. if (m_monitoredItem != null) { monitoredItem.Subscription.StateChanged -= m_SubscriptionStateChanged; monitoredItem.Subscription.PublishStatusChanged -= m_PublishStatusChanged; monitoredItem.Notification -= m_MonitoredItemNotification; } // start receiving notifications from the new subscription. m_monitoredItem = monitoredItem; m_subscription = null; if (m_monitoredItem != null) { m_subscription = monitoredItem.Subscription; m_monitoredItem.Subscription.StateChanged += m_SubscriptionStateChanged; m_monitoredItem.Subscription.PublishStatusChanged += m_PublishStatusChanged; m_monitoredItem.Notification += m_MonitoredItemNotification; } WindowMI_Click(WindowStatusMI, null); WindowMI_Click(WindowLatestValueMI, null); MonitoredItemsCTRL.Initialize(m_monitoredItem); EventsCTRL.Initialize(m_subscription, m_monitoredItem); DataChangesCTRL.Initialize(m_subscription, m_monitoredItem); LatestValueCTRL.ShowValue(m_monitoredItem, false); }