GetTargetIcon() public static method

Returns to display icon for the target of a reference.
public static GetTargetIcon ( Session session, NodeClass nodeClass, ExpandedNodeId typeDefinitionId ) : string
session Session
nodeClass NodeClass
typeDefinitionId ExpandedNodeId
return string
示例#1
0
        /// <summary>
        /// Displays the a root in the control.
        /// </summary>
        public void Initialize(
            Session session,
            NodeId rootId,
            NodeId viewId,
            NodeId referenceTypeId,
            BrowseDirection browseDirection)
        {
            m_session         = session;
            m_rootId          = rootId;
            m_viewId          = viewId;
            m_referenceTypeId = referenceTypeId;
            m_browseDirection = browseDirection;

            NodesTV.Nodes.Clear();

            if (m_session == null)
            {
                return;
            }

            if (NodeId.IsNull(m_rootId))
            {
                m_rootId = Objects.RootFolder;
            }

            if (NodeId.IsNull(m_referenceTypeId))
            {
                m_referenceTypeId = ReferenceTypeIds.HierarchicalReferences;
            }

            ReferenceTypeCTRL.Initialize(m_session, ReferenceTypeIds.HierarchicalReferences);
            ReferenceTypeCTRL.SelectedTypeId = m_referenceTypeId;

            ILocalNode root = m_session.NodeCache.Find(m_rootId) as ILocalNode;

            if (root == null)
            {
                return;
            }

            ReferenceDescription reference = new ReferenceDescription();

            reference.ReferenceTypeId = referenceTypeId;
            reference.IsForward       = true;
            reference.NodeId          = root.NodeId;
            reference.NodeClass       = root.NodeClass;
            reference.BrowseName      = root.BrowseName;
            reference.DisplayName     = root.DisplayName;
            reference.TypeDefinition  = root.TypeDefinitionId;

            TreeNode rootNode = new TreeNode(reference.ToString());

            rootNode.ImageKey = rootNode.SelectedImageKey = GuiUtils.GetTargetIcon(session, reference);
            rootNode.Tag      = reference;
            rootNode.Nodes.Add(new TreeNode());

            NodesTV.Nodes.Add(rootNode);
        }
示例#2
0
        /// <see cref="Opc.Ua.Client.Controls.BaseListCtrl.UpdateItem(ListViewItem,object)" />
        protected override void UpdateItem(ListViewItem listItem, object item)
        {
            ILocalNode node = item as ILocalNode;

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

            listItem.SubItems[0].Text = Utils.Format("{0}", node.DisplayName);
            listItem.SubItems[1].Text = Utils.Format("{0}", node.NodeId);

            listItem.ImageKey = GuiUtils.GetTargetIcon(m_session, node.NodeClass, node.TypeDefinitionId);
            listItem.Tag      = item;
        }
示例#3
0
        /// <see cref="Opc.Ua.Client.Controls.BaseListCtrl.UpdateItem(ListViewItem,object)" />
        protected override void UpdateItem(ListViewItem listItem, object item)
        {
            IReference reference = item as IReference;

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

            IReferenceType referenceType = m_session.NodeCache.Find(reference.ReferenceTypeId) as IReferenceType;

            if (referenceType != null)
            {
                if (reference.IsInverse)
                {
                    listItem.SubItems[0].Text = Utils.Format("{0}", referenceType.InverseName);
                }
                else
                {
                    listItem.SubItems[0].Text = Utils.Format("{0}", referenceType.DisplayName);
                }
            }
            else
            {
                listItem.SubItems[0].Text = Utils.Format("{0}", reference.ReferenceTypeId);
            }

            INode target = m_session.NodeCache.Find(reference.TargetId) as INode;

            if (target != null)
            {
                listItem.SubItems[1].Text = Utils.Format("{0}", target.DisplayName);
            }
            else
            {
                listItem.SubItems[1].Text = Utils.Format("{0}", reference.TargetId);
            }

            listItem.ImageKey = GuiUtils.GetTargetIcon(m_session, NodeClass.ReferenceType, null);
            listItem.Tag      = reference;
        }
示例#4
0
        /// <summary>
        /// Adds the browse results to the node (if not null).
        /// </summary>
        private void UpdateNode(TreeNode parent, ReferenceDescriptionCollection references)
        {
            try {
                for (int ii = 0; ii < references.Count; ii++)
                {
                    ReferenceDescription reference = references[ii];

                    TreeNode childNode = new TreeNode(reference.ToString());

                    childNode.ImageKey = childNode.SelectedImageKey = GuiUtils.GetTargetIcon(m_session, reference);
                    childNode.Tag      = reference;

                    childNode.Nodes.Add(new TreeNode());

                    parent.Nodes.Add(childNode);
                }
            } catch (Exception exception) {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }