File size: 3,073 Bytes
b1b3bae |
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 |
Imports System.ComponentModel.Design
Imports System.Text
Imports DWSIM.Interfaces
Public Class FormExtraProperties
Inherits WeifenLuo.WinFormsUI.Docking.DockContent
Public SimObject As ISimulationObject
Public Loaded As Boolean = False
Private Sub FormExtraProperties_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.AutoScaleMode = AutoScaleMode.Dpi
Me.AutoScaleDimensions = New System.Drawing.SizeF(96, 96)
For Each control As Control In Me.Controls
control.Font = Drawing.SystemFonts.MessageBoxFont
If GlobalSettings.Settings.DpiScale > 1.0 Then
If TypeOf control Is DataGridView Then
Dim dgv = DirectCast(control, DataGridView)
dgv.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None
dgv.AllowUserToResizeRows = False
dgv.RowTemplate.Height = 23 * GlobalSettings.Settings.DpiScale
dgv.ColumnHeadersHeight *= GlobalSettings.Settings.DpiScale
End If
End If
Next
UpdateValues()
End Sub
Public Sub UpdateValues()
Loaded = False
Text = SimObject.GraphicObject.Tag + ": " + SimObject.GetFlowsheet().GetTranslatedString("AdditionalProperties")
TabText = Text
grid1.Rows.Clear()
Dim col1 = DirectCast(SimObject.ExtraProperties, IDictionary(Of String, Object))
Dim col2 = DirectCast(SimObject.ExtraPropertiesDescriptions, IDictionary(Of String, Object))
For Each prop In col1
If Not col2.ContainsKey(prop.Key) Then
grid1.Rows.Add(New Object() {prop.Key, prop.Value})
End If
Next
Loaded = True
End Sub
Private Sub grid1_KeyDown(sender As Object, e As KeyEventArgs) Handles grid1.KeyDown
If e.KeyCode = Keys.V And e.Modifiers = Keys.Control Then PasteData(grid1)
End Sub
Private Sub grid1_DataError(sender As Object, e As DataGridViewDataErrorEventArgs) Handles grid1.DataError
End Sub
Private Sub grid1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles grid1.CellValueChanged
If Loaded Then
If e.ColumnIndex = 1 Then
Dim col1 = DirectCast(SimObject.ExtraProperties, IDictionary(Of String, Object))
Dim id = grid1.Rows(e.RowIndex).Cells(0).Value
Dim value = grid1.Rows(e.RowIndex).Cells(1).Value
Try
If TypeOf col1(id) Is Double Then
col1(id) = Double.Parse(value.ToString())
Else
col1(id) = value
End If
SimObject.GetFlowsheet().RequestCalculation(SimObject)
Catch ex As Exception
MessageBox.Show(ex.Message, SimObject.GetFlowsheet().GetTranslatedString("Erro"), MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End If
End Sub
End Class |