-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
FormSimulSettings.vb
1985 lines (1606 loc) · 93.9 KB
/
FormSimulSettings.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
' Copyright 2008 Daniel Wagner O. de Medeiros
'
' This file is part of DWSIM.
'
' DWSIM is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' DWSIM is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with DWSIM. If not, see <http://www.gnu.org/licenses/>.
Imports System.Xml.Serialization
Imports DWSIM.Thermodynamics.BaseClasses
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Runtime.Serialization.Formatters
Imports System.IO
Imports DWSIM.FlowsheetSolver
Imports System.Linq
Imports DWSIM.Thermodynamics.PropertyPackages
Imports DWSIM.Simulate365.FormFactories
Imports DWSIM.Simulate365.Models
Imports DWSIM.Interfaces
Imports DWSIM.SharedClassesCSharp.FilePicker
Imports AeroWizard
Public Class FormSimulSettings
Inherits WeifenLuo.WinFormsUI.Docking.DockContent
Public CurrentFlowsheet As FormFlowsheet
Public loaded As Boolean = False
Public initialized As Boolean = False
Public supports As Boolean = True
Private availableproperties As New Dictionary(Of String, String())
Private aTypeList As New List(Of Type)
Private aTypeRefs As New Dictionary(Of String, String)
Private prevsort As System.ComponentModel.ListSortDirection = System.ComponentModel.ListSortDirection.Ascending
Private prevcol As Integer = 1
Private CompoundList As List(Of String)
Private Indexes As Dictionary(Of String, Integer)
Dim vdPP, vdSR As MessageBox()
Dim SetHeights As Boolean = False
Public Shared AddMoreTabs As Action(Of TabControl, IFlowsheet)
Private Sub FormStSim_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sw As Integer = Screen.PrimaryScreen.Bounds.Width
Dim sh As Integer = Screen.PrimaryScreen.Bounds.Height
Dim w = 900 * GlobalSettings.Settings.DpiScale
Dim h = 600 * GlobalSettings.Settings.DpiScale
If Me.Pane IsNot Nothing Then
Me.Pane.FloatWindow.SetBounds((sw - w) / 2, (sh - h) / 2, w, h)
End If
Me.TabText = Me.Text
initialized = True
If DWSIM.App.IsRunningOnMono Then
Me.ogc1.SelectionMode = DataGridViewSelectionMode.CellSelect
Me.dgvpp.SelectionMode = DataGridViewSelectionMode.CellSelect
End If
Dim rm As New FormReacManager
rm.CurrentFlowsheet = CurrentFlowsheet
rm.Dock = DockStyle.Fill
TabPageReactions.Controls.Add(rm)
DataGridViewPP.Columns(1).Width = 24 * Settings.DpiScale
Init()
AddMoreTabs?.Invoke(TabControl1, CurrentFlowsheet)
End Sub
Private Sub FormStSim_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If CurrentFlowsheet IsNot Nothing Then
If Me.CurrentFlowsheet.Options.SelectedComponents.Count = 0 And Me.CurrentFlowsheet.Options.PropertyPackages.Count = 0 Then
MessageBox.Show(DWSIM.App.GetLocalString("Adicionesubstnciassi"), DWSIM.App.GetLocalString("Erro"), MessageBoxButtons.OK, MessageBoxIcon.Error)
MessageBox.Show(DWSIM.App.GetLocalString("NoexistemPacotesdePr"), DWSIM.App.GetLocalString("Erro"), MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Me.CurrentFlowsheet.Options.SelectedComponents.Count = 0 Then
MessageBox.Show(DWSIM.App.GetLocalString("Adicionesubstnciassi"), DWSIM.App.GetLocalString("Erro"), MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Me.CurrentFlowsheet.Options.PropertyPackages.Count = 0 Then
MessageBox.Show(DWSIM.App.GetLocalString("NoexistemPacotesdePr"), DWSIM.App.GetLocalString("Erro"), MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End If
CurrentFlowsheet?.EnableUndoRedo()
End Sub
Sub Init(Optional ByVal reset As Boolean = False)
'If Not SetHeights Then
' ogc1.RowTemplate.Height = 23 * Settings.DpiScale
' DataGridViewPP.RowTemplate.Height = 23 * Settings.DpiScale
' dgvpp.RowTemplate.Height = 23 * Settings.DpiScale
' ogc1.ColumnHeadersHeight *= Settings.DpiScale
' DataGridViewPP.ColumnHeadersHeight *= Settings.DpiScale
' dgvpp.ColumnHeadersHeight *= Settings.DpiScale
' SetHeights = True
'End If
CurrentFlowsheet.SetDirtyStatus()
Dim pathsep As Char = Path.DirectorySeparatorChar
Dim comp As BaseClasses.ConstantProperties
If Not loaded Or reset Then
ExtensionMethods.ChangeDefaultFont(Me)
colAdd.ValueType = True.GetType()
colAdd.FalseValue = False
colAdd.TrueValue = True
colAdd.IndeterminateValue = False
txtSearch.AutoCompleteCustomSource = New AutoCompleteStringCollection()
CompoundList = New List(Of String)()
Indexes = New Dictionary(Of String, Integer)
Dim rowlist As New List(Of DataGridViewRow)
ogc1.Rows.Clear()
For Each comp In Me.CurrentFlowsheet.Options.SelectedComponents.Values
Dim r As New DataGridViewRow()
Dim data = New Object() {comp.Name, True, comp.Name, comp.Tag, comp.CAS_Number, DWSIM.App.GetComponentType(comp), comp.Formula, comp.CurrentDB, comp.IsCOOLPROPSupported}
r.CreateCells(ogc1, data)
r.Height = 23 * Settings.DpiScale
rowlist.Add(r)
CompoundList.Add(comp.CAS_Number)
CompoundList.Add(comp.Formula)
If Not Indexes.ContainsKey(comp.Name) Then Indexes.Add(comp.Name, ogc1.Rows.Count - 1)
If Not Indexes.ContainsKey(comp.CAS_Number) Then Indexes.Add(comp.CAS_Number, ogc1.Rows.Count - 1)
If Not Indexes.ContainsKey(comp.Formula) Then Indexes.Add(comp.Formula, ogc1.Rows.Count - 1)
Next
For Each comp In Me.CurrentFlowsheet.Options.NotSelectedComponents.Values
Dim r As New DataGridViewRow()
Dim data = New Object() {comp.Name, False, comp.Name, comp.Tag, comp.CAS_Number, DWSIM.App.GetComponentType(comp), comp.Formula, comp.CurrentDB, comp.IsCOOLPROPSupported}
r.CreateCells(ogc1, data)
r.Height = 23 * Settings.DpiScale
rowlist.Add(r)
CompoundList.Add(comp.CAS_Number)
CompoundList.Add(comp.Formula)
If Not Indexes.ContainsKey(comp.Name) Then Indexes.Add(comp.Name, ogc1.Rows.Count - 1)
If Not Indexes.ContainsKey(comp.CAS_Number) Then Indexes.Add(comp.CAS_Number, ogc1.Rows.Count - 1)
If Not Indexes.ContainsKey(comp.Formula) Then Indexes.Add(comp.Formula, ogc1.Rows.Count - 1)
Next
ogc1.Rows.AddRange(rowlist.ToArray())
txtSearch.AutoCompleteCustomSource.AddRange(CompoundList.ToArray())
Dim addobj As Boolean = True
'property packages
Me.DataGridViewPP.Rows.Clear()
For Each pp2 As PropertyPackages.PropertyPackage In FormMain.PropertyPackages.Values.OrderBy(Function(x) x.ComponentName)
If Not CurrentFlowsheet.MobileCompatibilityMode Then
addobj = True
Else
addobj = pp2.MobileCompatible
End If
If addobj Then Me.DataGridViewPP.Rows.Add(New Object() {pp2.ComponentName, pp2.GetDisplayIcon(), pp2.ComponentName, pp2.ComponentDescription})
Next
If Not FormMain.IsPro Then
ProFeatures.Functions.AddProPPs2(DataGridViewPP)
End If
DataGridViewPP.Sort(DataGridViewPP.Columns(2), System.ComponentModel.ListSortDirection.Ascending)
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
aTypeList.Clear()
aTypeList.AddRange(calculatorassembly.GetTypes().Where(Function(x)
If x.GetInterface("DWSIM.Interfaces.ISimulationObject") IsNot Nothing Then
Return True
Else
Return False
End If
End Function))
aTypeList.AddRange(unitopassembly.GetTypes().Where(Function(x)
If x.GetInterface("DWSIM.Interfaces.ISimulationObject") IsNot Nothing Then
Return True
Else
Return False
End If
End Function))
Dim add As Boolean = False
If CurrentFlowsheet.FlowsheetOptions.VisibleProperties.Count = 0 Then add = True
cbObjectType.Items.Clear()
availableproperties.Clear()
aTypeRefs.Clear()
For Each item In aTypeList.OrderBy(Function(x) x.Name)
If Not item.IsAbstract Then
Dim obj = DirectCast(Activator.CreateInstance(item), Interfaces.ISimulationObject)
obj.SetFlowsheet(CurrentFlowsheet)
cbObjectType.Items.Add(obj.GetDisplayName)
availableproperties.Add(obj.GetDisplayName, obj.GetProperties(PropertyType.ALL))
aTypeRefs.Add(obj.GetDisplayName, item.Name)
If add Then CurrentFlowsheet.FlowsheetOptions.VisibleProperties.Add(item.Name, obj.GetDefaultProperties.ToList)
obj.SetFlowsheet(Nothing)
obj = Nothing
End If
Next
cbObjectType.SelectedIndex = 0
cbObjectType.Sorted = True
With Me.dgvpp.Rows
.Clear()
For Each pp2 As PropertyPackages.PropertyPackage In CurrentFlowsheet.Options.PropertyPackages.Values
.Add(New Object() {pp2.UniqueID, pp2.Tag, pp2.ComponentName})
Next
End With
Me.ComboBox2.Items.Clear()
Me.ComboBox2.Items.AddRange(FormMain.AvailableUnitSystems.Keys.ToArray)
Else
For Each r As DataGridViewRow In ogc1.Rows
If CurrentFlowsheet.Options.NotSelectedComponents.ContainsKey(r.Cells(0).Value) Then
comp = CurrentFlowsheet.Options.NotSelectedComponents(r.Cells(0).Value)
For Each c As DataGridViewCell In r.Cells
If comp.Acentric_Factor = 0.0# Or comp.Critical_Compressibility = 0.0# Then
c.Style.ForeColor = Color.Red
c.ToolTipText = DWSIM.App.GetLocalString("CompMissingData")
End If
Next
End If
Next
End If
ComboBox1.SelectedItem = Me.CurrentFlowsheet?.Options.NumberFormat
ComboBox3.SelectedItem = Me.CurrentFlowsheet?.Options.FractionNumberFormat
If Me.CurrentFlowsheet.Options.SelectedUnitSystem.Name <> "" Then
ComboBox2.SelectedItem = Me.CurrentFlowsheet.Options.SelectedUnitSystem.Name
Else
ComboBox2.SelectedIndex = 0
End If
Me.TBaut.Text = Me.CurrentFlowsheet.Options.SimulationAuthor
Me.TBdesc.Text = Me.CurrentFlowsheet.Options.SimulationComments.Replace(vbLf, vbCrLf)
Me.TBtit.Text = Me.CurrentFlowsheet.Options.SimulationName
Me.tbPassword.Text = CurrentFlowsheet.Options.Password
Me.chkUsePassword.Checked = CurrentFlowsheet.Options.UsePassword
If DWSIM.App.IsRunningOnMono Then btnConfigPP.Enabled = True
cbMassBalanceCheck.SelectedIndex = CurrentFlowsheet.Options.MassBalanceCheck
cbEnergyBalanceCheck.SelectedIndex = CurrentFlowsheet.Options.EnergyBalanceCheck
tbMassBalTol.Text = CurrentFlowsheet.Options.MassBalanceRelativeTolerance.ToString()
tbEnergyBalTol.Text = CurrentFlowsheet.Options.EnergyBalanceRelativeTolerance.ToString()
chkShowFloatingTables.Checked = CurrentFlowsheet.Options.DisplayFloatingPropertyTables
chkShowAnchoredPropertyLists.Checked = CurrentFlowsheet.Options.DisplayCornerPropertyList
chkDisplayFloatingTableCompoundAmounts.Checked = CurrentFlowsheet.Options.DisplayFloatingTableCompoundAmounts
cbDefaultFloatingTableCompoundAmountBasis.SelectedIndex = CurrentFlowsheet.Options.DefaultFloatingTableCompoundAmountBasis
cbOrderCompoundsBy.SelectedIndex = CurrentFlowsheet.Options.CompoundOrderingMode
chkSkipEqCalcs.Checked = CurrentFlowsheet.Options.SkipEquilibriumCalculationOnDefinedStreams
chkShowExtraPropertiesEditor.Checked = CurrentFlowsheet.Options.DisplayUserDefinedPropertiesEditor
cbSpecCalcMode.SelectedIndex = CurrentFlowsheet.Options.SpecCalculationMode
chkForceObjectCalculation.Checked = CurrentFlowsheet.Options.ForceObjectSolving
Select Case CurrentFlowsheet.Options.ForceStreamPhase
Case ForcedPhase.None
cbForcePhase.SelectedIndex = 0
Case ForcedPhase.Vapor
cbForcePhase.SelectedIndex = 1
Case ForcedPhase.Liquid
cbForcePhase.SelectedIndex = 2
Case ForcedPhase.Solid
cbForcePhase.SelectedIndex = 3
End Select
chkShowMSTemp.Checked = CurrentFlowsheet.Options.DisplayMaterialStreamTemperatureValue
chkShowMSPressure.Checked = CurrentFlowsheet.Options.DisplayMaterialStreamPressureValue
chkMSShowW.Checked = CurrentFlowsheet.Options.DisplayMaterialStreamMassFlowValue
chkMSSHowM.Checked = CurrentFlowsheet.Options.DisplayMaterialStreamMolarFlowValue
chkMSShowV.Checked = CurrentFlowsheet.Options.DisplayMaterialStreamVolFlowValue
chkMSShowE.Checked = CurrentFlowsheet.Options.DisplayMaterialStreamEnergyFlowValue
chkESShowE.Checked = CurrentFlowsheet.Options.DisplayEnergyStreamPowerValue
chkShowDynProps.Checked = CurrentFlowsheet.Options.DisplayDynamicPropertyValues
chkIncludeFlowsheetMessagesInFile.Checked = CurrentFlowsheet.Options.SaveFlowsheetMessagesInFile
chkEnableUndoRedo.Checked = CurrentFlowsheet.Options.EnabledUndoRedo
Me.loaded = True
ExtensionMethods.ChangeDefaultFont(Me)
AddHandler DataGridView1.EditingControlShowing, AddressOf Me.myDataGridView_EditingControlShowing
End Sub
Private Sub myDataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs)
If (e.Control.GetType = GetType(DataGridViewComboBoxEditingControl)) Then
Dim cmb As ComboBox = CType(e.Control, ComboBox)
RemoveHandler DataGridView1.EditingControlShowing, AddressOf Me.cmb_SelectionChangeCommitted
AddHandler cmb.SelectionChangeCommitted, AddressOf Me.cmb_SelectionChangeCommitted
End If
End Sub
Private Sub cmb_SelectionChangeCommitted(ByVal sender As Object, ByVal e As EventArgs)
DataGridView1.CurrentCell.Value = CType(sender, DataGridViewComboBoxEditingControl).EditingControlFormattedValue
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
CurrentFlowsheet.Options.NumberFormat = Me.ComboBox1.SelectedItem
CurrentFlowsheet.UpdateOpenEditForms()
End Sub
Private Sub TBtit_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TBtit.TextChanged
If Me.loaded Then
Me.CurrentFlowsheet.Options.SimulationName = Me.TBtit.Text
Me.CurrentFlowsheet.Text = Me.TBtit.Text + " (" + Me.CurrentFlowsheet.Options.FilePath + ")"
End If
End Sub
Private Sub TBaut_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TBaut.TextChanged
If Me.loaded Then Me.CurrentFlowsheet.Options.SimulationAuthor = Me.TBaut.Text
End Sub
Private Sub TBdesc_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TBdesc.TextChanged
If Me.loaded Then Me.CurrentFlowsheet.Options.SimulationComments = Me.TBdesc.Text
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.CurrentFlowsheet.FrmPCBulk.ShowDialog(Me)
End Sub
Public Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
CurrentFlowsheet.Options.SelectedUnitSystem = FormMain.AvailableUnitSystems.Item(ComboBox2.SelectedItem.ToString)
Dim su As SystemsOfUnits.Units = CurrentFlowsheet.Options.SelectedUnitSystem
With Me.DataGridView1.Rows
.Clear()
.Add(New String() {DWSIM.App.GetLocalString("Temperatura"), su.temperature, DWSIM.App.GetLocalString("Presso"), su.pressure})
.Add(New String() {DWSIM.App.GetLocalString("Vazomssica"), su.massflow, DWSIM.App.GetLocalString("Vazomolar"), su.molarflow})
.Add(New String() {DWSIM.App.GetLocalString("Vazovolumtrica"), su.volumetricFlow, DWSIM.App.GetLocalString("EntalpiaEspecfica"), su.enthalpy})
.Add(New String() {DWSIM.App.GetLocalString("EntropiaEspecfica"), su.entropy, DWSIM.App.GetLocalString("Massamolar"), su.molecularWeight})
.Add(New String() {DWSIM.App.GetLocalString("Massaespecfica"), su.density, DWSIM.App.GetLocalString("Tensosuperficial"), su.surfaceTension})
.Add(New String() {DWSIM.App.GetLocalString("CapacidadeCalorfica"), su.heatCapacityCp, DWSIM.App.GetLocalString("Condutividadetrmica"), su.thermalConductivity})
.Add(New String() {DWSIM.App.GetLocalString("Viscosidadecinemtica"), su.cinematic_viscosity, DWSIM.App.GetLocalString("Viscosidadedinmica"), su.viscosity})
.Add(New String() {DWSIM.App.GetLocalString("DeltaT2"), su.deltaT, DWSIM.App.GetLocalString("DeltaP"), su.deltaP})
.Add(New String() {DWSIM.App.GetLocalString("ComprimentoHead"), su.head, DWSIM.App.GetLocalString("FluxodeEnergyFlow"), su.heatflow})
.Add(New String() {DWSIM.App.GetLocalString("Tempo"), su.time, DWSIM.App.GetLocalString("Volume"), su.volume})
.Add(New String() {DWSIM.App.GetLocalString("VolumeMolar"), su.molar_volume, DWSIM.App.GetLocalString("rea"), su.area})
.Add(New String() {DWSIM.App.GetLocalString("DimetroEspessura"), su.diameter, DWSIM.App.GetLocalString("Fora"), su.force})
.Add(New String() {DWSIM.App.GetLocalString("Aceleracao"), su.accel, DWSIM.App.GetLocalString("CoefdeTransfdeCalor"), su.heat_transf_coeff})
.Add(New String() {DWSIM.App.GetLocalString("ConcMolar"), su.molar_conc, DWSIM.App.GetLocalString("ConcMssica"), su.mass_conc})
.Add(New String() {DWSIM.App.GetLocalString("TaxadeReao"), su.reac_rate, DWSIM.App.GetLocalString("VolEspecfico"), su.spec_vol})
.Add(New String() {DWSIM.App.GetLocalString("MolarEnthalpy"), su.molar_enthalpy, DWSIM.App.GetLocalString("MolarEntropy"), su.molar_entropy})
.Add(New String() {DWSIM.App.GetLocalString("Velocity"), su.velocity, DWSIM.App.GetLocalString("HXFoulingFactor"), su.foulingfactor})
.Add(New String() {DWSIM.App.GetLocalString("FilterSpecificCakeResistance"), su.cakeresistance, DWSIM.App.GetLocalString("FilterMediumResistance"), su.mediumresistance})
.Add(New String() {DWSIM.App.GetLocalString("IsothermalCompressibility"), su.compressibility, DWSIM.App.GetLocalString("JouleThomsonCoefficient"), su.jouleThomsonCoefficient})
.Add(New String() {DWSIM.App.GetLocalString("Conductance"), su.conductance, DWSIM.App.GetLocalString("DistComp"), su.distance})
.Add(New String() {DWSIM.App.GetLocalString("Heat/Energy"), su.heat, DWSIM.App.GetLocalString("Mass"), su.mass})
.Add(New String() {DWSIM.App.GetLocalString("Moles"), su.mole, Nothing, Nothing})
End With
If ComboBox2.SelectedIndex <= 3 Then
Me.DataGridView1.Columns(1).ReadOnly = True
Me.DataGridView1.Columns(3).ReadOnly = True
Else
Me.DataGridView1.Columns(1).ReadOnly = False
Me.DataGridView1.Columns(3).ReadOnly = False
End If
'.Add(New Object() {DWSIM.App.GetLocalString("Temperatura")})
With DirectCast(Me.DataGridView1.Rows.Item(0).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.temperature).ToArray())
.Style.Tag = 1
.Value = su.temperature
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Presso")})
With DirectCast(Me.DataGridView1.Rows.Item(0).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.pressure).ToArray())
.Style.Tag = 2
.Value = su.pressure
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Vazomssica")})
With DirectCast(Me.DataGridView1.Rows.Item(1).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.massflow).ToArray())
.Style.Tag = 3
.Value = su.massflow
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Vazomolar")})
With DirectCast(Me.DataGridView1.Rows.Item(1).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.molarflow).ToArray())
.Value = su.molarflow
.Style.Tag = 4
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Vazovolumtrica")})
With DirectCast(Me.DataGridView1.Rows.Item(2).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.volumetricFlow).ToArray())
.Value = su.volumetricFlow
.Style.Tag = 5
End With
'.Add(New Object() {DWSIM.App.GetLocalString("EntalpiaEspecfica")})
With DirectCast(Me.DataGridView1.Rows.Item(2).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.enthalpy).ToArray())
.Value = su.enthalpy
.Style.Tag = 6
End With
'.Add(New Object() {DWSIM.App.GetLocalString("EntropiaEspecfica")})
With DirectCast(Me.DataGridView1.Rows.Item(3).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.entropy).ToArray())
.Value = su.entropy
.Style.Tag = 7
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Massamolar")})
With DirectCast(Me.DataGridView1.Rows.Item(3).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.molecularWeight).ToArray())
.Value = su.molecularWeight
.Style.Tag = 8
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Massaespecfica")})
With DirectCast(Me.DataGridView1.Rows.Item(4).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.density).ToArray())
.Value = su.density
.Style.Tag = 10
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Tensosuperficial")})
With DirectCast(Me.DataGridView1.Rows.Item(4).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.surfaceTension).ToArray())
.Value = su.surfaceTension
.Style.Tag = 9
End With
'.Add(New Object() {DWSIM.App.GetLocalString("CapacidadeCalorfica")})
With DirectCast(Me.DataGridView1.Rows.Item(5).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.heatCapacityCp).ToArray())
.Value = su.heatCapacityCp
.Style.Tag = 11
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Condutividadetrmica")})
With DirectCast(Me.DataGridView1.Rows.Item(5).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.thermalConductivity).ToArray())
.Value = su.thermalConductivity
.Style.Tag = 12
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Viscosidadecinemtica")})
With DirectCast(Me.DataGridView1.Rows.Item(6).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.cinematic_viscosity).ToArray())
.Value = su.cinematic_viscosity
.Style.Tag = 13
End With
'.Add(New Object() {DWSIM.App.GetLocalString("ViscosidadeDinmica1")})
With DirectCast(Me.DataGridView1.Rows.Item(6).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.viscosity).ToArray())
.Value = su.viscosity
.Style.Tag = 14
End With
'.Add(New Object() {DWSIM.App.GetLocalString("DeltaP")})
With DirectCast(Me.DataGridView1.Rows.Item(7).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.deltaP).ToArray())
.Value = su.deltaP
.Style.Tag = 15
End With
'.Add(New Object() {DWSIM.App.GetLocalString("DeltaT2")})
With DirectCast(Me.DataGridView1.Rows.Item(7).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.deltaT).ToArray())
.Value = su.deltaT
.Style.Tag = 16
End With
'.Add(New Object() {DWSIM.App.GetLocalString("ComprimentoHead")})
With DirectCast(Me.DataGridView1.Rows.Item(8).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.head).ToArray())
.Value = su.head
.Style.Tag = 17
End With
'.Add(New Object() {DWSIM.App.GetLocalString("FluxodeEnergyFlow")})
With DirectCast(Me.DataGridView1.Rows.Item(8).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.heatflow).ToArray())
.Value = su.heatflow
.Style.Tag = 18
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Tempo")})
With DirectCast(Me.DataGridView1.Rows.Item(9).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.time).ToArray())
.Value = su.time
.Style.Tag = 19
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Volume")})
With DirectCast(Me.DataGridView1.Rows.Item(9).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.volume).ToArray())
.Value = su.volume
.Style.Tag = 20
End With
'.Add(New Object() {DWSIM.App.GetLocalString("VolumeMolar")})
With DirectCast(Me.DataGridView1.Rows.Item(10).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.molar_volume).ToArray())
.Value = su.molar_volume
.Style.Tag = 21
End With
'.Add(New Object() {DWSIM.App.GetLocalString("rea")})
With DirectCast(Me.DataGridView1.Rows.Item(10).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.area).ToArray())
.Value = su.area
.Style.Tag = 22
End With
'.Add(New Object() {DWSIM.App.GetLocalString("DimetroEspessura")})
With DirectCast(Me.DataGridView1.Rows.Item(11).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.diameter).ToArray())
.Value = su.diameter
.Style.Tag = 23
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Fora")})
With DirectCast(Me.DataGridView1.Rows.Item(11).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.force).ToArray())
.Value = su.force
.Style.Tag = 24
End With
'.Add(New Object() {DWSIM.App.GetLocalString("CoefdeTransfdeCalor")})
With DirectCast(Me.DataGridView1.Rows.Item(12).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.heat_transf_coeff).ToArray())
.Value = su.heat_transf_coeff
.Style.Tag = 25
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Aceleracao")})
With DirectCast(Me.DataGridView1.Rows.Item(12).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.accel).ToArray())
.Value = su.accel
.Style.Tag = 26
End With
'.Add(New Object() {DWSIM.App.GetLocalString("ConcentraoMolar")})
With DirectCast(Me.DataGridView1.Rows.Item(13).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.molar_conc).ToArray())
.Value = su.molar_conc
.Style.Tag = 28
End With
'.Add(New Object() {DWSIM.App.GetLocalString("ConcentraoMssica")})
With DirectCast(Me.DataGridView1.Rows.Item(13).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.mass_conc).ToArray())
.Value = su.mass_conc
.Style.Tag = 29
End With
'.Add(New Object() {DWSIM.App.GetLocalString("TaxadeReao")})
With DirectCast(Me.DataGridView1.Rows.Item(14).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.reac_rate).ToArray())
.Value = su.reac_rate
.Style.Tag = 30
End With
'.Add(New Object() {DWSIM.App.GetLocalString("VolumeEspecfico")})
With DirectCast(Me.DataGridView1.Rows.Item(14).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.spec_vol).ToArray())
.Value = su.spec_vol
.Style.Tag = 27
End With
'.Add(New Object() {DWSIM.App.GetLocalString("MolarEnthalpy")})
With DirectCast(Me.DataGridView1.Rows.Item(15).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.molar_enthalpy).ToArray())
.Value = su.molar_enthalpy
.Style.Tag = 31
End With
'.Add(New Object() {DWSIM.App.GetLocalString("MolarEntropy")})
With DirectCast(Me.DataGridView1.Rows.Item(15).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.molar_entropy).ToArray())
.Value = su.molar_entropy
.Style.Tag = 32
End With
'.Add(New Object() {DWSIM.App.GetLocalString("Velocity")})
With DirectCast(Me.DataGridView1.Rows.Item(16).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.velocity).ToArray())
.Value = su.velocity
.Style.Tag = 33
End With
'.Add(New Object() {DWSIM.App.GetLocalString("HXFoulingFactor")})
With DirectCast(Me.DataGridView1.Rows.Item(16).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.foulingfactor).ToArray())
.Value = su.foulingfactor
.Style.Tag = 34
End With
'.Add(New Object() {DWSIM.App.GetLocalString("FilterSpecificCakeResistance")})
With DirectCast(Me.DataGridView1.Rows.Item(17).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.cakeresistance).ToArray())
.Value = su.cakeresistance
.Style.Tag = 35
End With
'.Add(New Object() {DWSIM.App.GetLocalString("FilterMediumResistance")})
With DirectCast(Me.DataGridView1.Rows.Item(17).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.mediumresistance).ToArray())
.Value = su.mediumresistance
.Style.Tag = 36
End With
With DirectCast(Me.DataGridView1.Rows.Item(18).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.compressibility).ToArray())
.Value = su.compressibility
.Style.Tag = 37
End With
With DirectCast(Me.DataGridView1.Rows.Item(18).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.jouleThomsonCoefficient).ToArray())
.Value = su.jouleThomsonCoefficient
.Style.Tag = 38
End With
With DirectCast(Me.DataGridView1.Rows.Item(19).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.conductance).ToArray)
.Value = su.conductance
.Style.Tag = 39
End With
With DirectCast(Me.DataGridView1.Rows.Item(19).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.distance).ToArray)
.Value = su.distance
.Style.Tag = 40
End With
With DirectCast(Me.DataGridView1.Rows.Item(20).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.heat).ToArray)
.Value = su.heat
.Style.Tag = 41
End With
With DirectCast(Me.DataGridView1.Rows.Item(20).Cells(3), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.mass).ToArray)
.Value = su.mass
.Style.Tag = 42
End With
With DirectCast(Me.DataGridView1.Rows.Item(21).Cells(1), DataGridViewComboBoxCell)
.Items.Clear()
.Items.AddRange(su.GetUnitSet(UnitOfMeasure.mole).ToArray)
.Value = su.mole
.Style.Tag = 43
End With
CurrentFlowsheet.UpdateOpenEditForms()
End Sub
Private Sub DataGridView1_CellValueChanged1(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
If loaded And e.RowIndex >= 0 Then
Dim cell As DataGridViewCell = Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex)
Dim oldvalue As String = ""
Dim member As String = ""
Dim su As SystemsOfUnits.Units = CurrentFlowsheet.Options.SelectedUnitSystem
Select Case cell.Style.Tag
Case 1
member = "spmp_temperature"
oldvalue = su.temperature
su.temperature = cell.Value
Case 2
member = "spmp_pressure"
oldvalue = su.pressure
su.pressure = cell.Value
Case 3
member = "spmp_massflow"
oldvalue = su.massflow
su.massflow = cell.Value
Case 4
member = "spmp_molarflow"
oldvalue = su.molarflow
su.molarflow = cell.Value
Case 5
member = "spmp_volumetricFlow"
oldvalue = su.volumetricFlow
su.volumetricFlow = cell.Value
Case 6
member = "spmp_enthalpy"
oldvalue = su.enthalpy
su.enthalpy = cell.Value
Case 7
member = "spmp_entropy"
oldvalue = su.entropy
su.entropy = cell.Value
Case 8
member = "spmp_molecularWeight"
oldvalue = su.molecularWeight
su.molecularWeight = cell.Value
Case 9
member = "tdp_surfaceTension"
oldvalue = su.surfaceTension
su.surfaceTension = cell.Value
Case 10
member = "spmp_density"
oldvalue = su.density
su.density = cell.Value
Case 11
member = "spmp_heatCapacityCp"
oldvalue = su.heatCapacityCp
su.heatCapacityCp = cell.Value
Case 12
member = "spmp_thermalConductivity"
oldvalue = su.thermalConductivity
su.thermalConductivity = cell.Value
Case 13
member = "spmp_cinematic_viscosity"
oldvalue = su.cinematic_viscosity
su.cinematic_viscosity = cell.Value
Case 14
member = "spmp_viscosity"
oldvalue = su.viscosity
su.viscosity = cell.Value
Case 15
member = "spmp_deltaP"
oldvalue = su.deltaP
su.deltaP = cell.Value
Case 16
member = "spmp_deltaT"
oldvalue = su.deltaT
su.deltaT = cell.Value
Case 17
member = "spmp_head"
oldvalue = su.head
su.head = cell.Value
Case 18
member = "spmp_heatflow"
oldvalue = su.heatflow
su.heatflow = cell.Value
Case 19
member = "time"
oldvalue = su.time
su.time = cell.Value
Case 20
member = "volume"
oldvalue = su.volume
su.volume = cell.Value
Case 21
member = "molar_volume"
oldvalue = su.molar_volume
su.molar_volume = cell.Value
Case 22
member = "area"
oldvalue = su.area
su.area = cell.Value
Case 23
member = "diameter"
oldvalue = su.diameter
su.diameter = cell.Value
Case 24
member = "force"
oldvalue = su.force
su.force = cell.Value
Case 25
member = "heat_transf_coeff"
oldvalue = su.heat_transf_coeff
su.heat_transf_coeff = cell.Value
Case 26
member = "accel"
oldvalue = su.accel
su.accel = cell.Value
Case 27
member = "spec_vol"
oldvalue = su.spec_vol
su.spec_vol = cell.Value
Case 28
member = "molar_conc"
oldvalue = su.molar_conc
su.molar_conc = cell.Value
Case 29
member = "mass_conc"
oldvalue = su.mass_conc
su.mass_conc = cell.Value
Case 30
member = "reac_rate"
oldvalue = su.reac_rate
su.reac_rate = cell.Value
Case 31
member = "molar_enthalpy"
oldvalue = su.molar_enthalpy
su.molar_enthalpy = cell.Value
Case 32
member = "molar_entropy"
oldvalue = su.molar_entropy
su.molar_entropy = cell.Value
Case 33
member = "velocity"
oldvalue = su.velocity
su.velocity = cell.Value
Case 34
member = "foulingfactor"
oldvalue = su.foulingfactor
su.foulingfactor = cell.Value
Case 35
member = "cakeresistance"
oldvalue = su.cakeresistance
su.cakeresistance = cell.Value
Case 36
member = "mediumresistance"
oldvalue = su.mediumresistance
su.mediumresistance = cell.Value
Case 37
member = "compressibility"
oldvalue = su.compressibility
su.compressibility = cell.Value
Case 38
member = "jouleThomsonCoefficient"
oldvalue = su.jouleThomsonCoefficient
su.jouleThomsonCoefficient = cell.Value
Case 39
member = "conductance"
oldvalue = su.conductance
su.conductance = cell.Value
Case 40
member = "distance"
oldvalue = su.distance
su.distance = cell.Value
Case 41
member = "heat"
oldvalue = su.heat
su.heat = cell.Value
Case 42
oldvalue = su.mass
su.mass = cell.Value
Case 43
oldvalue = su.mole
su.mole = cell.Value
End Select
Me.CurrentFlowsheet.FormSurface.UpdateSelectedObject()
CurrentFlowsheet.UpdateOpenEditForms()
End If
End Sub
Private Sub KryptonButton15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton15.Click
Dim frmUnit As New FormUnitGen
frmUnit.ShowDialog(Me)
End Sub
Private Sub KryptonButton18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton18.Click
If Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("SistemaSI") And
Me.ComboBox2.SelectedItem <> "SI (Engineering)" And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("SistemaCGS") And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("SistemaIngls") And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("Personalizado1BR") And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("Personalizado2SC") And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("Personalizado3CNTP") Then
Dim str = Me.ComboBox2.SelectedItem
CurrentFlowsheet.AddUndoRedoAction(New UndoRedoAction() With {.AType = UndoRedoActionType.SystemOfUnitsRemoved,
.NewValue = FormMain.AvailableUnitSystems(str),
.Name = String.Format(DWSIM.App.GetLocalString("UndoRedo_SystemOfUnitsRemoved"), FormMain.AvailableUnitSystems(str).Name)})
My.Application.UserUnitSystems.Remove(str)
FormMain.AvailableUnitSystems.Remove(Me.ComboBox2.SelectedItem)
Me.ComboBox2.SelectedIndex = 0
Me.ComboBox2.Items.Remove(str)
Else
MessageBox.Show(DWSIM.App.GetLocalString("EsteSistemadeUnidade"))
End If
End Sub
Private Sub KryptonButton23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton23.Click
If Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("SistemaSI") And
Me.ComboBox2.SelectedItem <> "SI (Engineering)" And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("SistemaCGS") And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("SistemaIngls") And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("Personalizado1BR") And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("Personalizado2SC") And
Me.ComboBox2.SelectedItem <> DWSIM.App.GetLocalString("Personalizado3CNTP") Then
Dim filePickerForm As IFilePicker = FilePickerService.GetInstance().GetFilePicker()
Dim handler As IVirtualFile = filePickerForm.ShowSaveDialog(
New List(Of FilePickerAllowedType) From {New FilePickerAllowedType("DWSIM System of Units File", "*.dwund")})
If handler IsNot Nothing Then
Using stream As New IO.MemoryStream()
Dim su As SystemsOfUnits.Units = CurrentFlowsheet.Options.SelectedUnitSystem
Dim mySerializer As Binary.BinaryFormatter = New Binary.BinaryFormatter(Nothing, New System.Runtime.Serialization.StreamingContext())
Try
mySerializer.Serialize(stream, su)
handler.Write(stream)
Catch ex As System.Runtime.Serialization.SerializationException
MessageBox.Show(ex.Message, DWSIM.App.GetLocalString("Erro"), MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try