IMDBNode Interface

              

 

The IMDBNode interface can be used to access the data (cache) of individual Module Database objects like PIModule, PIAlias and PIProperty. Each IMDBNode interface is associated with one ModuleDB specific object and the underlying, native tree node object.

 

When to Use This Class

 

The typical use for this class is to obtain some rudimentary ModuleDB data without going to server. The native tree-view Node object can also be used for various purposes, like child/parent relations etc.

 

How to Use This Class

 

Subscribe to MDBTreeNet control events, most of them pass an instance of this class as an event argument. Users can also use the SelectedNodes property of the control to get a list of currently selected tree/IMDBNode nodes. For more detailed information please see the provided example.

 

 

Remarks

The users should not cache instances of IMDBNode because the "contained' native TreeNode object can go out of scope for various reasons. You should always have a proper error handling in place when accessing the properties of the IMDBNode or the native TreeNode object.

Note: You must type cast the interface instance to TreeNode in order to access the node itself.

 

Requirements

    Assembly: OSIsoft.PISDK.Controls.IMDBNode (in OSIsoft.PISDK.Controls.MDBTreeNet.dll).

 


 

Example

 

1. Create a Windows Form application for MDBTreeNet user control (see "how to" instructions)

2. Add a standard textboxe and make it fairly large. Right-click on the text box and select properties.

3. Change the "Multiline" property to TRUE, you may also want to specify scroll-bars.

5. Right-click on the MDBTree control, select "Events" tab from the properties window and double-click on the "NodeSelected" event.

6. Replace the empty method definition by the following code:

 

/// <summary>

/// This method is invoked whenever a user selects a tree node.

/// This example demonstrates how to utilize the various properties of the IMDBNode object,

/// which the application receives as an event argument.

/// </summary>

/// <param name="sender">Event source</param>

/// <param name="e"><Event arguments class for this event/param>

private void mdbTreeNet1_nodeSelectedEvent(object sender, OSIsoft.PISDK.Controls.NodeSelectedEventArgs e)

{

    IMDBNode iNode = e.TreeNode; // get the IMDBNode interface instance

    System.Windows.Forms.TreeNode nativeNode = (TreeNode)iNode; // cast to native tree node

    string text = "---- NODE INFORMATION ----" + Environment.NewLine; // title

    text += "Name: " + iNode.ItemName + " Text:" + nativeNode.Text + Environment.NewLine; // text and name

    text += "Path:" + iNode.FullPathName + Environment.NewLine; // full path

    if (nativeNode.Parent != null)

        text += "Parent text:" + nativeNode.Parent.Text + Environment.NewLine; // Parent name

    text += "# of child nodes:" + nativeNode.Nodes.Count.ToString() + Environment.NewLine; // child count (tree nodes, not MDB children)

    text += "Type:" + iNode.ModuleType.ToString(); // module type

    textBox1.Text = text; // finally show text

}

Enabling Operational Intelligence