The following plugin prevents the user from drawing observed variables. Running the plugin creates a ButtonPressed event handler that is executed each time the user presses a button in the toolbox (or makes a selection from the Amos Graphics menu). If the user presses the Draw Observed button, the event handler sets Handled = True, preventing Amos Graphics from responding to the button press.
Imports Microsoft.VisualBasic
Imports Amos
<System.ComponentModel.Composition.Export(GetType(IPlugin))>
Public Class CustomCode
Implements IPlugin
Public Function Mainsub() As Integer Implements IPlugin.Mainsub
AddHandler pd.ButtonPressed, AddressOf ButtonPressed
MsgBox("ButtonPressed Event Example is now installed",, "ButtonPressed Event")
End Function
Private Sub ButtonPressed(ByVal ButtonNumber As Integer, ByRef Handled As Boolean)
If ButtonNumber = 101 Then
MsgBox("Sorry, you are not allowed to draw boxes.",, "ButtonPressed Event")
'Suppress Amos Graphics's normal response
'to the Draw Observed button.
Handled = True
Else
'Allow Amos Graphics to respond in the normal way
'to the button click.
Handled = False
End If
End Sub
Public Function Name() As String Implements IPlugin.Name
End Function
Public Function Description() As String Implements IPlugin.Description
End Function
End Class