private void BrowseTV_BeforeExpand(object sender, TreeViewCancelEventArgs e)
{
try
{
ReferenceDescription reference = (ReferenceDescription)e.Node.Tag;
e.Node.Nodes.Clear();
// browse HasEventSource to display the sources but it won't be possible to select them.
BrowseDescription nodeToBrowse = new BrowseDescription();
nodeToBrowse.NodeId = Opc.Ua.ObjectTypeIds.BaseEventType;
nodeToBrowse.BrowseDirection = BrowseDirection.Forward;
nodeToBrowse.ReferenceTypeId = ReferenceTypeIds.HasSubtype;
nodeToBrowse.IncludeSubtypes = false;
nodeToBrowse.NodeClassMask = 0;
nodeToBrowse.ResultMask = (uint)BrowseResultMask.All;
if (reference != null)
{
nodeToBrowse.NodeId = (NodeId)reference.NodeId;
}
// add the childen to the control.
ReferenceDescriptionCollection references = FormUtils.Browse(m_session, nodeToBrowse, false);
for (int ii = 0; ii < references.Count; ii++)
{
reference = references[ii];
// ignore out of server references.
if (reference.NodeId.IsAbsolute)
{
continue;
}
TreeNode child = new TreeNode(reference.ToString());
child.Nodes.Add(new TreeNode());
child.Tag = reference;
e.Node.Nodes.Add(child);
}
}
catch (Exception exception)
{
ClientUtils.HandleException(this.Text, exception);
}
}
#endregion