The following plugin creates a MouseUp event handler that displays a message when the user releases a mouse button. If the user clicks an object such as a rectangle, the event handler displays a description of the object. If the user clicks a region of the path diagram that is not occupied by an object, the event handler displays the message "No object".
Imports Amos
Imports Amos.pd
Imports System.Environment
Imports Microsoft.VisualBasic
<System.ComponentModel.Composition.Export(GetType(IPlugin))>
Public Class CustomCode
Implements IPlugin
Public Function Mainsub() As Integer Implements IPlugin.Mainsub
AddHandler pd.MouseUp, AddressOf MouseUp
MsgBox("MouseUp Event Example is now installed.")
End Function
Private Sub MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim message As String
message &= "x = " & X
message &= NewLine & "y = " & Y
message &= NewLine & NewLine
Dim pde As PDElement = XYObject(X, Y)
If pde Is Nothing Then
message &= "No object"
ElseIf pde.IsObservedVariable Then
message &= "Rectangle: " & pde.NameOrCaption
ElseIf pde.IsUnobservedVariable Then
message &= "Ellipse: " & pde.NameOrCaption
ElseIf pde.IsPath Then
message &= "Single-headed arrow"
ElseIf pde.IsCovariance Then
message &= "Double-headed arrow"
ElseIf pde.IsCaption Then
message &= "Caption: "
message &= vbCrLf & pde.NameOrCaption
End If
MsgBox(message, MsgBoxStyle.MsgBoxSetForeground)
End Sub
Public Function Name() As String Implements IPlugin.Name
End Function
Public Function Description() As String Implements IPlugin.Description
End Function
End Class