48 lines
1.7 KiB
VB.net
48 lines
1.7 KiB
VB.net
Imports System.Collections.Generic
|
|
Imports System.Text
|
|
|
|
Public Class SelectionHelper(Of KeyType)
|
|
Dim selectedValues As Dictionary(Of KeyType, Boolean) = New Dictionary(Of KeyType, Boolean)
|
|
Dim RwHdlSeleccionados As Dictionary(Of KeyType, Boolean) = New Dictionary(Of KeyType, Boolean)
|
|
Public Function GetIsSelected(ByVal key As KeyType) As Boolean
|
|
Dim isSelected As Boolean
|
|
If selectedValues.TryGetValue(key, isSelected) Then
|
|
Return isSelected
|
|
End If
|
|
Return False
|
|
End Function
|
|
Public Sub SetIsSelected(rwh As KeyType, ByVal key As KeyType, ByVal value As Boolean)
|
|
If value Then
|
|
selectedValues(key) = value
|
|
RwHdlSeleccionados(rwh) = value
|
|
Else
|
|
selectedValues.Remove(key)
|
|
RwHdlSeleccionados.Remove(rwh)
|
|
End If
|
|
End Sub
|
|
Public Function GetSelectedKeys() As List(Of KeyType)
|
|
Dim list As New List(Of KeyType)()
|
|
For Each key As KeyType In selectedValues.Keys
|
|
list.Add(key)
|
|
Next key
|
|
Return list
|
|
End Function
|
|
Public Function GetSelectedrwh() As List(Of KeyType)
|
|
Dim list As New List(Of KeyType)()
|
|
For Each key As KeyType In RwHdlSeleccionados.Keys
|
|
list.Add(key)
|
|
Next key
|
|
Return list
|
|
End Function
|
|
Public Function GetSelectedKeysAsString() As String
|
|
Dim list As List(Of KeyType) = GetSelectedKeys()
|
|
Dim str As New StringBuilder()
|
|
For i As Integer = 0 To list.Count - 1
|
|
str.AppendLine(list(i).ToString())
|
|
Next i
|
|
Return str.ToString()
|
|
End Function
|
|
Public Function GetSelectionCount() As Integer
|
|
Return selectedValues.Count
|
|
End Function
|
|
End Class |