Updates for issue #22

This commit is contained in:
Michael J. Seiferling
2016-03-11 16:26:20 -06:00
parent 09c7bf8f05
commit a6341ffa76
7 changed files with 202 additions and 51 deletions
+43 -19
View File
@@ -22,28 +22,22 @@ Partial Class frmAdvancedImport
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
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
+96 -21
View File
@@ -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
+1 -1
View File
@@ -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