Exemplo n.º 1
0
        /// <see cref="BaseListCtrl.UpdateItem" />
        protected override void UpdateItem(ListViewItem listItem, object item)
        {
            MonitoredItem monitoredItem = item as MonitoredItem;

            if (monitoredItem == null)
            {
                base.UpdateItem(listItem, item);
                return;
            }

            listItem.SubItems[0].Text = String.Format("{0}", monitoredItem.Status.Id);
            listItem.SubItems[1].Text = String.Format("{0}", monitoredItem.DisplayName);
            listItem.SubItems[2].Text = String.Format("{0}", monitoredItem.NodeClass);
            listItem.SubItems[3].Text = String.Format("{0}", monitoredItem.Status.SamplingInterval);
            listItem.SubItems[4].Text = String.Format("{0}", monitoredItem.Status.QueueSize);
            listItem.SubItems[5].Text = String.Empty;
            listItem.SubItems[6].Text = String.Format("{0}", monitoredItem.Status.Error);
            listItem.SubItems[7].Text = String.Empty;

            IEncodeable value = monitoredItem.LastValue;

            if (value != null)
            {
                MonitoredItemNotification datachange = value as MonitoredItemNotification;

                if (datachange != null)
                {
                    listItem.SubItems[5].Text = String.Format("{0}", datachange.Value);

                    if (datachange.Value.SourceTimestamp != DateTime.MinValue)
                    {
                        listItem.SubItems[7].Text = String.Format("{0:HH:mm:ss.fff}",
                                                                  datachange.Value.SourceTimestamp.ToLocalTime());
                    }
                }

                EventFieldList eventFields = value as EventFieldList;

                if (eventFields != null)
                {
                    listItem.SubItems[5].Text = String.Format("{0}", monitoredItem.GetEventType(eventFields));
                    listItem.SubItems[7].Text = String.Format("{0:HH:mm:ss.fff}",
                                                              monitoredItem.GetEventTime(eventFields).ToLocalTime());
                }
            }

            listItem.Tag = item;
        }