forked from EVEIPH/EVE-IPH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmIndustryBeltFlip.vb
1245 lines (1034 loc) · 49.8 KB
/
frmIndustryBeltFlip.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
Imports System.Data.SQLite
Public Class frmIndustryBeltFlip
Private Ore1ColumnClicked As Integer
Private Ore1ColumnSortOrder As SortOrder
Private Mineral1ColumnClicked As Integer
Private Mineral1ColumnSortOrder As SortOrder
Private Ore2ColumnClicked As Integer
Private Ore2ColumnSortOrder As SortOrder
Private Mineral2ColumnClicked As Integer
Private Mineral2ColumnSortOrder As SortOrder
Private Ore3ColumnClicked As Integer
Private Ore3ColumnSortOrder As SortOrder
Private Mineral3ColumnClicked As Integer
Private Mineral3ColumnSortOrder As SortOrder
Private Ore4ColumnClicked As Integer
Private Ore4ColumnSortOrder As SortOrder
Private Mineral4ColumnClicked As Integer
Private Mineral4ColumnSortOrder As SortOrder
Private Ore5ColumnClicked As Integer
Private Ore5ColumnSortOrder As SortOrder
Private Mineral5ColumnClicked As Integer
Private Mineral5ColumnSortOrder As SortOrder
Private FirstLoad As Boolean
Public Sub New()
FirstLoad = True
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Call LoadSettings()
Ore1ColumnClicked = 0
Ore1ColumnSortOrder = SortOrder.None
Mineral1ColumnClicked = 0
Mineral1ColumnSortOrder = SortOrder.None
Ore2ColumnClicked = 0
Ore2ColumnSortOrder = SortOrder.None
Mineral2ColumnClicked = 0
Mineral2ColumnSortOrder = SortOrder.None
Ore3ColumnClicked = 0
Ore3ColumnSortOrder = SortOrder.None
Mineral3ColumnClicked = 0
Mineral3ColumnSortOrder = SortOrder.None
Ore4ColumnClicked = 0
Ore4ColumnSortOrder = SortOrder.None
Mineral4ColumnClicked = 0
Mineral4ColumnSortOrder = SortOrder.None
Ore5ColumnClicked = 0
Ore5ColumnSortOrder = SortOrder.None
Mineral5ColumnClicked = 0
Mineral5ColumnSortOrder = SortOrder.None
End Sub
Private Sub frmIndustryBeltFlip_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown
Me.Cursor = Cursors.WaitCursor
Call LoadAllTables()
Me.Cursor = Cursors.Default
FirstLoad = False
End Sub
Private Sub LoadSettings()
' Station refinery settings
cmbMineStationEff.Text = FormatPercent(UserIndustryFlipBeltSettings.RefiningEfficiency, 0)
txtMineRefineStanding.Text = FormatNumber(UserIndustryFlipBeltSettings.RefineCorpStanding, 2)
cmbRefineStationTax.Text = FormatPercent(UserIndustryFlipBeltSettings.RefiningTax, 1)
' Miner settings
txtCycleTime.Text = FormatNumber(UserIndustryFlipBeltSettings.CycleTime)
txtm3perCycle.Text = FormatNumber(UserIndustryFlipBeltSettings.m3perCycle)
cmbNumMiners.Text = CStr(UserIndustryFlipBeltSettings.NumMiners)
chkCompressOre.Checked = UserIndustryFlipBeltSettings.CompressOre
chkIPHperMiner.Checked = UserIndustryFlipBeltSettings.IPHperMiner
If UserIndustryFlipBeltSettings.TrueSec = "" Or UserIndustryFlipBeltSettings.TrueSec = rbtn0percent.Text Then
rbtn0percent.Checked = True
ElseIf UserIndustryFlipBeltSettings.TrueSec = rbtn5percent.Text Then
rbtn5percent.Checked = True
ElseIf UserIndustryFlipBeltSettings.TrueSec = rbtn10percent.Text Then
rbtn10percent.Checked = True
End If
'm3/hr/miner = m3 per cycle / cycletime * 3600
lblm3perhrperminer.Text = FormatNumber(CDbl(txtm3perCycle.Text) / CDbl(txtCycleTime.Text) * 3600, 2)
' Tax settings
chkMineIncludeBrokerFees.Checked = UserIndustryFlipBeltSettings.IncludeBrokerFees
chkMineIncludeTaxes.Checked = UserIndustryFlipBeltSettings.IncludeTaxes
If UserApplicationSettings.ShowToolTips Then
ttMain.SetToolTip(rbtn0percent, "No Bonus for Enormous or Colossal Belts")
ttMain.SetToolTip(rbtn5percent, "5% Ore Variants in Enormous or Colossal Belts")
ttMain.SetToolTip(rbtn10percent, "10% Ore Variants in Enormous or Colossal Belts")
End If
End Sub
Private Function CheckEnteredData() As Boolean
If Trim(cmbNumMiners.Text) <> "" Then
If Not IsNumeric(cmbNumMiners.Text) Then
MsgBox("Invalid Number of Miners value", vbExclamation, Application.ProductName)
cmbNumMiners.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
Else
MsgBox("Please enter a Number of Miners value", vbExclamation, Application.ProductName)
cmbNumMiners.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
If CInt(cmbNumMiners.Text) > 101 Then
MsgBox("Maximum miners is 100", vbExclamation, Application.ProductName)
cmbNumMiners.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
If CInt(cmbNumMiners.Text) <= 0 Then
MsgBox("Number of miners must be greater than 0", vbExclamation, Application.ProductName)
cmbNumMiners.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
If Trim(txtCycleTime.Text) <> "" Then
If Not IsNumeric(txtCycleTime.Text) Then
MsgBox("Invalid Cycle Time value", vbExclamation, Application.ProductName)
txtCycleTime.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
Else
MsgBox("Please enter a Cycle Time value", vbExclamation, Application.ProductName)
cmbNumMiners.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
If CDbl(txtCycleTime.Text) <= 0 Then
MsgBox("Cycle time must be greater than 0", vbExclamation, Application.ProductName)
txtm3perCycle.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
If Trim(txtm3perCycle.Text) <> "" Then
If Not IsNumeric(txtm3perCycle.Text) Then
MsgBox("Invalid m3 per Cycle value", vbExclamation, Application.ProductName)
txtm3perCycle.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
Else
MsgBox("Please enter a m3 per Cycle value", vbExclamation, Application.ProductName)
cmbNumMiners.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
If CDbl(txtm3perCycle.Text) <= 0 Then
MsgBox("m3 per Cycle value must be greater than 0", vbExclamation, Application.ProductName)
txtm3perCycle.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
' Check the refine values
If Trim(txtMineRefineStanding.Text) <> "" Then
If CDbl(txtMineRefineStanding.Text) > 10 Then
MsgBox("Please set a smaller station standing value", vbExclamation, Application.ProductName)
txtMineRefineStanding.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
Else
MsgBox("Please enter a Refine Standing value", vbExclamation, Application.ProductName)
cmbNumMiners.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
If Trim(cmbRefineStationTax.Text) = "" Then
MsgBox("Please enter a Refine Station Tax value", vbExclamation, Application.ProductName)
cmbNumMiners.Focus()
tabIndustryBelts.SelectedTab = tabSummary
Return False
End If
Return True
End Function
Private Sub btnSaveSettings_Click(sender As System.Object, e As System.EventArgs) Handles btnSaveSettings.Click
Dim TempSettings As IndustryFlipBeltSettings = Nothing
Dim Settings As New ProgramSettings
Dim TempDouble As Double
If Not CheckEnteredData() Then
Exit Sub
End If
' Refining
' Station numbers
TempDouble = CDbl(cmbMineStationEff.Text.Replace("%", ""))
If TempDouble <= 0 Then
TempSettings.RefiningEfficiency = 0
Else
TempSettings.RefiningEfficiency = TempDouble / 100
End If
TempDouble = CDbl(cmbRefineStationTax.Text.Replace("%", ""))
If TempDouble <= 0 Then
TempSettings.RefiningTax = 0
Else
TempSettings.RefiningTax = TempDouble / 100
End If
' Allow them to update the refine standing here as well
TempSettings.RefineCorpStanding = CDbl(txtMineRefineStanding.Text)
TempSettings.CompressOre = chkCompressOre.Checked
TempSettings.IPHperMiner = chkIPHperMiner.Checked
TempSettings.CycleTime = CDbl(txtCycleTime.Text)
TempSettings.m3perCycle = CDbl(txtm3perCycle.Text)
TempSettings.NumMiners = CInt(cmbNumMiners.Text)
TempSettings.IncludeBrokerFees = chkMineIncludeBrokerFees.Checked
TempSettings.IncludeTaxes = chkMineIncludeTaxes.Checked
If rbtn0percent.Checked Then
TempSettings.TrueSec = rbtn0percent.Text
ElseIf rbtn5percent.Checked Then
TempSettings.TrueSec = rbtn5percent.Text
ElseIf rbtn10percent.Checked Then
TempSettings.TrueSec = rbtn10percent.Text
End If
' Save it in the Application settings
Call Settings.SaveApplicationSettings(UserApplicationSettings)
' Save the data in the XML file
Call Settings.SaveIndustryFlipBeltSettings(TempSettings)
' Save the data to the local variable
UserIndustryFlipBeltSettings = TempSettings
' Refresh tables
Call LoadAllTables()
MsgBox("Settings Saved", vbInformation, Application.ProductName)
End Sub
Private Sub btnRefresh_Click(sender As System.Object, e As System.EventArgs) Handles btnRefresh.Click
Call LoadAllTables()
End Sub
Private Sub LoadAllTables()
FirstLoad = True
Me.Cursor = Cursors.WaitCursor
Application.DoEvents()
If Not CheckEnteredData() Then
FirstLoad = False
Me.Cursor = Cursors.Default
Application.DoEvents()
Exit Sub
End If
' Calc the m3 per hr per miner first
' m3/hr/miner = m3 per cycle / cycletime * 3600
lblm3perhrperminer.Text = FormatNumber(CDbl(txtm3perCycle.Text) / CDbl(txtCycleTime.Text) * 3600, 2)
' Small
Call LoadBeltTable(BeltType.Small)
Call DisplayBeltMinerals(BeltType.Small)
' Moderate
Call LoadBeltTable(BeltType.Medium)
Call DisplayBeltMinerals(BeltType.Medium)
' Large
Call LoadBeltTable(BeltType.Large)
Call DisplayBeltMinerals(BeltType.Large)
' Extra Large
Call LoadBeltTable(BeltType.Enormous)
Call DisplayBeltMinerals(BeltType.Enormous)
' Giant
Call LoadBeltTable(BeltType.Colossal)
Call DisplayBeltMinerals(BeltType.Colossal)
FirstLoad = False
Me.Cursor = Cursors.Default
Application.DoEvents()
End Sub
Private Sub LoadBeltTable(Belt As BeltType)
Dim SQL As String
Dim readerBelts As SQLiteDataReader
Dim lstOreRow As ListViewItem
Dim CurrentList As ListView = Nothing
If Not CheckEnteredData() Then
Me.Cursor = Cursors.Default
Application.DoEvents()
Exit Sub
End If
SQL = "SELECT ORE, AMOUNT, NUMBER_ASTEROIDS FROM INDUSTRY_UPGRADE_BELTS "
SQL = SQL & "WHERE ( BELT_NAME = "
Select Case Belt
Case BeltType.Small
SQL = SQL & "'Small' "
CurrentList = lstOresLevel1
Case BeltType.Medium
SQL = SQL & "'Medium' "
CurrentList = lstOresLevel2
Case BeltType.Large
SQL = SQL & "'Large' "
CurrentList = lstOresLevel3
Case BeltType.Enormous
SQL = SQL & "'Enormous' "
CurrentList = lstOresLevel4
Case BeltType.Colossal
SQL = SQL & "'Colossal' "
CurrentList = lstOresLevel5
End Select
SQL = SQL & ") "
' Select ore type based on truesec bonus
If rbtn0percent.Checked Or Belt = BeltType.Small Or Belt = BeltType.Medium Then ' Small and Medium belts are always base ores
SQL = SQL & "AND TRUESEC_BONUS = 0 "
ElseIf rbtn5percent.Checked Then
SQL = SQL & "AND TRUESEC_BONUS = 5 "
ElseIf rbtn10percent.Checked Then
SQL = SQL & "AND TRUESEC_BONUS = 10 "
End If
SQL = SQL & "ORDER BY ORE"
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
readerBelts = DBCommand.ExecuteReader
Call CurrentList.Items.Clear()
Call CurrentList.BeginUpdate()
While readerBelts.Read
lstOreRow = New ListViewItem("")
'The remaining columns are subitems
lstOreRow.SubItems.Add(readerBelts.GetString(0))
lstOreRow.SubItems.Add(CStr(readerBelts.GetInt32(2)))
lstOreRow.SubItems.Add(FormatNumber(readerBelts.GetInt32(1), 0))
' All records are initially checked
lstOreRow.Checked = GetOreCheckValue(readerBelts.GetString(0), Belt)
Call CurrentList.Items.Add(lstOreRow)
End While
Call CurrentList.EndUpdate()
End Sub
' Set ore checks by the type of belt sent and ore
Private Function GetOreCheckValue(ByVal OreName As String, Belt As BeltType) As Boolean
Dim Settings As IndustryBeltOreChecks
Dim ReturnValue As Boolean
Select Case Belt
Case BeltType.Small
Settings = UserIndustryFlipBeltOreCheckSettings1
Case BeltType.Medium
Settings = UserIndustryFlipBeltOreCheckSettings2
Case BeltType.Large
Settings = UserIndustryFlipBeltOreCheckSettings3
Case BeltType.Enormous
Settings = UserIndustryFlipBeltOreCheckSettings4
Case BeltType.Colossal
Settings = UserIndustryFlipBeltOreCheckSettings5
End Select
Select Case OreName
Case "Plagioclase"
ReturnValue = Settings.Plagioclase
Case "Spodumain"
ReturnValue = Settings.Spodumain
Case "Kernite"
ReturnValue = Settings.Kernite
Case "Hedbergite"
ReturnValue = Settings.Hedbergite
Case "Arkonor"
ReturnValue = Settings.Arkonor
Case "Bistot"
ReturnValue = Settings.Bistot
Case "Pyroxeres"
ReturnValue = Settings.Pyroxeres
Case "Crokite"
ReturnValue = Settings.Crokite
Case "Jaspet"
ReturnValue = Settings.Jaspet
Case "Omber"
ReturnValue = Settings.Omber
Case "Scordite"
ReturnValue = Settings.Scordite
Case "Gneiss"
ReturnValue = Settings.Gneiss
Case "Veldspar"
ReturnValue = Settings.Veldspar
Case "Hemorphite"
ReturnValue = Settings.Hemorphite
Case "Dark Ochre"
ReturnValue = Settings.DarkOchre
Case "Mercoxit"
ReturnValue = Settings.Mercoxit
Case "Crimson Arkonor"
ReturnValue = Settings.CrimsonArkonor
Case "Prime Arkonor"
ReturnValue = Settings.PrimeArkonor
Case "Triclinic Bistot"
ReturnValue = Settings.TriclinicBistot
Case "Monoclinic Bistot"
ReturnValue = Settings.MonoclinicBistot
Case "Sharp Crokite"
ReturnValue = Settings.SharpCrokite
Case "Crystalline Crokite"
ReturnValue = Settings.CrystallineCrokite
Case "Onyx Ochre"
ReturnValue = Settings.OnyxOchre
Case "Obsidian Ochre"
ReturnValue = Settings.ObsidianOchre
Case "Vitric Hedbergite"
ReturnValue = Settings.VitricHedbergite
Case "Glazed Hedbergite"
ReturnValue = Settings.GlazedHedbergite
Case "Vivid Hemorphite"
ReturnValue = Settings.VividHemorphite
Case "Radiant Hemorphite"
ReturnValue = Settings.RadiantHemorphite
Case "Pure Jaspet"
ReturnValue = Settings.PureJaspet
Case "Pristine Jaspet"
ReturnValue = Settings.PristineJaspet
Case "Luminous Kernite"
ReturnValue = Settings.LuminousKernite
Case "Fiery Kernite"
ReturnValue = Settings.FieryKernite
Case "Azure Plagioclase"
ReturnValue = Settings.AzurePlagioclase
Case "Rich Plagioclase"
ReturnValue = Settings.RichPlagioclase
Case "Solid Pyroxeres"
ReturnValue = Settings.SolidPyroxeres
Case "Viscous Pyroxeres"
ReturnValue = Settings.ViscousPyroxeres
Case "Condensed Scordite"
ReturnValue = Settings.CondensedScordite
Case "Massive Scordite"
ReturnValue = Settings.MassiveScordite
Case "Bright Spodumain"
ReturnValue = Settings.BrightSpodumain
Case "Gleaming Spodumain"
ReturnValue = Settings.GleamingSpodumain
Case "Concentrated Veldspar"
ReturnValue = Settings.ConcentratedVeldspar
Case "Dense Veldspar"
ReturnValue = Settings.DenseVeldspar
Case "Iridescent Gneiss"
ReturnValue = Settings.IridescentGneiss
Case "Prismatic Gneiss"
ReturnValue = Settings.PrismaticGneiss
Case "Silvery Omber"
ReturnValue = Settings.SilveryOmber
Case "Golden Omber"
ReturnValue = Settings.GoldenOmber
Case "Magma Mercoxit"
ReturnValue = Settings.MagmaMercoxit
Case "Vitreous Mercoxit"
ReturnValue = Settings.VitreousMercoxit
End Select
Return ReturnValue
End Function
' Refines the belt sent and loads the appropriate table
Private Sub DisplayBeltMinerals(Belt As BeltType)
Dim SQL As String = ""
Dim readerBelts As SQLiteDataReader
Dim lstOreRow As ListViewItem = Nothing
Dim CurrentOreList As ListView = Nothing
Dim CurrentMineralList As ListView = Nothing
Dim TotalIskLabelForm As Label = Nothing
Dim HrsToFlipForm As Label = Nothing
Dim IPHForm As Label = Nothing
Dim TotalVolumeForm As Label = Nothing
Dim TotalIskLabelSum As Label = Nothing
Dim HrsToFlipSum As Label = Nothing
Dim IPHSum As Label = Nothing
Dim TotalVolumeSum As Label = Nothing
Dim item As ListViewItem
Dim checkedItems As ListView.CheckedListViewItemCollection
Dim TotalRefinedMinerals As New Materials
Dim TotalCost As Double = 0
Dim OutputNumber As Double
Dim OreName As String
Dim BeltVolume As Double
Dim CompressedVolume As Double
Dim TimeToFlip As Double
Dim TimeToFlipPer As Double
' Refining
Dim StationEffiency As Double
Dim StationTax As Double
Dim TempDouble = CDbl(cmbMineStationEff.Text.Replace("%", ""))
If TempDouble <= 0 Then
StationEffiency = 0
Else
StationEffiency = TempDouble / 100
End If
TempDouble = CDbl(cmbRefineStationTax.Text.Replace("%", ""))
If TempDouble <= 0 Then
StationTax = 0
Else
StationTax = TempDouble / 100
End If
Dim RefinedMaterials As New Materials
Dim RefiningStation As New RefiningReprocessing(SelectedCharacter.Skills.GetSkillLevel(3385), _
SelectedCharacter.Skills.GetSkillLevel(3389), _
SelectedCharacter.Skills.GetSkillLevel(12196), _
UserApplicationSettings.RefiningImplantValue, _
StationEffiency, StationTax, CDbl(txtMineRefineStanding.Text))
Me.Cursor = Cursors.WaitCursor
Application.DoEvents()
If Not CheckEnteredData() Then
Me.Cursor = Cursors.Default
Application.DoEvents()
Exit Sub
End If
Select Case Belt
Case BeltType.Small
SQL = SQL & "'Small' "
CurrentOreList = lstOresLevel1
CurrentMineralList = lstMineralsLevel1
TotalIskLabelForm = lblTotalIskLevel1
HrsToFlipForm = lblTotalHourstoFlip1
IPHForm = lblIPH1
TotalVolumeForm = lblTotalBeltVolume1
TotalIskLabelSum = lblTotalIskLevel1Sum
HrsToFlipSum = lblTotalHourstoFlip1Sum
IPHSum = lblTotalIPH1Sum
TotalVolumeSum = lblTotalBeltVolume1Sum
Case BeltType.Medium
SQL = SQL & "'Medium' "
CurrentOreList = lstOresLevel2
CurrentMineralList = lstMineralsLevel2
TotalIskLabelForm = lblTotalIskLevel2
HrsToFlipForm = lblTotalHourstoFlip2
IPHForm = lblIPH2
TotalVolumeForm = lblTotalBeltVolume2
TotalIskLabelSum = lblTotalIskLevel2Sum
HrsToFlipSum = lblTotalHourstoFlip2Sum
IPHSum = lblTotalIPH2Sum
TotalVolumeSum = lblTotalBeltVolume2Sum
Case BeltType.Large
SQL = SQL & "'Large' "
CurrentOreList = lstOresLevel3
CurrentMineralList = lstMineralsLevel3
TotalIskLabelForm = lblTotalIskLevel3
HrsToFlipForm = lblTotalHourstoFlip3
IPHForm = lblIPH3
TotalVolumeForm = lblTotalBeltVolume3
TotalIskLabelSum = lblTotalIskLevel3Sum
HrsToFlipSum = lblTotalHourstoFlip3Sum
IPHSum = lblTotalIPH3Sum
TotalVolumeSum = lblTotalBeltVolume3Sum
Case BeltType.Enormous
SQL = SQL & "'Extra Large' "
CurrentOreList = lstOresLevel4
CurrentMineralList = lstMineralsLevel4
TotalIskLabelForm = lblTotalIskLevel4
HrsToFlipForm = lblTotalHourstoFlip4
IPHForm = lblIPH4
TotalVolumeForm = lblTotalBeltVolume4
TotalIskLabelSum = lblTotalIskLevel4Sum
HrsToFlipSum = lblTotalHourstoFlip4Sum
IPHSum = lblTotalIPH4Sum
TotalVolumeSum = lblTotalBeltVolume4Sum
Case BeltType.Colossal
SQL = SQL & "'Giant' "
CurrentOreList = lstOresLevel5
CurrentMineralList = lstMineralsLevel5
TotalIskLabelForm = lblTotalIskLevel5
HrsToFlipForm = lblTotalHourstoFlip5
IPHForm = lblIPH5
TotalVolumeForm = lblTotalBeltVolume5
TotalIskLabelSum = lblTotalIskLevel5Sum
HrsToFlipSum = lblTotalHourstoFlip5Sum
IPHSum = lblTotalIPH5Sum
TotalVolumeSum = lblTotalBeltVolume5Sum
End Select
' Just work with the ones that are checked
checkedItems = CurrentOreList.CheckedItems
If checkedItems.Count > 0 Then
' Update each item based on inputs
For Each item In checkedItems
OreName = CType(item.SubItems(1).Text, String)
SQL = "SELECT typeID from INVENTORY_TYPES WHERE typeName = '" & OreName & "'"
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
readerBelts = DBCommand.ExecuteReader
If readerBelts.Read Then
' Refine each ore in the ore list, store refined minerals
RefinedMaterials = RefiningStation.RefineOre(readerBelts.GetInt64(0), SelectedCharacter.Skills.GetSkillLevel(OreName & " Processing"), _
CType(item.SubItems(3).Text, Double), chkMineIncludeTaxes.Checked, chkMineIncludeBrokerFees.Checked, OutputNumber)
' Store the refined materials
TotalRefinedMinerals.InsertMaterialList(RefinedMaterials.GetMaterialList)
If chkCompressOre.Checked = False Then
' Save the total cost separate so we take into account taxes and fees
TotalCost = TotalCost + RefinedMaterials.GetTotalMaterialsCost
Else
Dim readerOre As SQLiteDataReader
Dim OreUnitPrice As Double
Dim TotalCompressedUnits As Integer
' First, get the unit price and volume for the compressed ore
SQL = "SELECT PRICE FROM ITEM_PRICES WHERE ITEM_NAME LIKE 'Compressed " & OreName & "'"
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
readerOre = DBCommand.ExecuteReader
If readerOre.Read() Then
OreUnitPrice = readerOre.GetDouble(0)
TotalCompressedUnits = CInt(Math.Floor(CInt(item.SubItems(3).Text) / 100))
' Calc total cost, assume all mined and then compressed
TotalCost = TotalCost + (OreUnitPrice * TotalCompressedUnits)
End If
readerOre.Close()
End If
' Reset the value of the refined materials
TotalRefinedMinerals.ResetTotalValue(TotalCost)
End If
readerBelts.Close()
DBCommand = Nothing
Next
' Sort the list
Call TotalRefinedMinerals.SortMaterialListByQuantity()
Call CurrentMineralList.BeginUpdate()
Call CurrentMineralList.Items.Clear()
' Now that we've refined all the ores, put the minerals into minerals list
For i = 0 To TotalRefinedMinerals.GetMaterialList.Count - 1
lstOreRow = New ListViewItem(TotalRefinedMinerals.GetMaterialList(i).GetMaterialName)
'The remaining columns are subitems
lstOreRow.SubItems.Add(FormatNumber(TotalRefinedMinerals.GetMaterialList(i).GetQuantity, 0))
lstOreRow.SubItems.Add(FormatNumber(TotalRefinedMinerals.GetMaterialList(i).GetTotalCost, 2))
Call CurrentMineralList.Items.Add(lstOreRow)
Next
Call CurrentMineralList.EndUpdate()
TotalIskLabelForm.Text = FormatNumber(TotalRefinedMinerals.GetTotalMaterialsCost, 2) & " ISK"
TotalIskLabelSum.Text = FormatNumber(TotalRefinedMinerals.GetTotalMaterialsCost, 2) & " ISK"
CompressedVolume = GetTotalVolume(Belt, chkCompressOre.Checked)
BeltVolume = GetTotalVolume(Belt, False)
TotalVolumeSum.Text = FormatNumber(CompressedVolume, 2)
TotalVolumeForm.Text = FormatNumber(CompressedVolume, 2)
TimeToFlip = (BeltVolume / (CDbl(lblm3perhrperminer.Text) * CInt(cmbNumMiners.Text))) * 3600
TimeToFlipPer = (BeltVolume / CDbl(lblm3perhrperminer.Text)) * 3600
HrsToFlipForm.Text = FormatIPHTime(TimeToFlip)
HrsToFlipSum.Text = FormatIPHTime(TimeToFlip)
If chkIPHperMiner.Checked = True Then
IPHForm.Text = FormatNumber(TotalRefinedMinerals.GetTotalMaterialsCost / (TimeToFlipPer / 3600), 2)
IPHSum.Text = FormatNumber(TotalRefinedMinerals.GetTotalMaterialsCost / (TimeToFlipPer / 3600), 2)
Else
IPHForm.Text = FormatNumber(TotalRefinedMinerals.GetTotalMaterialsCost / (TimeToFlip / 3600), 2)
IPHSum.Text = FormatNumber(TotalRefinedMinerals.GetTotalMaterialsCost / (TimeToFlip / 3600), 2)
End If
Else
' Nothing checked so clear
CurrentMineralList.Items.Clear()
End If
Me.Cursor = Cursors.Default
Application.DoEvents()
End Sub
' Returns the total volume compressed or regular for the belt sent - DOESN'T WORK ANYMORE - TODO
Private Function GetTotalVolume(ByVal Belt As BeltType, ByVal Compress As Boolean) As Double
Dim SQL As String = ""
Dim readerBelts As SQLiteDataReader
Dim CurrentOreList As ListView = Nothing
Dim checkedItems As ListView.CheckedListViewItemCollection
Dim OreName As String
Dim OreUnits As Long
Dim OreVolume As Double
Dim TotalOreVolume As Double
Dim CompressedBlockVolume As Double
Dim CompressedBlocks As Long
Dim UnitsToCompress As Long
Dim item As ListViewItem
Select Case Belt
Case BeltType.Small
CurrentOreList = lstOresLevel1
Case BeltType.Medium
CurrentOreList = lstOresLevel2
Case BeltType.Large
CurrentOreList = lstOresLevel3
Case BeltType.Enormous
CurrentOreList = lstOresLevel4
Case BeltType.Colossal
CurrentOreList = lstOresLevel5
End Select
' Just work with the ones that are checked
checkedItems = CurrentOreList.CheckedItems
If checkedItems.Count > 0 Then
' For each row of ore, look up the volume and compressed volume. Then total volume + leftover amount
For Each item In checkedItems
OreName = CType(item.SubItems(1).Text, String)
OreUnits = CType(item.SubItems(3).Text, Integer)
SQL = "SELECT ORE_VOLUME "
SQL = SQL & "FROM ORES WHERE BELT_TYPE = 'Ore' "
If Compress Then
SQL = SQL & "AND ORE_NAME ='Compressed " & OreName & "'"
Else
SQL = SQL & "AND ORE_NAME = '" & OreName & "'"
End If
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
readerBelts = DBCommand.ExecuteReader
If readerBelts.Read Then
' Get all the base values
OreVolume = readerBelts.GetDouble(0)
UnitsToCompress = 100 ' Always 100 now
Else
Return 0
End If
readerBelts.Close()
If Compress Then
' Compressed ORE
CompressedBlocks = CLng(Math.Floor(OreUnits / UnitsToCompress))
CompressedBlockVolume = OreVolume
' Reset the total ore units so we can look up the rest
OreUnits = OreUnits - (UnitsToCompress * CompressedBlocks)
Else ' Only use the total ore volume
CompressedBlockVolume = 0
End If
TotalOreVolume = TotalOreVolume + (CompressedBlockVolume * CompressedBlocks) + (OreVolume * OreUnits)
Next
End If
Return TotalOreVolume
End Function
Private Sub SaveSelectedOres(Belt As BeltType)
Dim TempSettings As IndustryBeltOreChecks = Nothing
Dim Settings As New ProgramSettings
Dim SavedSettings As New IndustryBeltOreChecks
Dim OreList As New ListView
Select Case Belt
Case BeltType.Small
OreList = lstOresLevel1
Case BeltType.Medium
OreList = lstOresLevel2
Case BeltType.Large
OreList = lstOresLevel3
Case BeltType.Enormous
OreList = lstOresLevel4
Case BeltType.Colossal
OreList = lstOresLevel5
End Select
' Reset them all to default settings first if not found
TempSettings = AllSettings.SetDefaultIndustryBeltOreChecksSettings((Belt))
With TempSettings
' Loop through the ore list and save the value
For i = 0 To OreList.Items.Count - 1
Select Case OreList.Items(i).SubItems(1).Text
Case "Plagioclase"
.Plagioclase = OreList.Items(i).Checked
Case "Spodumain"
.Spodumain = OreList.Items(i).Checked
Case "Kernite"
.Kernite = OreList.Items(i).Checked
Case "Hedbergite"
.Hedbergite = OreList.Items(i).Checked
Case "Arkonor"
.Arkonor = OreList.Items(i).Checked
Case "Bistot"
.Bistot = OreList.Items(i).Checked
Case "Pyroxeres"
.Pyroxeres = OreList.Items(i).Checked
Case "Crokite"
.Crokite = OreList.Items(i).Checked
Case "Jaspet"
.Jaspet = OreList.Items(i).Checked
Case "Omber"
.Omber = OreList.Items(i).Checked
Case "Scordite"
.Scordite = OreList.Items(i).Checked
Case "Gneiss"
.Gneiss = OreList.Items(i).Checked
Case "Veldspar"
.Veldspar = OreList.Items(i).Checked
Case "Hemorphite"
.Hemorphite = OreList.Items(i).Checked
Case "Dark Ochre"
.DarkOchre = OreList.Items(i).Checked
Case "Mercoxit"
.Mercoxit = OreList.Items(i).Checked
Case "Crimson Arkonor"
.CrimsonArkonor = OreList.Items(i).Checked
Case "Prime Arkonor"
.PrimeArkonor = OreList.Items(i).Checked
Case "Triclinic Bistot"
.TriclinicBistot = OreList.Items(i).Checked
Case "Monoclinic Bistot"
.MonoclinicBistot = OreList.Items(i).Checked
Case "Sharp Crokite"
.SharpCrokite = OreList.Items(i).Checked
Case "Crystalline Crokite"
.CrystallineCrokite = OreList.Items(i).Checked
Case "Onyx Ochre"
.OnyxOchre = OreList.Items(i).Checked
Case "Obsidian Ochre"
.ObsidianOchre = OreList.Items(i).Checked
Case "Vitric Hedbergite"
.VitricHedbergite = OreList.Items(i).Checked
Case "Glazed Hedbergite"
.GlazedHedbergite = OreList.Items(i).Checked
Case "Vivid Hemorphite"
.VividHemorphite = OreList.Items(i).Checked
Case "Radiant Hemorphite"
.RadiantHemorphite = OreList.Items(i).Checked
Case "Pure Jaspet"
.PureJaspet = OreList.Items(i).Checked
Case "Pristine Jaspet"
.PristineJaspet = OreList.Items(i).Checked
Case "Luminous Kernite"
.LuminousKernite = OreList.Items(i).Checked
Case "Fiery Kernite"
.FieryKernite = OreList.Items(i).Checked
Case "Azure Plagioclase"
.AzurePlagioclase = OreList.Items(i).Checked
Case "Rich Plagioclase"
.RichPlagioclase = OreList.Items(i).Checked
Case "Solid Pyroxeres"
.SolidPyroxeres = OreList.Items(i).Checked
Case "Viscous Pyroxeres"
.ViscousPyroxeres = OreList.Items(i).Checked
Case "Condensed Scordite"
.CondensedScordite = OreList.Items(i).Checked
Case "Massive Scordite"
.MassiveScordite = OreList.Items(i).Checked
Case "Bright Spodumain"
.BrightSpodumain = OreList.Items(i).Checked
Case "Gleaming Spodumain"
.GleamingSpodumain = OreList.Items(i).Checked
Case "Concentrated Veldspar"
.ConcentratedVeldspar = OreList.Items(i).Checked
Case "Dense Veldspar"
.DenseVeldspar = OreList.Items(i).Checked
Case "Iridescent Gneiss"
.IridescentGneiss = OreList.Items(i).Checked
Case "Prismatic Gneiss"
.PrismaticGneiss = OreList.Items(i).Checked
Case "Silvery Omber"
.SilveryOmber = OreList.Items(i).Checked
Case "Golden Omber"
.GoldenOmber = OreList.Items(i).Checked
Case "Magma Mercoxit"
.MagmaMercoxit = OreList.Items(i).Checked
Case "Vitreous Mercoxit"
.VitreousMercoxit = OreList.Items(i).Checked
End Select
Next
End With
' Save the data in the XML file
Settings.SaveIndustryBeltOreChecksSettings(TempSettings, Belt)
' Save them locally
Select Case Belt
Case BeltType.Small
UserIndustryFlipBeltOreCheckSettings1 = TempSettings
Case BeltType.Medium
UserIndustryFlipBeltOreCheckSettings2 = TempSettings
Case BeltType.Large
UserIndustryFlipBeltOreCheckSettings3 = TempSettings
Case BeltType.Enormous
UserIndustryFlipBeltOreCheckSettings4 = TempSettings
Case BeltType.Colossal
UserIndustryFlipBeltOreCheckSettings5 = TempSettings
End Select
MsgBox("Settings Saved", vbInformation, Application.ProductName)
End Sub
#Region "Event Functions"
Private Sub cmbNumMiners_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles cmbNumMiners.KeyDown
If e.KeyCode = Keys.Enter Or e.KeyCode = Keys.Tab And Not FirstLoad Then
Call LoadAllTables()
End If
End Sub
Private Sub cmbNumMiners_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbNumMiners.SelectedIndexChanged
If Not FirstLoad Then
Call LoadAllTables()
End If
End Sub
Private Sub cmbNumMiners_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles cmbNumMiners.KeyPress
' Only allow numbers or backspace
If e.KeyChar <> ControlChars.Back Then
If allowedRunschars.IndexOf(e.KeyChar) = -1 Then
' Invalid Character
e.Handled = True
End If