-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFrmSettings.vb
392 lines (305 loc) · 15 KB
/
FrmSettings.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
Imports Microsoft.Win32
Public Class FrmSettings
Dim formIsLoading As Boolean = True
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
EnableCap = CheckBox1.Checked
EnableNum = CheckBox2.Checked
EnableScroll = CheckBox3.Checked
'<<<<<<< Updated upstream
EnableNormalize = CheckBox4.Checked
'=======
ShowPop = CheckBox5.Checked
'>>>>>>> Stashed changes
If CheckBox4.Checked = True Then
FrmMain.Timer2.Enabled = True
Else
FrmMain.Timer2.Enabled = False
End If
If RadioButton1.Checked = True Then
SelectedNormalizationSound = 0
ElseIf RadioButton2.Checked = True Then
SelectedNormalizationSound = 1
ElseIf RadioButton3.Checked = True Then
SelectedNormalizationSound = 2
ElseIf RadioButton4.Checked = True Then
SelectedNormalizationSound = 3
End If
MakeSoundOnNormalize = CheckBox6.Checked
SoundOnNormalChange = CheckBox7.Checked
WhichSound = NumericUpDown2.Value
CapsLockNormalValue = ComboBox1.Text
NumLockNormalValue = ComboBox2.Text
ScrollLockNormalValue = ComboBox3.Text
EnableHardwareIntegration = ChkHardwareIntegration.Checked
TimeToNormalize = NumericUpDown1.Value
CountToNormal = 0
Call Savesettings()
FrmMain.EnableDisableIcons()
Me.Close()
End Sub
Sub LoadSettings()
Dim deftop As Integer = (My.Computer.Screen.WorkingArea.Height - Me.Height) / 2
Dim defleft As Integer = (My.Computer.Screen.WorkingArea.Width - Me.Width) / 2
Me.Top = GetSetting("KeysPal", "GeneralSettings", "frmSettingstop", deftop)
Me.Left = GetSetting("KeysPal", "GeneralSettings", "frmSettingsleft", defleft)
If Me.Left < 0 Then
Me.Left = defleft
End If
If Me.Top < 0 Then
Me.Top = deftop
End If
ChkRunAtStartup.Checked = GetSetting("KeysPal", "GeneralSettings", "StartWithWindows", False)
ChkHardwareIntegration.Checked = EnableHardwareIntegration
End Sub
Sub Savesettings()
SaveSetting("KeysPal", "GeneralSettings", "frmSettingstop", Top)
SaveSetting("KeysPal", "GeneralSettings", "frmSettingsleft", Left)
SaveSetting("KeysPal", "GeneralSettings", "CapsLock", CheckBox1.Checked)
SaveSetting("KeysPal", "GeneralSettings", "NumLock", CheckBox2.Checked)
SaveSetting("KeysPal", "GeneralSettings", "ScrollLock", CheckBox3.Checked)
SaveSetting("KeysPal", "GeneralSettings", "timetonormalize", NumericUpDown1.Value)
SaveSetting("KeysPal", "GeneralSettings", "EnableNormalize", CheckBox4.Checked)
SaveSetting("KeysPal", "GeneralSettings", "ShowPop", CheckBox5.Checked)
SaveSetting("KeysPal", "GeneralSettings", "MakeSoundOnNormalize", CheckBox6.Checked)
SaveSetting("KeysPal", "GeneralSettings", "SelectedNormalizationSound", SelectedNormalizationSound)
SaveSetting("KeysPal", "GeneralSettings", "CapsLockNormalValue", CapsLockNormalValue)
SaveSetting("KeysPal", "GeneralSettings", "NumLockNormalValue", NumLockNormalValue)
SaveSetting("KeysPal", "GeneralSettings", "ScrollLockNormalValue", ScrollLockNormalValue)
SaveSetting("KeysPal", "GeneralSettings", "SoundOnNormalChange", SoundOnNormalChange)
SaveSetting("KeysPal", "GeneralSettings", "WhichSound", WhichSound)
SaveSetting("KeysPal", "GeneralSettings", "EnableHardwareIntegration", ChkHardwareIntegration.Checked)
End Sub
Private Declare Function HideCaret Lib "user32" (ByVal hwnd As Integer) As Integer
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
formIsLoading = True
CheckBox1.Checked = EnableCap
CheckBox2.Checked = EnableNum
CheckBox3.Checked = EnableScroll
CheckBox4.Checked = EnableNormalize
CheckBox5.Checked = ShowPop
CheckBox7.Checked = SoundOnNormalChange
ChkHardwareIntegration.Checked = EnableHardwareIntegration
NumericUpDown2.Value = WhichSound
NumericUpDown1.Value = TimeToNormalize
CheckBox6.Checked = MakeSoundOnNormalize
If SelectedNormalizationSound = 0 Then
RadioButton1.Checked = True
ElseIf SelectedNormalizationSound = 1 Then
RadioButton2.Checked = True
ElseIf SelectedNormalizationSound = 2 Then
RadioButton3.Checked = True
ElseIf SelectedNormalizationSound = 3 Then
RadioButton4.Checked = True
Else
End If
Call CheckBox6_CheckedChanged(Nothing, Nothing)
ComboBox1.Text = CapsLockNormalValue
ComboBox2.Text = NumLockNormalValue
ComboBox3.Text = ScrollLockNormalValue
LoadSettings()
Dim deftop As Integer
Dim defleft As Integer
If FrmMain.Visible = True Then
deftop = FrmMain.Top + ((FrmMain.Height - Me.Height) / 2)
defleft = FrmMain.Left + ((FrmMain.Width - Me.Width) / 2)
Else
deftop = (My.Computer.Screen.WorkingArea.Height - Me.Height) / 2
defleft = (My.Computer.Screen.WorkingArea.Width - Me.Width) / 2
End If
ListPrograms()
Me.Top = deftop
Me.Left = defleft
NumericUpDown2.ReadOnly = True
NumericUpDown2.BackColor = Color.White
HideCaret(NumericUpDown2.Controls(1).Handle)
formIsLoading = False
End Sub
Sub ListPrograms()
Try
For i As Integer = 0 To UpperCaseProgramList.Count - 1
RichTextBox1.AppendText(UpperCaseProgramList(i) & vbNewLine)
Next
Catch ex As Exception
End Try
Try
For i As Integer = 0 To LowerCaseProgramList.Count - 1
RichTextBox2.AppendText(LowerCaseProgramList(i) & vbNewLine)
Next
Catch ex As Exception
End Try
End Sub
Private Sub ChkRunAtStartup_CheckedChanged(sender As Object, e As EventArgs) Handles ChkRunAtStartup.CheckedChanged
If ChkRunAtStartup.Checked = True Then
SetStartUpValue(Application.ProductName, Application.ExecutablePath)
SaveSetting("KeysPal", "GeneralSettings", "StartWithWindows", True)
Else
RemoveStartUpValue(Application.ProductName)
SaveSetting("KeysPal", "GeneralSettings", "StartWithWindows", False)
End If
End Sub
'setvalue
Public Sub SetStartUpValue(ByVal ApplicationName As String, ByVal ApplicationPath As String)
Dim CU As Microsoft.Win32.RegistryKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
With CU
.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
.SetValue(ApplicationName, ApplicationPath)
End With
End Sub
'remove value
Public Sub RemoveStartUpValue(ByVal ApplicationName As String)
Dim CU As Microsoft.Win32.RegistryKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
With CU
.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
.DeleteValue(ApplicationName, False)
End With
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If RadioButton1.Checked = True Then
My.Computer.Audio.Play(My.Resources.DeepBeep, AudioPlayMode.Background)
ElseIf RadioButton2.Checked = True Then
My.Computer.Audio.Play(My.Resources.HarmonyBeep, AudioPlayMode.Background)
ElseIf RadioButton3.Checked = True Then
My.Computer.Audio.Play(My.Resources.HappyHarmonyBeep, AudioPlayMode.Background)
ElseIf RadioButton4.Checked = True Then
My.Computer.Audio.Play(My.Resources.RobotBeep, AudioPlayMode.Background)
End If
End Sub
Private Sub RadioButton4_Click(sender As Object, e As EventArgs) Handles RadioButton4.Click
My.Computer.Audio.Play(My.Resources.RobotBeep, AudioPlayMode.Background)
End Sub
Private Sub RadioButton3_Click(sender As Object, e As EventArgs) Handles RadioButton3.Click
My.Computer.Audio.Play(My.Resources.HappyHarmonyBeep, AudioPlayMode.Background)
End Sub
Private Sub RadioButton2_Click(sender As Object, e As EventArgs) Handles RadioButton2.Click
My.Computer.Audio.Play(My.Resources.HarmonyBeep, AudioPlayMode.Background)
End Sub
Private Sub RadioButton1_Click(sender As Object, e As EventArgs) Handles RadioButton1.Click
My.Computer.Audio.Play(My.Resources.DeepBeep, AudioPlayMode.Background)
End Sub
Private Sub CheckBox6_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox6.CheckedChanged
If CheckBox6.Checked = True Then
RadioButton1.Enabled = True
RadioButton2.Enabled = True
RadioButton3.Enabled = True
RadioButton4.Enabled = True
Else
RadioButton1.Enabled = False
RadioButton2.Enabled = False
RadioButton3.Enabled = False
RadioButton4.Enabled = False
End If
End Sub
Private Sub CheckBox4_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox4.CheckedChanged
ComboBox1.Enabled = CheckBox4.Checked
ComboBox2.Enabled = CheckBox4.Checked
ComboBox3.Enabled = CheckBox4.Checked
CheckBox6.Enabled = CheckBox4.Checked
NumericUpDown1.Enabled = CheckBox4.Checked
' If CheckBox6.Checked Then
RadioButton1.Enabled = CheckBox4.Checked
RadioButton2.Enabled = CheckBox4.Checked
RadioButton3.Enabled = CheckBox4.Checked
RadioButton4.Enabled = CheckBox4.Checked
' End If
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged
End Sub
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
'Dim filepath = Application.StartupPath & "\lists.ini"
'If System.IO.File.Exists(filepath) = True Then
' Try
' Process.Start(filepath)
' Catch ex As Exception
' End Try
'Else
' ' Try
' Dim fs As System.IO.FileStream = System.IO.File.Create(filepath)
' fs.Close()
' Dim file As System.IO.StreamWriter
' file = My.Computer.FileSystem.OpenTextFileWriter(filepath, True)
' file.WriteLine("")
' file.WriteLine("[UpperCase]")
' file.WriteLine("Program1 = ""Set your UPPER CASE programs here"" ")
' file.WriteLine("Program2 = ""a part of title is normally enough"" ")
' file.WriteLine("Program3 = ""but please try to use unique values to avoid misbehavior"" ")
' file.WriteLine("Program4 = ""set program4 here"" ")
' file.WriteLine("Program5 = ""set program5 here"" ")
' file.WriteLine("Program6 = ""set program6 here"" ")
' file.WriteLine("Program7 = ""set program7 here"" ")
' file.WriteLine("Program8 = ""set program8 here"" ")
' file.WriteLine("Program9 = ""set program9 here"" ")
' file.WriteLine("Program10 = ""set program10 here"" ")
' file.WriteLine("[Lowercase]")
' file.WriteLine("Program1 = ""SET YOUR lower case PROGRAMS HERE"" ")
' file.WriteLine("Program2 = ""a part of title is normally enough"" ")
' file.WriteLine("Program3 = ""but please try to use unique values to avoid misbehavior"" ")
' file.WriteLine("Program4 = ""set program4 here"" ")
' file.WriteLine("Program5 = ""set program5 here"" ")
' file.WriteLine("Program6 = ""set program6 here"" ")
' file.WriteLine("Program7 = ""set program7 here"" ")
' file.WriteLine("Program8 = ""set program8 here"" ")
' file.WriteLine("Program9 = ""set program9 here"" ")
' file.WriteLine("Program10 = ""set program10 here"" ")
' file.Close()
' wait(500)
' Process.Start(filepath)
' ' Catch ex As Exception
' ' End Try
'End If
FrmEditor.Show()
End Sub
Private Sub wait(ByVal interval As Integer) ' taken from https://stackoverflow.com/questions/13519274/delaying-in-vb-net/13520695
Dim sw As New Stopwatch
sw.Start()
Do While sw.ElapsedMilliseconds < interval
' Allows UI to remain responsive
Application.DoEvents()
Loop
sw.Stop()
End Sub
Sub LinkLabel2_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
RichTextBox1.Clear()
RichTextBox2.Clear()
LoadForceToPrograms()
ListPrograms()
End Sub
Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton3.CheckedChanged
End Sub
Private Sub CheckBox5_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox5.CheckedChanged
End Sub
Private Sub NumericUpDown2_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown2.ValueChanged
If formIsLoading = False Then
If NumericUpDown2.Value = 1 Then
My.Computer.Audio.Play(My.Resources.wav_ding01a, AudioPlayMode.Background)
ElseIf NumericUpDown2.Value = 2 Then
My.Computer.Audio.Play(My.Resources.wav_ding01b, AudioPlayMode.Background)
ElseIf NumericUpDown2.Value = 3 Then
My.Computer.Audio.Play(My.Resources.wav_ding02, AudioPlayMode.Background)
ElseIf NumericUpDown2.Value = 4 Then
My.Computer.Audio.Play(My.Resources.wav_ding03, AudioPlayMode.Background)
ElseIf NumericUpDown2.Value = 5 Then
My.Computer.Audio.Play(My.Resources.wav_ding04, AudioPlayMode.Background)
ElseIf NumericUpDown2.Value = 6 Then
My.Computer.Audio.Play(My.Resources.wav_ding05, AudioPlayMode.Background)
ElseIf NumericUpDown2.Value = 7 Then
My.Computer.Audio.Play(My.Resources.wav_ding06, AudioPlayMode.Background)
ElseIf NumericUpDown2.Value = 8 Then
My.Computer.Audio.Play(My.Resources.wav_ding07, AudioPlayMode.Background)
ElseIf NumericUpDown2.Value = 9 Then
My.Computer.Audio.Play(My.Resources.wav_ding08, AudioPlayMode.Background)
ElseIf NumericUpDown2.Value = 10 Then
My.Computer.Audio.Play(My.Resources.wav_ding09, AudioPlayMode.Background)
End If
End If
End Sub
Private Sub LinkLabel3_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
FrmDisplayFormostWindow.Show()
End Sub
Private Sub ChkHardwareIntegration_CheckedChanged(sender As Object, e As EventArgs) Handles ChkHardwareIntegration.CheckedChanged
If ChkHardwareIntegration.Checked = True Then
lnkOptions.Enabled = True
Else
lnkOptions.Enabled = False
End If
End Sub
End Class