Implementing the plug in form class, Implementing the plug-in form class – Echelon LNS Plug-in User Manual

Page 27

Advertising
background image

"Tests device."

,

// Description

EnumCommandIds

.Test,

// CommandId

EnumClassIds

.AppDevice,

// ComponentClassId

false

,

// DefaultAppFlag

ComponentAppScope

.System

// Scope

)

// TODO: add additional commands here

};

public

override

PluginCommand

[] PluginCommands

{

get

{

return

_PluginCommands; }

}


// constructor

public

MyPluginObject()

{

// create and ‘register’ the plug-in user interface

PluginForm =

new

MyPluginForm

();

PluginForm.Visible =

false

;

}
}
}

Note: The PluginObject class implements much of the plug-in behavior; therefore, if you are creating
more complex plug-ins, you may need to take the following additional steps in your PluginObject
class:

• Override the ActivatePlugin virtual method in your PluginObject class and perform the

command actions specified in the base class Actions property. Typically, though, your plug-in
will show a user interface, and you will override the equivalent method in the PluginForm class
instead (see the following section, Implementing the Plug-in Form Class).

• Override any ILnsPlugin properties or methods, if extra processing is required before or after the

framework implementation is executed (for example, before setting the base class Network
property, which will open the LNS network, the plug-in may set LNS attributes that need to be set
before any networks are opened). Typically this is not necessary.

• Override the base class RegisterClass and UnregisterClass virtual methods to perform additional

plug-in specific registration and unregistration actions. Typically this is not necessary.

Implementing the Plug-in Form Class

To implement your plug-in form class, modify the source code as follows:

1. Add using System.Runtime.InteropServices, using Echelon.LNS.Plugin, and using

Echelon.LNS.Interop directives.

2. Derive your plug-in form class from PluginFormBase (located in the Echelon.LNS.Plugin

namespace) instead of Form. PluginFormBase is itself derived from Form.

3. Override the ActivatePlugin virtual method in your plug-in form class and implement the code to

perform the command actions specified in your plug-in object base class
PluginObjectBase.Actions property. There is a reference to your plug-in object stored in the
PluginFormBase.Plugin property. The Actions property is an array of PluginAction objects that
contain the fields shown in the following table:

Field Description

CommandId

A value identifying the command.

ComponentClassId

A value identifying the LNS objects to which this command
can be applied.

Advertising