forked from EVEIPH/EVE-IPH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmAssetsViewer.vb
1634 lines (1359 loc) · 59.2 KB
/
frmAssetsViewer.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.Runtime.InteropServices
Imports System.Data.SQLite
Public Class frmAssetsViewer
Private ToggleAllOpen As Boolean
Private UpdatingChecks As Boolean
Private RefreshAssetButton As Boolean
Private SelectedSettings As AssetWindowSettings
' The saved location ids
Private SavedLocationIDs As List(Of LocationInfo)
Private m_ControlsCollection As ControlsCollection
Private TechCheckBoxes() As CheckBox
Private UpdateAllTechChecks As Boolean = True ' Whether to update all Tech checks in items or not
Private FirstPriceShipTypesComboLoad As Boolean
Private FirstPriceChargeTypesComboLoad As Boolean
' For checks that are enabled
Private PriceCheckT1Enabled As Boolean
Private PriceCheckT2Enabled As Boolean
Private PriceCheckT3Enabled As Boolean
Private PriceCheckT4Enabled As Boolean
Private PriceCheckT5Enabled As Boolean
Private PriceCheckT6Enabled As Boolean
' Where the form was loaded from
Private WindowForm As AssetWindow
Private AnchorNode As TreeNode
'Private AssetTreeTest As TriStateTreeView
' For drawing checkboxes
Private Const TVIF_STATE As Integer = &H8
Private Const TVIS_STATEIMAGEMASK As Integer = &HF000
Private Const TV_FIRST As Integer = &H1100
Private Const TVM_SETITEM As Integer = TV_FIRST + 63
#Region "Special processing for checks"
<StructLayout(LayoutKind.Sequential)> _
Public Structure TVITEM
Public mask As Integer
Public hItem As IntPtr
Public state As Integer
Public stateMask As Integer
<MarshalAs(UnmanagedType.LPTStr)>
Public lpszText As String
Public cchTextMax As Integer
Public iImage As Integer
Public iSelectedImage As Integer
Public cChildren As Integer
Public lParam As IntPtr
End Structure
Private Declare Auto Function SendMessage Lib "User32.dll" (ByVal hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByRef lParam As TVITEM) As Integer
Private Sub HideRootCheckBox(ByVal node As TreeNode)
Dim tvi As New TVITEM
tvi.hItem = node.Handle
tvi.mask = TVIF_STATE
tvi.stateMask = TVIS_STATEIMAGEMASK
tvi.state = 0
SendMessage(AssetTree.Handle, TVM_SETITEM, IntPtr.Zero, tvi)
End Sub
Private Sub AssetTree_DrawNode(ByVal sender As Object, ByVal e As DrawTreeNodeEventArgs) Handles AssetTree.DrawNode
' Don't show the top node with a check box
If e.Node.Parent Is Nothing Then
HideRootCheckBox(e.Node)
End If
' For high, mid, rigs, and low slots on ships, don't show check boxes
If e.Node.Text.Contains("power slot") Or e.Node.Text.Contains("Personal Assets") Or e.Node.Text.Contains("Corporation Assets") Then
HideRootCheckBox(e.Node)
End If
' Don't show a checkbox on any nodes without children
If e.Node.Nodes.Count = 0 Then
HideRootCheckBox(e.Node)
End If
e.DrawDefault = True
End Sub
Public ReadOnly Property MyControls() As Collection
Get
Return m_ControlsCollection.Controls
End Get
End Property
#End Region
Public Sub New(ByVal AssetType As AssetWindow)
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
WindowForm = AssetType
' Mark where the window is attached - can have multiple open
Select Case AssetType
Case AssetWindow.DefaultView
Me.Text = "Default Asset Viewer"
SelectedSettings = UserAssetWindowDefaultSettings
Case AssetWindow.ManufacturingTab
Me.Text = "Manufacturing Asset Viewer"
SelectedSettings = UserAssetWindowManufacturingTabSettings
Case AssetWindow.ShoppingList
Me.Text = "Shopping List Assets"
SelectedSettings = UserAssetWindowShoppingListSettings
End Select
' For this window, get the asset locations saved for the character
SavedLocationIDs = SelectedCharacter.Assets.GetAssetLocationIDs(WindowForm, SelectedCharacter.ID, SelectedCharacter.CharacterCorporation)
' For the disabling of the price update form
PriceCheckT1Enabled = True
PriceCheckT2Enabled = True
PriceCheckT3Enabled = True
PriceCheckT4Enabled = True
PriceCheckT5Enabled = True
PriceCheckT6Enabled = True
AssetTree.DrawMode = TreeViewDrawMode.OwnerDrawAll
AssetTree.CheckBoxes = True
End Sub
Private Sub frmAssetsViewer_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
' If we have no assets, then refresh the table to show that
If SelectedCharacter.GetAssets.GetAssetCount = 0 Then
Call RefreshTree()
End If
End Sub
Private Sub frmAssetsViewer_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown
Call InitForm()
End Sub
' Initialize the form based on user settings
Private Sub InitForm()
Application.DoEvents()
FirstLoad = True
btnToggleExpand.Visible = True
btnToggleRetract.Visible = False
Timer1.Interval = 1000 ' 1 second
Timer1.Enabled = True
FirstPriceChargeTypesComboLoad = True
FirstPriceShipTypesComboLoad = True
btnScanCorpAssets.Enabled = False
btnScanPersonalAssets.Enabled = False
' Create the controls collection class
m_ControlsCollection = New ControlsCollection(Me)
' Get Region check boxes (note index starts at 1)
TechCheckBoxes = DirectCast(ControlArrayUtils.getControlArray(Me, Me.MyControls, "chkItemsT"), CheckBox())
' Main form
Select Case SelectedSettings.AssetType
Case rbtnAllAssets.Text
rbtnAllAssets.Checked = True
Case rbtnPersonalAssets.Text
rbtnPersonalAssets.Checked = True
Case rbtnCorpAssets.Text
rbtnCorpAssets.Checked = True
End Select
If SelectedSettings.SortbyName Then
rbtnSortName.Checked = True
Else
rbtnSortQuantity.Checked = True
End If
lblReloadCorpAssets.Text = "---"
lblReloadPersonalAssets.Text = "---"
If UserApplicationSettings.ShowToolTips Then
ttMain.SetToolTip(btnToggleExpand, "Expand all Assets")
ttMain.SetToolTip(btnToggleRetract, "Retract all Assets")
ttMain.SetToolTip(chkToggle, "Check/Uncheck all Assets")
End If
' Search settings form
If SelectedSettings.AllItems Then
rbtnAllItems.Checked = True
Else
rbtnBPMats.Checked = True
End If
txtItemFilter.Text = SelectedSettings.ItemFilterText
' Load the search settings
With SelectedSettings
chkRawMaterialItems.Checked = .AllRawMats
chkMinerals.Checked = .Minerals
chkIceProducts.Checked = .IceProducts
chkGas.Checked = .Gas
chkAbyssalMaterials.Checked = .AbyssalMaterials
chkMisc.Checked = .Misc
chkBPCs.Checked = .BPCs
chkAncientRelics.Checked = .AncientRelics
chkAncientSalvage.Checked = .AncientSalvage
chkSalvage.Checked = .Salvage
chkPlanetary.Checked = .Planetary
chkDatacores.Checked = .Datacores
chkDecryptors.Checked = .Decryptors
chkRawMats.Checked = .RawMats
chkProcessedMats.Checked = .ProcessedMats
chkAdvancedMats.Checked = .AdvancedMats
chkMatsandCompounds.Checked = .MatsandCompounds
chkDroneComponents.Checked = .DroneComponents
chkBoosterMats.Checked = .BoosterMats
chkPolymers.Checked = .Polymers
chkAsteroids.Checked = .Asteroids
chkManufacturedItems.Checked = .AllManufacturedItems
chkShips.Checked = .Ships
chkModules.Checked = .Modules
chkDrones.Checked = .Drones
chkBoosters.Checked = .Boosters
chkRigs.Checked = .Rigs
chkCharges.Checked = .Charges
chkSubsystems.Checked = .Subsystems
chkStructures.Checked = .Structures
chkTools.Checked = .Tools
chkCelestials.Checked = .Celestials
chkDeployables.Checked = .Deployables
chkImplants.Checked = .Implants
chkStructureRigs.Checked = .StructureRigs
chkStructureModules.Checked = .StructureModules
chkDataInterfaces.Checked = .DataInterfaces
chkCapT2Components.Checked = .CapT2Components
chkCapitalComponents.Checked = .CapitalComponents
chkComponents.Checked = .Components
chkHybrid.Checked = .Hybrid
chkFuelBlocks.Checked = .FuelBlocks
chkItemsT1.Checked = .T1
chkItemsT2.Checked = .T2
chkItemsT3.Checked = .T3
chkItemsT4.Checked = .Storyline
chkItemsT5.Checked = .Faction
chkItemsT6.Checked = .Pirate
End With
FirstLoad = False
' Everything will be just normal at first - add to settings for the format they save? Also, check the locations they have checked only TODO-AV!
ToggleAllOpen = False
Call RefreshTree()
End Sub
' Returns true if an selected item is checked
Private Function ItemsChecked() As Boolean
If chkMinerals.Checked Then
Return True
ElseIf chkIceProducts.Checked Then
Return True
ElseIf chkGas.Checked Then
Return True
ElseIf chkAbyssalMaterials.Checked Then
Return True
ElseIf chkMisc.Checked Then
Return True
ElseIf chkBPCs.Checked Then
Return True
ElseIf chkAncientRelics.Checked Then
Return True
ElseIf chkAncientSalvage.Checked Then
Return True
ElseIf chkSalvage.Checked Then
Return True
ElseIf chkStructureRigs.Checked Then
Return True
ElseIf chkPlanetary.Checked Then
Return True
ElseIf chkDatacores.Checked Then
Return True
ElseIf chkDecryptors.Checked Then
Return True
ElseIf chkRawMats.Checked Then
Return True
ElseIf chkProcessedMats.Checked Then
Return True
ElseIf chkAdvancedMats.Checked Then
Return True
ElseIf chkMatsandCompounds.Checked Then
Return True
ElseIf chkDroneComponents.Checked Then
Return True
ElseIf chkBoosterMats.Checked Then
Return True
ElseIf chkPolymers.Checked Then
Return True
ElseIf chkAsteroids.Checked Then
Return True
ElseIf chkShips.Checked Then
Return True
ElseIf chkModules.Checked Then
Return True
ElseIf chkDrones.Checked Then
Return True
ElseIf chkBoosters.Checked Then
Return True
ElseIf chkRigs.Checked Then
Return True
ElseIf chkCharges.Checked Then
Return True
ElseIf chkSubsystems.Checked Then
Return True
ElseIf chkStructures.Checked Then
Return True
ElseIf chkTools.Checked Then
Return True
ElseIf chkDataInterfaces.Checked Then
Return True
ElseIf chkCapT2Components.Checked Then
Return True
ElseIf chkCapitalComponents.Checked Then
Return True
ElseIf chkComponents.Checked Then
Return True
ElseIf chkHybrid.Checked Then
Return True
ElseIf chkFuelBlocks.Checked Then
Return True
ElseIf chkStructureRigs.Checked Then
Return True
ElseIf chkCelestials.Checked Then
Return True
ElseIf chkDeployables.Checked Then
Return True
ElseIf chkImplants.Checked Then
Return True
End If
' If we got here, nothing checked
Return False
End Function
' Main function that refresh's the tree
Public Sub RefreshTree()
Dim BaseNode As New TreeNode
Dim SortOption As SortType
Dim SearchItemList As List(Of Long)
Dim OnlyBPCs As Boolean ' Pass through if the BPIDs we sent need to only be shown if a copy
Application.UseWaitCursor = True
Application.DoEvents()
' Make sure they have an item selected
If Not ItemsChecked() And Not rbtnAllItems.Checked Then
MsgBox("You must select an item category to display.", vbExclamation, Application.ProductName)
tabMain.SelectedTab = tabSearchSettings
Me.Cursor = Cursors.Default
Application.UseWaitCursor = False
Exit Sub
End If
' Set the tree object
AssetTree.Update()
AssetTree.Nodes.Clear()
If rbtnSortName.Checked Then
SortOption = SortType.Name
ElseIf rbtnSortQuantity.Checked Then
SortOption = SortType.Quantity
End If
' Get the list based on options selected, if not all or if all, they have a text item to search
If rbtnBPMats.Checked Or Trim(txtItemFilter.Text) <> "" Then
SearchItemList = GetSearchItemsList(rbtnAllItems.Checked)
Else
SearchItemList = New List(Of Long) ' set to a blank list
End If
' Set OnlyBPCs
If chkBPCs.Checked And rbtnBPMats.Checked Then
OnlyBPCs = True
Else
OnlyBPCs = False
End If
' Add the base node
AnchorNode = AssetTree.Nodes.Add("Asset List")
' If we get nothing back from the search item list, then just clear the assets and exit - we have no items to display
If IsNothing(SearchItemList) Then
AssetTree.EndUpdate()
AssetTree.Refresh()
Application.UseWaitCursor = False
Application.DoEvents()
MsgBox("No items found.", vbInformation, Application.ProductName)
Me.Refresh()
Exit Sub
End If
' Get the base node of the full tree (may want to save these options globally so we don't need to load them every time)
If rbtnPersonalAssets.Checked Or rbtnAllAssets.Checked Then
BaseNode = SelectedCharacter.GetAssets.GetAssetTreeAnchorNode(SortOption, SearchItemList, "Personal Assets", SelectedCharacter.ID, SavedLocationIDs, OnlyBPCs)
' Need to add it to the tree but as a clone
AnchorNode.Nodes.Add(CType(BaseNode.Clone, TreeNode))
End If
If rbtnCorpAssets.Checked Or rbtnAllAssets.Checked Then
BaseNode = SelectedCharacter.CharacterCorporation.GetAssets.GetAssetTreeAnchorNode(SortOption, SearchItemList, "Corporation Assets", SelectedCharacter.CharacterCorporation.CorporationID, SavedLocationIDs, OnlyBPCs)
' Need to add it to the tree but as a clone
AnchorNode.Nodes.Add(CType(BaseNode.Clone, TreeNode))
End If
' Update
AssetTree.EndUpdate()
AssetTree.Refresh()
' Open up the top node and the personal/corp nodes. Plus reset toggle since we just reloaded
ToggleAllOpen = False
AssetTree.TopNode.Expand()
AssetTree.Nodes(0).Nodes(0).Expand()
If rbtnAllAssets.Checked Then
AssetTree.Nodes(0).Nodes(1).Expand()
End If
' Expand all parents for check boxes that have values checked
Call ExpandCheckedNodes(AssetTree.Nodes(0).Nodes, AssetTree)
' Scroll to top
AssetTree.TopNode = AssetTree.Nodes(0)
Application.UseWaitCursor = False
Application.DoEvents()
Me.Refresh()
End Sub
Private Sub ExpandCheckedNodes(NodeSet As TreeNodeCollection, ByRef BaseTree As TreeView)
Dim node As New TreeNode
For Each node In NodeSet
FindCheckedNode(node, BaseTree)
Next
End Sub
Private Sub FindCheckedNode(SentNode As TreeNode, ByRef BaseTree As TreeView)
Dim tn As TreeNode
For Each tn In SentNode.Nodes
If tn.Checked = True Then
BaseTree.SelectedNode = tn
BaseTree.SelectedNode.Parent.Expand()
End If
FindCheckedNode(tn, BaseTree)
Next
End Sub
' Gets TypeIDs for items we only want to see in the asset tree from stuff we can set a price for
Private Function GetSearchItemsList(SearchAllItems As Boolean) As List(Of Long)
Dim ItemIDList As New List(Of Long)
Dim readerMats As SQLiteDataReader
Dim SQL As String
Dim TechSQL As String = ""
Dim TechChecked As Boolean = False
Dim ItemChecked As Boolean = False
' Working
Me.Cursor = Cursors.WaitCursor
Application.DoEvents()
' If we want all items, look in inventory types with links to groups/categories
If SearchAllItems Then
' Get the item id from prices, since these are items we can set a price for and will be used in building items
SQL = "SELECT typeID AS ITEM_ID FROM INVENTORY_TYPES, INVENTORY_GROUPS, INVENTORY_CATEGORIES "
SQL = SQL & "WHERE INVENTORY_TYPES.groupID = INVENTORY_GROUPS.groupID "
SQL = SQL & "AND INVENTORY_GROUPS.categoryID = INVENTORY_CATEGORIES.categoryID "
' Search based on text
If txtItemFilter.Text <> "" Then
SQL = SQL & " AND typeName LIKE '%" & FormatDBString(Trim(txtItemFilter.Text)) & "%' "
End If
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
readerMats = DBCommand.ExecuteReader
' Fill list
While readerMats.Read
Call ItemIDList.Add(readerMats.GetInt64(0))
End While
readerMats.Close()
readerMats = Nothing
DBCommand = Nothing
Else
' Want just building materials (from prices)
' Get the item id from prices, since these are items we can set a price for and will be used in building items
SQL = "SELECT ITEM_ID FROM ITEM_PRICES, INVENTORY_TYPES"
SQL = SQL & " WHERE ITEM_PRICES.ITEM_ID = INVENTORY_TYPES.typeID AND ("
' Raw materials - non-manufacturable
If chkMinerals.Checked Then
SQL = SQL & "ITEM_GROUP = 'Mineral' OR "
ItemChecked = True
End If
If chkIceProducts.Checked Then
SQL = SQL & "ITEM_GROUP = 'Ice Product' OR "
ItemChecked = True
End If
If chkPlanetary.Checked Then
SQL = SQL & "(ITEM_CATEGORY LIKE 'Planetary%' OR ITEM_NAME IN ('Oxygen','Water')) OR "
ItemChecked = True
End If
If chkDatacores.Checked Then
SQL = SQL & "ITEM_GROUP = 'Datacores' OR "
ItemChecked = True
End If
If chkDecryptors.Checked Then
SQL = SQL & "ITEM_GROUP LIKE '%Decryptor%' OR " ' Storyline decryptors are category 'Commodity'
ItemChecked = True
End If
If chkGas.Checked Then
SQL = SQL & "ITEM_GROUP = 'Harvestable Cloud' OR "
ItemChecked = True
End If
'If chkAbyssalMaterials.Checked Then
' SQL = SQL & "ITEM_GROUP = 'Abyssal Materials' OR "
' ItemChecked = True
'End If
If chkBPCs.Checked Then
SQL = SQL & "ITEM_CATEGORY = 'Blueprint' OR "
ItemChecked = True
End If
If chkMisc.Checked Then
SQL = SQL & "(" & "ITEM_GROUP IN ('General','Livestock','Abyssal Materials','Radioactive','Biohazard','Commodities', 'Miscellaneous') AND ITEM_NAME NOT IN ('Oxygen','Water')) OR "
ItemChecked = True
End If
If chkSalvage.Checked Then
SQL = SQL & "ITEM_GROUP = 'Salvaged Materials' OR "
ItemChecked = True
End If
If chkAncientSalvage.Checked Then
SQL = SQL & "ITEM_GROUP = 'Ancient Salvage' OR "
ItemChecked = True
End If
If chkAncientRelics.Checked Then
SQL = SQL & "ITEM_CATEGORY = 'Ancient Relics' OR "
ItemChecked = True
End If
If chkPolymers.Checked Then
SQL = SQL & "ITEM_GROUP = 'Hybrid Polymers' OR "
ItemChecked = True
End If
If chkRawMats.Checked Then
SQL = SQL & "ITEM_GROUP = 'Moon Materials' OR "
ItemChecked = True
End If
If chkProcessedMats.Checked Then
SQL = SQL & "ITEM_GROUP = 'Intermediate Materials' OR "
ItemChecked = True
End If
If chkAdvancedMats.Checked Then
SQL = SQL & "ITEM_GROUP = 'Composite' OR "
ItemChecked = True
End If
If chkMatsandCompounds.Checked Then
SQL = SQL & "ITEM_GROUP IN ('Materials and Compounds', 'Artifacts and Prototypes') OR "
ItemChecked = True
End If
If chkDroneComponents.Checked Then
SQL = SQL & "ITEM_GROUP = 'Rogue Drone Components' OR ITEM_NAME = 'Elite Drone AI' OR "
ItemChecked = True
End If
If chkBoosterMats.Checked Then
SQL = SQL & "ITEM_GROUP = 'Biochemical Material' OR "
ItemChecked = True
End If
If chkStructureModules.Checked Then
SQL = SQL & "(ITEM_CATEGORY = 'Structure Module' AND ITEM_GROUP NOT LIKE '%Rig%') OR "
ItemChecked = True
End If
If chkStructureRigs.Checked Then
SQL = SQL & "ITEM_CATEGORY = 'Structure Rigs' OR "
ItemChecked = True
End If
If chkAsteroids.Checked Then
SQL = SQL & "ITEM_CATEGORY = 'Asteroid' OR "
ItemChecked = True
End If
' Other Manufacturables
If chkCapT2Components.Checked Then
SQL = SQL & "ITEM_GROUP = 'Advanced Capital Construction Components' OR "
ItemChecked = True
End If
If chkCapitalComponents.Checked Then
SQL = SQL & "ITEM_GROUP = 'Capital Construction Components' OR "
ItemChecked = True
End If
If chkComponents.Checked Then
SQL = SQL & "ITEM_GROUP = 'Construction Components' OR "
ItemChecked = True
End If
If chkHybrid.Checked Then
SQL = SQL & "ITEM_GROUP = 'Hybrid Tech Components' OR "
ItemChecked = True
End If
If chkTools.Checked Then
SQL = SQL & "ITEM_GROUP = 'Tool' OR "
ItemChecked = True
End If
If chkDataInterfaces.Checked Then
SQL = SQL & "ITEM_GROUP = 'Data Interfaces' OR "
ItemChecked = True
End If
If chkFuelBlocks.Checked Then
SQL = SQL & "ITEM_GROUP = 'Fuel Block' OR "
ItemChecked = True
End If
If chkImplants.Checked Then
SQL = SQL & "ITEM_GROUP = 'Cyberimplant' OR "
ItemChecked = True
End If
If chkDeployables.Checked Then
SQL = SQL & "ITEM_CATEGORY = 'Deployable' OR "
ItemChecked = True
End If
If chkCelestials.Checked Then
SQL = SQL & "(ITEM_CATEGORY IN ('Celestial','Orbitals','Sovereignty Structures', 'Station','Accessories','Infrastructure Upgrades') AND ITEM_GROUP <> 'Harvestable Cloud') OR "
ItemChecked = True
End If
' Manufactured Items
If (chkShips.Checked Or chkModules.Checked Or chkDrones.Checked Or chkBoosters.Checked Or chkRigs.Checked Or chkSubsystems.Checked Or chkStructures.Checked Or chkCharges.Checked) Then
' Make sure we have at least one tech checked that is enabled
TechChecked = CheckTechChecks()
If Not TechChecked And Not ItemChecked Then
' There isn't an item checked before this and these items all require tech, so exit
ItemChecked = False
Else
ItemChecked = True
End If
' If they choose a tech level, then build this part of the SQL query
If TechChecked Then
If PriceCheckT1Enabled Then
If chkItemsT1.Checked Then
' Add to SQL query for tech level
TechSQL = TechSQL & "ITEM_TYPE = 1 OR "
End If
End If
If PriceCheckT2Enabled Then
If chkItemsT2.Checked Then
' Add to SQL query for tech level
TechSQL = TechSQL & "ITEM_TYPE = 2 OR "
End If
End If
If PriceCheckT3Enabled Then
If chkItemsT3.Checked Then
' Add to SQL query for tech level
TechSQL = TechSQL & "ITEM_TYPE = 14 OR "
End If
End If
' Add the Pirate, Storyline, Navy search string
' Storyline
If PriceCheckT4Enabled Then
If chkItemsT4.Checked Then
' Add to SQL query for tech level
TechSQL = TechSQL & "ITEM_TYPE = 3 OR "
End If
End If
' Navy
If PriceCheckT5Enabled Then
If chkItemsT5.Checked Then
' Add to SQL query for tech level
TechSQL = TechSQL & "ITEM_TYPE = 16 OR "
End If
End If
' Pirate
If PriceCheckT6Enabled Then
If chkItemsT6.Checked Then
' Add to SQL query for tech level
TechSQL = TechSQL & "ITEM_TYPE = 15 OR "
End If
End If
' Format TechSQL - Add on Meta codes
If TechSQL <> "" Then
TechSQL = "(" & TechSQL.Substring(0, TechSQL.Length - 3) & " OR ITEM_NAME IN (21,22,23,24))"
End If
' Build Tech 1,2,3 Manufactured Items
If chkCharges.Checked Then
SQL = SQL & "(ITEM_CATEGORY= 'Charge' AND " & TechSQL
If cmbPriceChargeTypes.Text <> "All Charge Types" Then
SQL = SQL & " AND ITEM_GROUP = '" & cmbPriceChargeTypes.Text & "'"
End If
SQL = SQL & ") OR "
End If
If chkDrones.Checked Then
SQL = SQL & "(ITEM_CATEGORY IN ('Drone', 'Fighter') AND " & TechSQL & ") OR "
End If
If chkModules.Checked Then ' Not rigs but Modules
SQL = SQL & "(ITEM_CATEGORY IN ('Module', 'Deployable') AND " & "ITEM_GROUP NOT LIKE 'Rig%' AND " & TechSQL & ") OR "
End If
If chkShips.Checked Then
SQL = SQL & "(ITEM_CATEGORY= 'Ship' AND " & TechSQL
If cmbPriceShipTypes.Text <> "All Ship Types" Then
SQL = SQL & " AND ITEM_GROUP = '" & cmbPriceShipTypes.Text & "'"
End If
SQL = SQL & ") OR "
End If
If chkSubsystems.Checked Then
SQL = SQL & "(ITEM_CATEGORY= 'Subsystem' AND " & TechSQL & ") OR "
End If
If chkBoosters.Checked Then
SQL = SQL & "(ITEM_GROUP = 'Booster' AND " & TechSQL & ") OR "
End If
If chkRigs.Checked Then ' Rigs
SQL = SQL & "(ITEM_CATEGORY = 'Module' AND ITEM_GROUP LIKE 'Rig%' AND " & TechSQL & ") OR "
End If
If chkStructures.Checked Then
SQL = SQL & "((ITEM_CATEGORY IN ('Starbase','Structure') AND " & TechSQL & ") OR ITEM_GROUP = 'Station Components') OR "
End If
Else
' No tech level chosen, so just continue with other options and skip these that require a tech selection
End If
End If
' Leave function if no items checked
If ItemChecked Then
' Take off last OR and add the final )
SQL = SQL.Substring(0, SQL.Length - 4)
SQL = SQL & ")"
' Search based on text
If txtItemFilter.Text <> "" Then
SQL = SQL & " AND ITEM_NAME LIKE '%" & FormatDBString(Trim(txtItemFilter.Text)) & "%' "
End If
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
readerMats = DBCommand.ExecuteReader
' Fill list
While readerMats.Read
Call ItemIDList.Add(readerMats.GetInt64(0))
End While
readerMats.Close()
readerMats = Nothing
DBCommand = Nothing
End If
' Blueprint Copies
If chkBPCs.Checked And Not SearchAllItems Then
' Look up the typeIDs for all BPs and add them to the list
SQL = "SELECT BLUEPRINT_ID, ITEM_NAME FROM ALL_BLUEPRINTS "
' Search based on text
If txtItemFilter.Text <> "" Then
SQL = SQL & " WHERE ITEM_NAME LIKE '%" & FormatDBString(Trim(txtItemFilter.Text)) & "%' "
End If
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
readerMats = DBCommand.ExecuteReader
' Fill list
While readerMats.Read
Call ItemIDList.Add(readerMats.GetInt64(0))
End While
readerMats.Close()
readerMats = Nothing
DBCommand = Nothing
End If
End If
Me.Cursor = Cursors.Default
Application.DoEvents()
' If we have no items to return, then return nothing not a blank list
If ItemIDList.Count = 0 Then
Return Nothing
Else
Return ItemIDList
End If
End Function
' Just loads the assets from API then DB
Private Sub ScanForAssets(ByVal BPScanType As ScanType)
' New scan, so run update and reload assets
If BPScanType = ScanType.Personal Then
SelectedCharacter.GetAssets.LoadAssets(SelectedCharacter.ID, SelectedCharacter.CharacterTokenData, True)
Else
SelectedCharacter.CharacterCorporation.GetAssets.LoadAssets(SelectedCharacter.CharacterCorporation.CorporationID,
SelectedCharacter.CharacterTokenData, True)
End If
' Reload the tree
Call RefreshTree()
End Sub
' Will use CAK and scan for bps in the user's items and store a temp table of these bps for loading in the grid
Private Sub btnScanPersonalBPs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScanPersonalAssets.Click
RefreshAssetButton = True
Me.Cursor = Cursors.WaitCursor
If rbtnAllAssets.Checked = False Then
rbtnPersonalAssets.Checked = True
End If
Application.DoEvents()
If SelectedCharacter.AssetsAccess Then
Call ScanForAssets(ScanType.Personal)
Else
MsgBox("You have not enabled access to Assets with this key.", vbExclamation, Application.ProductName)
End If
Me.Cursor = Cursors.Default
Application.DoEvents()
RefreshAssetButton = False
End Sub
' Will use CAK and scan for bps in the corps items and store a temp table of these bps for loading in the grid
Private Sub btnScanCorpBPs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScanCorpAssets.Click
RefreshAssetButton = True
Me.Cursor = Cursors.WaitCursor
If rbtnAllAssets.Checked = False Then
rbtnCorpAssets.Checked = True
End If
Application.DoEvents()
If SelectedCharacter.CharacterCorporation.AssetAccess Then
Call ScanForAssets(ScanType.Corporation)
Else
MsgBox("You do not have a corporation key installed with access to Assets.", vbExclamation, Application.ProductName)
End If
Me.Cursor = Cursors.Default
Application.DoEvents()
RefreshAssetButton = False
End Sub
' Displays the time remaining on refreshing assets
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Dim TempTime As Long
' On each tick just update the labels
If SelectedCharacter.AssetsAccess Then
TempTime = DateDiff(DateInterval.Second, Date.UtcNow, SelectedCharacter.GetAssets.CachedUntil)
If TempTime <= 0 Then
lblReloadPersonalAssets.Text = "Now"
Else
lblReloadPersonalAssets.Text = FormatTimeToComplete(TempTime)
End If
Else
lblReloadPersonalAssets.Text = "No Access"
End If
If lblReloadPersonalAssets.Text = "Now" Then
' Enable refresh button
btnScanPersonalAssets.Enabled = True
Else
btnScanPersonalAssets.Enabled = False
End If
If SelectedCharacter.CharacterCorporation.AssetAccess Then
TempTime = DateDiff(DateInterval.Second, Date.UtcNow, SelectedCharacter.CharacterCorporation.GetAssets.CachedUntil)
If TempTime <= 0 Then
lblReloadCorpAssets.Text = "Now"
Else
lblReloadCorpAssets.Text = FormatTimeToComplete(TempTime)
End If
Else
lblReloadCorpAssets.Text = "No Access"
End If
If lblReloadCorpAssets.Text = "Now" Then
' Enable refresh button
btnScanCorpAssets.Enabled = True
Else
btnScanCorpAssets.Enabled = False
End If
End Sub
' Saves the settings on the Selected Items Form for later loading
Private Sub btnSaveSettings_Click(sender As System.Object, e As System.EventArgs) Handles btnSaveSettings.Click
Call SaveWindowSettings()
End Sub
' Saves the main settings for the general form
Private Sub btnSaveMainSettings_Click(sender As System.Object, e As System.EventArgs) Handles btnSaveMainSettings.Click
Call SaveWindowSettings()
End Sub
' Saves the settings on both tabs for the asset window
Private Sub SaveWindowSettings()
Dim TempSettings As AssetWindowSettings = Nothing
Dim TempLocationIDs As New List(Of Long)
Dim SQL As String
With TempSettings
.SortbyName = rbtnSortName.Checked
If rbtnAllAssets.Checked Then
.AssetType = rbtnAllAssets.Text
ElseIf rbtnPersonalAssets.Checked Then
.AssetType = rbtnPersonalAssets.Text
ElseIf rbtnCorpAssets.Checked Then
.AssetType = rbtnCorpAssets.Text
End If
If rbtnAllItems.Checked Then
.AllItems = True
Else
.AllItems = False
End If
.AllRawMats = chkRawMaterialItems.Checked
.Minerals = chkMinerals.Checked
.IceProducts = chkIceProducts.Checked
.Gas = chkGas.Checked
.AbyssalMaterials = chkAbyssalMaterials.Checked
.Misc = chkMisc.Checked
.BPCs = chkBPCs.Checked
.AncientRelics = chkAncientRelics.Checked
.AncientSalvage = chkAncientSalvage.Checked
.Salvage = chkSalvage.Checked
.StructureRigs = chkStructureRigs.Checked
.StructureModules = chkStructureModules.Checked
.Planetary = chkPlanetary.Checked
.Datacores = chkDatacores.Checked
.Decryptors = chkDecryptors.Checked
.RawMats = chkRawMats.Checked
.ProcessedMats = chkProcessedMats.Checked
.AdvancedMats = chkAdvancedMats.Checked
.MatsandCompounds = chkMatsandCompounds.Checked
.DroneComponents = chkDroneComponents.Checked
.BoosterMats = chkBoosterMats.Checked
.Polymers = chkPolymers.Checked
.Asteroids = chkAsteroids.Checked
.AllManufacturedItems = chkManufacturedItems.Checked
.Ships = chkShips.Checked
.Modules = chkModules.Checked
.Drones = chkDrones.Checked
.Boosters = chkBoosters.Checked
.Rigs = chkRigs.Checked
.Charges = chkCharges.Checked
.Subsystems = chkSubsystems.Checked
.Structures = chkStructures.Checked
.Tools = chkTools.Checked
.DataInterfaces = chkDataInterfaces.Checked
.CapT2Components = chkCapT2Components.Checked
.CapitalComponents = chkCapitalComponents.Checked
.Components = chkComponents.Checked
.Hybrid = chkHybrid.Checked