forked from lee-soft/ViStart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Options.bas
137 lines (97 loc) · 3.81 KB
/
Options.bas
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
Attribute VB_Name = "OptionsHelper"
Option Explicit
Public Const POWERMENU_HEIGHT As Long = 233
Public Const POWERMENU_WIDTH As Long = 122
Public bAutoClick As Boolean
Public strIndexingPath As String
Public strNewIndexingPath As String
Public lngIndexingLimit As Long
Public lngNewIndexingLimit As Long
'Properties
Public PrimaryFont As String
Public SecondaryFont As String
Public sFonts() As String
Dim Reg As New RegistryKey
Private m_logger As SeverityLogger
Private Property Get Logger() As SeverityLogger
If m_logger Is Nothing Then
Set m_logger = LogManager.GetLogger("OptionsHelper")
End If
Set Logger = m_logger
End Property
Function StartsWithWindows() As Boolean
StartsWithWindows = False
Dim startWithWindowsRegKey As RegistryKey
Set startWithWindowsRegKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run\")
If startWithWindowsRegKey Is Nothing Then
Logger.Error "Unable to open registry key", "StartWithWindows"
Exit Function
End If
If LCase$(startWithWindowsRegKey.GetValue("ViStart", "<Empty>")) = LCase$(AppPath & App.EXEName & ".exe") Then
StartsWithWindows = True
End If
End Function
Public Function ValidateOptions() As Boolean
Dim newSkin As frmSkinSelect
If Settings.CurrentSkin = vbNullString Then
Settings.CurrentSkin = "Windows 7 Official Start Menu"
Set newSkin = New frmSkinSelect
newSkin.Show vbModal
ValidateOptions = ValidateOptions()
Exit Function
End If
If FSO.FolderExists(sCon_AppDataPath & "_skins\" & Settings.CurrentSkin) = False Then
If FSO.FolderExists(sCon_AppDataPath & "_skins\" & "Windows 7 Official Start Menu") = False Then
Set newSkin = New frmSkinSelect
newSkin.Show vbModal
ValidateOptions = ValidateOptions()
Exit Function
Else
If FileCheck(sCon_AppDataPath & "_skins\" & "Windows 7 Official Start Menu") = False Then
MsgBox "The base skin is broken. Reinstall ViStart", vbCritical
Exit Function
End If
Settings.CurrentSkin = "Windows 7 Official Start Menu"
End If
End If
g_resourcesPath = sCon_AppDataPath & "_skins\" & Settings.CurrentSkin & "\"
ValidateOptions = True
End Function
Public Function PutOptions()
If Not Settings Is Nothing Then Settings.Comit
If Not MetroUtility Is Nothing Then MetroUtility.DumpOptions
End Function
Function GetChildSkins(strPath As String) As Collection
Dim xmlLayout As New DOMDocument
Dim startMenuElement As IXMLDOMElement
Dim childSkins As Collection: Set childSkins = New Collection
Dim child As IXMLDOMElement
Dim startMenuName As String
Dim startMenuID As String
Dim nextStartMenu As CollectionItem
Set GetChildSkins = childSkins
If Not FileExists(strPath) Then
Exit Function
End If
If Not xmlLayout.Load(strPath) Then
Exit Function
End If
For Each child In xmlLayout.selectNodes("startmenus//startmenu_base")
Set nextStartMenu = New CollectionItem
nextStartMenu.Value = getAttribute_IgnoreError(child, "name", vbNullString)
nextStartMenu.Key = getAttribute_IgnoreError(child, "id", vbNullString)
If nextStartMenu.Value <> vbNullString And nextStartMenu.Key <> vbNullString Then
childSkins.Add nextStartMenu, nextStartMenu.Key
End If
Next
End Function
Private Sub IndexingPath()
If (strNewIndexingPath <> strIndexingPath) Or _
(lngNewIndexingLimit <> lngIndexingLimit) Then
strIndexingPath = strNewIndexingPath
lngIndexingLimit = lngNewIndexingLimit
If g_bIndexing Then
g_bAbortIndexing = True
End If
End If
End Sub