Test fixes for issue #43
This commit is contained in:
+39
-4
@@ -25,6 +25,9 @@ Partial Class frmFileFolderSearch
|
||||
Me.txtCurrentLocation = New System.Windows.Forms.TextBox()
|
||||
Me.btnCancel = New System.Windows.Forms.Button()
|
||||
Me.bwSearch = New System.ComponentModel.BackgroundWorker()
|
||||
Me.lstResults = New System.Windows.Forms.ListBox()
|
||||
Me.btnOk = New System.Windows.Forms.Button()
|
||||
Me.lblResults = New System.Windows.Forms.Label()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'txtCurrentLocation
|
||||
@@ -32,16 +35,16 @@ Partial Class frmFileFolderSearch
|
||||
Me.txtCurrentLocation.Location = New System.Drawing.Point(12, 12)
|
||||
Me.txtCurrentLocation.Name = "txtCurrentLocation"
|
||||
Me.txtCurrentLocation.ReadOnly = True
|
||||
Me.txtCurrentLocation.Size = New System.Drawing.Size(379, 20)
|
||||
Me.txtCurrentLocation.Size = New System.Drawing.Size(460, 20)
|
||||
Me.txtCurrentLocation.TabIndex = 0
|
||||
Me.txtCurrentLocation.TabStop = False
|
||||
'
|
||||
'btnCancel
|
||||
'
|
||||
Me.btnCancel.Location = New System.Drawing.Point(397, 10)
|
||||
Me.btnCancel.Location = New System.Drawing.Point(397, 114)
|
||||
Me.btnCancel.Name = "btnCancel"
|
||||
Me.btnCancel.Size = New System.Drawing.Size(75, 23)
|
||||
Me.btnCancel.TabIndex = 0
|
||||
Me.btnCancel.TabIndex = 4
|
||||
Me.btnCancel.Text = "&Cancel"
|
||||
Me.btnCancel.UseVisualStyleBackColor = True
|
||||
'
|
||||
@@ -49,11 +52,40 @@ Partial Class frmFileFolderSearch
|
||||
'
|
||||
Me.bwSearch.WorkerSupportsCancellation = True
|
||||
'
|
||||
'lstResults
|
||||
'
|
||||
Me.lstResults.FormattingEnabled = True
|
||||
Me.lstResults.Location = New System.Drawing.Point(12, 52)
|
||||
Me.lstResults.Name = "lstResults"
|
||||
Me.lstResults.Size = New System.Drawing.Size(460, 56)
|
||||
Me.lstResults.TabIndex = 2
|
||||
'
|
||||
'btnOk
|
||||
'
|
||||
Me.btnOk.Location = New System.Drawing.Point(316, 114)
|
||||
Me.btnOk.Name = "btnOk"
|
||||
Me.btnOk.Size = New System.Drawing.Size(75, 23)
|
||||
Me.btnOk.TabIndex = 3
|
||||
Me.btnOk.Text = "&OK"
|
||||
Me.btnOk.UseVisualStyleBackColor = True
|
||||
'
|
||||
'lblResults
|
||||
'
|
||||
Me.lblResults.AutoSize = True
|
||||
Me.lblResults.Location = New System.Drawing.Point(9, 36)
|
||||
Me.lblResults.Name = "lblResults"
|
||||
Me.lblResults.Size = New System.Drawing.Size(45, 13)
|
||||
Me.lblResults.TabIndex = 1
|
||||
Me.lblResults.Text = "Results:"
|
||||
'
|
||||
'frmFileFolderSearch
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(484, 46)
|
||||
Me.ClientSize = New System.Drawing.Size(484, 146)
|
||||
Me.Controls.Add(Me.lblResults)
|
||||
Me.Controls.Add(Me.btnOk)
|
||||
Me.Controls.Add(Me.lstResults)
|
||||
Me.Controls.Add(Me.btnCancel)
|
||||
Me.Controls.Add(Me.txtCurrentLocation)
|
||||
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
|
||||
@@ -70,4 +102,7 @@ Partial Class frmFileFolderSearch
|
||||
Friend WithEvents txtCurrentLocation As System.Windows.Forms.TextBox
|
||||
Friend WithEvents btnCancel As System.Windows.Forms.Button
|
||||
Friend WithEvents bwSearch As System.ComponentModel.BackgroundWorker
|
||||
Friend WithEvents lstResults As System.Windows.Forms.ListBox
|
||||
Friend WithEvents btnOk As System.Windows.Forms.Button
|
||||
Friend WithEvents lblResults As System.Windows.Forms.Label
|
||||
End Class
|
||||
|
||||
@@ -12,6 +12,7 @@ Public Class frmFileFolderSearch
|
||||
Dim bShutdown As Boolean = False
|
||||
|
||||
Delegate Sub UpdateInfoCallBack(ByVal sCurrentFolder As String)
|
||||
Delegate Sub UpdateResultsCallBack(ByVal sItem As String)
|
||||
|
||||
Public Property GameName As String
|
||||
Get
|
||||
@@ -58,6 +59,15 @@ Public Class frmFileFolderSearch
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub UpdateResults(ByVal sItem As String)
|
||||
If lstResults.InvokeRequired = True Then
|
||||
Dim d As New UpdateInfoCallBack(AddressOf UpdateResults)
|
||||
Me.Invoke(d, New Object() {sItem})
|
||||
Else
|
||||
lstResults.Items.Add(sItem)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function SearchDirectory(ByVal dir As DirectoryInfo, ByVal sDirectoryName As String) As String
|
||||
Dim sSubSearch As String = String.Empty
|
||||
Dim sFoundItem As String = String.Empty
|
||||
@@ -77,11 +87,7 @@ Public Class frmFileFolderSearch
|
||||
'Search Current Directory
|
||||
If dir.GetDirectories(sDirectoryName).Length > 0 Then
|
||||
sFoundItem = dir.FullName & Path.DirectorySeparatorChar & sDirectoryName
|
||||
If mgrCommon.ShowMessage(mgrPath_ConfirmPathCorrect, New String() {GameName, sFoundItem}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
|
||||
Return sFoundItem
|
||||
Else
|
||||
Return String.Empty
|
||||
End If
|
||||
UpdateResults(sFoundItem)
|
||||
End If
|
||||
|
||||
'Search Sub Directory
|
||||
@@ -90,7 +96,7 @@ Public Class frmFileFolderSearch
|
||||
sSubSearch = SearchDirectory(newDir, sDirectoryName)
|
||||
If sSubSearch <> String.Empty Then
|
||||
Return sSubSearch
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Catch e As System.UnauthorizedAccessException
|
||||
'Do Nothing
|
||||
@@ -120,11 +126,7 @@ Public Class frmFileFolderSearch
|
||||
'Search Current Directory
|
||||
If dir.GetFiles(sFileName).Length > 0 Then
|
||||
sFoundItem = Path.GetDirectoryName(dir.FullName & Path.DirectorySeparatorChar & sFileName)
|
||||
If mgrCommon.ShowMessage(mgrPath_ConfirmPathCorrect, New String() {GameName, sFoundItem}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
|
||||
Return sFoundItem
|
||||
Else
|
||||
Return String.Empty
|
||||
End If
|
||||
UpdateResults(sFoundItem)
|
||||
End If
|
||||
|
||||
'Search Sub Directory
|
||||
@@ -166,16 +168,22 @@ Public Class frmFileFolderSearch
|
||||
If FoundItem = "Cancel" Then FoundItem = String.Empty
|
||||
|
||||
If oDrives.Count > iCurrentDrive And FoundItem = String.Empty Then
|
||||
oResult = mgrCommon.ShowMessage(frmFileFolderSearch_SwitchDrives, New String() {oSearchDrive.Root.ToString, oDrives(iCurrentDrive).RootDirectory.ToString}, MsgBoxStyle.YesNo)
|
||||
oResult = mgrCommon.ShowMessage(frmFileFolderSearch_SwitchDrives, New String() {oDrives(iCurrentDrive).RootDirectory.ToString}, MsgBoxStyle.YesNo)
|
||||
If oResult = MsgBoxResult.Yes Then
|
||||
Search(oDrives(iCurrentDrive))
|
||||
Else
|
||||
bShutdown = True
|
||||
Me.Close()
|
||||
End If
|
||||
Else
|
||||
SearchComplete()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SearchComplete()
|
||||
If lstResults.Items.Count = 0 Then
|
||||
bShutdown = True
|
||||
Me.Close()
|
||||
Else
|
||||
txtCurrentLocation.Text = frmFileFolderSearch_SearchComplete
|
||||
lstResults.SelectedIndex = 0
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -184,6 +192,8 @@ Public Class frmFileFolderSearch
|
||||
Me.Text = frmFileFolderSearch_FormName
|
||||
|
||||
'Set Form Text
|
||||
lblResults.Text = frmFileFolderSearch_lblResults
|
||||
btnOk.Text = frmFileFolderSearch_btnOk
|
||||
btnCancel.Text = frmFileFolderSearch_btnCancel
|
||||
End Sub
|
||||
|
||||
@@ -206,11 +216,29 @@ Public Class frmFileFolderSearch
|
||||
End Sub
|
||||
|
||||
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
|
||||
bwSearch.CancelAsync()
|
||||
If bwSearch.IsBusy Then
|
||||
bwSearch.CancelAsync()
|
||||
Else
|
||||
bShutdown = True
|
||||
Me.Close()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub frmFileFolderSearch_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
|
||||
bwSearch.CancelAsync()
|
||||
If Not bShutdown Then e.Cancel = True
|
||||
End Sub
|
||||
|
||||
Private Sub btnOk_Click(sender As Object, e As EventArgs) Handles btnOk.Click
|
||||
Dim sItem As String
|
||||
|
||||
If lstResults.SelectedItems.Count = 1 Then
|
||||
sItem = lstResults.SelectedItem.ToString
|
||||
If mgrCommon.ShowMessage(mgrPath_ConfirmPathCorrect, New String() {GameName, sItem}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
|
||||
FoundItem = sItem
|
||||
bShutdown = True
|
||||
Me.Close()
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
+36
-16
@@ -146,15 +146,11 @@ Public Class frmMain
|
||||
End Sub
|
||||
|
||||
Private Sub ExecuteBackup(ByVal oBackupList As List(Of clsGame))
|
||||
'Init Backup Settings
|
||||
oBackup.Settings = oSettings
|
||||
oBackup.DoBackup(oBackupList)
|
||||
OperationEnded()
|
||||
End Sub
|
||||
|
||||
Private Sub ExecuteRestore(ByVal oRestoreList As List(Of clsBackup))
|
||||
'Init Restore Settings
|
||||
oRestore.Settings = oSettings
|
||||
Private Sub ExecuteRestore(ByVal oRestoreList As List(Of clsBackup))
|
||||
oRestore.DoRestore(oRestoreList)
|
||||
OperationEnded()
|
||||
End Sub
|
||||
@@ -165,19 +161,26 @@ Public Class frmMain
|
||||
Dim oReadyList As New List(Of clsBackup)
|
||||
Dim oRestoreInfo As clsBackup
|
||||
Dim bTriggerReload As Boolean = False
|
||||
|
||||
Dim bPathVerified As Boolean
|
||||
eCurrentOperation = eOperation.Restore
|
||||
OperationStarted()
|
||||
|
||||
'Build Restore List
|
||||
For Each oGame In oRestoreList
|
||||
bPathVerified = False
|
||||
oRestoreInfo = oBackupData(oGame.Name)
|
||||
|
||||
If mgrRestore.CheckPath(oRestoreInfo, oGame, bTriggerReload) Then
|
||||
oReadyList.Add(oRestoreInfo)
|
||||
bPathVerified = True
|
||||
Else
|
||||
UpdateLog(mgrCommon.FormatString(frmMain_ErrorRestorePath, oRestoreInfo.Name), False, ToolTipIcon.Error, True)
|
||||
End If
|
||||
|
||||
If bPathVerified Then
|
||||
If oRestore.CheckRestorePrereq(oRestoreInfo) Then
|
||||
oReadyList.Add(oRestoreInfo)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
'Reload the monitor list if any game data was changed during the path checks
|
||||
@@ -197,6 +200,7 @@ Public Class frmMain
|
||||
Private Sub RunManualBackup(ByVal oBackupList As List(Of clsGame))
|
||||
Dim oGame As clsGame
|
||||
Dim bNoAuto As Boolean
|
||||
Dim bPathVerified As Boolean
|
||||
Dim oReadyList As New List(Of clsGame)
|
||||
|
||||
eCurrentOperation = eOperation.Backup
|
||||
@@ -205,6 +209,7 @@ Public Class frmMain
|
||||
'Build Backup List
|
||||
For Each oGame In oBackupList
|
||||
bNoAuto = False
|
||||
bPathVerified = False
|
||||
gMonStripStatusButton.Enabled = False
|
||||
|
||||
UpdateLog(mgrCommon.FormatString(frmMain_ManualBackup, oGame.Name), False)
|
||||
@@ -216,12 +221,18 @@ Public Class frmMain
|
||||
End If
|
||||
|
||||
If oGame.ProcessPath <> String.Empty Then
|
||||
oReadyList.Add(oGame)
|
||||
bPathVerified = True
|
||||
Else
|
||||
UpdateLog(mgrCommon.FormatString(frmMain_ErrorBackupUnknownPath, oGame.Name), True, ToolTipIcon.Error, True)
|
||||
UpdateLog(mgrCommon.FormatString(frmMain_ErrorBackupUnknownPath, oGame.Name), False, ToolTipIcon.Error, True)
|
||||
End If
|
||||
Else
|
||||
oReadyList.Add(oGame)
|
||||
bPathVerified = True
|
||||
End If
|
||||
|
||||
If bPathVerified Then
|
||||
If oBackup.CheckBackupPrereq(oGame) Then
|
||||
oReadyList.Add(oGame)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
@@ -290,7 +301,7 @@ Public Class frmMain
|
||||
SetLastAction(mgrCommon.FormatString(frmMain_ErrorBackupCancel, oProcess.GameInfo.CroppedName))
|
||||
OperationEnded()
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
bDoBackup = False
|
||||
@@ -300,11 +311,16 @@ Public Class frmMain
|
||||
End If
|
||||
|
||||
If bDoBackup Then
|
||||
'Run the backup
|
||||
oReadyList.Add(oProcess.GameInfo)
|
||||
Dim trd As New System.Threading.Thread(AddressOf ExecuteBackup)
|
||||
trd.IsBackground = True
|
||||
trd.Start(oReadyList)
|
||||
If Not oBackup.CheckBackupPrereq(oProcess.GameInfo) Then
|
||||
SetLastAction(mgrCommon.FormatString(frmMain_ErrorBackupCancel, oProcess.GameInfo.CroppedName))
|
||||
OperationEnded()
|
||||
Else
|
||||
'Run the backup
|
||||
oReadyList.Add(oProcess.GameInfo)
|
||||
Dim trd As New System.Threading.Thread(AddressOf ExecuteBackup)
|
||||
trd.IsBackground = True
|
||||
trd.Start(oReadyList)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -684,6 +700,8 @@ Public Class frmMain
|
||||
PauseScan()
|
||||
If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
|
||||
oSettings = frm.Settings
|
||||
oBackup.Settings = oSettings
|
||||
oRestore.Settings = oSettings
|
||||
'Set Remote Database Location
|
||||
mgrPath.RemoteDatabaseLocation = oSettings.BackupFolder
|
||||
SetupSyncWatcher()
|
||||
@@ -806,6 +824,8 @@ Public Class frmMain
|
||||
|
||||
'Load Settings
|
||||
oSettings.LoadSettings()
|
||||
oBackup.Settings = oSettings
|
||||
oRestore.Settings = oSettings
|
||||
|
||||
If Not bFirstRun Then
|
||||
'The application cannot continue if this fails
|
||||
|
||||
Reference in New Issue
Block a user