-
Notifications
You must be signed in to change notification settings - Fork 37
/
Globals.vb
3054 lines (2443 loc) · 121 KB
/
Globals.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
Imports System.Globalization
Imports System.Net
Imports System.IO
Imports System.Security.Cryptography
' Place to store all public variables and functions
Public Module Public_Variables
' DB name and version
Public Const SDEVersion As String = "November 12, 2024 Release"
Public Const VersionNumber As String = "5.0.*"
Public TestingVersion As Boolean ' This flag will test the test downloads from the server for an update
Public Developer As Boolean ' This is if I'm developing something and only want me to see it instead of public release
Public LocalCulture As CultureInfo
Public EVEDB As DBConnection
Public DBCommand As SQLiteCommand
' For checking the DB to see if it's ok to write
Public DBLock As New Object
Public SelectedCharacter As New Character
Public SelectedBlueprint As Blueprint
Public Const DummyClient As String = ""
Public Const DefaultCharacterCode As Integer = -1 ' To indicate the default character
Public Const DummyCharacterID As Long = -1
Public Const DummyCorporationID As Long = -1
Public Const CommonSavedFacilitiesID As Integer = -2
Public Const CommonLoadBPsID As Integer = -2
' Variable to hold error tracking data when the error is hard to find - used for debugging only but mostly this is set to empty string
Public ErrorTracker As String
Public ESIErrorHandler As ESIErrorProcessor
Public DefaultCharSelected As Boolean
Public FirstLoad As Boolean ' If the program just opened
Public SkillsUpdated As Boolean ' To track if skills where updated in the skill override screen
Public ManufacturingTabColumnsChanged As Boolean ' To track if thy changed columns
' File Paths
Public DynamicFilePath As String = "" ' Where the update and settings files are stored that we can write, create, delete, etc.
Public DBFilePath As String = "" ' Where the DB is stored for updates
Public Const PatchNotesURL = "https://raw.githubusercontent.com/EVEIPH/LatestFiles/master/Patch%20Notes.txt"
Public Const XMLUpdateFileURL = "https://raw.githubusercontent.com/EVEIPH/LatestFiles/master/LatestVersionIPH.xml"
Public Const XMLUpdateTestFileURL = "https://github.com/EVEIPH/LatestFiles/raw/master/LatestVersionIPH_Test.xml"
Public Const DynamicAppDataPath As String = "EVE IPH"
Public Const UserImagePath As String = "EVEIPH Images"
Public Const UpdatePath As String = "EVE IPH Updates"
Public Const SettingsFolder As String = "Settings" ' For saving all settings
Public Const SQLiteDBFileName As String = "EVEIPH DB.sqlite"
Public ReactionTypes As New List(Of String)(New String() {"Composite", "Intermediate Materials", "Hybrid Polymers"})
' For updates
Public Const UpdaterFileName As String = "EVEIPH Updater.exe"
Public Const SQLiteDLLUpdater As String = "EVEIPH SQLite DLL Updater.exe"
Public Const XMLUpdaterFileName As String = "EVEIPH_Updater.exe" ' For use in the XML files to remove spaces from row names
Public Const XMLLatestVersionFileName As String = "LatestVersionIPH.xml"
Public Const XMLLatestVersionTest As String = "LatestVersionIPH Test.xml"
' Only request ESI scopes I need - if I add a scope, the user will need to re-authorize for the new scopes.
Public ESIScopesString As String = ""
Public Const TheForgeTypeID As Long = 10000002
Public Const JitaPerimeter As String = "Jita/Perimeter"
Public Const USER_BLUEPRINTS As String = "(SELECT ALL_BLUEPRINTS.BLUEPRINT_ID AS BP_ID, ALL_BLUEPRINTS.BLUEPRINT_GROUP, ALL_BLUEPRINTS.BLUEPRINT_NAME, " _
& "ITEM_GROUP_ID, ITEM_GROUP, ITEM_CATEGORY_ID, CASE WHEN ITEM_GROUP LIKE 'RIG%' THEN 'RIG' ELSE ITEM_CATEGORY END AS ITEM_CATEGORY, " _
& "ALL_BLUEPRINTS.ITEM_ID, ITEM_NAME," _
& "CASE WHEN OBP.ME IS NOT NULL THEN OBP.ME ELSE 0 END AS ME," _
& "CASE WHEN OBP.TE IS NOT NULL THEN OBP.TE ELSE 0 END AS TE," _
& "CASE WHEN USER_ID IS NOT NULL THEN USER_ID ELSE 0 END AS USER_ID, ITEM_TYPE," _
& "CASE WHEN ALL_BLUEPRINTS.RACE_ID IS NOT NULL THEN ALL_BLUEPRINTS.RACE_ID ELSE 0 END AS RACE_ID," _
& "CASE WHEN OBP.OWNED IS NOT NULL THEN OBP.OWNED ELSE 0 END AS OWNED," _
& "CASE WHEN OBP.SCANNED IS NOT NULL THEN OBP.SCANNED ELSE 0 END AS SCANNED," _
& "CASE WHEN OBP.BP_TYPE IS NOT NULL THEN OBP.BP_TYPE ELSE 0 END AS BP_TYPE," _
& "CASE WHEN OBP.ITEM_ID IS NOT NULL THEN OBP.ITEM_ID ELSE 0 END AS UNIQUE_BP_ITEM_ID, " _
& "CASE WHEN OBP.FAVORITE IS NOT NULL THEN OBP.FAVORITE " _
& "ELSE CASE WHEN ALL_BLUEPRINTS.FAVORITE IS NOT NULL THEN ALL_BLUEPRINTS.FAVORITE ELSE 0 END END AS FAVORITE, " _
& "IT.VOLUME, IT.MARKETGROUPID, " _
& "CASE WHEN OBP.ADDITIONAL_COSTS IS NOT NULL THEN OBP.ADDITIONAL_COSTS ELSE 0 END AS ADDITIONAL_COSTS, " _
& "CASE WHEN OBP.LOCATION_ID IS NOT NULL THEN OBP.LOCATION_ID ELSE 0 END AS LOCATION_ID, " _
& "CASE WHEN OBP.QUANTITY IS NOT NULL THEN OBP.QUANTITY ELSE 0 END AS QUANTITY, " _
& "CASE WHEN OBP.FLAG_ID IS NOT NULL THEN OBP.FLAG_ID ELSE 0 END AS FLAG_ID, " _
& "CASE WHEN OBP.RUNS IS NOT NULL THEN OBP.RUNS ELSE 0 END AS RUNS, " _
& "IGNORE, ALL_BLUEPRINTS.TECH_LEVEL, SIZE_GROUP, " _
& "CASE WHEN IT2.MARKETGROUPID IS NULL THEN 0 ELSE 1 END AS NPC_BPO " _
& "FROM ALL_BLUEPRINTS LEFT OUTER JOIN " _
& "(SELECT * FROM OWNED_BLUEPRINTS) AS OBP " _
& "ON ALL_BLUEPRINTS.BLUEPRINT_ID = OBP.BLUEPRINT_ID " _
& "AND (OBP.USER_ID = @USERBP_USERID OR OBP.USER_ID = @USERBP_CORPID), " _
& "INVENTORY_TYPES AS IT, INVENTORY_TYPES AS IT2 " _
& "WHERE ALL_BLUEPRINTS.ITEM_ID = IT.TYPEID AND ALL_BLUEPRINTS.BLUEPRINT_ID = IT2.TYPEID) AS X "
' Shopping List
Public TotalShoppingList As New ShoppingList
' For a new shopping list, so we can upate it when it's open
Public frmShop As frmShoppingList = New frmShoppingList
Public frmConversionOptions As frmConversiontoOreSettings
Public CopyPasteRefineryMaterialText As String
' Same with assets
Public frmDefaultAssets As frmAssetsViewer
Public frmShoppingAssets As frmAssetsViewer
Public frmRefineryAssets As frmAssetsViewer
Public frmViewStructures As frmViewSavedStructures = New frmViewSavedStructures
Public frmRepoPlant As frmReprocessingPlant
' The only allowed characters for text entry
Public Const allowedPriceChars As String = "0123456789.,"
Public Const allowedMETEChars As String = "0123456789."
Public Const allowedRunschars As String = "0123456789"
Public Const allowedDecimalChars As String = "0123456789.-"
Public Const allowedPercentChars As String = "0123456789.%"
Public Const allowedNegativePercentChars As String = "0123456789.%-"
Public Const SQLiteDateFormat As String = "yyyy-MM-dd HH:mm:ss"
Public Const IndustryNoCompletedDate As DateTime = #1/1/2001#
Public Const DataCoreRedeemCost As Double = 10000.0
Public FirstIndustryJobsViewerLoad As Boolean
Public Const SpaceFlagCode As Integer = 500
' For update prices, to cancel update
Public CancelUpdatePrices As Boolean
Public CancelManufacturingTabCalc As Boolean
Public CancelThreading As Boolean
' Column processing
Public Const NumManufacturingTabColumns As Integer = 110
Public Const NumIndustryJobColumns As Integer = 21
Public Const BaseRefineRate As Double = 0.5
Public Const NoDate As Date = #1/1/1900#
Public Const NoExpiry As Date = #1/1/2200#
' For T3 Relics
Public Const IntactRelic As String = "Intact"
Public Const MalfunctioningRelic As String = "Malfunctioning"
Public Const WreckedRelic As String = "Wrecked"
Public Const MineralGroupID As Integer = 18
' T2 BPC base ME/TE
Public Const BaseT2T3ME As Integer = 2
Public Const BaseT2T3TE As Integer = 4
' For industry tab loading
Public Const BPTab As String = "BP"
Public Const CalcTab As String = "Calc"
' For update prices
Public Const DefaultSystemPriceCombo As String = "Select System"
Public Const DefaultRegionPriceCombo As String = "Select Region"
Public Const AllSystems As String = "All Systems"
' For unhandled exceptions
Public frmErrorText As String = ""
Public ErrorTest As String = ""
Public PriceQueryCount As Integer ' This will track the number of times the user queries EVE Central - used to warn them for over pinging
Public CalcHistoryRegionLoaded As Boolean
Public ShownPriceUpdateError As Boolean ' Only want to show them the error once
Public Const BPO As String = "BPO"
Public Const BPC As String = "BPC"
Public Const InventedBPC As String = "Invented BPC"
Public Const UnownedBP As String = "Unowned"
Public Const Yes As String = "Yes"
Public Const No As String = "No"
Public Const Unknown As String = "Unknown"
Public Const Unlimited As String = "Unlimited"
Public Const Male As String = "male"
Public NoFacility As New IndustryFacility
Public Const None As String = "None" ' For decryptors and facilities
Public MiningUpgradesCollection As New List(Of String)
Public CancelESISSOLogin As Boolean
Public NoPOSCategoryIDs As List(Of Long) ' For facilities
' Mining Ship Name constants
Public Const Procurer As String = "Procurer"
Public Const Retriever As String = "Retriever"
Public Const Covetor As String = "Covetor"
Public Const Skiff As String = "Skiff"
Public Const Mackinaw As String = "Mackinaw"
Public Const Hulk As String = "Hulk"
Public Const Venture As String = "Venture"
Public Const Prospect As String = "Prospect"
Public Const Endurance As String = "Endurance"
Public Const Rorqual As String = "Rorqual"
Public Const Porpoise As String = "Porpoise"
Public Const Orca As String = "Orca"
Public Const Drake As String = "Drake"
Public Const Gnosis As String = "Gnosis"
Public Const Rokh As String = "Rokh"
' For exporting Data
Public Const DefaultTextDataExport As String = "Default"
Public Const CSVDataExport As String = "CSV"
Public Const SSVDataExport As String = "SSV"
Public Const MultiBuyDataExport As String = "Multibuy"
Public SetTaxFeeChecks As Boolean
Public LocationIDs As New List(Of Long)
Public MaxStationID As Long = 67000000
Public MinStationID As Long = 60000000
' Opened forms from menu
Public ReprocessingPlantOpen As Boolean
Public OreBeltFlipOpen As Boolean
Public IceBeltFlipOpen As Boolean
' Limits for Market History endpoint
Public Const MaxMarketHistoryCallsPerMinute As Integer = 300
Public MarketHistoryCallsPerMinute As Integer = 0
Public LastMarketHistoryUpdate As Date = NoDate
Public PriceUpdateDown As Boolean = False
' For scanning assets
Public Enum ScanType
Personal = 0
Corporation = 1
End Enum
' BP Types: -1 is original, -2 is copy from API, others are built for IPH
Public Enum BPType
NotOwned = 0
' These are assumed owned, since they are marked or loaded from API
Original = -1
Copy = -2
InventedBPC = -3
End Enum
' For scanning assets
Public Enum SkillType
BPReqSkills = 1
BPComponentSkills = 2
REReqSkills = 3
InventionReqSkills = 4
End Enum
Public Enum MaterialType
BaseMats = 0
ExtraMats = 1
End Enum
Public Enum BPTechLevel
T1 = 1
T2 = 2
T3 = 3
End Enum
Public Enum BeltType
Small = 1
Medium = 2
Large = 3
Enormous = 4
Colossal = 5
End Enum
Public Enum ItemSize
Small = 1
Medium = 2
Large = 3
ExtraLarge = 4
End Enum
Public Enum SentFromLocation
None = 0
BlueprintTab = 1
ManufacturingTab = 2
History = 3
ShoppingList = 4
End Enum
Public Enum CopyPasteWindowType
Materials = 1
Blueprints = 2
End Enum
Public Enum CopyPasteWindowLocation
Assets = 1
RefineMaterials = 2
End Enum
' To play ding sound without box
Public Sub PlayNotifySound()
If Not UserApplicationSettings.DisableSound Then
My.Computer.Audio.PlaySystemSound(System.Media.SystemSounds.Asterisk)
End If
End Sub
Public Class LocationInfo
Public AccountID As Long
Public LocationID As Long
Public FlagID As Integer ' ID in the INVENTORY_FLAGS Table
End Class
' For error processing
Public Structure MyError
Dim Description As String
Dim Number As Integer
End Structure
Public Structure BrokerFeeInfo
Dim IncludeFee As BrokerFeeType
Dim FixedRate As Double
End Structure
Public Enum BrokerFeeType
NoFee = 0
Fee = 1
SpecialFee = 2
End Enum
' For importing blueprints via cut/paste
Public Structure CopyPasteBlueprint
Dim Name As String
Dim Quantity As Long
Dim Group As String
Dim Category As String
Dim Copy As Boolean
Dim ML As Integer
Dim PL As Integer
Dim Runs As Integer
End Structure
' For shopping list
Public Structure ItemBuyType
Dim ItemName As String
Dim BuyType As String
End Structure
' For updating the splash screen with what is going on
Private Delegate Sub ProgressSetter(ByVal progress As String)
Public Sub SetProgress(ByVal progress As String)
'Get a reference to the application's splash screen.
Dim splash As SplashScreen = DirectCast(My.Application.SplashScreen, SplashScreen)
'Invoke the splach screen's SetProgress method on the thread that owns it.
splash.Invoke(New ProgressSetter(AddressOf splash.SetProgress), progress)
End Sub
' Takes a string value percent and returns a double
Public Function CpctD(ByVal PercentValue As String) As Double
Dim PercentNumber As String = PercentValue.Replace("%", "")
If IsNumeric(PercentNumber) And Not PercentNumber.Contains("E") Then
Return CDbl(PercentNumber) / 100
Else
Return 0
End If
End Function
Public Structure BuildBuyItem
Dim ItemID As Long
Dim BuildItem As Boolean ' True, we build it regardless, False we do not regardless. If not in list, we don't do anything differently
End Structure
' Returns the ReactionGroupID number if sent is a reaction, else -1
Public Function ReactionGroupID(CheckID As Integer) As Integer
Select Case CheckID
Case ItemIDs.ReactionBiochemicalsGroupID, ItemIDs.ReactionCompositesGroupID, ItemIDs.ReactionPolymersGroupID, ItemIDs.ReactionsIntermediateGroupID, ItemIDs.ReactionMolecularForgedGroupID
Return CheckID
Case Else
Return -1
End Select
End Function
Public Function IsReaction(ByVal ItemGroupID As Integer) As Boolean
If ReactionGroupID(ItemGroupID) <> -1 Then
Return True
Else
Return False
End If
End Function
Public Enum ItemIDs
None = 0
' These are all the capital ships that use capital parts
CapitalIndustrialShipGroupID = 883
CarrierGroupID = 547
DreadnoughtGroupID = 485
FreighterGroupID = 513
IndustrialCommandShipGroupID = 941
JumpFreighterGroupID = 902
SupercarrierGroupID = 659
FAXGroupID = 1538
TitanGroupID = 30
BoosterGroupID = 303
BoosterCategoryID = 20
' T3 items
StrategicCruiserGroupID = 963
TacticalDestroyerGroupID = 1305
SubsystemCategoryID = 32
' T3 Bps for facility updates
StrategicCruiserBPGroupID = 996
TacticalDestroyerBPGroupID = 1309
SubsystemBPGroupID = 973
ShipCategoryID = 6 ' for loading invention and copying and basic t1
FrigateGroupID = 25
' Reactions
ReactionsIntermediateGroupID = 428
ReactionCompositesGroupID = 429
ReactionPolymersGroupID = 974
ReactionBiochemicalsGroupID = 712
ReactionMolecularForgedGroupID = 4096
ConstructionComponentsGroupID = 334 ' Use this for all non-capital components
ComponentCategoryID = 17
CapitalComponentGroupID = 873
AdvCapitalComponentGroupID = 913
ProtectiveComponentGroupID = -3 ' My manual group ID until they fix it in the SDE
BlueprintCategoryID = 9
FrigateBlueprintGroupID = 105
AsteroidsCategoryID = 25 ' category for asteroids,ice,moons = 25
' Ice group id = 465
IceGroupID = 465
' Groupids for moon ores - 1884, 1920, 1921, 1922, 1923
CommonMoonAsteroids = 1920
ExceptionalMoonAsteroids = 1923
RareMoonAsteroids = 1922
UbiquitousMoonAsteroids = 1884
UncommonMoonAsteroids = 1921
' Groupid's for asteroid types - regular ore
Arkonor = 450
Bistot = 451
Crokite = 452
DarkOchre = 453
Gneiss = 467
Hedbergite = 454
Hemorphite = 455
Jaspet = 456
Kernite = 457
Mercoxit = 468
Omber = 469
Plagioclase = 458
Pyroxeres = 459
Scordite = 460
Spodumain = 461
Veldspar = 462
End Enum
#Region "Taxes/Fees"
Public Function AdjustPriceforTaxesandFees(ByVal OriginalPrice As Double, ByVal SetTax As Boolean, ByVal BrokerFeeData As BrokerFeeInfo) As Double
If OriginalPrice <= 0 Then
Return 0
End If
Dim NewPrice As Double = 0
' Apply taxes and fees
If SetTax Then
NewPrice = OriginalPrice - GetSalesTax(OriginalPrice) - GetSalesBrokerFee(OriginalPrice, BrokerFeeData)
Else
NewPrice = OriginalPrice - GetSalesBrokerFee(OriginalPrice, BrokerFeeData)
End If
Return NewPrice
End Function
' Returns the tax on an item price only
Public Function GetSalesTax(ByVal ItemMarketCost As Double) As Double
Dim Accounting As Integer = SelectedCharacter.Skills.GetSkillLevel(16622)
' Each level of accounting reduces tax by 11%, Max/Base Sales Tax: 8%, Min Sales Tax: 3.6%
' Latest info: https://www.eveonline.com/news/view/restructuring-taxes-after-relief
Return (UserApplicationSettings.BaseSalesTaxRate - (Accounting * 0.11 * UserApplicationSettings.BaseSalesTaxRate)) / 100 * ItemMarketCost
End Function
' Returns the tax on setting up a sell order for an item price only
Public Function GetSalesBrokerFee(ByVal ItemMarketCost As Double, BrokerFee As BrokerFeeInfo) As Double
Dim BrokerRelations As Integer = SelectedCharacter.Skills.GetSkillLevel(3446)
Dim TempFee As Double
If BrokerFee.IncludeFee = BrokerFeeType.Fee Then
' 3%-(0.3%*BrokerRelationsLevel)-(0.03%*FactionStanding)-(0.02%*CorpStanding) - uses unmodified standings
' Base broker fee = 3%, Min broker fees: 1.0%
' Latest info: https://www.eveonline.com/news/view/restructuring-taxes-after-relief
' and https://www.eveonline.com/de/news/view/viridian-expansion-notes
Dim BrokerTax = UserApplicationSettings.BaseBrokerFeeRate - (0.3 * BrokerRelations) - (0.03 * UserApplicationSettings.BrokerFactionStanding) - (0.02 * UserApplicationSettings.BrokerCorpStanding)
TempFee = (BrokerTax / 100) * ItemMarketCost
ElseIf BrokerFee.IncludeFee = BrokerFeeType.SpecialFee Then
' use a flat rate to set the fee - Since they are setting this, assume they are in an Upwell and add in the SCC fixed rate fee added in Viridian
TempFee = (BrokerFee.FixedRate * ItemMarketCost) + (UserApplicationSettings.SCCBrokerFeeSurcharge * ItemMarketCost)
Else
Return 0
End If
If TempFee < 100 Then
Return 100
Else
Return TempFee
End If
End Function
' Get Broker Fee data
Public Function GetBrokerFeeData(ByVal BrokerCheck As CheckBox, SpecialRateBox As TextBox) As BrokerFeeInfo
Dim TempBF As BrokerFeeInfo
If BrokerCheck.CheckState = CheckState.Indeterminate Then
' Get the special fee
TempBF.FixedRate = FormatManualPercentEntry(SpecialRateBox.Text)
TempBF.IncludeFee = BrokerFeeType.SpecialFee
ElseIf BrokerCheck.CheckState = CheckState.Checked Then
TempBF.IncludeFee = BrokerFeeType.Fee
Else
TempBF.IncludeFee = BrokerFeeType.NoFee
End If
Return TempBF
End Function
#End Region
#Region "Character Loading"
' Loads the character for the program
Public Sub LoadCharacter(RefreshAssets As Boolean, RefreshBPs As Boolean)
On Error GoTo 0
' Try to load the character
If Not SelectedCharacter.LoadDefaultCharacter(RefreshBPs, RefreshAssets) Then
' Didn't find a default character. Either we don't have one selected or there are no characters in the DB yet
Dim CMDCount As New SQLiteCommand("SELECT COUNT(*) FROM ESI_CHARACTER_DATA WHERE CHARACTER_ID <> " & CStr(DummyCharacterID), EVEDB.DBREf)
If CInt(CMDCount.ExecuteScalar()) = 0 Then
' No characters loaded yet so load dummy for all
Call SelectedCharacter.LoadDummyCharacter(True)
Else
' Have a set of chars, need to set a default, open that form
Dim f2 = New frmSetCharacterDefault
f2.ShowDialog()
End If
End If
End Sub
' Loads a default character from name sent
Public Sub LoadCharacter(CharacterName As String, Optional PlaySound As Boolean = True)
' Load only if a new character
If SelectedCharacter.Name <> CharacterName Then
' Update them all to 0 first
Call EVEDB.ExecuteNonQuerySQL("UPDATE ESI_CHARACTER_DATA SET IS_DEFAULT = 0")
Call EVEDB.ExecuteNonQuerySQL("UPDATE ESI_CHARACTER_DATA SET IS_DEFAULT = " & CStr(DefaultCharacterCode) & " WHERE CHARACTER_NAME = '" & FormatDBString(CharacterName) & "'")
' Load the character as default for program and reload additional API data
Call SelectedCharacter.LoadDefaultCharacter(UserApplicationSettings.LoadAssetsonStartup, UserApplicationSettings.LoadBPsonStartup)
If PlaySound Then
Call PlayNotifySound()
End If
End If
End Sub
#End Region
#Region "Time Functions"
' Converts a time in d h m s to a long of seconds - 3d 12h 2m 33s or 1 Day 12:23:33
Public Function ConvertDHMSTimetoSeconds(ByVal SentTime As String) As Long
Dim Days As Long = 0
Dim Hours As Integer = 0
Dim Minutes As Integer = 0
Dim Seconds As Integer = 0
Dim StringMarker As String = ""
SentTime = Trim(SentTime)
If SentTime.Contains("Day ") Or SentTime.Contains("Days ") Or SentTime.Contains(":") Then
' Time in 2 Days 12:23:05 format
If SentTime.Contains("Days") Then
StringMarker = "Days "
ElseIf SentTime.Contains("Day") Then
StringMarker = "Day "
Else
StringMarker = ""
End If
If StringMarker <> "" Then
' Get the days
Days = CInt(SentTime.Substring(0, SentTime.IndexOf(StringMarker)))
' Reset the string
SentTime = Trim(SentTime.Substring(SentTime.IndexOf(StringMarker) + Len(StringMarker)))
End If
'Now parse the times
Hours = CInt(SentTime.Substring(0, SentTime.IndexOf(":")))
SentTime = Trim(SentTime.Substring(SentTime.IndexOf(":") + 1))
Minutes = CInt(SentTime.Substring(0, SentTime.IndexOf(":")))
SentTime = Trim(SentTime.Substring(SentTime.IndexOf(":") + 1))
Seconds = CInt(SentTime)
Else
If SentTime.Contains("d ") Then
StringMarker = "d "
' Get the days
Days = CInt(SentTime.Substring(0, SentTime.IndexOf(StringMarker)))
' Reset the string
SentTime = Trim(SentTime.Substring(SentTime.IndexOf(StringMarker) + Len(StringMarker)))
End If
If SentTime.Contains("h ") Then
' Get the days
Hours = CInt(SentTime.Substring(0, SentTime.IndexOf("h")))
' Reset the string
SentTime = Trim(SentTime.Substring(SentTime.IndexOf("h") + 1))
End If
If SentTime.Contains("m ") Then
' Get the days
Minutes = CInt(SentTime.Substring(0, SentTime.IndexOf("m")))
' Reset the string
SentTime = Trim(SentTime.Substring(SentTime.IndexOf("m") + 1))
End If
If SentTime.Contains("s") Then
' Get the days
Seconds = CInt(SentTime.Substring(0, SentTime.IndexOf("s")))
End If
End If
Return (Days * 24 * 60 * 60) + (Hours * 60 * 60) + (Minutes * 60) + Seconds
End Function
' Formats seconds into a time for display with days, hours, min, sec
Public Function FormatTimeToComplete(TimeinSeconds As Long) As String
Dim FinalTime As String = ""
Dim Days As Long
Dim Hours As Long
Dim Minutes As Long
Dim Seconds As Long
Seconds = TimeinSeconds
Days = CLng(Math.Floor(Seconds / (24 * 60 * 60)))
Seconds = Seconds - (Days * 24 * 60 * 60)
Hours = CLng(Math.Floor(Seconds / (60 * 60)))
Seconds = Seconds - (Hours * 60 * 60)
Minutes = CLng(Math.Floor(Seconds / 60))
Seconds = Seconds - (Minutes * 60)
If Days <> 0 Then
FinalTime = CStr(Days) & "d " & CStr(Hours) & "h " & CStr(Minutes) & "m " & CStr(Seconds) & "s"
ElseIf Days = 0 And Hours <> 0 Then
FinalTime = CStr(Hours) & "h " & CStr(Minutes) & "m " & CStr(Seconds) & "s"
ElseIf Days = 0 And Hours = 0 And Minutes <> 0 Then
FinalTime = CStr(Minutes) & "m " & CStr(Seconds) & "s"
ElseIf Days = 0 And Hours = 0 And Minutes = 0 And Seconds <> 0 Then
FinalTime = CStr(Seconds) & "s"
End If
Return FinalTime
End Function
' Takes a time in seconds and converts it to a string display of Days HH:MM:SS
Public Function FormatIPHTime(ByVal SentTimeString As Double) As String
Dim Seconds As Long
Dim Minutes As Integer
Dim Hours As Integer
Dim Days As Integer
Dim TimeString As String = ""
Seconds = CLng(SentTimeString)
' Calcuate Days
Days = CInt(Seconds \ 86400)
Seconds = Seconds Mod 86400
'Calculate Hours and remaining Seconds
Hours = CInt(Seconds \ 3600)
Seconds = Seconds Mod 3600
'Calculate Minutes and remaining Seconds
Minutes = CInt(Seconds \ 60)
Seconds = Seconds Mod 60
' Add Days on if needed
If Days <> 0 Then
TimeString = CStr(Days) & " Days "
End If
Return (TimeString & Format(Hours, "00") & ":" & Format(Minutes, "00") & ":" & Format(Seconds, "00"))
End Function
' Takes a date/time like "1d 22h 38m 46s" and converts it to seconds
Public Function FormatStringdate(ByVal SentTimeString As String) As Long
Dim Days As Integer
Dim Hours As Integer
Dim Minutes As Integer
Dim Seconds As Integer
Dim strArr() As String
Dim count As Integer
On Error GoTo InvalidDate
If SentTimeString = "" Then
GoTo InvalidDate
End If
' Break up the string sections
strArr = SentTimeString.Split(New Char() {" "c})
For count = strArr.Count - 1 To 0 Step -1
' Loop from seconds to the days
If strArr(count).Substring(strArr(count).Length - 1) = "s" Then
If Not IsNumeric(strArr(count).Substring(0, InStr(strArr(count), "s") - 1)) Then
GoTo InvalidDate
Else
Seconds = CInt(strArr(count).Substring(0, InStr(strArr(count), "s") - 1))
End If
End If
If strArr(count).Substring(strArr(count).Length - 1) = "m" Then
If Not IsNumeric(strArr(count).Substring(0, InStr(strArr(count), "m") - 1)) Then
GoTo InvalidDate
Else
Seconds = CInt(strArr(count).Substring(0, InStr(strArr(count), "m") - 1))
End If
End If
If strArr(count).Substring(strArr(count).Length - 1) = "h" Then
If Not IsNumeric(strArr(count).Substring(0, InStr(strArr(count), "h") - 1)) Then
GoTo InvalidDate
Else
Seconds = CInt(strArr(count).Substring(0, InStr(strArr(count), "h") - 1))
End If
End If
If strArr(count).Substring(strArr(count).Length - 1) = "d" Then
If Not IsNumeric(strArr(count).Substring(0, InStr(strArr(count), "d") - 1)) Then
GoTo InvalidDate
Else
Seconds = CInt(strArr(count).Substring(0, InStr(strArr(count), "d") - 1))
End If
End If
Next
Return CInt(Seconds) + (60 * CInt(Minutes)) + (360 * CInt(Hours)) + (360 * 24 * CInt(Days))
InvalidDate:
On Error Resume Next
Return -1
End Function
' Takes a date/time like "1d 22h 38m 6s" and sees if it is a date/time
Public Function IsStringdate(ByVal SentTimeString As String) As Boolean
Dim strArr() As String
Dim count As Integer
If SentTimeString = "" Then
Return False
End If
' Make sure the sent string has no extra spaces that create a blank array entry
SentTimeString = Trim(SentTimeString)
' Break up the string sections
strArr = SentTimeString.Split(New Char() {" "c})
For count = strArr.Count - 1 To 0 Step -1
' Loop from seconds to the days
Select Case strArr(count).Substring(strArr(count).Length - 1)
Case "s"
If Not IsNumeric(strArr(count).Substring(0, InStr(strArr(count), "s") - 1)) Then
Return False
End If
Case "m"
If Not IsNumeric(strArr(count).Substring(0, InStr(strArr(count), "m") - 1)) Then
Return False
End If
Case "h"
If Not IsNumeric(strArr(count).Substring(0, InStr(strArr(count), "h") - 1)) Then
Return False
End If
Case "d"
If Not IsNumeric(strArr(count).Substring(0, InStr(strArr(count), "d") - 1)) Then
Return False
End If
Case Else
Return False
End Select
Next
Return True
End Function
#End Region
' Checks entry of percentage chars in keypress
Public Function CheckPercentCharEntry(ke As KeyPressEventArgs, box As TextBox) As Boolean
Dim Istr As String = box.Text
' Only allow numbers or backspace
If ke.KeyChar <> ControlChars.Back Then
If allowedNegativePercentChars.IndexOf(ke.KeyChar) = -1 Then
' Invalid Character
Return True
ElseIf (Asc(ke.KeyChar) = 45 And Istr.Contains("-")) Or (Asc(ke.KeyChar) = 37 And Istr.Contains("%")) Or (Asc(ke.KeyChar) = 46 And Istr.Contains(".")) Then ' If the dash, percent, or period is pressed again, don't accept
Return True
End If
End If
Return False
End Function
' Formats the manual entry of a percent in a string
Public Function FormatManualPercentEntry(Entry As String) As Double
Dim EntryText As String
If Entry.Contains("%") Then
' Strip the percent first
EntryText = Entry.Substring(0, Len(Entry) - 1)
Else
EntryText = Entry
End If
If IsNumeric(EntryText) Then
Return CDbl(EntryText) / 100
Else
Return 0
End If
End Function
' Returns the sent text box text as a percent in string format
Public Function GetFormattedPercentEntry(RefTextbox As TextBox) As String
Return FormatPercent(FormatManualPercentEntry(RefTextbox.Text), 1)
End Function
Public Function GetBPType(BPTypeValue As Object) As BPType
If IsNothing(BPTypeValue) Then
Return BPType.NotOwned
End If
If IsDBNull(BPTypeValue) Then
Return BPType.NotOwned
End If
If BPTypeValue.GetType.Name = "String" Then
Select Case CStr(BPTypeValue)
Case BPO
Return BPType.Original
Case BPC
Return BPType.Copy
Case InventedBPC
Return BPType.InventedBPC
Case UnownedBP
Return BPType.NotOwned
End Select
Else
Select Case CInt(BPTypeValue)
Case BPType.Original
Return BPType.Original
Case BPType.Copy
Return BPType.Copy
Case BPType.InventedBPC
Return BPType.InventedBPC
Case BPType.NotOwned
Return BPType.NotOwned
End Select
End If
Return BPType.NotOwned
End Function
Public Function GetBPTypeString(BPTypeValue As Object) As String
If IsNothing(BPTypeValue) Then
Return UnownedBP
End If
If IsDBNull(BPTypeValue) Then
Return UnownedBP
End If
Select Case CInt(BPTypeValue)
Case BPType.Original
Return BPO
Case BPType.Copy
Return BPC
Case BPType.InventedBPC
Return InventedBPC
Case BPType.NotOwned
Return UnownedBP
End Select
Return UnownedBP
End Function
' Function takes a recordset reference and processes it to return the cache date from the query
' Assumes the first field is the cache date
Public Function ProcessCacheDate(ByRef rsCache As SQLiteDataReader) As Date
Dim CacheDate As Date
Try
If rsCache.Read Then
If Not IsDBNull(rsCache.GetValue(0)) Then
If rsCache.GetString(0) = "" Then
CacheDate = NoDate
Else
CacheDate = CDate(rsCache.GetString(0))
End If
Else
CacheDate = NoDate
End If
Else
CacheDate = NoDate
End If
Catch ex As Exception
CacheDate = NoDate
End Try
Return CacheDate
End Function
' Returns the price of the typeID sent in item_prices
Public Function GetItemPrice(ByVal TypeID As Long) As Double
Dim readerCost As SQLiteDataReader
Dim SQL As String
Dim ItemPrice As Double = 0
' Look up the cost for the material
SQL = "SELECT PRICE FROM ITEM_PRICES WHERE ITEM_ID =" & TypeID
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
readerCost = DBCommand.ExecuteReader
If readerCost.Read Then
ItemPrice = readerCost.GetDouble(0)
End If
readerCost.Close()
Return ItemPrice
End Function
' Sorts the reference listview and column
''' <summary>
'''
''' </summary>
''' <param name="ColumnIndex"></param>
''' <param name="RefListView"></param>
''' <param name="ListPrevColumnClicked"></param>
''' <param name="ListPrevColumnSortOrder"></param>
''' <param name="UseSentSortType"></param>
Public Sub ListViewColumnSorter(ByVal ColumnIndex As Integer, ByRef RefListView As ListView, ByRef ListPrevColumnClicked As Integer, ByRef ListPrevColumnSortOrder As SortOrder,
Optional UseSentSortType As Boolean = False)