forked from lee-soft/ViPad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViPickWindow.frm
2519 lines (1789 loc) · 71.5 KB
/
ViPickWindow.frm
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
VERSION 5.00
Begin VB.Form ViPickWindow
AutoRedraw = -1 'True
BackColor = &H00000000&
BorderStyle = 0 'None
Caption = " "
ClientHeight = 4140
ClientLeft = -1395
ClientTop = 19860
ClientWidth = 4620
Icon = "ViPickWindow.frx":0000
LinkTopic = "Form2"
ScaleHeight = 276
ScaleMode = 3 'Pixel
ScaleWidth = 308
ShowInTaskbar = 0 'False
Tag = "00"
Visible = 0 'False
Begin VB.Timer timTurnOfKeepOnTop
Enabled = 0 'False
Interval = 100
Left = 7920
Top = 8880
End
Begin VB.Timer timHoldCount
Enabled = 0 'False
Interval = 100
Left = 9600
Top = 8880
End
Begin VB.Timer timSlideAnimation
Enabled = 0 'False
Interval = 5
Left = 9120
Top = 8880
End
End
Attribute VB_Name = "ViPickWindow"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'
'
'
Option Explicit
Public lpPrevWndProc As Long
Public UniqueID As String
Private m_itemOptionsMenu As ContextMenu
Private m_itemTabsMenu As ContextMenu
Private m_itemTabsMenuCopy As ContextMenu
Private WithEvents m_glassWindow As GlassContainer
Attribute m_glassWindow.VB_VarHelpID = -1
Private m_layeredAttributes As LayerdWindowHandles
Private m_trayMenu As ContextMenu
Private m_defaultMenu As ContextMenu
Private m_ignoreClick As Boolean
Private WithEvents m_header As ViPickHeader
Attribute m_header.VB_VarHelpID = -1
Private WithEvents m_optionsWindow As OptionsWindow
Attribute m_optionsWindow.VB_VarHelpID = -1
Private WithEvents m_trayIcon As TrayIcon
Attribute m_trayIcon.VB_VarHelpID = -1
Private WithEvents m_urlCatcher As URLNotification
Attribute m_urlCatcher.VB_VarHelpID = -1
Private WithEvents m_pageSelector As PageSelector
Attribute m_pageSelector.VB_VarHelpID = -1
Private Const IDMNU_EDIT As Long = 1
Private Const IDMNU_DELETE As Long = 2
Private Const IDMNU_TABMOVE As Long = 100
Private Const IDMNU_TABCOPY As Long = 200
Private Const IDMNU_RESTORE As Long = 1
Private Const IDMNU_EXIT As Long = 2
Private Const IDMNU_SETTINGS As Long = 3
Private Const IDMNU_ABOUT As Long = 4
Private Const IDMNU_QUIT As Long = 5
Private m_blankItem As LaunchPadItem
Private m_dragItem As LaunchPadItem
Private m_currentItems As Collection
Private m_previousItems As Collection
Private m_searchMode As Boolean
Private m_itemBank As ViBank
Private m_pickGrids As Collection
Private m_activePickGridIndex As Long
Private m_graphics As GDIPGraphics
Private m_fontFamily As GDIPFontFamily
Private m_font As GDIPFont
Private m_blackBrush As GDIPBrush
Private m_whiteBrush As GDIPBrush
Private m_rollOver As GDIPGraphicPath
Private m_rowCapacity As Long
Private m_totalCapacity As Long
Private m_columnCapacity As Long
Private m_selectedItemIndex As Long
Private m_selectedItem As LaunchPadItem
Private m_tempLinkPath As String
Private m_singleInstanceCollection As Collection
Private m_selectedItemIsEmpty As Boolean
Private m_pivotToIndex As Long
Private m_finalX As Long
Private m_oldSelectedItemIndex As Long
Private m_systemId As String
Private m_windowDimensions As win.SIZEL
Private Const X_MARGIN As Long = 50
Private Const Y_MARGIN As Long = 12
Private Const PAGE_SELECTOR_GAP As Long = 24
Private Const X_ICON_GAP As Long = 80
Private Const Y_ICON_GAP As Long = 90
Private Const ICON_SIZE As Long = 70
Private Const ITEM_TEXT_SIZE As Single = 12.5
Private Const WM_TaskbarRClick As Long = &H313
'Private Const WM_NCHITTEST As Long = &H84
Private m_drawCapY As Long
Private newPen As GDIPPen
Private m_testX As Long
Private m_currentBitmap As New GDIPBitmap
Private m_currentBitmap_XOffset As Long
Private m_xSlideSpeed As Long
Private m_mouseXOffset As Long
Private m_mouseYOffset As Long
'Current Mouse Co-ordinates (relative to form)
Private m_mouseX As Single
Private m_mouseY As Single
Private m_lastReportedX As Single
Private m_lastReportedY As Single
Private m_holdTicker As Long
'Drag offsets, sets the offset amount for the dragged item
Private m_dragOffsetX As Long
Private m_dragOffsetY As Long
Private m_contextMenuOpen As Boolean
Private m_IconSize As Long
Private m_panelIndex As Long
Private m_dragMode As Boolean
Private m_DefaultBrowserCommand As String
Private m_defaultBrowserIcon As String
Private m_showURLCatcher As Boolean
Private m_showHeader As Boolean
Private m_headerOffset As Single
Private m_gridOffsetX As Long
Private m_padChanged As Boolean
Private m_glassApplied As Boolean
Private m_glassMode As Boolean
Private m_firstTime As Boolean
Private m_searchResults As Collection
Private m_masterCollection As Collection
Private m_myTab As ViTab
Private WithEvents m_searchTextBox As SearchTextBox
Attribute m_searchTextBox.VB_VarHelpID = -1
Implements IHookSink
'for slide animation, draw all images to one big image, and then slide this way
'seperate drawing text and graphics, so that you can redraw text rollover quick and avoid redrawing graphcs
Public Property Get GlassContainer() As GlassContainer
Set GlassContainer = m_glassWindow
End Property
Public Function zOrderWindow() As Boolean
If Not m_glassWindow Is Nothing Then
m_glassWindow.ZOrder
Me.ZOrder
'zOrderGlassIfPossible = True
Else
Me.ZOrder
End If
End Function
Public Function SetSelectedTab(ByRef newViTab As ViTab)
Set m_myTab = newViTab
Me.UniqueID = newViTab.SharedViPadIdentifer
Set m_singleInstanceCollection = m_myTab.Children
Set m_currentItems = m_singleInstanceCollection
m_header.SetSingleInstanceMode m_myTab.Alias
If Not Config.DockMode Then
m_showHeader = True
m_headerOffset = 30
m_header.Y = 0
m_header.WindowWidth = m_windowDimensions.cx
End If
PositionItems
ReDraw
End Function
Private Sub DrawStarterHint()
Dim A As POINTF
'm_graphics.DrawString "Drag items here to begin!", m_font, m_blackBrush, A
End Sub
Private Sub SetupGrid(ByRef thisGrid As PickGrid)
Dim newWindowSize As SIZEL
newWindowSize.Height = m_windowDimensions.cy
newWindowSize.Width = m_windowDimensions.cx
thisGrid.WindowSize = newWindowSize
End Sub
Private Sub PositionItems()
If m_currentItems Is Nothing Then Exit Sub
Dim rowIndex As Long: rowIndex = 0
Dim columnIndex As Long: columnIndex = 0
Dim ItemIndex As Long: ItemIndex = 0
Dim itemCount As Long: itemCount = 0
Dim thisItem As LaunchPadItem
Dim rectTextPosition As RECTF
Dim rectTextPosition2 As RECTF
Dim A As Long
Dim thisPickGrid As PickGrid
GdipCreateStringFormat 0, 0, A
GdipSetStringFormatAlign A, StringAlignmentCenter
Set m_pickGrids = New Collection
While itemCount <= m_currentItems.Count
Set thisPickGrid = New PickGrid
Set thisPickGrid.Items = New Collection
m_pickGrids.Add thisPickGrid
SetupGrid thisPickGrid
For rowIndex = 0 To (m_rowCapacity - 1)
For columnIndex = 0 To (m_columnCapacity - 1)
ItemIndex = ItemIndex + 1
If (itemCount + ItemIndex) <= m_currentItems.Count Then
Set thisItem = m_currentItems(itemCount + ItemIndex)
thisPickGrid.Items.Add thisItem
thisItem.X = (columnIndex * (X_ICON_GAP + m_IconSize)) + X_MARGIN
thisItem.Y = (rowIndex * (Y_ICON_GAP + m_IconSize)) + Y_MARGIN
rectTextPosition = GetTextItemRect(thisItem)
rectTextPosition2.Left = rectTextPosition.Left + 1
rectTextPosition2.Top = rectTextPosition.Top + 1
rectTextPosition2.Height = rectTextPosition.Height
rectTextPosition2.Width = rectTextPosition.Width
thisPickGrid.BlackTextGP.AddString thisItem.Caption, m_fontFamily, FontStyle.FontStyleBold, ITEM_TEXT_SIZE, rectTextPosition2, A
thisPickGrid.WhiteTextGP.AddString thisItem.Caption, m_fontFamily, FontStyle.FontStyleBold, ITEM_TEXT_SIZE, rectTextPosition, A
End If
Next
Next
itemCount = itemCount + ItemIndex
If m_drawCapY = 0 Then m_drawCapY = ItemIndex
ItemIndex = 0
Wend
If thisPickGrid.Items.Count = 0 Then
m_pickGrids.Remove m_pickGrids.Count
End If
m_pageSelector.MaxPage = m_pickGrids.Count
m_pageSelector.X = (m_windowDimensions.cx / 2) - (m_pageSelector.Width / 2)
'Debug.Print "m_pickGrids:: " & m_pickGrids.count
'm_drawCapY = itemIndex
GdipDeleteStringFormat A
End Sub
Private Function PrepareRollover()
Debug.Print "PrepareRollover!"
If m_currentBitmap_XOffset <> m_finalX And m_currentBitmap_XOffset <> -m_finalX Then Exit Function
Dim thisItem As LaunchPadItem
Dim thisTextItemWidth As Long
Dim thisTextItemRect As RECTF
Dim centeredStartX As Single
Dim lineCount As Long
On Error GoTo Handler
If m_graphics Is Nothing Then Exit Function
If m_selectedItem Is Nothing Then
Exit Function
End If
thisTextItemRect = GetTextItemRect(m_selectedItem)
thisTextItemWidth = GetTextItemWidth(m_selectedItem, lineCount) + 16
If thisTextItemWidth >= m_IconSize + 75 Then
thisTextItemWidth = (m_IconSize + 75) + 16
End If
centeredStartX = (thisTextItemRect.Left) + (thisTextItemRect.Width / 2) - (thisTextItemWidth / 2)
Debug.Print lineCount * 17
'Add Rollover
m_rollOver.AddArc m_gridOffsetX + centeredStartX, _
GetItemYPlusOffset(m_selectedItem.Y + m_IconSize + 14), 28, lineCount * 17, 135, 90
m_rollOver.AddArc m_gridOffsetX + centeredStartX + (thisTextItemWidth - 28), _
GetItemYPlusOffset(m_selectedItem.Y + m_IconSize + 14), 28, lineCount * 17, -45, 90
m_graphics.FillPath m_blackBrush, m_rollOver
m_graphics.DrawImage m_pickGrids(m_activePickGridIndex).Bitmap.Image, m_gridOffsetX + (m_windowDimensions.cx * (m_activePickGridIndex - 1)) + m_currentBitmap_XOffset, m_headerOffset, CSng(m_windowDimensions.cx), CSng(m_windowDimensions.cy)
m_graphics.DrawImage m_pickGrids(m_activePickGridIndex + 1).Bitmap.Image, m_gridOffsetX + (m_windowDimensions.cx * (m_activePickGridIndex)) + m_currentBitmap_XOffset, m_headerOffset, CSng(m_windowDimensions.cx), CSng(m_windowDimensions.cy)
Exit Function
Handler:
End Function
Public Function DrawHeader()
If m_lastReportedY < m_headerOffset Then
m_header.VirginRollover = False
m_graphics.FillPath m_blackBrush, m_header.rollOver
Else
If Not m_header.VirginRollover Then
m_header.VirginRollover = True
m_header.ResetRollover
Set m_header.rollOver = New GDIPGraphicPath
End If
End If
m_graphics.FillPath m_blackBrush, m_header.thePath2
m_graphics.FillPath m_whiteBrush, m_header.thePath
End Function
Public Function DrawItemRollover()
If m_currentBitmap_XOffset <> m_finalX And m_currentBitmap_XOffset <> -m_finalX Then Exit Function
Dim thisItem As LaunchPadItem
Dim thisTextItemWidth As Long
Dim thisTextItemRect As RECTF
Dim centeredStartX As Single
Dim lineCount As Long
Dim arcWidth As Single
Dim arcHeight As Single
Dim arcStart As Single
On Error GoTo Handler
If m_graphics Is Nothing Then Exit Function
If m_selectedItem Is Nothing Then
RefreshHDC
Exit Function
End If
thisTextItemRect = GetTextItemRect(m_selectedItem)
thisTextItemWidth = GetTextItemWidth(m_selectedItem, lineCount) + 16
If thisTextItemWidth > ((m_IconSize + 75) + 16) Then
thisTextItemWidth = (m_IconSize + 75) + 16
End If
centeredStartX = (thisTextItemRect.Left) + (thisTextItemRect.Width / 2) - (thisTextItemWidth / 2)
'Debug.Print "LineCount:: " & lineCount
'Add Rollover
'm_rollOver.AddArc m_gridOffsetX + centeredStartX, GetItemYPlusOffset(m_selectedItem.Y + m_IconSize + 14), 10 + (lineCount * 18), (lineCount * 17), 135, 90
'm_rollOver.AddArc m_gridOffsetX + centeredStartX, GetItemYPlusOffset(m_selectedItem.Y + m_IconSize + 14), 10 + (lineCount * 18), (lineCount * 17), -45, 90
'm_rollOver.AddRectangle m_gridOffsetX + centeredStartX, GetItemYPlusOffset(m_selectedItem.Y + m_IconSize + 14), _
CSng(thisTextItemWidth), CSng(lineCount * 14) + 3
arcWidth = (lineCount * 10) + (lineCount * 18)
arcHeight = (lineCount * 17)
arcStart = GetItemYPlusOffset(m_selectedItem.Y + m_IconSize + 14)
m_rollOver.AddArc (m_gridOffsetX + centeredStartX), _
arcStart, _
arcWidth, _
arcHeight, _
135, _
90
m_rollOver.AddArc (thisTextItemWidth + m_gridOffsetX + centeredStartX) - arcWidth, _
arcStart, _
arcWidth, _
arcHeight, _
-45, _
90
m_graphics.Clear
'If Not m_glassWindow Is Nothing Then m_glassWindow.DrawGlass m_graphics
m_graphics.FillPath m_blackBrush, m_rollOver
If m_showHeader Then DrawHeader
m_pageSelector.Draw m_graphics
m_graphics.DrawImage m_pickGrids(m_activePickGridIndex).Bitmap.Image, m_gridOffsetX + (m_windowDimensions.cx * (m_activePickGridIndex - 1)) + m_currentBitmap_XOffset, m_headerOffset, CSng(m_windowDimensions.cx), CSng(m_windowDimensions.cy)
m_graphics.DrawImage m_pickGrids(m_activePickGridIndex + 1).Bitmap.Image, m_gridOffsetX + (m_windowDimensions.cx * (m_activePickGridIndex)) + m_currentBitmap_XOffset, m_headerOffset, CSng(m_windowDimensions.cx), CSng(m_windowDimensions.cy)
Handler:
UpdateMe
End Function
Public Function DrawItemRollover_1()
If m_currentBitmap_XOffset <> m_finalX And m_currentBitmap_XOffset <> -m_finalX Then Exit Function
Dim thisItem As LaunchPadItem
Dim thisTextItemWidth As Long
Dim thisTextItemRect As RECTF
Dim centeredStartX As Single
Dim lineCount As Long
On Error GoTo Handler
If m_graphics Is Nothing Then Exit Function
If m_selectedItem Is Nothing Then
RefreshHDC
Exit Function
End If
thisTextItemRect = GetTextItemRect(m_selectedItem)
thisTextItemWidth = GetTextItemWidth(m_selectedItem, lineCount) + 16
If (thisTextItemWidth > m_IconSize + 75) + 16 Then
Debug.Print ":O!"
thisTextItemWidth = (m_IconSize)
End If
centeredStartX = (thisTextItemRect.Left) + (thisTextItemRect.Width / 2) - (thisTextItemWidth / 2)
'Add Rollover
m_rollOver.AddArc m_gridOffsetX + centeredStartX, GetItemYPlusOffset(m_selectedItem.Y + m_IconSize + 14), 10 + (lineCount * 18), (lineCount * 17), 135, 90
m_rollOver.AddArc m_gridOffsetX + centeredStartX + thisTextItemWidth, GetItemYPlusOffset(m_selectedItem.Y + m_IconSize + 14), 10 + (lineCount * 18), (lineCount * 17), -45, 90
m_graphics.Clear
'If Not m_glassWindow Is Nothing Then m_glassWindow.DrawGlass m_graphics
m_graphics.FillPath m_blackBrush, m_rollOver
If m_showHeader Then DrawHeader
m_pageSelector.Draw m_graphics
m_graphics.DrawImage m_pickGrids(m_activePickGridIndex).Bitmap.Image, m_gridOffsetX + (m_windowDimensions.cx * (m_activePickGridIndex - 1)) + m_currentBitmap_XOffset, m_headerOffset, CSng(m_windowDimensions.cx), CSng(m_windowDimensions.cy)
m_graphics.DrawImage m_pickGrids(m_activePickGridIndex + 1).Bitmap.Image, m_gridOffsetX + (m_windowDimensions.cx * (m_activePickGridIndex)) + m_currentBitmap_XOffset, m_headerOffset, CSng(m_windowDimensions.cx), CSng(m_windowDimensions.cy)
Handler:
UpdateMe
End Function
Private Function GetItemYPlusOffset(theY As Long) As Long
GetItemYPlusOffset = theY + m_headerOffset
End Function
Public Function DrawItems()
'Debug.Print "DrawItems!!"
On Error GoTo Handler
Dim thisItem As LaunchPadItem
Dim thisTextItemWidth As Long
Dim thisTextItemRect As RECTF
Dim centeredStartX As Single
Dim sourceGraphicsDevice As GDIPGraphics
Dim thisPickGrid As PickGrid
Dim pickGridIndex As Long
For pickGridIndex = 1 To m_pickGrids.Count
If pickGridIndex >= m_activePickGridIndex - 1 And pickGridIndex <= m_activePickGridIndex + 1 Then
'Debug.Print "pickGridIndex: " & pickGridIndex
Set thisPickGrid = m_pickGrids(pickGridIndex)
Set sourceGraphicsDevice = thisPickGrid.GraphicsImage
sourceGraphicsDevice.Clear
For Each thisItem In thisPickGrid.Items
If thisItem.Icon Is Nothing Then
Debug.Print "ViPad has prevented a catastrophic error from occuring!"
Exit For
End If
sourceGraphicsDevice.DrawImage thisItem.Icon, thisItem.X, thisItem.Y, CSng(m_IconSize), CSng(m_IconSize)
Next
sourceGraphicsDevice.FillPath m_blackBrush, thisPickGrid.BlackTextGP
sourceGraphicsDevice.FillPath m_whiteBrush, thisPickGrid.WhiteTextGP
End If
Next
Handler:
End Function
Private Property Let CurrentBitmapX(newX As Long)
m_currentBitmap_XOffset = newX
RefreshHDC
ReDrawPanelCheck
End Property
Private Property Let CurrentBitmapY(newY As Long)
RefreshHDC
End Property
Private Function AddLaunchItem(newItem As LaunchPadItem, Optional position As Long = -1)
If position = -1 Or position = 0 Then position = m_currentItems.Count + 1
If position > m_currentItems.Count Then
m_currentItems.Add newItem
Else
m_currentItems.Add newItem, , position
End If
m_masterCollection.Add newItem, newItem.GlobalIdentifer
'm_currentItems.Add newItem, newItem.GlobalIdentifer
End Function
Private Sub Form_DblClick()
Dim cursorPos As win.POINTL
GetCursorPos cursorPos
m_optionsWindow.Show , Me
End Sub
Private Sub Form_DragDropFile(szFilePath As String)
Dim thisPadItem As LaunchPadItem
Dim thisIconImage As GDIPImage
Dim thisAlphaIcon As AlphaIcon
Dim IconPath As String
Dim theIcon As Long
Dim programName As String
Dim imageFileNamePath As String
Dim thisShellLink As New ShellLinkClass
Dim isLNKFile As Boolean
Set thisPadItem = New LaunchPadItem
Set thisPadItem.Icon = New GDIPImage
Set thisAlphaIcon = New AlphaIcon
If LCase(szFilePath) = LCase(VIPAD_SPECIAL_URL) Then
If Not URLCatcher Is Nothing Then
MakeInternetShortcut URLCatcher.Title, URLCatcher.URL
Exit Sub
End If
End If
If thisShellLink.Resolve(szFilePath) Then
isLNKFile = True
End If
programName = StripExtension(GetFileNameFromPath(szFilePath))
IconPath = Wow64Wrapper(szFilePath)
theIcon = IconHelper.GetIconFromFile(IconPath, SHIL_JUMBO)
If IconHelper.IconIs48(IconPath) Then
theIcon = IconHelper.GetIconFromFile(IconPath, SHIL_EXTRALARGE)
End If
thisAlphaIcon.CreateFromHICON theIcon
thisPadItem.Caption = programName
If isLNKFile Then
If thisShellLink.Target = vbNullString Or _
InStr(LCase(thisShellLink.Target), "windows\installer") > 0 Then
thisPadItem.TargetPath = CopyLnkToBank(szFilePath)
If thisPadItem.TargetPath = vbNullString Then
Exit Sub
End If
Else
If FileExists(Replace(thisShellLink.Target, " (x86)", "")) Then
thisPadItem.TargetPath = Replace(thisShellLink.Target, " (x86)", "")
Else
thisPadItem.TargetPath = thisShellLink.Target
End If
thisPadItem.TargetArguements = thisShellLink.Arguments
End If
Else
thisPadItem.TargetPath = szFilePath
End If
Set thisPadItem.Icon = thisAlphaIcon.Image
imageFileNamePath = GenerateAvailableFileName
If imageFileNamePath <> vbNullString Then
thisAlphaIcon.Image.Save imageFileNamePath, GetPngCodecCLSID()
thisPadItem.IconPath = GetFileNameFromPath(imageFileNamePath)
End If
Set thisPadItem.AlphaIconStore = thisAlphaIcon
'MsgBox m_mouseX & ":" & m_mouseY
If GetSelectedItemIndex(m_lastReportedX, m_lastReportedY) < 0 Then
AddLaunchItem thisPadItem
'MsgBox ":D"
Else
AddLaunchItem thisPadItem, m_selectedItemIndex
End If
PositionItems
DrawItems
RefreshHDC
m_padChanged = True
End Sub
Private Function InitializeText()
Dim colorMaker As Colour
Set m_fontFamily = New GDIPFontFamily
Set m_font = New GDIPFont
Set colorMaker = New Colour
colorMaker.SetColourByHex "#363535"
Set m_blackBrush = New GDIPBrush: m_blackBrush.Colour = colorMaker
Set colorMaker = New Colour
colorMaker.SetColourByHex "#ffffff"
Set m_whiteBrush = New GDIPBrush: m_whiteBrush.Colour = colorMaker
m_fontFamily.Constructor "Arial"
m_font.Constructor m_fontFamily, ITEM_TEXT_SIZE, FontStyleBold
End Function
Private Function InitializeGraphics()
Debug.Print "ViPickWindow::InitializeGraphics"
Set m_graphics = New GDIPGraphics
If Not m_layeredAttributes Is Nothing And m_glassMode = False Then
Set m_layeredAttributes = MakeLayerdWindow(Me)
If m_layeredAttributes Is Nothing Then Exit Function
m_graphics.FromHDC m_layeredAttributes.theDC
Else
m_graphics.FromHDC Me.hdc
End If
m_graphics.SmoothingMode = SmoothingModeHighQuality
m_graphics.InterpolationMode = InterpolationModeHighQualityBicubic
End Function
Private Function CalculateCapacities()
m_columnCapacity = Floor((m_windowDimensions.cx - (X_MARGIN)) / (m_IconSize + X_ICON_GAP))
m_rowCapacity = Floor((m_windowDimensions.cy - (Y_MARGIN) - PAGE_SELECTOR_GAP) / (m_IconSize + Y_ICON_GAP))
m_gridOffsetX = ((m_windowDimensions.cx - (m_columnCapacity * (m_IconSize + X_ICON_GAP))) - (X_MARGIN / 2)) / 2
If m_rowCapacity < 1 Then m_rowCapacity = 1
If m_columnCapacity < 1 Then m_columnCapacity = 1
m_totalCapacity = m_rowCapacity * m_columnCapacity
End Function
Private Function InitializeGrid()
InitializeGraphics
CalculateCapacities
PositionItems
End Function
Private Function GetTextItemWidth(ByRef theItem As LaunchPadItem, Optional ByRef lineCount As Long) As Single
Dim layout As SIZEF
layout.Width = m_IconSize + 75
layout.Height = 900
GetTextItemWidth = m_graphics.DotNet_MeasureString(theItem.Caption, m_font, layout, 0, lineCount).Width
If lineCount > 3 Then lineCount = 3
'GetTextItemWidth = m_graphics.MeasureString(theItem.Caption, m_font).Width
End Function
Private Function GetTextItemRect(ByRef theItem As LaunchPadItem) As RECTF
Dim rectTextPosition As RECTF
Dim actualTextWidth As Long
actualTextWidth = m_graphics.MeasureString(theItem.Caption, m_font).Width
If actualTextWidth > m_IconSize + 75 Then
actualTextWidth = m_IconSize + 75
End If
rectTextPosition.Left = theItem.X - 39
rectTextPosition.Top = theItem.Y + m_IconSize + 15
rectTextPosition.Width = m_IconSize + 75
rectTextPosition.Height = 40
'rectTextPosition.Left = rectTextPosition.Left + _
((ICON_SIZE + 75) / 2) - (actualTextWidth / 2) - 1
GetTextItemRect = rectTextPosition
End Function
Private Sub Form_Initialize()
m_systemId = ProgramSupport.GetNextViPadInstanceID
MainMod.ViPickWindows.Add Me, m_systemId
If WindowsVersion.dwMajorVersion > 5 Then
ChangeWindowMessageFilter WM_DROPFILES, MSGFLT_ADD
ChangeWindowMessageFilter WM_COPYDATA, MSGFLT_ADD
ChangeWindowMessageFilter &H49, MSGFLT_ADD
End If
DragAcceptFiles Me.hWnd, APITRUE
End Sub
Sub LayeredWindowHandler()
If Config.ForceLayeredMode Or Not IsGlassAvailable Then
Set m_glassWindow = New GlassContainer
m_glassWindow.DragDrop = True
Set m_layeredAttributes = MakeLayerdWindow(Me)
Else
m_glassMode = True
If ApplyGlassIfPossible(Me.hWnd) Then
m_glassApplied = True
Else
Set m_glassWindow = New GlassContainer
m_glassWindow.DragDrop = True
Set m_layeredAttributes = MakeLayerdWindow(Me)
End If
End If
HandleWindowStyle
If Not m_glassWindow Is Nothing Then
m_glassWindow.AttachForm Me
m_glassWindow.Show
m_firstTime = True
End If
End Sub
Sub DisplayTab(ByRef theTab As ViTab)
Set m_currentItems = theTab.Children
UpdateTabMenu
PositionItems
ReDraw
End Sub
Sub ShowTabByIndex(ByVal tabIndex As Long)
Set m_currentItems = m_itemBank.GetCollectionByIndex(tabIndex)
m_panelIndex = tabIndex
m_header.SetClickedItemByIndex tabIndex - 1
UpdateTabMenu
PositionItems
ReDraw
End Sub
Sub CreateNewTab()
If Config.InstanceMode Then
Dim thisInstance As ViPickWindow
Set thisInstance = New ViPickWindow
Load thisInstance
thisInstance.SetSelectedTab PublicItemBank.AddNewCollection("New Tab")
thisInstance.Left = (Screen.Width / 2) - (thisInstance.Width / 2)
thisInstance.Top = (Screen.Height / 2) - (thisInstance.Height / 2)
thisInstance.Show
thisInstance.LayeredWindowHandler
thisInstance.ZOrder
Else
Set m_currentItems = m_itemBank.AddNewCollection("New Tab").Children
m_panelIndex = m_itemBank.GetCollectionCount - 1
m_header.PopulateHeader m_itemBank
m_header.SetClickedItemByIndex m_panelIndex
PositionItems
ReDraw
UpdateTabMenu
End If
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
On Error GoTo Handler
Dim collectionIndex As Long
Dim initialText As String
If (KeyAscii < 48 Or KeyAscii > 57) And (KeyAscii <> 9) Then
'Set m_currentItems = m_searchResults
If KeyAscii <> 13 Then initialText = Chr(KeyAscii)
SummonLocalSearchBox initialText
m_header.ResetHeader
SetSearchMode QueryByString(m_masterCollection, m_searchTextBox.Text)
Else
If Config.InstanceMode Then
Set m_currentItems = m_singleInstanceCollection
Else
collectionIndex = Chr(KeyAscii)
While m_itemBank.GetCollectionCount < collectionIndex
m_itemBank.AddNewCollection "New Tab"
Wend
'If Chr(KeyAscii) = 2 Then
Set m_currentItems = m_itemBank.GetCollectionByIndex(collectionIndex)
m_panelIndex = collectionIndex
End If
End If
'm_pageSelector.MaxPage = m_itemBank.
'Set m_blackText = New GDIPGraphicPath
'Set m_whiteText = New GDIPGraphicPath
'm_currentPickGrid.ClearTextGraphicPaths
'finalXPosition = 0
m_activePickGridIndex = 1
m_pageSelector.CurrentIndex = m_activePickGridIndex
m_currentBitmap_XOffset = 0
m_finalX = 0
PositionItems
ReDraw
If Not Config.InstanceMode Then
m_header.PopulateHeader m_itemBank
m_header.SetClickedItemByIndex collectionIndex - 1
End If
UpdateTabMenu
'End If
Exit Sub
Handler:
End Sub
Private Sub InitializeObjects()
Set m_trayIcon = MainMod.AppTrayIcon
Set m_blankItem = New LaunchPadItem
Set m_blankItem.Icon = New GDIPImage
m_blankItem.Caption = ""
Set m_currentItems = New Collection
Set m_itemBank = PublicItemBank
Set m_pickGrids = New Collection
InitializeText
Set m_header = New ViPickHeader
m_header.ParentForm = Me
End Sub
Private Sub HideInTaskBar()
SetWindowStyle Me.hWnd, True, WS_EX_TOOLWINDOW, True, True
SetWindowStyle Me.hWnd, True, WS_EX_APPWINDOW, False, True
SetWindowPos Me.hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOSIZE Or SWP_NOMOVE
End Sub
Private Sub MakeVisibleInTaskBar()
SetWindowStyle Me.hWnd, True, WS_EX_TOOLWINDOW, False, True
SetWindowStyle Me.hWnd, True, WS_EX_APPWINDOW, True, True
End Sub
Private Sub HandleWindowStyle()
Dim windowStyle As Long
Dim extendedStyle As Long
'windowStyle = WS_BORDER Or WS_CAPTION Or WS_THICKFRAME Or WS_EX_APPWINDOW Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX
If m_glassWindow Is Nothing Then
windowStyle = WS_BORDER Or WS_CAPTION Or WS_THICKFRAME Or WS_MAXIMIZEBOX
If Not Config.StickToDesktop Then
windowStyle = windowStyle Or WS_MINIMIZEBOX
MakeVisibleInTaskBar
Else
HideInTaskBar
End If
If Config.ShowControlBox Then
windowStyle = windowStyle Or WS_SYSMENU
End If
SetWindowStyle Me.hWnd, False, windowStyle, True, False
If Not Config.StickToDesktop Then SetWindowStyle Me.hWnd, True, WS_EX_APPWINDOW, True, True
Else
windowStyle = GetWindowLong(hWnd, GWL_STYLE) And Not WS_BORDER And Not WS_CAPTION And Not WS_THICKFRAME And Not WS_MAXIMIZEBOX
SetWindowStyle Me.hWnd, True, WS_EX_LAYERED, False, True