88' This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY
99
1010Imports WinNUT_Params = WinNUT_Client_Common.WinNUT_Params
11- Imports Logger = WinNUT_Client_Common.Logger
1211Imports LogLvl = WinNUT_Client_Common.LogLvl
13- Imports WinNUT_Client_Common.WinNUT_Globals
1412Imports System.IO
1513
1614Public Class Pref_Gui
1715 Private IsShowed As Boolean = False
1816 Private IsSaved As Boolean = False
1917
2018 Private Sub Btn_Cancel_Click(sender As Object , e As EventArgs) Handles Btn_Cancel.Click
21- LogFile.LogTracing( "Close Pref Gui from Button Cancel" , LogLvl.LOG_DEBUG, Me )
19+ WinNUT. LogFile.LogTracing("Close Pref Gui from Button Cancel" , LogLvl.LOG_DEBUG, Me )
2220 Me .Close()
2321 End Sub
2422
2523 Private Sub Save_Params()
2624 Try
2725 Me .IsSaved = False
28- LogFile.LogTracing( "Save Parameters." , LogLvl.LOG_DEBUG, Me )
26+ WinNUT. LogFile.LogTracing("Save Parameters." , LogLvl.LOG_DEBUG, Me )
2927 WinNUT_Params.Arr_Reg_Key.Item( "ServerAddress" ) = Tb_Server_IP.Text
3028 WinNUT_Params.Arr_Reg_Key.Item( "Port" ) = CInt (Tb_Port.Text)
3129 WinNUT_Params.Arr_Reg_Key.Item( "UPSName" ) = Tb_UPS_Name.Text
@@ -66,19 +64,19 @@ Public Class Pref_Gui
6664 If CB_Start_W_Win.Checked Then
6765 If My.Computer.Registry.GetValue( "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" , Application.ProductName, Nothing ) Is Nothing Then
6866 My.Computer.Registry.CurrentUser.OpenSubKey( "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" , True ).SetValue(Application.ProductName, Application.ExecutablePath)
69- LogFile.LogTracing( "WinNUT Added to Startup." , LogLvl.LOG_DEBUG, Me )
67+ WinNUT. LogFile.LogTracing("WinNUT Added to Startup." , LogLvl.LOG_DEBUG, Me )
7068 End If
7169 Else
7270 If Not My.Computer.Registry.GetValue( "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" , Application.ProductName, Nothing ) Is Nothing Then
7371 My.Computer.Registry.CurrentUser.OpenSubKey( "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" , True ).DeleteValue(Application.ProductName)
74- LogFile.LogTracing( "WinNUT Removed From Startup." , LogLvl.LOG_DEBUG, Me )
72+ WinNUT. LogFile.LogTracing("WinNUT Removed From Startup." , LogLvl.LOG_DEBUG, Me )
7573 End If
7674 End If
7775
78- LogFile.LogLevel = Cbx_LogLevel.SelectedIndex
79- LogFile.IsWritingToFile = CB_Use_Logfile.Checked
76+ WinNUT. LogFile.LogLevel = Cbx_LogLevel.SelectedIndex
77+ WinNUT. LogFile.IsWritingToFile = CB_Use_Logfile.Checked
8078
81- LogFile.LogTracing( "Pref_Gui Params Saved" , 1 , Me )
79+ WinNUT. LogFile.LogTracing("Pref_Gui Params Saved" , 1 , Me )
8280
8381 SetLogControlsStatus()
8482 WinNUT.WinNUT_PrefsChanged()
@@ -184,11 +182,11 @@ Public Class Pref_Gui
184182 Next
185183 Me .Btn_Apply.Enabled = False
186184 Me .IsShowed = True
187- LogFile.LogTracing( "Pref Gui Opened." , LogLvl.LOG_DEBUG, Me )
185+ WinNUT. LogFile.LogTracing("Pref Gui Opened." , LogLvl.LOG_DEBUG, Me )
188186 Catch Except As Exception
189187 Me .IsShowed = False
190188 Me .Close()
191- LogFile.LogTracing( "Error on Opening Pref_Gui." , LogLvl.LOG_ERROR, Me )
189+ WinNUT. LogFile.LogTracing("Error on Opening Pref_Gui." , LogLvl.LOG_ERROR, Me )
192190 End Try
193191 End Sub
194192
@@ -238,7 +236,7 @@ Public Class Pref_Gui
238236 Dim Result As Object = 0
239237 Dim MinValue, MaxValue As Integer
240238
241- LogFile.LogTracing( String .Format( "Check that the value of {0} for {1} is correct." , sender.Text, sender.Name), LogLvl.LOG_DEBUG, Me )
239+ WinNUT. LogFile.LogTracing(String .Format( "Check that the value of {0} for {1} is correct." , sender.Text, sender.Name), LogLvl.LOG_DEBUG, Me )
242240 Select Case sender.Name
243241 Case "Tb_Delay_Com"
244242 MinValue = 0
@@ -267,10 +265,10 @@ Public Class Pref_Gui
267265
268266 If Integer .TryParse(sender.Text, Result) Then
269267 If (Result >= MinValue And Result <= MaxValue) Then
270- LogFile.LogTracing( String .Format( "Value of {0} for {1} is valid." , Result, sender.Name), LogLvl.LOG_DEBUG, Me )
268+ WinNUT. LogFile.LogTracing(String .Format( "Value of {0} for {1} is valid." , Result, sender.Name), LogLvl.LOG_DEBUG, Me )
271269 sender.BackColor = Color.White
272270 Else
273- LogFile.LogTracing( String .Format( "Value of {0} for {1} is invalid." , Result, sender.Name), LogLvl.LOG_ERROR, Me )
271+ WinNUT. LogFile.LogTracing(String .Format( "Value of {0} for {1} is invalid." , Result, sender.Name), LogLvl.LOG_ERROR, Me )
274272 e.Cancel = True
275273 sender.BackColor = Color.Red
276274 End If
@@ -281,34 +279,34 @@ Public Class Pref_Gui
281279 End If
282280 End Sub
283281 Private Sub Correct_IP_Validating(sender As Object , e As System.ComponentModel.CancelEventArgs) Handles Tb_Server_IP.Validating
284- LogFile.LogTracing( "Check that the Nut Host address is valid." , LogLvl.LOG_DEBUG, Me )
282+ WinNUT. LogFile.LogTracing("Check that the Nut Host address is valid." , LogLvl.LOG_DEBUG, Me )
285283 Dim Pattern As String
286284 Dim StrTest As String = sender.Text
287285 Dim Is_Correct As Boolean = False
288286 'Test IPV4
289287 Pattern = "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$"
290288 If System.Text.RegularExpressions.Regex.IsMatch(sender.Text, Pattern) Then
291289 Is_Correct = True
292- LogFile.LogTracing( "The Nut Host address is a valid IPV4 address." , LogLvl.LOG_WARNING, Me )
290+ WinNUT. LogFile.LogTracing("The Nut Host address is a valid IPV4 address." , LogLvl.LOG_WARNING, Me )
293291 End If
294292 'Test IPV6
295293 Pattern = "^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$"
296294 If (System.Text.RegularExpressions.Regex.IsMatch(sender.Text, Pattern) And Not Is_Correct) Then
297295 Is_Correct = True
298- LogFile.LogTracing( "The Nut Host address is a valid IPV6 address." , LogLvl.LOG_WARNING, Me )
296+ WinNUT. LogFile.LogTracing("The Nut Host address is a valid IPV6 address." , LogLvl.LOG_WARNING, Me )
299297 End If
300298 'Test fqdn
301299 Pattern = "^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$"
302300 If (System.Text.RegularExpressions.Regex.IsMatch(sender.Text, Pattern) And Not Is_Correct) Then
303301 Is_Correct = True
304- LogFile.LogTracing( "The Nut Host address is a valid FQDN address." , LogLvl.LOG_WARNING, Me )
302+ WinNUT. LogFile.LogTracing("The Nut Host address is a valid FQDN address." , LogLvl.LOG_WARNING, Me )
305303 End If
306304
307305 'Result
308306 If Is_Correct Then
309307 sender.BackColor = Color.White
310308 Else
311- LogFile.LogTracing( "The Nut Host address is a invalid" , LogLvl.LOG_ERROR, Me )
309+ WinNUT. LogFile.LogTracing("The Nut Host address is a invalid" , LogLvl.LOG_ERROR, Me )
312310 e.Cancel = True
313311 sender.BackColor = Color.Red
314312 End If
@@ -324,32 +322,32 @@ Public Class Pref_Gui
324322 End Sub
325323
326324 Private Sub Btn_DeleteLog_Click(sender As Object , e As EventArgs) Handles Btn_DeleteLog.Click
327- LogFile.LogTracing( "Delete LogFile" , LogLvl.LOG_DEBUG, Me )
325+ WinNUT. LogFile.LogTracing("Delete LogFile" , LogLvl.LOG_DEBUG, Me )
328326
329- If LogFile.DeleteLogFile() Then
330- LogFile.LogTracing( "LogFile Deleted" , LogLvl.LOG_DEBUG, Me )
327+ If WinNUT. LogFile.DeleteLogFile() Then
328+ WinNUT. LogFile.LogTracing("LogFile Deleted" , LogLvl.LOG_DEBUG, Me )
331329 Else
332- LogFile.LogTracing( "Error deleting log file." , LogLvl.LOG_WARNING, Me )
330+ WinNUT. LogFile.LogTracing("Error deleting log file." , LogLvl.LOG_WARNING, Me )
333331 End If
334332
335- LogFile.IsWritingToFile = WinNUT_Params.Arr_Reg_Key.Item( "UseLogFile" )
333+ WinNUT. LogFile.IsWritingToFile = WinNUT_Params.Arr_Reg_Key.Item( "UseLogFile" )
336334 SetLogControlsStatus()
337335 End Sub
338336
339337 Private Sub Btn_ViewLog_Click(sender As Object , e As EventArgs) Handles Btn_ViewLog.Click
340- LogFile.LogTracing( "Show LogFile" , LogLvl.LOG_DEBUG, Me )
341- If File.Exists(LogFile.LogFileLocation) Then
342- Process.Start(LogFile.LogFileLocation)
338+ WinNUT. LogFile.LogTracing("Show LogFile" , LogLvl.LOG_DEBUG, Me )
339+ If File.Exists(WinNUT. LogFile.LogFileLocation) Then
340+ Process.Start(WinNUT. LogFile.LogFileLocation)
343341 Else
344- LogFile.LogTracing( "LogFile does not exists" , LogLvl.LOG_WARNING, Me )
342+ WinNUT. LogFile.LogTracing("LogFile does not exists" , LogLvl.LOG_WARNING, Me )
345343 Btn_ViewLog.Enabled = False
346344 Btn_DeleteLog.Enabled = False
347345 End If
348346 End Sub
349347
350348 Private Sub Pref_Gui_Load(sender As Object , e As EventArgs) Handles MyBase .Load
351349 Me .Icon = WinNUT.Icon
352- LogFile.LogTracing( "Load Pref Gui" , LogLvl.LOG_DEBUG, Me )
350+ WinNUT. LogFile.LogTracing("Load Pref Gui" , LogLvl.LOG_DEBUG, Me )
353351 End Sub
354352
355353 Private Sub Event_Ctrl_Value_Changed(sender As Object , e As EventArgs)
@@ -371,6 +369,6 @@ Public Class Pref_Gui
371369 Btn_DeleteLog.Enabled = False
372370 End If
373371
374- LogFile.LogTracing( "Setting LogControl statuses." , LogLvl.LOG_DEBUG, Me )
372+ WinNUT. LogFile.LogTracing("Setting LogControl statuses." , LogLvl.LOG_DEBUG, Me )
375373 End Sub
376374End Class
0 commit comments