Example #1
0
        /// <summary>
        /// Updates the application after connecting to or disconnecting from the server.
        /// </summary>
        private void Server_ConnectComplete(object sender, EventArgs e)
        {
            try
            {
                m_session = ConnectServerCTRL.Session;

                // set a suitable initial state.
                if (m_session != null && !m_connectedOnce)
                {
                    EventsLV.IsSubscribed = false;
                    EventsLV.ChangeArea(ExpandedNodeId.ToNodeId(ObjectIds.Plaforms, m_session.NamespaceUris), true);

                    TypeDeclaration type = new TypeDeclaration();
                    type.NodeId       = ExpandedNodeId.ToNodeId(ObjectTypeIds.WellTestReportType, m_session.NamespaceUris);
                    type.Declarations = ModelUtils.CollectInstanceDeclarationsForType(m_session, type.NodeId);

                    EventsLV.ChangeFilter(new FilterDeclaration(type, null), true);
                    m_connectedOnce = true;
                }

                EventsLV.IsSubscribed = Events_EnableSubscriptionMI.Checked;
                EventsLV.ChangeSession(m_session, true);
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Example #2
0
        /// <summary>
        /// Handles the AfterSelect event of the BrowseTV control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.TreeViewEventArgs"/> instance containing the event data.</param>
        private void BrowseTV_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                DeclarationsLV.Items.Clear();

                if (e.Node == null)
                {
                    OkBTN.Enabled = false;
                    return;
                }

                OkBTN.Enabled = true;

                // get the currently selected event.
                NodeId typeId = m_rootId;
                ReferenceDescription reference = e.Node.Tag as ReferenceDescription;

                if (reference != null)
                {
                    typeId = (NodeId)reference.NodeId;
                }

                // get the instance declarations.
                List <InstanceDeclaration> instances = ModelUtils.CollectInstanceDeclarationsForType(m_session, typeId);

                // populate the list box.
                for (int ii = 0; ii < instances.Count; ii++)
                {
                    InstanceDeclaration instance = instances[ii];

                    ListViewItem item = new ListViewItem(instance.DisplayPath);
                    item.SubItems.Add(instance.DataTypeDisplayText);
                    item.SubItems.Add(instance.Description);
                    item.Tag = instance;

                    DeclarationsLV.Items.Add(item);
                }

                // resize columns to fit text.
                for (int ii = 0; ii < DeclarationsLV.Columns.Count; ii++)
                {
                    DeclarationsLV.Columns[ii].Width = -2;
                }
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }