From a6341ffa76088e7b47f5b7eaf905cd23fec51bf7 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Fri, 11 Mar 2016 16:26:20 -0600 Subject: [PATCH] Updates for issue #22 --- GBM/Forms/frmAdvancedImport.Designer.vb | 62 +++++++++---- GBM/Forms/frmAdvancedImport.vb | 117 +++++++++++++++++++----- GBM/Forms/frmGameManager.vb | 2 +- GBM/Managers/mgrCommon.vb | 10 +- GBM/Managers/mgrMonitorList.vb | 6 +- GBM/My Project/Resources.Designer.vb | 40 +++++++- GBM/My Project/Resources.resx | 16 +++- 7 files changed, 202 insertions(+), 51 deletions(-) diff --git a/GBM/Forms/frmAdvancedImport.Designer.vb b/GBM/Forms/frmAdvancedImport.Designer.vb index 4e81648..f8ca1cf 100644 --- a/GBM/Forms/frmAdvancedImport.Designer.vb +++ b/GBM/Forms/frmAdvancedImport.Designer.vb @@ -22,28 +22,22 @@ Partial Class frmAdvancedImport 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - Me.lstGames = New System.Windows.Forms.CheckedListBox() Me.btnImport = New System.Windows.Forms.Button() Me.chkSelectAll = New System.Windows.Forms.CheckBox() Me.lblGames = New System.Windows.Forms.Label() Me.lblSelected = New System.Windows.Forms.Label() Me.btnCancel = New System.Windows.Forms.Button() + Me.lstGames = New System.Windows.Forms.ListView() + Me.txtFilter = New System.Windows.Forms.TextBox() + Me.lblFilter = New System.Windows.Forms.Label() Me.SuspendLayout() ' - 'lstGames - ' - Me.lstGames.CheckOnClick = True - Me.lstGames.Location = New System.Drawing.Point(12, 30) - Me.lstGames.Name = "lstGames" - Me.lstGames.Size = New System.Drawing.Size(335, 334) - Me.lstGames.TabIndex = 1 - ' 'btnImport ' - Me.btnImport.Location = New System.Drawing.Point(191, 370) + Me.btnImport.Location = New System.Drawing.Point(416, 375) Me.btnImport.Name = "btnImport" Me.btnImport.Size = New System.Drawing.Size(75, 23) - Me.btnImport.TabIndex = 2 + Me.btnImport.TabIndex = 3 Me.btnImport.Text = "&Import" Me.btnImport.UseVisualStyleBackColor = True ' @@ -58,9 +52,9 @@ Partial Class frmAdvancedImport ' 'lblGames ' - Me.lblGames.Location = New System.Drawing.Point(12, 12) + Me.lblGames.Location = New System.Drawing.Point(12, 380) Me.lblGames.Name = "lblGames" - Me.lblGames.Size = New System.Drawing.Size(335, 14) + Me.lblGames.Size = New System.Drawing.Size(560, 14) Me.lblGames.TabIndex = 0 Me.lblGames.Text = "Games" Me.lblGames.TextAlign = System.Drawing.ContentAlignment.TopCenter @@ -68,7 +62,7 @@ Partial Class frmAdvancedImport 'lblSelected ' Me.lblSelected.AutoSize = True - Me.lblSelected.Location = New System.Drawing.Point(9, 375) + Me.lblSelected.Location = New System.Drawing.Point(9, 380) Me.lblSelected.Name = "lblSelected" Me.lblSelected.Size = New System.Drawing.Size(77, 13) Me.lblSelected.TabIndex = 0 @@ -76,23 +70,51 @@ Partial Class frmAdvancedImport ' 'btnCancel ' - Me.btnCancel.Location = New System.Drawing.Point(272, 370) + Me.btnCancel.Location = New System.Drawing.Point(497, 375) Me.btnCancel.Name = "btnCancel" Me.btnCancel.Size = New System.Drawing.Size(75, 23) - Me.btnCancel.TabIndex = 3 + Me.btnCancel.TabIndex = 4 Me.btnCancel.Text = "&Cancel" Me.btnCancel.UseVisualStyleBackColor = True ' + 'lstGames + ' + Me.lstGames.CheckBoxes = True + Me.lstGames.FullRowSelect = True + Me.lstGames.Location = New System.Drawing.Point(12, 32) + Me.lstGames.Name = "lstGames" + Me.lstGames.Size = New System.Drawing.Size(560, 332) + Me.lstGames.TabIndex = 2 + Me.lstGames.UseCompatibleStateImageBehavior = False + Me.lstGames.View = System.Windows.Forms.View.Details + ' + 'txtFilter + ' + Me.txtFilter.Location = New System.Drawing.Point(416, 9) + Me.txtFilter.Name = "txtFilter" + Me.txtFilter.Size = New System.Drawing.Size(156, 20) + Me.txtFilter.TabIndex = 1 + ' + 'lblFilter + ' + Me.lblFilter.Location = New System.Drawing.Point(363, 12) + Me.lblFilter.Name = "lblFilter" + Me.lblFilter.Size = New System.Drawing.Size(47, 14) + Me.lblFilter.TabIndex = 0 + Me.lblFilter.Text = "Search:" + ' 'frmAdvancedImport ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(359, 402) + Me.ClientSize = New System.Drawing.Size(584, 411) + Me.Controls.Add(Me.lblFilter) + Me.Controls.Add(Me.txtFilter) + Me.Controls.Add(Me.lstGames) Me.Controls.Add(Me.btnCancel) Me.Controls.Add(Me.lblSelected) Me.Controls.Add(Me.chkSelectAll) Me.Controls.Add(Me.btnImport) - Me.Controls.Add(Me.lstGames) Me.Controls.Add(Me.lblGames) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False @@ -105,10 +127,12 @@ Partial Class frmAdvancedImport Me.PerformLayout() End Sub - Friend WithEvents lstGames As System.Windows.Forms.CheckedListBox Friend WithEvents btnImport As System.Windows.Forms.Button Friend WithEvents chkSelectAll As System.Windows.Forms.CheckBox Friend WithEvents lblGames As System.Windows.Forms.Label Friend WithEvents lblSelected As System.Windows.Forms.Label Friend WithEvents btnCancel As System.Windows.Forms.Button + Friend WithEvents lstGames As System.Windows.Forms.ListView + Friend WithEvents txtFilter As System.Windows.Forms.TextBox + Friend WithEvents lblFilter As System.Windows.Forms.Label End Class diff --git a/GBM/Forms/frmAdvancedImport.vb b/GBM/Forms/frmAdvancedImport.vb index c6695e2..4d1e869 100644 --- a/GBM/Forms/frmAdvancedImport.vb +++ b/GBM/Forms/frmAdvancedImport.vb @@ -3,8 +3,10 @@ Public Class frmAdvancedImport Private hshImportData As Hashtable + Private hshFinalData As New Hashtable Private bSelectAll As Boolean = False Private bIsLoading As Boolean = False + Private WithEvents tmFilterTimer As Timer Public Property ImportData As Hashtable Set(value As Hashtable) @@ -15,33 +17,67 @@ Public Class frmAdvancedImport End Get End Property + Public ReadOnly Property FinalData As Hashtable + Get + Return hshFinalData + End Get + End Property + + Private Sub SelectToggle() + Cursor.Current = Cursors.WaitCursor + lstGames.BeginUpdate() bSelectAll = Not bSelectAll For i As Integer = 0 To lstGames.Items.Count - 1 - lstGames.SetItemChecked(i, bSelectAll) + lstGames.Items(i).Checked = bSelectAll Next + lstGames.EndUpdate() + Cursor.Current = Cursors.Default UpdateSelected() End Sub - Private Sub LoadData() + Private Sub LoadData(Optional ByVal sFilter As String = "") Dim oApp As clsGame - Dim oData As KeyValuePair(Of String, String) - Dim oList As New List(Of KeyValuePair(Of String, String)) + Dim oListViewItem As ListViewItem + Dim sTags As String + + + Cursor.Current = Cursors.WaitCursor + lstGames.BeginUpdate() + + lstGames.Clear() + + lstGames.Columns.Add(frmAdvancedImport_ColumnName, 215) + lstGames.Columns.Add(frmAdvancedImport_ColumnProcess, 130) + lstGames.Columns.Add(frmAdvancedImport_ColumnTags, 190) For Each de As DictionaryEntry In ImportData oApp = DirectCast(de.Value, clsGame) - oData = New KeyValuePair(Of String, String)(oApp.CompoundKey, oApp.Name & " (" & oApp.TrueProcess & ")") - oList.Add(oData) + sTags = String.Empty + oApp.ImportTags.Sort(AddressOf mgrCommon.CompareImportTagsByName) + For Each oTag As Tag In oApp.ImportTags + sTags &= oTag.Name & ", " + Next + sTags = sTags.TrimEnd(New Char() {",", " "}) + + oListViewItem = New ListViewItem(New String() {oApp.Name, oApp.TrueProcess, sTags}) + oListViewItem.Tag = oApp.CompoundKey + oListViewItem.Checked = bSelectAll + + If sFilter = String.Empty Then + lstGames.Items.Add(oListViewItem) + Else + If oApp.Name.ToLower.Contains(sFilter.ToLower) Or oApp.TrueProcess.ToLower.Contains(sFilter.ToLower) Or sTags.ToLower.Contains(sFilter.ToLower) Then + lstGames.Items.Add(oListViewItem) + End If + End If Next - oList.Sort(AddressOf mgrCommon.CompareByName) - - lstGames.BeginUpdate() - lstGames.DataSource = oList - lstGames.ValueMember = "Key" - lstGames.DisplayMember = "Value" + lstGames.ListViewItemSorter = New ListViewItemComparer(0) lstGames.EndUpdate() - lstGames.ClearSelected() + UpdateSelected() + lblGames.Text = mgrCommon.FormatString(frmAdvancedImport_NewConfigs, lstGames.Items.Count) + Cursor.Current = Cursors.Default End Sub Private Sub SetForm() @@ -49,21 +85,24 @@ Public Class frmAdvancedImport Me.Text = frmAdvancedImport_FormName 'Set Form Text + lblFilter.Text = frmAdvancedImport_lblFilter btnCancel.Text = frmAdvancedImport_btnCancel btnImport.Text = frmAdvancedImport_btnImport chkSelectAll.Checked = True - lblGames.Text = mgrCommon.FormatString(frmAdvancedImport_NewConfigs, ImportData.Count) + + 'Init Filter Timer + tmFilterTimer = New Timer() + tmFilterTimer.Interval = 1000 + tmFilterTimer.Enabled = False End Sub Private Sub BuildList() - Dim oData As KeyValuePair(Of String, String) + Dim oData As ListViewItem - For i As Integer = 0 To lstGames.Items.Count - 1 - If Not lstGames.GetItemChecked(i) Then - oData = lstGames.Items(i) - ImportData.Remove(oData.Key) - End If + For i As Integer = 0 To lstGames.CheckedItems.Count - 1 + oData = lstGames.Items(i) + FinalData.Add(oData.Tag, ImportData(oData.Tag)) Next End Sub @@ -83,7 +122,7 @@ Public Class frmAdvancedImport If Not bIsLoading Then SelectToggle() End Sub - Private Sub lstGames_SelectedValueChanged(sender As Object, e As EventArgs) Handles lstGames.SelectedValueChanged + Private Sub lstGames_ItemChecked(sender As Object, e As ItemCheckedEventArgs) Handles lstGames.ItemChecked If Not bIsLoading Then UpdateSelected() End Sub @@ -96,4 +135,40 @@ Public Class frmAdvancedImport If ImportData.Count > 0 Then Me.DialogResult = Windows.Forms.DialogResult.OK Me.Close() End Sub + + Private Sub lstGames_ColumnClick(sender As Object, e As ColumnClickEventArgs) Handles lstGames.ColumnClick + lstGames.ListViewItemSorter = New ListViewItemComparer(e.Column) + End Sub + + Private Sub txtFilter_TextChanged(sender As Object, e As EventArgs) Handles txtFilter.TextChanged + If Not tmFilterTimer.Enabled Then + tmFilterTimer.Enabled = True + tmFilterTimer.Start() + End If + End Sub + + Private Sub tmFilterTimer_Tick(sender As Object, ByVal e As EventArgs) Handles tmFilterTimer.Tick + LoadData(txtFilter.Text) + tmFilterTimer.Stop() + tmFilterTimer.Enabled = False + End Sub +End Class + +' Column Sorter +Class ListViewItemComparer + Implements IComparer + + Private col As Integer + + Public Sub New() + col = 0 + End Sub + + Public Sub New(ByVal column As Integer) + col = column + End Sub + + Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare + Return String.Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text) + End Function End Class \ No newline at end of file diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 3c22b5d..7262207 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -384,7 +384,7 @@ Public Class frmGameManager oList.Add(oData) Next - oList.Sort(AddressOf mgrCommon.CompareByName) + oList.Sort(AddressOf mgrCommon.CompareByListBoxItemByValue) lstGames.BeginUpdate() lstGames.DataSource = oList diff --git a/GBM/Managers/mgrCommon.vb b/GBM/Managers/mgrCommon.vb index f9f9ec1..93a4835 100644 --- a/GBM/Managers/mgrCommon.vb +++ b/GBM/Managers/mgrCommon.vb @@ -251,9 +251,13 @@ Public Class mgrCommon Return sString End Function - 'Compare function for list boxes - Public Shared Function CompareByName(sItem1 As KeyValuePair(Of String, String), sItem2 As KeyValuePair(Of String, String)) As Integer - Return String.Compare(sItem1.Value, sItem2.value) + 'Compare functions + Public Shared Function CompareImportTagsByName(oItem1 As Tag, oItem2 As Tag) As Integer + Return String.Compare(oItem1.Name, oItem2.Name) + End Function + + Public Shared Function CompareByListBoxItemByValue(sItem1 As KeyValuePair(Of String, String), sItem2 As KeyValuePair(Of String, String)) As Integer + Return String.Compare(sItem1.Value, sItem2.Value) End Function 'Maintenance Only - Function for string management diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index 2485354..82956f2 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -228,8 +228,8 @@ Public Class mgrMonitorList If frm.ShowDialog() = DialogResult.OK Then Cursor.Current = Cursors.WaitCursor - DoListAddUpdateSync(frm.ImportData) - mgrTags.DoTagAddImport(frm.ImportData) + DoListAddUpdateSync(frm.FinalData) + mgrTags.DoTagAddImport(frm.FinalData) Cursor.Current = Cursors.Default mgrCommon.ShowMessage(mgrMonitorList_ImportComplete, MsgBoxStyle.Information) @@ -243,7 +243,7 @@ Public Class mgrMonitorList Public Shared Function DoImport(ByVal sPath As String) As Boolean If (sPath.IndexOf("http://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Or _ - (sPath.IndexOf("https://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Then + (sPath.IndexOf("https://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Then If mgrCommon.CheckAddress(sPath) Then ImportMonitorList(sPath, True) Return True diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 00e26a3..a2545c8 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -726,6 +726,33 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Name. + ''' + Friend ReadOnly Property frmAdvancedImport_ColumnName() As String + Get + Return ResourceManager.GetString("frmAdvancedImport_ColumnName", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Process. + ''' + Friend ReadOnly Property frmAdvancedImport_ColumnProcess() As String + Get + Return ResourceManager.GetString("frmAdvancedImport_ColumnProcess", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Tags. + ''' + Friend ReadOnly Property frmAdvancedImport_ColumnTags() As String + Get + Return ResourceManager.GetString("frmAdvancedImport_ColumnTags", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Import Game Configurations. ''' @@ -736,7 +763,16 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to [PARAM] new configurations available.. + ''' Looks up a localized string similar to Search:. + ''' + Friend ReadOnly Property frmAdvancedImport_lblFilter() As String + Get + Return ResourceManager.GetString("frmAdvancedImport_lblFilter", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to [PARAM] configurations available. ''' Friend ReadOnly Property frmAdvancedImport_NewConfigs() As String Get @@ -2284,7 +2320,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to [PARAM] backup was cancelled due to session length.. + ''' Looks up a localized string similar to [PARAM] backup was cancelled due to session length. ''' Friend ReadOnly Property frmMain_ErrorBackupSessionLength() As String Get diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 69f176a..633b177 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -212,7 +212,7 @@ [PARAM] backup was cancelled. - [PARAM] backup was cancelled due to session length. + [PARAM] backup was cancelled due to session length [PARAM] backup was cancelled due to unknown path. @@ -872,7 +872,7 @@ Import Game Configurations - [PARAM] new configurations available. + [PARAM] configurations available [PARAM] Selected @@ -1570,4 +1570,16 @@ PNG files (*.png)|*.png + + Search: + + + Name + + + Process + + + Tags + \ No newline at end of file