-
Notifications
You must be signed in to change notification settings - Fork 0
/
cPlugin.vb
73 lines (52 loc) · 2.49 KB
/
cPlugin.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Imports SAP2000v1
Public Class cPlugin
Private Shared modality As String = "Non-Modal"
Friend Shared VersionString As String = "Version " _
& System.Reflection.Assembly.GetExecutingAssembly.GetName().Version.ToString _
& " , .NET Only , Compiled as " _
& System.Reflection.Assembly.GetExecutingAssembly.GetName().ProcessorArchitecture.ToString _
& " , " & modality
Public Function Info(ByRef Text As String) As Integer
Try
Text = "This external Plugin is supplied by Rapicavoli Davide"
Text &= VersionString
Catch ex As Exception
End Try
Return 0
End Function
Public Sub Main(ByRef SapModel As cSapModel, ByRef ISapPlugin As cPluginCallback)
Dim aForm As New FramesToLinks
Try
aForm.setParentPluginObject(Me)
aForm.setSapModel(SapModel, ISapPlugin)
If StrComp(modality, "Non-Modal", CompareMethod.Text) = 0 Then
' Non-modal form, allows graphics refresh operations in CSI program,
' but Main will return to CSI program before the form is closed.
aForm.Show()
Else
' Modal form, will not return to CSI program until form is closed,
' but may cause errors when refreshing the view.
aForm.ShowDialog()
End If
' It is very important to call ISapPlugin.Finish(iError) when form closes, !!!
' otherwise, CSI program will wait and be hung !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' this must be done inside the closing event for the form itself, not here !!!
' if you simply have algorithmic code here without any forms,
' then call ISapPlugin.Finish(iError) here before returning to CSI program
' if your code will run for more than a few seconds, you should exercise
' the Windows messaging loop to keep the program responsive. You may
' also want to provide an opportunity for the user to cancel operations.
Catch ex As Exception
MsgBox("The following error terminated the Plugin:" & vbCrLf & ex.Message)
' call Finish to inform CSI program that the PlugIn has terminated
Try
ISapPlugin.Finish(1)
Catch ex1 As Exception
End Try
End Try
Return
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class