forked from DanWBR/dwsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormAddFlowsheetObject.vb
155 lines (127 loc) · 5.69 KB
/
FormAddFlowsheetObject.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
Imports System.Reflection
Imports System.Linq
Public Class FormAddFlowsheetObject
Public Flowsheet As FormFlowsheet
Dim typelist As New List(Of Type)
Dim objlist As New Dictionary(Of String, Interfaces.ISimulationObject)
Private Sub FormAddFlowsheetObject_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ExtensionMethods.ChangeDefaultFont(Me)
Dim calculatorassembly = My.Application.Info.LoadedAssemblies.Where(Function(x) x.FullName.Contains("DWSIM.Thermodynamics,")).FirstOrDefault
Dim unitopassembly = My.Application.Info.LoadedAssemblies.Where(Function(x) x.FullName.Contains("DWSIM.UnitOperations")).FirstOrDefault
Dim availableTypes As New List(Of Type)()
availableTypes.AddRange(calculatorassembly.GetTypes().Where(Function(x) If(x.GetInterface("DWSIM.Interfaces.ISimulationObject") IsNot Nothing, True, False)))
availableTypes.AddRange(unitopassembly.GetTypes().Where(Function(x) If(x.GetInterface("DWSIM.Interfaces.ISimulationObject") IsNot Nothing, True, False)))
Dim add As Boolean = True
For Each item In availableTypes
If Not item.IsAbstract Then
Dim obj = DirectCast(Activator.CreateInstance(item), Interfaces.ISimulationObject)
If Not Flowsheet.MobileCompatibilityMode Then
add = True
Else
add = obj.MobileCompatible
End If
If add Then
obj.SetFlowsheet(Flowsheet)
objlist.Add(obj.GetDisplayName, obj)
ListBox1.Items.Add(obj.GetDisplayName)
End If
End If
Next
ListBox1.SelectedIndex = 0
ListBox1.Sorted = True
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
If ListBox1.SelectedIndex < 0 Then Exit Sub
Dim obj = objlist(ListBox1.SelectedItem.ToString)
Dim fi = FileVersionInfo.GetVersionInfo(obj.GetType.Assembly.Location)
lblName.Text = obj.GetDisplayName
lblVersion.Text = obj.GetVersion.ToString
lblLibrary.Text = fi.OriginalFilename
lblLibVersion.Text = obj.GetType.Assembly.GetName.Version.ToString
txtDesc.Text = obj.GetDisplayDescription
txtAbout.Text = fi.FileDescription + vbCrLf + fi.Comments + vbCrLf + fi.LegalCopyright
PictureBox1.Image = obj.GetIconBitmap
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
Dim tobj As ObjectType = ObjectType.Nenhum
Select Case objlist(ListBox1.SelectedItem.ToString).GetType.Name
Case "Adjust"
tobj = ObjectType.OT_Adjust
Case "Spec"
tobj = ObjectType.OT_Spec
Case "Recycle"
tobj = ObjectType.OT_Recycle
Case "EnergyRecycle"
tobj = ObjectType.OT_EnergyRecycle
Case "Mixer"
tobj = ObjectType.NodeIn
Case "Splitter"
tobj = ObjectType.NodeOut
Case "Pump"
tobj = ObjectType.Pump
Case "Tank"
tobj = ObjectType.Tank
Case "Vessel"
tobj = ObjectType.Vessel
Case "MaterialStream"
tobj = ObjectType.MaterialStream
Case "EnergyStream"
tobj = ObjectType.EnergyStream
Case "Compressor"
tobj = ObjectType.Compressor
Case "Expander"
tobj = ObjectType.Expander
Case "Cooler"
tobj = ObjectType.Cooler
Case "Heater"
tobj = ObjectType.Heater
Case "Pipe"
tobj = ObjectType.Pipe
Case "Valve"
tobj = ObjectType.Valve
Case "Reactor_Conversion"
tobj = ObjectType.RCT_Conversion
Case "Reactor_Equilibrium"
tobj = ObjectType.RCT_Equilibrium
Case "Reactor_Gibbs"
tobj = ObjectType.RCT_Gibbs
Case "Reactor_CSTR"
tobj = ObjectType.RCT_CSTR
Case "Reactor_PFR"
tobj = ObjectType.RCT_PFR
Case "HeatExchanger"
tobj = ObjectType.HeatExchanger
Case "ShortcutColumn"
tobj = ObjectType.ShortcutColumn
Case "DistillationColumn"
tobj = ObjectType.DistillationColumn
Case "AbsorptionColumn"
tobj = ObjectType.AbsorptionColumn
Case "ReboiledAbsorber"
tobj = ObjectType.ReboiledAbsorber
Case "RefluxedAbsorber"
tobj = ObjectType.RefluxedAbsorber
Case "ComponentSeparator"
tobj = ObjectType.ComponentSeparator
Case "OrificePlate"
tobj = ObjectType.OrificePlate
Case "CustomUO"
tobj = ObjectType.CustomUO
Case "ExcelUO"
tobj = ObjectType.ExcelUO
Case "CapeOpenUO"
tobj = ObjectType.CapeOpenUO
Case "SolidsSeparator"
tobj = ObjectType.SolidSeparator
Case "Filter"
tobj = ObjectType.Filter
Case "Flowsheet"
tobj = ObjectType.FlowsheetUO
End Select
Flowsheet.AddObject(tobj, 30, 30, "")
Me.Close()
End Sub
End Class