Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public void Show(Subscription subscription)
        {
            if (subscription == null)
            {
                throw new ArgumentNullException("subscription");
            }

            Show();
            BringToFront();

            // remove previous subscription.
            if (m_subscription != null)
            {
                m_subscription.StateChanged         -= m_SubscriptionStateChanged;
                m_subscription.PublishStatusChanged -= m_PublishStatusChanged;
                m_subscription.Session.Notification -= m_SessionNotification;
            }

            // start receiving notifications from the new subscription.
            m_subscription = subscription;

            if (subscription != null)
            {
                m_subscription.StateChanged         += m_SubscriptionStateChanged;
                m_subscription.PublishStatusChanged += m_PublishStatusChanged;
                m_subscription.Session.Notification += m_SessionNotification;
            }

            MonitoredItemsCTRL.Initialize(subscription);
            EventsCTRL.Initialize(subscription, null);
            DataChangesCTRL.Initialize(subscription, null);

            WindowMI_Click(WindowDataChangesMI, null);

            UpdateStatus();
        }