Every object visualized with Nevron Graphics can have an associated interactivity style that controls the interactive object behavior. The interactivity style of the object is represented by the NInteractivityStyle class. This object contains a collection of interactivity attributes like tooltip, cursor, HTML image map area script etc. Furthermore the NInteractivityStyle class has several properties allowing you to access attributes from certain type directly, which makes code less bulky.
You add interactivity attributes to the NInteractivityStyle by obtaining a reference to the NInteractivityAttributeCollection collection. For example:
C# |
Copy Code
|
NCursorAttribute cursorAttribute = new NCursorAttribute(CursorType.Hand);
someObject.InteractivityStyle.InteractivityAttributes.Add(cursorAttribute);
|
Visual Basic |
Copy Code
|
Dim cursorAttribute As New NCursorAttribute(CursorType.Hand)
someObject.InteractivityStyle.InteractivityAttributes.Add(cursorAttribute)
|
When you have more than one interactivity attribute in the collection from the same type (for example two tooltip attributes) the framework will always choose the first one. That's why when you're not certain that the collection already contains such an attribute you should first check and then add a new one only if necessary. Because the NInteractivityStyle is attached to many objects (practically all visible objects) its InteractivityAttributes collection is created on demand. This is needed to minimize the control memory footprint. To check whether the collection already contains an interactivity attribute you should use the FindAttributeOfType method instead of obtaining a reference to the collection:
C# |
Copy Code
|
NUrlLinkAttribute urlLinkAttribute = someObject.InteractivityStyle.FindAttributeOfType(typeof(NUrlLinkAttribute)) as NUrlLinkAttribute;
if (urlLinkAttribute != null)
{
// do something with attribute
}
else
{
// add new attribute
}
|
Visual Basic |
Copy Code
|
Dim urlLinkAttribute As NUrlLinkAttribute = CType(someObject.InteractivityStyle.FindAttributeOfType(GetType(NUrlLinkAttribute)), NUrlLinkAttribute)
If Not (urlLinkAttribute Is Nothing) Then
' do something with attribute
Else
' add new attribute
End If
|
The following topics discuss each interactivity attribute in detail.