/// <summary> /// Updates the display with a new value for a monitored variable. /// </summary> private void MonitoredItem_Notification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e) { if (this.InvokeRequired) { this.BeginInvoke(new MonitoredItemNotificationEventHandler(MonitoredItem_Notification), monitoredItem, e); return; } try { // check for valid notification. EventFieldList notification = e.NotificationValue as EventFieldList; if (notification == null) { return; } // check if monitored item has changed. if (!Object.ReferenceEquals(m_monitoredItem, monitoredItem)) { return; } // check if the filter has changed. if (notification.EventFields.Count != m_filter.Fields.Count + 1) { return; } if (m_displayConditions) { NodeId eventTypeId = m_filter.GetValue <NodeId>(Opc.Ua.BrowseNames.EventType, notification.EventFields, null); if (eventTypeId == Opc.Ua.ObjectTypeIds.RefreshStartEventType) { EventsLV.Items.Clear(); } if (eventTypeId == Opc.Ua.ObjectTypeIds.RefreshEndEventType) { return; } } // create an item and add to top of list. ListViewItem item = CreateListItem(m_filter, notification.EventFields); if (item.ListView == null) { EventsLV.Items.Insert(0, item); } // adjust the width of the columns. for (int ii = 0; ii < EventsLV.Columns.Count; ii++) { EventsLV.Columns[ii].Width = -2; } } catch (Exception exception) { ClientUtils.HandleException(this.Text, exception); } }