-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
GraphicObjectControlPanelModeEditors.vb
49 lines (40 loc) · 3.26 KB
/
GraphicObjectControlPanelModeEditors.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
Imports DWSIM.ExtensionMethods
Imports DWSIM.Interfaces
Imports DWSIM.SharedClasses
Imports System.Linq
Imports System.Windows.Forms
Public Class GraphicObjectControlPanelModeEditors
Public Shared Sub SetInputDelegate(gobj As IGraphicObject, myObj As ISimulationObject)
gobj.ControlPanelModeEditorDisplayDelegate = Sub()
Dim f As New FormTextBoxInput
Dim SelectedObject = myObj?.GetFlowsheet.SimulationObjects.Values.Where(Function(x2) x2.Name = myObj.SelectedObjectID).FirstOrDefault
If Not SelectedObject Is Nothing Then
Dim currentvalue = SystemsOfUnits.Converter.ConvertFromSI(myObj.SelectedPropertyUnits, SelectedObject.GetPropertyValue(myObj.SelectedProperty))
f.TextBox1.Text = currentvalue.ToString(myObj?.GetFlowsheet.FlowsheetOptions.NumberFormat)
f.Text = SelectedObject.GraphicObject.Tag + "/" + myObj?.GetFlowsheet.GetTranslatedString(myObj.SelectedProperty)
AddHandler f.TextBox1.KeyDown,
Sub(s, e)
If e.KeyCode = Keys.Enter Then
Try
SelectedObject.SetPropertyValue(myObj.SelectedProperty, f.TextBox1.Text.ToDoubleFromCurrent().ConvertToSI(myObj.SelectedPropertyUnits))
f.Close()
Catch ex As Exception
MessageBox.Show("Error", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
f.StartPosition = FormStartPosition.Manual
f.Location = Cursor.Position
f.ShowDialog()
End If
End Sub
End Sub
Public Shared Sub SetPIDDelegate(gobj As IGraphicObject, myObj As ISimulationObject)
gobj.ControlPanelModeEditorDisplayDelegate = Sub()
Dim f As New FormPIDCPEditor With {.PID = myObj}
f.StartPosition = FormStartPosition.Manual
f.Location = Cursor.Position
f.ShowDialog()
End Sub
End Sub
End Class