-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
FormInteractiveIronPythonConsole.vb
63 lines (40 loc) · 3.25 KB
/
FormInteractiveIronPythonConsole.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
Imports System.Windows.Forms.Integration
Public Class FormInteractiveIronPythonConsole
Inherits WeifenLuo.WinFormsUI.Docking.DockContent
Public Property Flowsheet As Interfaces.IFlowsheet
Private LoadedAssemblies As Boolean = False
Private wpfCtrl As IronPythonConsole.PythonConsoleWindow
Private Sub FormInteractiveIronPythonConsole_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Width = 600
Me.AutoHidePortion = 600
ExtensionMethods.ChangeDefaultFont(Me)
Dim ctrlHost = New ElementHost()
ctrlHost.Dock = DockStyle.Fill
Me.Panel1.Controls.Add(ctrlHost)
wpfCtrl = New IronPythonConsole.PythonConsoleWindow()
wpfCtrl.InitializeComponent()
ctrlHost.Child = wpfCtrl
AddHandler wpfCtrl.ConsoleInitialized, Sub(s2, e2)
wpfCtrl.PythonConsole.UpdateVariables =
Sub(scope)
Dim engine = scope.Engine
If Not LoadedAssemblies Then
engine.Runtime.LoadAssembly(GetType(System.String).Assembly)
engine.Runtime.LoadAssembly(GetType(Thermodynamics.BaseClasses.ConstantProperties).Assembly)
engine.Runtime.LoadAssembly(GetType(Drawing.SkiaSharp.GraphicObjects.GraphicObject).Assembly)
engine.Runtime.LoadAssembly(GetType(UnitOperations.UnitOperations.Compressor).Assembly)
LoadedAssemblies = True
End If
Dim scriptSource = engine.CreateScriptSourceFromString(My.Resources.pythonfunctions, Microsoft.Scripting.SourceCodeKind.Statements)
scriptSource.Execute(scope)
scope.SetVariable("Flowsheet", Flowsheet)
scope.SetVariable("Spreadsheet", Flowsheet.FormSpreadsheet.Spreadsheet)
For Each obj As SharedClasses.UnitOperations.BaseClass In Flowsheet.Collections.FlowsheetObjectCollection.Values
scope.SetVariable(obj.GraphicObject.Tag.Replace("-", "").Replace(" ", "").Replace("_", ""), obj)
Next
End Sub
End Sub
End Sub
Private Sub FormInteractiveIronPythonConsole_Shown(sender As Object, e As EventArgs) Handles Me.Shown
End Sub
End Class