forked from lee-soft/ViStart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViSettings.cls
147 lines (114 loc) · 5.75 KB
/
ViSettings.cls
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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ViSettings"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Public Programs As clsProgramDB
Public NavigationPane As ViNavigationPane
Private m_settingsDoc As DOMDocument
Public navigationXML As IXMLDOMElement
Public programsXML As IXMLDOMElement
Private m_generalXML As IXMLDOMElement
Public CurrentSkin As String
Public CurrentOrb As String
Public CurrentChildSkin As String
Public CurrentRollover As String
Public EnableAutoClick As Boolean
Public EnableTrayIcon As Boolean
Public ShowUserPicture As Boolean
Public ShowProgramsFirst As Boolean
Public StartButtonShowsWindowsMenu As Boolean
Public CatchLeftWindowsKey As Boolean
Public CatchRightWindowsKey As Boolean
Public ShowSplashScreen As Boolean
Public LanguageFile As String
Private m_logger As SeverityLogger
Property Get Logger() As SeverityLogger
Set Logger = m_logger
End Property
'Public IndexingLimit As Boolean
'Public IndexingPath As String
Private Sub Class_Initialize()
Set m_logger = LogManager.GetCurrentClassLogger(Me)
On Error GoTo Handler
SetVars_IfNeeded
Dim settingsXML As IXMLDOMElement
Set m_settingsDoc = New DOMDocument
Set NavigationPane = New ViNavigationPane
Set Programs = New clsProgramDB
If Not m_settingsDoc.Load(sCon_AppDataPath & "settings.xml") Then
m_settingsDoc.loadXML LoadStringFromResource("default_settings.xml", "SCHEMA")
End If
Set settingsXML = m_settingsDoc.firstChild
Set navigationXML = settingsXML.selectSingleNode("//navigation_pane")
Set programsXML = settingsXML.selectSingleNode("//programs")
Set m_generalXML = settingsXML.selectSingleNode("//general")
Me.CurrentSkin = CStr(ExtractXMLTextElement(m_generalXML, "current_skin", ""))
Me.CurrentOrb = CStr(ExtractXMLTextElement(m_generalXML, "current_orb", ""))
Me.CurrentRollover = CStr(ExtractXMLTextElement(m_generalXML, "current_rollover", ""))
Me.EnableTrayIcon = CBool(ExtractXMLTextElement(m_generalXML, "enable_trayicon", CStr(True)))
Me.ShowUserPicture = CBool(ExtractXMLTextElement(m_generalXML, "show_userpicture", CStr(True)))
Me.ShowProgramsFirst = CBool(ExtractXMLTextElement(m_generalXML, "show_program_menu_first", CStr(False)))
Me.StartButtonShowsWindowsMenu = CBool(ExtractXMLTextElement(m_generalXML, "start_button_shows_windows_menu", CStr(False)))
Me.CatchLeftWindowsKey = CBool(ExtractXMLTextElement(m_generalXML, "catch_left_windows_key", CStr(True)))
Me.CatchRightWindowsKey = CBool(ExtractXMLTextElement(m_generalXML, "catch_right_windows_key", CStr(True)))
Me.ShowSplashScreen = CBool(ExtractXMLTextElement(m_generalXML, "show_splash_screen", CStr(True)))
Me.LanguageFile = CStr(ExtractXMLTextElement(m_generalXML, "language", vbNullString))
If Not FileExists(App.Path & "\languages\" & Me.LanguageFile & ".xml") Then
If FileExists(App.Path & "\languages\" & g_WindowsLanguage & ".xml") Then
Me.LanguageFile = g_WindowsLanguage
ElseIf FileExists(App.Path & "\languages\" & g_WindowsLanguageInt & ".xml") Then
Me.LanguageFile = g_WindowsLanguageInt
Else
If FileExists(App.Path & "\languages\english.xml") Then
Logger.Warn "Native Language: " & g_WindowsLanguageInt & " / " & g_WindowsLanguage & " unavailable, defaulting to American English..", "Class_Initialize"
Me.LanguageFile = "English"
Else
Logger.Warn "No languages installed.. using precompiled values", "Class_Initialize"
End If
End If
End If
PopulateUserStringsFromXML App.Path & "\languages\" & Me.LanguageFile & ".xml"
Programs.ReadPrograms programsXML
Handler:
End Sub
Public Function Comit()
Dim settingsXML As IXMLDOMElement
Dim generalXML As IXMLDOMElement
'Dim navigationXML As IXMLDOMElement
Set m_settingsDoc = New DOMDocument
Set settingsXML = m_settingsDoc.createElement("settings")
Set generalXML = m_settingsDoc.createElement("general")
m_settingsDoc.appendChild settingsXML
settingsXML.appendChild generalXML
CreateXMLTextElement m_settingsDoc, generalXML, "current_skin", Me.CurrentSkin
CreateXMLTextElement m_settingsDoc, generalXML, "current_orb", Me.CurrentOrb
CreateXMLTextElement m_settingsDoc, generalXML, "current_rollover", Me.CurrentRollover
CreateXMLTextElement m_settingsDoc, generalXML, "enable_trayicon", CStr(Me.EnableTrayIcon)
CreateXMLTextElement m_settingsDoc, generalXML, "show_userpicture", CStr(Me.ShowUserPicture)
CreateXMLTextElement m_settingsDoc, generalXML, "show_program_menu_first", CStr(Me.ShowProgramsFirst)
CreateXMLTextElement m_settingsDoc, generalXML, "start_button_shows_windows_menu", CStr(Me.StartButtonShowsWindowsMenu)
CreateXMLTextElement m_settingsDoc, generalXML, "catch_left_windows_key", CStr(Me.CatchLeftWindowsKey)
CreateXMLTextElement m_settingsDoc, generalXML, "catch_right_windows_key", CStr(Me.CatchRightWindowsKey)
CreateXMLTextElement m_settingsDoc, generalXML, "show_splash_screen", CStr(Me.ShowSplashScreen)
CreateXMLTextElement m_settingsDoc, generalXML, "language", CStr(Me.LanguageFile)
If Not Programs.DumpPrograms(m_settingsDoc, settingsXML) Then
Exit Function
End If
If Not NavigationPane.DumpOptions(m_settingsDoc, settingsXML) Then
Exit Function
End If
m_settingsDoc.Save sCon_AppDataPath & "settings.xml"
End Function
Private Sub Class_Terminate()
Comit
End Sub