Changes for issue #117
This commit is contained in:
@@ -1,19 +1,34 @@
|
||||
Imports GBM.My.Resources
|
||||
Imports System.Globalization
|
||||
Imports System.ComponentModel
|
||||
|
||||
Public Class frmSessions
|
||||
|
||||
Private bInitFinished As Boolean = False
|
||||
Private WithEvents tmFilterTimer As Timer
|
||||
Private bStartSortAsc As Boolean = True
|
||||
Private iStartSortCol As Integer = 2
|
||||
Private iStartDisplayCol As Integer = 3
|
||||
Private bEndSortAsc As Boolean = True
|
||||
Private iEndSortCol As Integer = 4
|
||||
Private iEndDisplayCol As Integer = 5
|
||||
|
||||
Private Sub FormatGrid()
|
||||
dgSessions.Columns.Add("MonitorID", frmSessions_ColumnMonitorID)
|
||||
dgSessions.Columns.Add("Name", frmSessions_ColumnGameName)
|
||||
dgSessions.Columns.Add("StartUnix", frmSessions_ColumnStart)
|
||||
dgSessions.Columns.Add("Start", frmSessions_ColumnStart)
|
||||
dgSessions.Columns.Add("EndUnix", frmSessions_ColumnEnd)
|
||||
dgSessions.Columns.Add("End", frmSessions_ColumnEnd)
|
||||
|
||||
'Hide the ID
|
||||
'Set Sorting
|
||||
dgSessions.Columns("Start").SortMode = DataGridViewColumnSortMode.Programmatic
|
||||
dgSessions.Columns("End").SortMode = DataGridViewColumnSortMode.Programmatic
|
||||
|
||||
'Hide Columns
|
||||
dgSessions.Columns("MonitorID").Visible = False
|
||||
dgSessions.Columns("StartUnix").Visible = False
|
||||
dgSessions.Columns("EndUnix").Visible = False
|
||||
End Sub
|
||||
|
||||
Private Sub LoadData()
|
||||
@@ -30,7 +45,7 @@ Public Class frmSessions
|
||||
dgSessions.Rows.Clear()
|
||||
|
||||
For Each dr As DataRow In oData.Tables(0).Rows
|
||||
dgSessions.Rows.Add(New Object() {dr("MonitorID"), dr("Name"), mgrCommon.UnixToDate(dr("Start")), mgrCommon.UnixToDate(dr("End"))})
|
||||
dgSessions.Rows.Add(New Object() {dr("MonitorID"), dr("Name"), dr("Start"), mgrCommon.UnixToDate(dr("Start")), dr("End"), mgrCommon.UnixToDate(dr("End"))})
|
||||
Next
|
||||
|
||||
dgSessions.AutoResizeColumns()
|
||||
@@ -51,7 +66,6 @@ Public Class frmSessions
|
||||
tmFilterTimer.Interval = 1000
|
||||
tmFilterTimer.Enabled = False
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ResetFilterFields()
|
||||
@@ -90,6 +104,7 @@ Public Class frmSessions
|
||||
End Sub
|
||||
|
||||
Private Sub Reset()
|
||||
ClearManualSortGlyphs()
|
||||
ResetFilterFields()
|
||||
LoadData()
|
||||
End Sub
|
||||
@@ -111,6 +126,38 @@ Public Class frmSessions
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ClearManualSortGlyphs()
|
||||
dgSessions.Columns(iStartDisplayCol).HeaderCell.SortGlyphDirection = SortOrder.None
|
||||
dgSessions.Columns(iEndDisplayCol).HeaderCell.SortGlyphDirection = SortOrder.None
|
||||
End Sub
|
||||
|
||||
Private Function GetSortOrder(ByVal bToggle As Boolean, ByVal iCol As Integer) As ListSortDirection
|
||||
Dim oSortType As ListSortDirection
|
||||
|
||||
If bToggle Then
|
||||
oSortType = ListSortDirection.Ascending
|
||||
dgSessions.Columns(iCol).HeaderCell.SortGlyphDirection = SortOrder.Ascending
|
||||
Else
|
||||
oSortType = ListSortDirection.Descending
|
||||
dgSessions.Columns(iCol).HeaderCell.SortGlyphDirection = SortOrder.Descending
|
||||
End If
|
||||
|
||||
Return oSortType
|
||||
End Function
|
||||
|
||||
Private Sub HandleSort(ByVal iCol As Integer)
|
||||
ClearManualSortGlyphs()
|
||||
|
||||
Select Case iCol
|
||||
Case iStartDisplayCol
|
||||
bStartSortAsc = Not bStartSortAsc
|
||||
dgSessions.Sort(dgSessions.Columns(iStartSortCol), GetSortOrder(bStartSortAsc, iCol))
|
||||
Case iEndDisplayCol
|
||||
bEndSortAsc = Not bEndSortAsc
|
||||
dgSessions.Sort(dgSessions.Columns(iEndSortCol), GetSortOrder(bEndSortAsc, iCol))
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub frmSession_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
SetForm()
|
||||
ResetFilterFields()
|
||||
@@ -155,4 +202,8 @@ Public Class frmSessions
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub dgSessions_ColumnHeaderMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgSessions.ColumnHeaderMouseClick
|
||||
HandleSort(e.ColumnIndex)
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user