Changes for Issues #46 and #47

This commit is contained in:
Michael J. Seiferling
2016-05-26 14:13:14 -06:00
parent 7f19ae6345
commit cb9bab9892
10 changed files with 207 additions and 66 deletions
+42 -36
View File
@@ -24,6 +24,8 @@ Public Class frmMain
Private bCancelledByUser As Boolean = False
Private bShutdown As Boolean = False
Private bInitFail As Boolean = False
Private bPathDetectionFailure As Boolean = False
Private sPathDetectionError As String = String.Empty
Private bMenuEnabled As Boolean = True
Private bLockdown As Boolean = True
Private bFirstRun As Boolean = False
@@ -1520,7 +1522,6 @@ Public Class frmMain
Private Sub ScanTimerEventProcessor(myObject As Object, ByVal myEventArgs As EventArgs) Handles tmScanTimer.Tick
Dim bNeedsPath As Boolean = False
Dim bContinue As Boolean = True
Dim bAskForRestart As Boolean = False
Dim iErrorCode As Integer = 0
Dim sErrorMessage As String = String.Empty
@@ -1532,39 +1533,24 @@ Public Class frmMain
If iErrorCode = 5 Then
If oProcess.Duplicate Then
sErrorMessage = mgrCommon.FormatString(frmMain_ErrorMultiAdmin)
mgrCommon.ShowMessage(sErrorMessage, MsgBoxStyle.Exclamation)
bAskForRestart = True
UpdateLog(sErrorMessage, True, ToolTipIcon.Warning, True)
Else
If Not CheckForSavedPath() Then
sErrorMessage = mgrCommon.FormatString(frmMain_ErrorAdminBackup, oProcess.GameInfo.Name)
oProcess.GameInfo.ProcessPath = mgrPath.ProcessPathSearch(oProcess.GameInfo.Name, oProcess.GameInfo.ProcessName, sErrorMessage)
If oProcess.GameInfo.ProcessPath <> String.Empty Then
'Update and reload
mgrMonitorList.DoListUpdate(oProcess.GameInfo)
LoadGameSettings()
bContinue = True
End If
Else
bContinue = True
bPathDetectionFailure = True
sPathDetectionError = mgrCommon.FormatString(frmMain_ErrorAdminBackup, oProcess.GameInfo.Name)
End If
bContinue = True
End If
ElseIf iErrorCode = 299 Then
If oProcess.Duplicate Then
sErrorMessage = mgrCommon.FormatString(frmMain_ErrorMulti64)
mgrCommon.ShowMessage(sErrorMessage, MsgBoxStyle.Exclamation)
UpdateLog(sErrorMessage, True, ToolTipIcon.Warning, True)
Else
If Not CheckForSavedPath() Then
sErrorMessage = mgrCommon.FormatString(frmMain_Error64Backup, oProcess.GameInfo.Name)
oProcess.GameInfo.ProcessPath = mgrPath.ProcessPathSearch(oProcess.GameInfo.Name, oProcess.GameInfo.ProcessName, sErrorMessage)
If oProcess.GameInfo.ProcessPath <> String.Empty Then
'Update and reload
mgrMonitorList.DoListUpdate(oProcess.GameInfo)
LoadGameSettings()
bContinue = True
End If
Else
bContinue = True
bPathDetectionFailure = True
sPathDetectionError = mgrCommon.FormatString(frmMain_Error64Backup, oProcess.GameInfo.Name)
End If
bContinue = True
End If
End If
End If
@@ -1584,9 +1570,6 @@ Public Class frmMain
bwMonitor.RunWorkerAsync()
Else
StopScan()
If bAskForRestart Then
RestartAsAdmin()
End If
End If
End If
End Sub
@@ -1607,21 +1590,44 @@ Public Class frmMain
End Sub
Private Sub bwMain_RunWorkerCompleted(sender As System.Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bwMonitor.RunWorkerCompleted
Dim bContinue As Boolean = True
oProcess.EndTime = Now
If Not bCancelledByUser Then
If DoMultiGameCheck() Then
UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False)
If oSettings.TimeTracking Then HandleTimeSpent()
RunBackup()
Else
UpdateLog(frmMain_UnknownGameEnded, False)
oProcess.GameInfo = Nothing
ResetGameInfo()
ResumeScan()
'Check if we failed to detect the game path
If bPathDetectionFailure Then
oProcess.GameInfo.ProcessPath = mgrPath.ProcessPathSearch(oProcess.GameInfo.Name, oProcess.GameInfo.ProcessName, sPathDetectionError)
If oProcess.GameInfo.ProcessPath <> String.Empty Then
'Update and reload
mgrMonitorList.DoListUpdate(oProcess.GameInfo)
LoadGameSettings()
Else
bContinue = False
If oSettings.TimeTracking Then HandleTimeSpent()
UpdateLog(mgrCommon.FormatString(frmMain_ErrorBackupUnknownPath, oProcess.GameInfo.Name), False)
oProcess.GameInfo = Nothing
ResetGameInfo()
ResumeScan()
End If
End If
If bContinue Then
If DoMultiGameCheck() Then
UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False)
If oSettings.TimeTracking Then HandleTimeSpent()
RunBackup()
Else
UpdateLog(frmMain_UnknownGameEnded, False)
oProcess.GameInfo = Nothing
ResetGameInfo()
ResumeScan()
End If
End If
End If
'Reset globals
bPathDetectionFailure = False
sPathDetectionError = String.Empty
bCancelledByUser = False
oProcess.StartTime = Now : oProcess.EndTime = Now
End Sub
+29 -10
View File
@@ -22,6 +22,7 @@ Partial Class frmSettings
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.chkMonitorOnStartup = New System.Windows.Forms.CheckBox()
Me.chkBackupConfirm = New System.Windows.Forms.CheckBox()
Me.grpGeneral = New System.Windows.Forms.GroupBox()
@@ -45,21 +46,24 @@ Partial Class frmSettings
Me.chkOverwriteWarning = New System.Windows.Forms.CheckBox()
Me.chkCreateFolder = New System.Windows.Forms.CheckBox()
Me.grp7z = New System.Windows.Forms.GroupBox()
Me.pbUtilityStatus = New System.Windows.Forms.PictureBox()
Me.btn7zLocation = New System.Windows.Forms.Button()
Me.txt7zLocation = New System.Windows.Forms.TextBox()
Me.lblLocation = New System.Windows.Forms.Label()
Me.txt7zArguments = New System.Windows.Forms.TextBox()
Me.lblArguments = New System.Windows.Forms.Label()
Me.lbl7zCopyright = New System.Windows.Forms.Label()
Me.cboCompression = New System.Windows.Forms.ComboBox()
Me.lblCompression = New System.Windows.Forms.Label()
Me.lbl7zCopyright = New System.Windows.Forms.Label()
Me.lbl7zProduct = New System.Windows.Forms.Label()
Me.btnDefaults = New System.Windows.Forms.Button()
Me.ttUtilityStatus = New System.Windows.Forms.ToolTip(Me.components)
Me.grpGeneral.SuspendLayout()
Me.grpPaths.SuspendLayout()
Me.grpBackup.SuspendLayout()
CType(Me.nudSupressBackupThreshold, System.ComponentModel.ISupportInitialize).BeginInit()
Me.grp7z.SuspendLayout()
CType(Me.pbUtilityStatus, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'chkMonitorOnStartup
@@ -290,6 +294,7 @@ Partial Class frmSettings
'
'grp7z
'
Me.grp7z.Controls.Add(Me.pbUtilityStatus)
Me.grp7z.Controls.Add(Me.btn7zLocation)
Me.grp7z.Controls.Add(Me.txt7zLocation)
Me.grp7z.Controls.Add(Me.lblLocation)
@@ -306,6 +311,15 @@ Partial Class frmSettings
Me.grp7z.TabStop = False
Me.grp7z.Text = "7z Options"
'
'pbUtilityStatus
'
Me.pbUtilityStatus.Location = New System.Drawing.Point(319, 93)
Me.pbUtilityStatus.Name = "pbUtilityStatus"
Me.pbUtilityStatus.Size = New System.Drawing.Size(35, 35)
Me.pbUtilityStatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.pbUtilityStatus.TabIndex = 7
Me.pbUtilityStatus.TabStop = False
'
'btn7zLocation
'
Me.btn7zLocation.Location = New System.Drawing.Point(327, 70)
@@ -347,6 +361,15 @@ Partial Class frmSettings
Me.lblArguments.TabIndex = 2
Me.lblArguments.Text = "Custom Arguments:"
'
'lbl7zCopyright
'
Me.lbl7zCopyright.AutoEllipsis = True
Me.lbl7zCopyright.Location = New System.Drawing.Point(9, 110)
Me.lbl7zCopyright.Name = "lbl7zCopyright"
Me.lbl7zCopyright.Size = New System.Drawing.Size(301, 17)
Me.lbl7zCopyright.TabIndex = 8
Me.lbl7zCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'cboCompression
'
Me.cboCompression.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
@@ -365,19 +388,12 @@ Partial Class frmSettings
Me.lblCompression.TabIndex = 0
Me.lblCompression.Text = "Compression:"
'
'lbl7zCopyright
'
Me.lbl7zCopyright.Location = New System.Drawing.Point(6, 110)
Me.lbl7zCopyright.Name = "lbl7zCopyright"
Me.lbl7zCopyright.Size = New System.Drawing.Size(348, 17)
Me.lbl7zCopyright.TabIndex = 8
Me.lbl7zCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'lbl7zProduct
'
Me.lbl7zProduct.AutoEllipsis = True
Me.lbl7zProduct.Location = New System.Drawing.Point(6, 93)
Me.lbl7zProduct.Name = "lbl7zProduct"
Me.lbl7zProduct.Size = New System.Drawing.Size(348, 17)
Me.lbl7zProduct.Size = New System.Drawing.Size(304, 17)
Me.lbl7zProduct.TabIndex = 7
Me.lbl7zProduct.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
@@ -419,6 +435,7 @@ Partial Class frmSettings
CType(Me.nudSupressBackupThreshold, System.ComponentModel.ISupportInitialize).EndInit()
Me.grp7z.ResumeLayout(False)
Me.grp7z.PerformLayout()
CType(Me.pbUtilityStatus, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
@@ -455,4 +472,6 @@ Partial Class frmSettings
Friend WithEvents txt7zArguments As TextBox
Friend WithEvents lblArguments As Label
Friend WithEvents btnDefaults As Button
Friend WithEvents pbUtilityStatus As PictureBox
Friend WithEvents ttUtilityStatus As ToolTip
End Class
+3
View File
@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ttUtilityStatus.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>32</value>
</metadata>
+23 -1
View File
@@ -116,19 +116,41 @@ Public Class frmSettings
End Function
Private Sub Get7zInfo(ByVal sLocation As String)
Dim bDefault As Boolean = False
Try
'Use default when no custom location is set
If sLocation = String.Empty Then
sLocation = mgrPath.Default7zLocation
bDefault = True
End If
'Get info
Dim oFileInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(sLocation)
lbl7zProduct.Text = oFileInfo.FileDescription & " " & oFileInfo.ProductVersion
lbl7zCopyright.Text = oFileInfo.LegalCopyright
'Set Status
If bDefault Then
If oSettings.Is7zUtilityValid Then
pbUtilityStatus.Image = Utility_Valid
ttUtilityStatus.ToolTipTitle = frmSettings_ttUtilityStatus_Title
ttUtilityStatus.SetToolTip(pbUtilityStatus, frmSettings_ttUtilityStatus_Valid7z)
Else
pbUtilityStatus.Image = Utility_Invalid
ttUtilityStatus.ToolTipTitle = frmSettings_ttUtilityStatus_Title
ttUtilityStatus.SetToolTip(pbUtilityStatus, frmSettings_ttUtilityStatus_Invalid7z)
End If
Else
pbUtilityStatus.Image = Utility_Custom
ttUtilityStatus.ToolTipTitle = frmSettings_ttUtilityStatus_Title
ttUtilityStatus.SetToolTip(pbUtilityStatus, frmSettings_ttUtilityStatus_Custom7z)
End If
Catch ex As Exception
lbl7zProduct.Text = mgrCommon.FormatString(frmSettings_Error7zInfo)
lbl7zProduct.Text = String.Empty
lbl7zCopyright.Text = String.Empty
pbUtilityStatus.Image = Utility_Invalid
ttUtilityStatus.ToolTipTitle = frmSettings_ttUtilityStatus_Title
ttUtilityStatus.SetToolTip(pbUtilityStatus, frmSettings_ttUtilityStatus_Failure7z)
End Try
End Sub