From 2beff1b46d33ecb311c10c3cc707ad7aa956f365 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Tue, 7 Jun 2016 17:11:52 -0600 Subject: [PATCH] Additions for issue #48 --- GBM/Classes/clsGame.vb | 46 +++++++- GBM/Forms/frmMain.vb | 14 +-- GBM/Forms/frmSettings.Designer.vb | 13 +++ GBM/Forms/frmSettings.vb | 53 ++++++--- GBM/Forms/frmStartUpWizard.vb | 8 +- GBM/Forms/frmSyncFields.Designer.vb | 163 +++++++++++++++++++++++++++ GBM/Forms/frmSyncFields.resx | 120 ++++++++++++++++++++ GBM/Forms/frmSyncFields.vb | 119 +++++++++++++++++++ GBM/Game Backup Monitor.vbproj | 9 ++ GBM/Managers/mgrCommon.vb | 8 ++ GBM/Managers/mgrMonitorList.vb | 90 ++++++++++++--- GBM/Managers/mgrSQLite.vb | 5 +- GBM/Managers/mgrSettings.vb | 16 ++- GBM/My Project/Resources.Designer.vb | 101 ++++++++++++++++- GBM/My Project/Resources.resx | 35 +++++- 15 files changed, 753 insertions(+), 47 deletions(-) create mode 100644 GBM/Forms/frmSyncFields.Designer.vb create mode 100644 GBM/Forms/frmSyncFields.resx create mode 100644 GBM/Forms/frmSyncFields.vb diff --git a/GBM/Classes/clsGame.vb b/GBM/Classes/clsGame.vb index 66a4eb4..081578f 100644 --- a/GBM/Classes/clsGame.vb +++ b/GBM/Classes/clsGame.vb @@ -19,6 +19,16 @@ Private bTempGame As Boolean = False Private oImportTags As New List(Of Tag) + Public Enum eOptionalSyncFields + None = 0 + GamePath = 1 + Company = 2 + Version = 4 + Icon = 16 + TimeStamp = 32 + MonitorGame = 64 + End Enum + Property ID As String Set(value As String) sGameID = value @@ -44,7 +54,6 @@ End Get End Property - Property Name As String Set(value As String) sGameName = value @@ -219,11 +228,12 @@ End Set End Property - Public Function SyncEquals(obj As Object) As Boolean + Public Function SyncEquals(obj As Object, eSyncFields As eOptionalSyncFields) As Boolean Dim oGame As clsGame = TryCast(obj, clsGame) If oGame Is Nothing Then Return False Else + 'Core Sync Fields If ID <> oGame.ID Then Return False End If @@ -257,6 +267,38 @@ If MonitorOnly <> oGame.MonitorOnly Then Return False End If + + 'Optional Sync Fields + If (eSyncFields And eOptionalSyncFields.Company) = eOptionalSyncFields.Company Then + If Company <> oGame.Company Then + Return False + End If + End If + If (eSyncFields And eOptionalSyncFields.GamePath) = eOptionalSyncFields.GamePath Then + If ProcessPath <> oGame.ProcessPath Then + Return False + End If + End If + If (eSyncFields And eOptionalSyncFields.Icon) = eOptionalSyncFields.Icon Then + If Icon <> oGame.Icon Then + Return False + End If + End If + If (eSyncFields And eOptionalSyncFields.MonitorGame) = eOptionalSyncFields.MonitorGame Then + If Enabled <> oGame.Enabled Then + Return False + End If + End If + If (eSyncFields And eOptionalSyncFields.TimeStamp) = eOptionalSyncFields.TimeStamp Then + If AppendTimeStamp <> oGame.AppendTimeStamp Then + Return False + End If + End If + If (eSyncFields And eOptionalSyncFields.Version) = eOptionalSyncFields.Version Then + If Version <> oGame.Version Then + Return False + End If + End If Return True End If End Function diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 4cb44af..29dd14b 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -556,7 +556,7 @@ Public Class frmMain End If mgrMonitorList.DoListUpdate(oProcess.GameInfo) - If oSettings.Sync Then mgrMonitorList.SyncMonitorLists() + If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) UpdateTimeSpent(dCurrentHours, oProcess.TimeSpent.TotalHours) End Sub @@ -671,7 +671,7 @@ Public Class frmMain Dim frm As New frmTags PauseScan() frm.ShowDialog() - If oSettings.Sync Then mgrMonitorList.SyncMonitorLists() + If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) ResumeScan() End Sub @@ -682,7 +682,7 @@ Public Class frmMain frm.PendingRestores = bPendingRestores frm.ShowDialog() LoadGameSettings() - If oSettings.Sync Then mgrMonitorList.SyncMonitorLists() + If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) ResumeScan() 'Handle backup trigger @@ -718,7 +718,7 @@ Public Class frmMain frm.GameData = mgrMonitorList.ReadList(mgrMonitorList.eListTypes.FullList) frm.ShowDialog() LoadGameSettings() - If oSettings.Sync Then mgrMonitorList.SyncMonitorLists() + If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) ResumeScan() End Sub @@ -727,7 +727,7 @@ Public Class frmMain PauseScan() frm.ShowDialog() mgrPath.CustomVariablesReload() - If oSettings.Sync Then mgrMonitorList.SyncMonitorLists() + If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) ResumeScan() End Sub @@ -798,7 +798,7 @@ Public Class frmMain Private Sub SyncGameSettings() 'Sync Monitor List - If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(False) + If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(oSettings.SyncFields, False) End Sub Private Sub LocalDatabaseCheck() @@ -1243,7 +1243,7 @@ Public Class frmMain oSettings.BackupFolder = sBackupPath oSettings.SaveSettings() oSettings.LoadSettings() - If oSettings.Sync Then mgrMonitorList.HandleBackupLocationChange() + If oSettings.Sync Then mgrMonitorList.HandleBackupLocationChange(oSettings) End If Return True Else diff --git a/GBM/Forms/frmSettings.Designer.vb b/GBM/Forms/frmSettings.Designer.vb index ed9d235..eeac30d 100644 --- a/GBM/Forms/frmSettings.Designer.vb +++ b/GBM/Forms/frmSettings.Designer.vb @@ -58,6 +58,7 @@ Partial Class frmSettings Me.lbl7zProduct = New System.Windows.Forms.Label() Me.btnDefaults = New System.Windows.Forms.Button() Me.ttUtilityStatus = New System.Windows.Forms.ToolTip(Me.components) + Me.btnOptionalFields = New System.Windows.Forms.Button() Me.grpGeneral.SuspendLayout() Me.grpPaths.SuspendLayout() Me.grpBackup.SuspendLayout() @@ -88,6 +89,7 @@ Partial Class frmSettings ' 'grpGeneral ' + Me.grpGeneral.Controls.Add(Me.btnOptionalFields) Me.grpGeneral.Controls.Add(Me.chkTimeTracking) Me.grpGeneral.Controls.Add(Me.chkSync) Me.grpGeneral.Controls.Add(Me.chkStartWindows) @@ -406,6 +408,16 @@ Partial Class frmSettings Me.btnDefaults.Text = "Set &Defaults" Me.btnDefaults.UseVisualStyleBackColor = True ' + 'btnOptionalFields + ' + Me.btnOptionalFields.DialogResult = System.Windows.Forms.DialogResult.OK + Me.btnOptionalFields.Location = New System.Drawing.Point(110, 130) + Me.btnOptionalFields.Name = "btnOptionalFields" + Me.btnOptionalFields.Size = New System.Drawing.Size(134, 23) + Me.btnOptionalFields.TabIndex = 6 + Me.btnOptionalFields.Text = "Choose &Optional Fields..." + Me.btnOptionalFields.UseVisualStyleBackColor = True + ' 'frmSettings ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -474,4 +486,5 @@ Partial Class frmSettings Friend WithEvents btnDefaults As Button Friend WithEvents pbUtilityStatus As PictureBox Friend WithEvents ttUtilityStatus As ToolTip + Friend WithEvents btnOptionalFields As Button End Class diff --git a/GBM/Forms/frmSettings.vb b/GBM/Forms/frmSettings.vb index f6534d5..75ac4a0 100644 --- a/GBM/Forms/frmSettings.vb +++ b/GBM/Forms/frmSettings.vb @@ -3,8 +3,9 @@ Imports System.IO Public Class frmSettings Dim bShutdown As Boolean = False - Dim bBackupLocationChanged As Boolean = False + Dim bSyncSettingsChanged As Boolean = False Dim bCheckSumDisabled As Boolean = False + Dim eCurrentSyncFields As clsGame.eOptionalSyncFields Private oSettings As mgrSettings Property Settings As mgrSettings @@ -16,15 +17,6 @@ Public Class frmSettings End Set End Property - Private Property BackupLocationChanged As Boolean - Get - Return bBackupLocationChanged - End Get - Set(value As Boolean) - bBackupLocationChanged = value - End Set - End Property - Private Sub HandleRegistryUpdate(ByVal bToggle As Boolean) Dim oKey As Microsoft.Win32.RegistryKey Dim sAppName As String = Application.ProductName @@ -76,13 +68,13 @@ Public Class frmSettings 'Turning syncing from off to on is the same as changing the backup folder If chkSync.Checked = True And oSettings.Sync = False Then - bBackupLocationChanged = True + bSyncSettingsChanged = True End If oSettings.Sync = chkSync.Checked If Directory.Exists(txtBackupFolder.Text) Then If oSettings.BackupFolder <> txtBackupFolder.Text Then - If chkSync.Checked Then bBackupLocationChanged = True + If chkSync.Checked Then bSyncSettingsChanged = True End If oSettings.BackupFolder = txtBackupFolder.Text Else @@ -101,13 +93,18 @@ Public Class frmSettings End If End If + 'We must trigger a sync if optional fields have changed + If Settings.Sync And (eCurrentSyncFields <> Settings.SyncFields) Then + bSyncSettingsChanged = True + End If + Return True End Function Private Function SaveSettings() As Boolean If ValidateSettings() Then oSettings.SaveSettings() - If BackupLocationChanged Then mgrMonitorList.HandleBackupLocationChange() + If bSyncSettingsChanged Then mgrMonitorList.HandleBackupLocationChange(Settings) If bCheckSumDisabled Then mgrManifest.DoManifestHashWipe() Return True Else @@ -184,6 +181,7 @@ Public Class frmSettings cboCompression.SelectedValue = oSettings.CompressionLevel txt7zArguments.Text = oSettings.Custom7zArguments txt7zLocation.Text = oSettings.Custom7zLocation + eCurrentSyncFields = oSettings.SyncFields 'Unix Handler If mgrCommon.IsUnix Then @@ -193,6 +191,9 @@ Public Class frmSettings 'Retrieve 7z Info Get7zInfo(oSettings.Custom7zLocation) + + 'Toggle Sync Button + ToggleSyncButton() End Sub Private Sub LoadCombos() @@ -212,6 +213,23 @@ Public Class frmSettings cboCompression.DataSource = oComboItems End Sub + Private Sub ToggleSyncButton() + If chkSync.Checked Then + btnOptionalFields.Enabled = True + Else + btnOptionalFields.Enabled = False + End If + End Sub + + Private Sub OpenOptionalFields() + Dim frm As New frmSyncFields + frm.SyncFields = Settings.SyncFields + frm.ShowDialog() + If frm.DialogResult = DialogResult.OK Then + Settings.SyncFields = frm.SyncFields + End If + End Sub + Private Sub SetForm() 'Set Form Name Me.Text = frmSettings_FormName @@ -242,6 +260,7 @@ Public Class frmSettings btnDefaults.Text = frmSettings_btnDefaults lblArguments.Text = frmSettings_lblArguments lblLocation.Text = frmSettings_lblLocation + btnOptionalFields.Text = frmSettings_btnOptionalFields 'Unix Handler If mgrCommon.IsUnix Then @@ -300,4 +319,12 @@ Public Class frmSettings Private Sub btnDefaults_Click(sender As Object, e As EventArgs) Handles btnDefaults.Click SetDefaults() End Sub + + Private Sub btnOptionalFields_Click(sender As Object, e As EventArgs) Handles btnOptionalFields.Click + OpenOptionalFields() + End Sub + + Private Sub chkSync_CheckedChanged(sender As Object, e As EventArgs) Handles chkSync.CheckedChanged + ToggleSyncButton() + End Sub End Class \ No newline at end of file diff --git a/GBM/Forms/frmStartUpWizard.vb b/GBM/Forms/frmStartUpWizard.vb index 1020093..71f2e8c 100644 --- a/GBM/Forms/frmStartUpWizard.vb +++ b/GBM/Forms/frmStartUpWizard.vb @@ -66,7 +66,7 @@ Public Class frmStartUpWizard If oDatabase.CheckDB() Then 'Make sure database is the latest version oDatabase.DatabaseUpgrade() - mgrMonitorList.SyncMonitorLists(False) + mgrMonitorList.SyncMonitorLists(oSettings.SyncFields, False) mgrCommon.ShowMessage(frmStartUpWizard_ExistingData, MsgBoxStyle.Information) End If End Sub @@ -107,7 +107,7 @@ Public Class frmStartUpWizard If mgrCommon.ShowMessage(frmStartUpWizard_ConfirmOfficialImport, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then If mgrMonitorList.DoImport(App_URLImport) Then oGameData = mgrMonitorList.ReadList(mgrMonitorList.eListTypes.FullList) - If oSettings.Sync Then mgrMonitorList.SyncMonitorLists() + If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) End If End If End Sub @@ -122,7 +122,7 @@ Public Class frmStartUpWizard frm.GameData = oGameData frm.ShowDialog() LoadGameSettings() - If oSettings.Sync Then mgrMonitorList.SyncMonitorLists() + If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) End Sub Private Sub OpenMonitorList() @@ -131,7 +131,7 @@ Public Class frmStartUpWizard frm.DisableExternalFunctions = True frm.ShowDialog() LoadGameSettings() - If oSettings.Sync Then mgrMonitorList.SyncMonitorLists() + If oSettings.Sync Then mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) End Sub Private Function ValidateBackupPath(ByVal strPath As String, ByRef sErrorMessage As String) As Boolean diff --git a/GBM/Forms/frmSyncFields.Designer.vb b/GBM/Forms/frmSyncFields.Designer.vb new file mode 100644 index 0000000..ffaa1d2 --- /dev/null +++ b/GBM/Forms/frmSyncFields.Designer.vb @@ -0,0 +1,163 @@ + _ +Partial Class frmSyncFields + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.grpFields = New System.Windows.Forms.GroupBox() + Me.chkMonitorGame = New System.Windows.Forms.CheckBox() + Me.chkIcon = New System.Windows.Forms.CheckBox() + Me.chkVersion = New System.Windows.Forms.CheckBox() + Me.chkCompany = New System.Windows.Forms.CheckBox() + Me.chkGamePath = New System.Windows.Forms.CheckBox() + Me.chkTimeStamp = New System.Windows.Forms.CheckBox() + Me.btnCancel = New System.Windows.Forms.Button() + Me.btnSave = New System.Windows.Forms.Button() + Me.grpFields.SuspendLayout() + Me.SuspendLayout() + ' + 'grpFields + ' + Me.grpFields.Controls.Add(Me.chkMonitorGame) + Me.grpFields.Controls.Add(Me.chkIcon) + Me.grpFields.Controls.Add(Me.chkVersion) + Me.grpFields.Controls.Add(Me.chkCompany) + Me.grpFields.Controls.Add(Me.chkGamePath) + Me.grpFields.Controls.Add(Me.chkTimeStamp) + Me.grpFields.Location = New System.Drawing.Point(12, 12) + Me.grpFields.Name = "grpFields" + Me.grpFields.Size = New System.Drawing.Size(195, 162) + Me.grpFields.TabIndex = 0 + Me.grpFields.TabStop = False + Me.grpFields.Text = "Available Fields" + ' + 'chkMonitorGame + ' + Me.chkMonitorGame.AutoSize = True + Me.chkMonitorGame.Location = New System.Drawing.Point(6, 134) + Me.chkMonitorGame.Name = "chkMonitorGame" + Me.chkMonitorGame.Size = New System.Drawing.Size(109, 17) + Me.chkMonitorGame.TabIndex = 5 + Me.chkMonitorGame.Text = "Monitor this game" + Me.chkMonitorGame.UseVisualStyleBackColor = True + ' + 'chkIcon + ' + Me.chkIcon.AutoSize = True + Me.chkIcon.Location = New System.Drawing.Point(6, 111) + Me.chkIcon.Name = "chkIcon" + Me.chkIcon.Size = New System.Drawing.Size(148, 17) + Me.chkIcon.TabIndex = 4 + Me.chkIcon.Text = "Icon (Not Recommended)" + Me.chkIcon.UseVisualStyleBackColor = True + ' + 'chkVersion + ' + Me.chkVersion.AutoSize = True + Me.chkVersion.Location = New System.Drawing.Point(6, 88) + Me.chkVersion.Name = "chkVersion" + Me.chkVersion.Size = New System.Drawing.Size(61, 17) + Me.chkVersion.TabIndex = 3 + Me.chkVersion.Text = "Version" + Me.chkVersion.UseVisualStyleBackColor = True + ' + 'chkCompany + ' + Me.chkCompany.AutoSize = True + Me.chkCompany.Location = New System.Drawing.Point(6, 65) + Me.chkCompany.Name = "chkCompany" + Me.chkCompany.Size = New System.Drawing.Size(70, 17) + Me.chkCompany.TabIndex = 2 + Me.chkCompany.Text = "Company" + Me.chkCompany.UseVisualStyleBackColor = True + ' + 'chkGamePath + ' + Me.chkGamePath.AutoSize = True + Me.chkGamePath.Location = New System.Drawing.Point(6, 42) + Me.chkGamePath.Name = "chkGamePath" + Me.chkGamePath.Size = New System.Drawing.Size(180, 17) + Me.chkGamePath.TabIndex = 1 + Me.chkGamePath.Text = "Game Path (Not Recommended)" + Me.chkGamePath.UseVisualStyleBackColor = True + ' + 'chkTimeStamp + ' + Me.chkTimeStamp.AutoSize = True + Me.chkTimeStamp.Location = New System.Drawing.Point(6, 19) + Me.chkTimeStamp.Name = "chkTimeStamp" + Me.chkTimeStamp.Size = New System.Drawing.Size(146, 17) + Me.chkTimeStamp.TabIndex = 0 + Me.chkTimeStamp.Text = "Time stamp each backup" + Me.chkTimeStamp.UseVisualStyleBackColor = True + ' + 'btnCancel + ' + Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.btnCancel.Location = New System.Drawing.Point(132, 180) + Me.btnCancel.Name = "btnCancel" + Me.btnCancel.Size = New System.Drawing.Size(75, 23) + Me.btnCancel.TabIndex = 2 + Me.btnCancel.Text = "&Cancel" + Me.btnCancel.UseVisualStyleBackColor = True + ' + 'btnSave + ' + Me.btnSave.DialogResult = System.Windows.Forms.DialogResult.OK + Me.btnSave.Location = New System.Drawing.Point(52, 180) + Me.btnSave.Name = "btnSave" + Me.btnSave.Size = New System.Drawing.Size(75, 23) + Me.btnSave.TabIndex = 1 + Me.btnSave.Text = "&Save" + Me.btnSave.UseVisualStyleBackColor = True + ' + 'frmSyncFields + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(219, 211) + Me.Controls.Add(Me.btnCancel) + Me.Controls.Add(Me.btnSave) + Me.Controls.Add(Me.grpFields) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "frmSyncFields" + Me.ShowIcon = False + Me.ShowInTaskbar = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Optional Sync Fields" + Me.grpFields.ResumeLayout(False) + Me.grpFields.PerformLayout() + Me.ResumeLayout(False) + + End Sub + + Friend WithEvents grpFields As GroupBox + Friend WithEvents chkMonitorGame As CheckBox + Friend WithEvents chkIcon As CheckBox + Friend WithEvents chkVersion As CheckBox + Friend WithEvents chkCompany As CheckBox + Friend WithEvents chkGamePath As CheckBox + Friend WithEvents chkTimeStamp As CheckBox + Friend WithEvents btnCancel As Button + Friend WithEvents btnSave As Button +End Class diff --git a/GBM/Forms/frmSyncFields.resx b/GBM/Forms/frmSyncFields.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/GBM/Forms/frmSyncFields.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GBM/Forms/frmSyncFields.vb b/GBM/Forms/frmSyncFields.vb new file mode 100644 index 0000000..fee8ff9 --- /dev/null +++ b/GBM/Forms/frmSyncFields.vb @@ -0,0 +1,119 @@ +Imports GBM.My.Resources + +Public Class frmSyncFields + Private eSyncFields As clsGame.eOptionalSyncFields + + Public Property SyncFields As clsGame.eOptionalSyncFields + Get + Return eSyncFields + End Get + Set(value As clsGame.eOptionalSyncFields) + eSyncFields = value + End Set + End Property + + Private Sub LoadForm() + 'Load fields + If (eSyncFields And clsGame.eOptionalSyncFields.Company) = clsGame.eOptionalSyncFields.Company Then + chkCompany.Checked = True + End If + If (eSyncFields And clsGame.eOptionalSyncFields.GamePath) = clsGame.eOptionalSyncFields.GamePath Then + chkGamePath.Checked = True + End If + If (eSyncFields And clsGame.eOptionalSyncFields.Icon) = clsGame.eOptionalSyncFields.Icon Then + chkIcon.Checked = True + End If + If (eSyncFields And clsGame.eOptionalSyncFields.MonitorGame) = clsGame.eOptionalSyncFields.MonitorGame Then + chkMonitorGame.Checked = True + End If + If (eSyncFields And clsGame.eOptionalSyncFields.TimeStamp) = clsGame.eOptionalSyncFields.TimeStamp Then + chkTimeStamp.Checked = True + End If + If (eSyncFields And clsGame.eOptionalSyncFields.Version) = clsGame.eOptionalSyncFields.Version Then + chkVersion.Checked = True + End If + End Sub + + Private Sub SetForm() + 'Set Form Name + Me.Text = frmSyncFields_FormName + + 'Set Form Text + btnCancel.Text = frmSyncFields_btnCancel + btnSave.Text = frmSyncFields_btnSave + grpFields.Text = frmSyncFields_grpFields + chkMonitorGame.Text = frmSyncFields_chkMonitorGame + chkIcon.Text = frmSyncFields_chkIcon + chkVersion.Text = frmSyncFields_chkVersion + chkCompany.Text = frmSyncFields_chkCompany + chkGamePath.Text = frmSyncFields_chkGamePath + chkTimeStamp.Text = frmSyncFields_chkTimeStamp + End Sub + + Private Sub frmSyncFields_Load(sender As Object, e As EventArgs) Handles MyBase.Load + SetForm() + LoadForm() + Dim sResources As String = String.Empty + Dim sCode As String = String.Empty + mgrCommon.GetAllStrings(Me, sResources, sCode, "frmSyncFields") + Clipboard.SetText(sResources & vbCrLf & vbCrLf & sCode) + End Sub + + Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click + Me.DialogResult = DialogResult.OK + Me.Close() + End Sub + + Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click + Me.DialogResult = DialogResult.Cancel + Me.Close() + End Sub + + Private Sub chkTimeStamp_CheckedChanged(sender As Object, e As EventArgs) Handles chkTimeStamp.CheckedChanged + If chkTimeStamp.Checked Then + SyncFields = mgrCommon.SetSyncField(SyncFields, clsGame.eOptionalSyncFields.TimeStamp) + Else + SyncFields = mgrCommon.RemoveSyncField(SyncFields, clsGame.eOptionalSyncFields.TimeStamp) + End If + End Sub + + Private Sub chkGamePath_CheckedChanged(sender As Object, e As EventArgs) Handles chkGamePath.CheckedChanged + If chkGamePath.Checked Then + SyncFields = mgrCommon.SetSyncField(SyncFields, clsGame.eOptionalSyncFields.GamePath) + Else + SyncFields = mgrCommon.RemoveSyncField(SyncFields, clsGame.eOptionalSyncFields.GamePath) + End If + End Sub + + Private Sub chkCompany_CheckedChanged(sender As Object, e As EventArgs) Handles chkCompany.CheckedChanged + If chkCompany.Checked Then + SyncFields = mgrCommon.SetSyncField(SyncFields, clsGame.eOptionalSyncFields.Company) + Else + SyncFields = mgrCommon.RemoveSyncField(SyncFields, clsGame.eOptionalSyncFields.Company) + End If + End Sub + + Private Sub chkVersion_CheckedChanged(sender As Object, e As EventArgs) Handles chkVersion.CheckedChanged + If chkVersion.Checked Then + SyncFields = mgrCommon.SetSyncField(SyncFields, clsGame.eOptionalSyncFields.Version) + Else + SyncFields = mgrCommon.RemoveSyncField(SyncFields, clsGame.eOptionalSyncFields.Version) + End If + End Sub + + Private Sub chkIcon_CheckedChanged(sender As Object, e As EventArgs) Handles chkIcon.CheckedChanged + If chkIcon.Checked Then + SyncFields = mgrCommon.SetSyncField(SyncFields, clsGame.eOptionalSyncFields.Icon) + Else + SyncFields = mgrCommon.RemoveSyncField(SyncFields, clsGame.eOptionalSyncFields.Icon) + End If + End Sub + + Private Sub chkMonitorGame_CheckedChanged(sender As Object, e As EventArgs) Handles chkMonitorGame.CheckedChanged + If chkMonitorGame.Checked Then + SyncFields = mgrCommon.SetSyncField(SyncFields, clsGame.eOptionalSyncFields.MonitorGame) + Else + SyncFields = mgrCommon.RemoveSyncField(SyncFields, clsGame.eOptionalSyncFields.MonitorGame) + End If + End Sub +End Class \ No newline at end of file diff --git a/GBM/Game Backup Monitor.vbproj b/GBM/Game Backup Monitor.vbproj index f437b39..d76079d 100644 --- a/GBM/Game Backup Monitor.vbproj +++ b/GBM/Game Backup Monitor.vbproj @@ -195,6 +195,12 @@ frmMain.vb Form + + frmSyncFields.vb + + + Form + frmTags.vb @@ -273,6 +279,9 @@ frmMain.vb Designer + + frmSyncFields.vb + frmTags.vb diff --git a/GBM/Managers/mgrCommon.vb b/GBM/Managers/mgrCommon.vb index 87d88b3..d2752fa 100644 --- a/GBM/Managers/mgrCommon.vb +++ b/GBM/Managers/mgrCommon.vb @@ -157,6 +157,14 @@ Public Class mgrCommon oProcess.Start() End Sub + Public Shared Function SetSyncField(ByVal eSyncFields As clsGame.eOptionalSyncFields, ByVal eSyncField As clsGame.eOptionalSyncFields) As clsGame.eOptionalSyncFields + Return eSyncFields Or eSyncField + End Function + + Public Shared Function RemoveSyncField(ByVal eSyncFields As clsGame.eOptionalSyncFields, ByVal eSyncField As clsGame.eOptionalSyncFields) As clsGame.eOptionalSyncFields + Return eSyncFields And (Not eSyncField) + End Function + 'Delete file based on OS type Public Shared Sub DeleteFile(ByVal sPath As String, Optional ByVal bRecycle As Boolean = True) If File.Exists(sPath) Then diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index bb1c598..77a5b77 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -10,7 +10,7 @@ Public Class mgrMonitorList Public Shared Event UpdateLog(sLogUpdate As String, bTrayUpdate As Boolean, objIcon As System.Windows.Forms.ToolTipIcon, bTimeStamp As Boolean) - Public Shared Sub HandleBackupLocationChange() + Public Shared Sub HandleBackupLocationChange(ByVal oSettings As mgrSettings) Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Remote) Dim iGameCount As Integer @@ -25,15 +25,15 @@ Public Class mgrMonitorList 'If the remote database actually contains a list, then ask what to do If iGameCount > 0 Then If mgrCommon.ShowMessage(mgrMonitorList_ConfirmExistingData, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then - mgrMonitorList.SyncMonitorLists() + mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) Else - mgrMonitorList.SyncMonitorLists(False) + mgrMonitorList.SyncMonitorLists(oSettings.SyncFields, False) End If Else - mgrMonitorList.SyncMonitorLists() + mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) End If Else - mgrMonitorList.SyncMonitorLists() + mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) End If End Sub @@ -61,22 +61,63 @@ Public Class mgrMonitorList End If End Sub - Public Shared Sub DoListAddUpdateSync(ByVal hshGames As Hashtable, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) + Public Shared Sub DoListAddUpdateSync(ByVal hshGames As Hashtable, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local, + Optional ByVal eSyncFields As clsGame.eOptionalSyncFields = clsGame.eOptionalSyncFields.None) Dim oDatabase As New mgrSQLite(iSelectDB) Dim sSQL As String Dim hshParams As Hashtable Dim oParamList As New List(Of Hashtable) + 'Handle Optional Sync Fields + Dim sGamePath As String + Dim sIcon As String + Dim sVersion As String + Dim sCompany As String + Dim sMonitorGame As String + Dim sTimeStamp As String + + 'Setup SQL for optional fields + If (eSyncFields And clsGame.eOptionalSyncFields.Company) = clsGame.eOptionalSyncFields.Company Then + sCompany = "@Company" + Else + sCompany = "(SELECT Company FROM monitorlist WHERE MonitorID=@ID)" + End If + If (eSyncFields And clsGame.eOptionalSyncFields.GamePath) = clsGame.eOptionalSyncFields.GamePath Then + sGamePath = "@ProcessPath" + Else + sGamePath = "(SELECT ProcessPath FROM monitorlist WHERE MonitorID=@ID)" + End If + If (eSyncFields And clsGame.eOptionalSyncFields.Icon) = clsGame.eOptionalSyncFields.Icon Then + sIcon = "@Icon" + Else + sIcon = "(SELECT Icon FROM monitorlist WHERE MonitorID=@ID)" + End If + If (eSyncFields And clsGame.eOptionalSyncFields.MonitorGame) = clsGame.eOptionalSyncFields.MonitorGame Then + sMonitorGame = "@Enabled" + Else + sMonitorGame = "COALESCE((SELECT Enabled FROM monitorlist WHERE MonitorID=@ID),1)" + End If + If (eSyncFields And clsGame.eOptionalSyncFields.TimeStamp) = clsGame.eOptionalSyncFields.TimeStamp Then + sTimeStamp = "@TimeStamp" + Else + sTimeStamp = "COALESCE((SELECT TimeStamp FROM monitorlist WHERE MonitorID=@ID),0)" + End If + If (eSyncFields And clsGame.eOptionalSyncFields.Version) = clsGame.eOptionalSyncFields.Version Then + sVersion = "@Version" + Else + sVersion = "(SELECT Version FROM monitorlist WHERE MonitorID=@ID)" + End If + sSQL = "INSERT OR REPLACE INTO monitorlist (MonitorID, Name, Process, Path, AbsolutePath, FolderSave, FileType, TimeStamp, ExcludeList, ProcessPath, Icon, Hours, Version, Company, Enabled, MonitorOnly) " sSQL &= "VALUES (@ID, @Name, @Process, @Path, @AbsolutePath, @FolderSave, @FileType, " - sSQL &= "@TimeStamp, @ExcludeList, (SELECT ProcessPath FROM monitorlist WHERE MonitorID=@ID), " - sSQL &= "(SELECT Icon FROM monitorlist WHERE MonitorID=@ID), @Hours, (SELECT Version FROM monitorlist WHERE MonitorID=@ID), " - sSQL &= "(SELECT Company FROM monitorlist WHERE MonitorID=@ID), COALESCE((SELECT Enabled FROM monitorlist WHERE MonitorID=@ID),1), @MonitorOnly);" + sSQL &= sTimeStamp & ", @ExcludeList, " & sGamePath & ", " + sSQL &= sIcon & ", @Hours, " & sVersion & ", " + sSQL &= sCompany & ", " & sMonitorGame & ", @MonitorOnly);" For Each oGame As clsGame In hshGames.Values hshParams = New Hashtable - 'Parameters + 'Core Parameters hshParams.Add("ID", oGame.ID) hshParams.Add("Name", oGame.Name) hshParams.Add("Process", oGame.TrueProcess) @@ -84,11 +125,30 @@ Public Class mgrMonitorList hshParams.Add("AbsolutePath", oGame.AbsolutePath) hshParams.Add("FolderSave", oGame.FolderSave) hshParams.Add("FileType", oGame.FileType) - hshParams.Add("TimeStamp", oGame.AppendTimeStamp) hshParams.Add("ExcludeList", oGame.ExcludeList) hshParams.Add("Hours", oGame.Hours) hshParams.Add("MonitorOnly", oGame.MonitorOnly) + 'Optional Parameters + If (eSyncFields And clsGame.eOptionalSyncFields.Company) = clsGame.eOptionalSyncFields.Company Then + hshParams.Add("Company", oGame.Company) + End If + If (eSyncFields And clsGame.eOptionalSyncFields.GamePath) = clsGame.eOptionalSyncFields.GamePath Then + hshParams.Add("ProcessPath", oGame.ProcessPath) + End If + If (eSyncFields And clsGame.eOptionalSyncFields.Icon) = clsGame.eOptionalSyncFields.Icon Then + hshParams.Add("Icon", oGame.Icon) + End If + If (eSyncFields And clsGame.eOptionalSyncFields.MonitorGame) = clsGame.eOptionalSyncFields.MonitorGame Then + hshParams.Add("Enabled", oGame.Enabled) + End If + If (eSyncFields And clsGame.eOptionalSyncFields.TimeStamp) = clsGame.eOptionalSyncFields.TimeStamp Then + hshParams.Add("TimeStamp", oGame.AppendTimeStamp) + End If + If (eSyncFields And clsGame.eOptionalSyncFields.Version) = clsGame.eOptionalSyncFields.Version Then + hshParams.Add("Version", oGame.Version) + End If + oParamList.Add(hshParams) Next @@ -118,7 +178,7 @@ Public Class mgrMonitorList oDatabase.RunMassParamQuery(sSQL, oParamList) End Sub - Public Shared Sub SyncMonitorLists(Optional ByVal bToRemote As Boolean = True) + Public Shared Sub SyncMonitorLists(ByVal eSyncFields As clsGame.eOptionalSyncFields, Optional ByVal bToRemote As Boolean = True) Dim hshCompareFrom As Hashtable Dim hshCompareTo As Hashtable Dim hshSyncItems As Hashtable @@ -149,16 +209,16 @@ Public Class mgrMonitorList For Each oFromItem In hshCompareFrom.Values If hshCompareTo.Contains(oFromItem.CompoundKey) Then oToItem = DirectCast(hshCompareTo(oFromItem.CompoundKey), clsGame) - If oFromItem.SyncEquals(oToItem) Then + If oFromItem.SyncEquals(oToItem, eSyncFields) Then hshSyncItems.Remove(oFromItem.CompoundKey) End If End If Next If bToRemote Then - DoListAddUpdateSync(hshSyncItems, mgrSQLite.Database.Remote) + DoListAddUpdateSync(hshSyncItems, mgrSQLite.Database.Remote, eSyncFields) Else - DoListAddUpdateSync(hshSyncItems, mgrSQLite.Database.Local) + DoListAddUpdateSync(hshSyncItems, mgrSQLite.Database.Local, eSyncFields) End If 'Sync Tags diff --git a/GBM/Managers/mgrSQLite.vb b/GBM/Managers/mgrSQLite.vb index d342d37..2f2fb1a 100644 --- a/GBM/Managers/mgrSQLite.vb +++ b/GBM/Managers/mgrSQLite.vb @@ -74,7 +74,7 @@ Public Class mgrSQLite "DisableConfirmation BOOLEAN NOT NULL, CreateSubFolder BOOLEAN NOT NULL, ShowOverwriteWarning BOOLEAN NOT NULL, RestoreOnLaunch BOOLEAN NOT NULL, " & "BackupFolder TEXT NOT NULL, Sync BOOLEAN NOT NULL, CheckSum BOOLEAN NOT NULL, StartWithWindows BOOLEAN NOT NULL, TimeTracking BOOLEAN NOT NULL, " & "SupressBackup BOOLEAN NOT NULL, SupressBackupThreshold INTEGER NOT NULL, CompressionLevel INTEGER NOT NULL, Custom7zArguments TEXT, " & - "Custom7zLocation TEXT);" + "Custom7zLocation TEXT, SyncFields INTEGER NOT NULL);" 'Add Tables (Monitor List) sSql &= "CREATE TABLE monitorlist (MonitorID TEXT NOT NULL UNIQUE, Name TEXT NOT NULL, Process TEXT NOT NULL, Path TEXT, " & @@ -537,9 +537,10 @@ Public Class mgrSQLite 'Backup DB before starting BackupDB("v96") - 'Add new setting + 'Add new settings sSQL = "ALTER TABLE settings ADD COLUMN Custom7zArguments TEXT;" sSQL &= "ALTER TABLE settings ADD COLUMN Custom7zLocation TEXT;" + sSQL &= "ALTER TABLE settings ADD COLUMN SyncFields INTEGER NOT NULL DEFAULT 32;" sSQL &= "PRAGMA user_version=97" RunParamQuery(sSQL, New Hashtable) diff --git a/GBM/Managers/mgrSettings.vb b/GBM/Managers/mgrSettings.vb index 94ecf4d..6db1bff 100644 --- a/GBM/Managers/mgrSettings.vb +++ b/GBM/Managers/mgrSettings.vb @@ -18,6 +18,7 @@ Public Class mgrSettings Private s7zArguments As String = String.Empty Private s7zLocation As String = String.Empty Private sBackupFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).TrimEnd(New Char() {"\", "/"}) + Private eSyncFields As clsGame.eOptionalSyncFields = clsGame.eOptionalSyncFields.None Or clsGame.eOptionalSyncFields.TimeStamp Property StartWithWindows As Boolean Get @@ -220,6 +221,15 @@ Public Class mgrSettings End Set End Property + Property SyncFields As clsGame.eOptionalSyncFields + Get + Return eSyncFields + End Get + Set(value As clsGame.eOptionalSyncFields) + eSyncFields = value + End Set + End Property + Private Sub SaveFromClass() Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Local) Dim sSQL As String @@ -230,7 +240,8 @@ Public Class mgrSettings sSQL = "INSERT INTO settings VALUES (1, @MonitorOnStartup, @StartToTray, @ShowDetectionToolTips, @DisableConfirmation, " sSQL &= "@CreateSubFolder, @ShowOverwriteWarning, @RestoreOnLaunch, @BackupFolder, @Sync, @CheckSum, @StartWithWindows, " - sSQL &= "@TimeTracking, @SupressBackup, @SupressBackupThreshold, @CompressionLevel, @Custom7zArguments, @Custom7zLocation)" + sSQL &= "@TimeTracking, @SupressBackup, @SupressBackupThreshold, @CompressionLevel, @Custom7zArguments, @Custom7zLocation, " + sSQL &= "@SyncFields)" hshParams.Add("MonitorOnStartup", MonitorOnStartup) hshParams.Add("StartToTray", StartToTray) @@ -249,7 +260,7 @@ Public Class mgrSettings hshParams.Add("CompressionLevel", CompressionLevel) hshParams.Add("Custom7zArguments", Custom7zArguments) hshParams.Add("Custom7zLocation", Custom7zLocation) - + hshParams.Add("SyncFields", SyncFields) oDatabase.RunParamQuery(sSQL, hshParams) End Sub @@ -281,6 +292,7 @@ Public Class mgrSettings CompressionLevel = CInt(dr("CompressionLevel")) If Not IsDBNull(dr("Custom7zArguments")) Then Custom7zArguments = CStr(dr("Custom7zArguments")) If Not IsDBNull(dr("Custom7zLocation")) Then Custom7zLocation = CStr(dr("Custom7zLocation")) + SyncFields = CInt(dr("SyncFields")) Next oDatabase.Disconnect() diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 65768d0..9bb462d 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -3147,6 +3147,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Choose &Optional Fields.... + ''' + Friend ReadOnly Property frmSettings_btnOptionalFields() As String + Get + Return ResourceManager.GetString("frmSettings_btnOptionalFields", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to &Save. ''' @@ -3759,6 +3768,96 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to &Cancel. + ''' + Friend ReadOnly Property frmSyncFields_btnCancel() As String + Get + Return ResourceManager.GetString("frmSyncFields_btnCancel", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to &Save. + ''' + Friend ReadOnly Property frmSyncFields_btnSave() As String + Get + Return ResourceManager.GetString("frmSyncFields_btnSave", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Company. + ''' + Friend ReadOnly Property frmSyncFields_chkCompany() As String + Get + Return ResourceManager.GetString("frmSyncFields_chkCompany", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Game Path (Not Recommended). + ''' + Friend ReadOnly Property frmSyncFields_chkGamePath() As String + Get + Return ResourceManager.GetString("frmSyncFields_chkGamePath", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Icon (Not Recommended). + ''' + Friend ReadOnly Property frmSyncFields_chkIcon() As String + Get + Return ResourceManager.GetString("frmSyncFields_chkIcon", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Monitor this game. + ''' + Friend ReadOnly Property frmSyncFields_chkMonitorGame() As String + Get + Return ResourceManager.GetString("frmSyncFields_chkMonitorGame", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Time stamp each backup. + ''' + Friend ReadOnly Property frmSyncFields_chkTimeStamp() As String + Get + Return ResourceManager.GetString("frmSyncFields_chkTimeStamp", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Version. + ''' + Friend ReadOnly Property frmSyncFields_chkVersion() As String + Get + Return ResourceManager.GetString("frmSyncFields_chkVersion", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Optional Sync Fields. + ''' + Friend ReadOnly Property frmSyncFields_FormName() As String + Get + Return ResourceManager.GetString("frmSyncFields_FormName", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Available Fields. + ''' + Friend ReadOnly Property frmSyncFields_grpFields() As String + Get + Return ResourceManager.GetString("frmSyncFields_grpFields", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to +. ''' @@ -4322,7 +4421,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to GBM data already exists in the backup folder.[BR][BR]Do you want to make your local game list the new master game list in this folder? (Recommended)[BR][BR]Choosing No will sync your local game list to the current master game list in this folder.. + ''' Looks up a localized string similar to The sync settings have changed and data already exists in the backup folder.[BR][BR]Do you want to make your current game data on this PC the new master game data in this folder? (Highly Recommended)[BR][BR]Choosing No will sync your game data on this PC to the current master game data in this folder.. ''' Friend ReadOnly Property mgrMonitorList_ConfirmExistingData() As String Get diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index e85fca8..a0a4ea7 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1361,7 +1361,7 @@ Would you like to apply a filter to your export? - GBM data already exists in the backup folder.[BR][BR]Do you want to make your local game list the new master game list in this folder? (Recommended)[BR][BR]Choosing No will sync your local game list to the current master game list in this folder. + The sync settings have changed and data already exists in the backup folder.[BR][BR]Do you want to make your current game data on this PC the new master game data in this folder? (Highly Recommended)[BR][BR]Choosing No will sync your game data on this PC to the current master game data in this folder. Export Complete. [PARAM] item(s) have been exported. @@ -1660,4 +1660,37 @@ A backup cannot be run on the selected game(s) with their current configuration. + + Choose &Optional Fields... + + + &Cancel + + + &Save + + + Company + + + Game Path (Not Recommended) + + + Icon (Not Recommended) + + + Monitor this game + + + Time stamp each backup + + + Version + + + Optional Sync Fields + + + Available Fields + \ No newline at end of file