- 2026-07-17 V1.4.2 Se añade compatibilidad con CardView

This commit is contained in:
2026-07-19 09:40:21 +02:00
parent f75f7a9022
commit 9aa0a5891f
5 changed files with 171 additions and 161 deletions

View File

@@ -1,6 +1,4 @@
Imports System.ComponentModel Imports System.ComponentModel
Imports System.Data.Entity.Core.Metadata.Edm
Imports System.Data.Entity.Core.Objects
Imports DevExpress.Xpf.Docking Imports DevExpress.Xpf.Docking
Imports DevExpress.Xpf.Editors Imports DevExpress.Xpf.Editors

View File

@@ -307,7 +307,7 @@ Public Class ContenedorAplicacion
For Each l In Me._Aplicacion.Lineas For Each l In Me._Aplicacion.Lineas
ls = New MemoryStream ls = New MemoryStream
ms.Add(ls) ms.Add(ls)
Dim vista As TableView = l.View Dim vista As DataViewBase = l.View
Select Case formato Select Case formato
Case DevExpress.Spreadsheet.DocumentFormat.Xls Case DevExpress.Spreadsheet.DocumentFormat.Xls
vista.ExportToXls(ls) vista.ExportToXls(ls)
@@ -394,7 +394,7 @@ Public Class ContenedorAplicacion
End Sub End Sub
Private Sub btSeleccionar_CheckedChanged(sender As Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs) Private Sub btSeleccionar_CheckedChanged(sender As Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs)
If _Aplicacion IsNot Nothing AndAlso _Aplicacion.GridSeleccion IsNot Nothing Then If _Aplicacion IsNot Nothing AndAlso _Aplicacion.GridSeleccion IsNot Nothing Then
Dim tv = DirectCast(_Aplicacion.GridSeleccion.View, TableView) Dim tv = TryCast(_Aplicacion.GridSeleccion.View, TableView)
If tv IsNot Nothing Then If tv IsNot Nothing Then
If btSeleccionar.IsChecked Then If btSeleccionar.IsChecked Then
_Aplicacion.GridSeleccion.SelectionMode = MultiSelectMode.MultipleRow _Aplicacion.GridSeleccion.SelectionMode = MultiSelectMode.MultipleRow

View File

@@ -25,19 +25,16 @@ Imports System.Globalization
Public Class tsGridControl Public Class tsGridControl
Inherits DevExpress.Xpf.Grid.GridControl Inherits DevExpress.Xpf.Grid.GridControl
Public ElementosSeleccionados As ObservableCollectionCore(Of Object) Public ElementosSeleccionados As ObservableCollectionCore(Of Object)
Public Property PopupFilterModeInicializado As Boolean Public Property PopupFilterModeInicializado As Boolean
Public ReadOnly Property MySelectedItems() As IList Public ReadOnly Property MySelectedItems() As IList
Get Get
Return ElementosSeleccionados Return ElementosSeleccionados
End Get End Get
End Property End Property
Private _NombreTablaBase As String Private _NombreTablaBase As String
Public Property PropiedadesTS As New PropiedadesTS Public Property PropiedadesTS As New PropiedadesTS
@@ -50,6 +47,7 @@ Public Class tsGridControl
Else Else
c.AllowEditing = If(SoloLectura, DevExpress.Utils.DefaultBoolean.False, DevExpress.Utils.DefaultBoolean.True) c.AllowEditing = If(SoloLectura, DevExpress.Utils.DefaultBoolean.False, DevExpress.Utils.DefaultBoolean.True)
End If End If
Dim bes = TryCast(c.EditSettings, DevExpress.Xpf.Editors.Settings.ButtonEditSettings) Dim bes = TryCast(c.EditSettings, DevExpress.Xpf.Editors.Settings.ButtonEditSettings)
If bes IsNot Nothing Then If bes IsNot Nothing Then
bes.AllowDefaultButton = Not SoloLectura bes.AllowDefaultButton = Not SoloLectura
@@ -58,11 +56,13 @@ Public Class tsGridControl
Next Next
End If End If
Next Next
If Not Me.ContextMenu Is Nothing AndAlso Me.ContextMenu.HasItems Then
If Me.ContextMenu IsNot Nothing AndAlso Me.ContextMenu.HasItems Then
Dim mi As MenuItem = Me.ContextMenu.Items(0) Dim mi As MenuItem = Me.ContextMenu.Items(0)
mi.IsEnabled = Not SoloLectura mi.IsEnabled = Not SoloLectura
End If End If
End Sub End Sub
Public Sub ReEstableceValoresDefectoSoloLectura() Public Sub ReEstableceValoresDefectoSoloLectura()
For Each c In Me.Columns For Each c In Me.Columns
If c.CellTemplate Is Nothing Then If c.CellTemplate Is Nothing Then
@@ -86,6 +86,7 @@ Public Class tsGridControl
Else Else
c.AllowEditing = DevExpress.Utils.DefaultBoolean.False c.AllowEditing = DevExpress.Utils.DefaultBoolean.False
End If End If
Dim bes = TryCast(c.EditSettings, DevExpress.Xpf.Editors.Settings.ButtonEditSettings) Dim bes = TryCast(c.EditSettings, DevExpress.Xpf.Editors.Settings.ButtonEditSettings)
If bes IsNot Nothing Then If bes IsNot Nothing Then
bes.AllowDefaultButton = False bes.AllowDefaultButton = False
@@ -112,7 +113,6 @@ Public Class tsGridControl
End If End If
End If End If
Next Next
End Sub End Sub
Public Property NombreTablaBase As String Public Property NombreTablaBase As String
@@ -123,6 +123,7 @@ Public Class tsGridControl
_NombreTablaBase = value _NombreTablaBase = value
End Set End Set
End Property End Property
Public Event AntesEliminar(ByVal gc As tsGridControl, ByRef Cancelar As Boolean) Public Event AntesEliminar(ByVal gc As tsGridControl, ByRef Cancelar As Boolean)
Public Event DespuesEliminar(ByVal gc As tsGridControl) Public Event DespuesEliminar(ByVal gc As tsGridControl)
Public Event EnterPulsado() Public Event EnterPulsado()
@@ -136,6 +137,7 @@ Public Class tsGridControl
RaiseEvent AntesExportar(gc, Cancelar) RaiseEvent AntesExportar(gc, Cancelar)
Return Cancelar Return Cancelar
End Function End Function
Friend Function LanzaAntesEliminar(gc As tsGridControl) As Boolean Friend Function LanzaAntesEliminar(gc As tsGridControl) As Boolean
Dim Cancelar As Boolean Dim Cancelar As Boolean
RaiseEvent AntesEliminar(gc, Cancelar) RaiseEvent AntesEliminar(gc, Cancelar)
@@ -147,27 +149,28 @@ Public Class tsGridControl
RaiseEvent DespuesEliminar(gc) RaiseEvent DespuesEliminar(gc)
Return Cancelar Return Cancelar
End Function End Function
Friend Function LanzaEnterPulsado() As Boolean Friend Function LanzaEnterPulsado() As Boolean
Dim Cancelar As Boolean Dim Cancelar As Boolean
RaiseEvent EnterPulsado() RaiseEvent EnterPulsado()
Return Cancelar Return Cancelar
End Function End Function
Public Sub New() Public Sub New()
MyBase.New() MyBase.New()
End Sub End Sub
Private NumeroColumnasAgrupadas As Integer
Friend Sub MyGridControl_StartGrouping(sender As Object, e As RoutedEventArgs)
Private NumeroColumnasAgrupadas As Integer
Friend Sub MyGridControl_StartGrouping(sender As Object, e As RoutedEventArgs)
updateLocker.Lock() updateLocker.Lock()
End Sub End Sub
Public Function ObtieneNumeroColumnasAgrupadas() As Integer Public Function ObtieneNumeroColumnasAgrupadas() As Integer
Return Me.Columns.Where(Function(x) x.IsGrouped).Count Return Me.Columns.Where(Function(x) x.IsGrouped).Count
End Function End Function
Friend Sub MyGridControl_EndGrouping(sender As Object, e As RoutedEventArgs) Friend Sub MyGridControl_EndGrouping(sender As Object, e As RoutedEventArgs)
'Dim nca = ObtieneNumeroColumnasAgrupadas()
'Dim bDesAgrupando As Boolean = NumeroColumnasAgrupadas > nca
'NumeroColumnasAgrupadas = nca
'If bDesAgrupando Then updateLocker.Unlock()
BeginSelection() BeginSelection()
For Each index As Integer In OrderedSelection For Each index As Integer In OrderedSelection
If CBool(selection(index)) Then If CBool(selection(index)) Then
@@ -175,53 +178,62 @@ Public Class tsGridControl
End If End If
Next Next
EndSelection() EndSelection()
' If Not bDesAgrupando Then updateLocker.Unlock()
updateLocker.Unlock() updateLocker.Unlock()
End Sub End Sub
Private selection As New Hashtable() Private selection As New Hashtable()
Private ReadOnly Property OrderedSelection() As IEnumerable Private ReadOnly Property OrderedSelection() As IEnumerable
Get Get
Return selection.Keys.Cast(Of Integer)().OrderBy(Function(x) x) Return selection.Keys.Cast(Of Integer)().OrderBy(Function(x) x)
End Get End Get
End Property End Property
Protected Overrides Sub OnItemsSourceChanged(oldValue As Object, newValue As Object) Protected Overrides Sub OnItemsSourceChanged(oldValue As Object, newValue As Object)
MyBase.OnItemsSourceChanged(oldValue, newValue) MyBase.OnItemsSourceChanged(oldValue, newValue)
selection.Clear() selection.Clear()
Dim itemsSource As IEnumerable = TryCast(newValue, IEnumerable) Dim itemsSource As IEnumerable = TryCast(newValue, IEnumerable)
If itemsSource Is Nothing Then If itemsSource Is Nothing Then Return
Return
End If
Dim i As Integer = 0 Dim i As Integer = 0
For Each item As Object In itemsSource For Each item As Object In itemsSource
selection(System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)) = False selection(Math.Max(System.Threading.Interlocked.Increment(i), i - 1)) = False
Next Next
End Sub End Sub
Protected Overrides Sub OnInitialized(e As EventArgs) Protected Overrides Sub OnInitialized(e As EventArgs)
MyBase.OnInitialized(e) MyBase.OnInitialized(e)
Try Try
' If Me.SelectionMode = MultiSelectMode.MultipleRow Then
AddHandler SelectionChanged, AddressOf MyGridControl_SelectionChanged AddHandler SelectionChanged, AddressOf MyGridControl_SelectionChanged
ElementosSeleccionados = New ObservableCollectionCore(Of Object)() ElementosSeleccionados = New ObservableCollectionCore(Of Object)()
AddHandler Me.EndGrouping, AddressOf MyGridControl_EndGrouping AddHandler Me.EndGrouping, AddressOf MyGridControl_EndGrouping
AddHandler Me.StartGrouping, AddressOf MyGridControl_StartGrouping AddHandler Me.StartGrouping, AddressOf MyGridControl_StartGrouping
If Me.PropiedadesTSGC.BusquedaAcentosInsensitivo OrElse Configuracion.BusquedaAcentosInsensitivo Then AddHandler Me.CustomRowFilter, AddressOf MyGridControl_CustomRowFilter
ConSeleccion = True If Me.PropiedadesTSGC.BusquedaAcentosInsensitivo OrElse Configuracion.BusquedaAcentosInsensitivo Then
'''' NumeroColumnasAgrupadas = ObtieneNumeroColumnasAgrupadas() AddHandler Me.CustomRowFilter, AddressOf MyGridControl_CustomRowFilter
' End If
If Me.View IsNot Nothing Then
If Me.View.GetType Is GetType(TableView) Then
DirectCast(Me.View, TableView).AllowFixedColumnMenu = True
'''' DirectCast(Me.View, TableView).UseLightweightTemplates = UseLightweightTemplates.None
'''' DirectCast(Me.View, TableView).GroupSummaryContentStyle = DirectCast(Me.FindResource("tsGroupSummaryContentStyle"), Style)
'''' DirectCast(Me.View, TableView).TotalSummaryContentStyle = DirectCast(Me.FindResource("tsTotalSummaryContentStyle"), Style)
End If
If Configuracion.ModoBusquedaAND Then
' Me.View.SearchPanelCriteriaOperatorType = DevExpress.Xpf.Editors.CriteriaOperatorType.And
Me.View.SearchPanelParseMode = DevExpress.Xpf.Editors.SearchPanelParseMode.And
End If
DirectCast(Me.View, GridViewBase).SearchPanelPosition = SearchPanelPosition.OverGroupPanel
End If End If
ConSeleccion = True
If Me.View IsNot Nothing Then
Dim tv = TryCast(Me.View, TableView)
If tv IsNot Nothing Then
tv.AllowFixedColumnMenu = True
End If
Dim gv = TryCast(Me.View, GridViewBase)
If gv IsNot Nothing Then
gv.SearchPanelPosition = SearchPanelPosition.OverGroupPanel
If Configuracion.ModoBusquedaAND Then
gv.SearchPanelParseMode = DevExpress.Xpf.Editors.SearchPanelParseMode.And
End If
End If
End If
Catch ex As Exception Catch ex As Exception
Debug.Write(ex.Message) Debug.Write(ex.Message)
End Try End Try
@@ -229,29 +241,31 @@ Public Class tsGridControl
Private Sub MyGridControl_CustomRowFilter(sender As Object, e As RowFilterEventArgs) Private Sub MyGridControl_CustomRowFilter(sender As Object, e As RowFilterEventArgs)
Dim gc As GridControl = TryCast(sender, GridControl) Dim gc As GridControl = TryCast(sender, GridControl)
If gc.ItemsSource IsNot Nothing Then If gc Is Nothing OrElse gc.ItemsSource Is Nothing Then Return
If gc IsNot Nothing Then
Dim filterStr As String = gc.View.SearchString.NothingAVacio Dim filterStr As String = gc.View.SearchString.NothingAVacio
If filterStr <> "" Then If filterStr = "" Then Return
Dim Palabras = RemoveDiacriticsCustom(filterStr.ToLowerInvariant).Split(" ")
e.Visible = False Dim Palabras = RemoveDiacriticsCustom(filterStr.ToLowerInvariant).Split(" ")
e.Handled = True e.Visible = False
For Each c As GridColumn In gc.Columns e.Handled = True
Dim value As String = RemoveDiacriticsCustom(gc.GetCellDisplayText(gc.GetRowHandleByListIndex(e.ListSourceRowIndex), c).ToLowerInvariant)
If c.Visible Then For Each c As GridColumn In gc.Columns
For Each p In Palabras If c.Visible Then
If value.Contains(p) Then Dim value As String = RemoveDiacriticsCustom(gc.GetCellDisplayText(gc.GetRowHandleByListIndex(e.ListSourceRowIndex), c).ToLowerInvariant)
e.Visible = True
Exit For For Each p In Palabras
End If If value.Contains(p) Then
Next e.Visible = True
If e.Visible Then Exit For Exit For
End If End If
Next Next
End If
If e.Visible Then Exit For
End If End If
End If Next
End Sub End Sub
Private Shared Function RemoveDiacriticsCustom(ByVal text As String) As String Private Shared Function RemoveDiacriticsCustom(ByVal text As String) As String
Return String.Concat(text.Normalize(NormalizationForm.FormD).Where(Function(ch) CharUnicodeInfo.GetUnicodeCategory(ch) <> UnicodeCategory.NonSpacingMark)).Normalize(NormalizationForm.FormC) Return String.Concat(text.Normalize(NormalizationForm.FormD).Where(Function(ch) CharUnicodeInfo.GetUnicodeCategory(ch) <> UnicodeCategory.NonSpacingMark)).Normalize(NormalizationForm.FormC)
End Function End Function
@@ -263,68 +277,69 @@ Public Class tsGridControl
ConSeleccion = False ConSeleccion = False
End Sub End Sub
Private updateLocker As New Locker() Private updateLocker As New Locker()
'Public Sub SeleccionaTodo()
' Me.SelectAll()
' MyGridControl_SelectionChanged(Me, Nothing)
'End Sub
Friend Sub MyGridControl_SelectionChanged(sender As Object, e As GridSelectionChangedEventArgs) Friend Sub MyGridControl_SelectionChanged(sender As Object, e As GridSelectionChangedEventArgs)
Try Try
If ConSeleccion AndAlso Not updateLocker.IsLocked Then If ConSeleccion AndAlso Not updateLocker.IsLocked Then
Dim drhws = GetDataRowHandles() Dim drhws = GetDataRowHandles()
'For i As Integer = 0 To VisibleRowCount - 1
For i As Integer = 0 To drhws.Count - 1 For i As Integer = 0 To drhws.Count - 1
'Dim rowHandle As Integer = GetRowHandleByVisibleIndex(i)
Dim rowHandle As Integer = drhws(i) Dim rowHandle As Integer = drhws(i)
selection(GetListIndexByRowHandle(rowHandle)) = View.IsRowSelected(rowHandle) selection(GetListIndexByRowHandle(rowHandle)) = View.IsRowSelected(rowHandle)
Next Next
ElementosSeleccionados.BeginUpdate() ElementosSeleccionados.BeginUpdate()
ElementosSeleccionados.Clear() ElementosSeleccionados.Clear()
For Each index As Integer In OrderedSelection For Each index As Integer In OrderedSelection
If CBool(selection(index)) Then If CBool(selection(index)) Then
ElementosSeleccionados.Add(GetRowByListIndex(index)) ElementosSeleccionados.Add(GetRowByListIndex(index))
End If End If
Next Next
ElementosSeleccionados.EndUpdate() ElementosSeleccionados.EndUpdate()
RaiseEvent SeleccionCambiada(sender, e) RaiseEvent SeleccionCambiada(sender, e)
End If End If
Catch ex As Exception Catch ex As Exception
Debug.Write(ex.Message) Debug.Write(ex.Message)
End Try End Try
End Sub End Sub
Protected Overrides Sub ApplyFilter(checkFilterEnabled As Boolean, Optional skipIfFilterEquals As Boolean = False) Protected Overrides Sub ApplyFilter(checkFilterEnabled As Boolean, Optional skipIfFilterEquals As Boolean = False)
If ConSeleccion Then If ConSeleccion Then
If DirectCast(Me.View, TableView).ShowCheckBoxSelectorColumn Then Dim tv = TryCast(Me.View, TableView)
If tv IsNot Nothing AndAlso tv.ShowCheckBoxSelectorColumn Then
updateLocker.DoLockedAction(Sub() updateLocker.DoLockedAction(Sub()
MyBase.ApplyFilter(checkFilterEnabled, skipIfFilterEquals) MyBase.ApplyFilter(checkFilterEnabled, skipIfFilterEquals)
BeginSelection() BeginSelection()
For Each index As Integer In OrderedSelection For Each index As Integer In OrderedSelection
If CBool(selection(index)) Then If CBool(selection(index)) Then
SelectItem(GetRowHandleByListIndex(index)) SelectItem(GetRowHandleByListIndex(index))
End If End If
Next Next
EndSelection()
EndSelection()
End Sub) End Sub)
Else Else
MyBase.ApplyFilter(checkFilterEnabled, skipIfFilterEquals) MyBase.ApplyFilter(checkFilterEnabled, skipIfFilterEquals)
End If End If
Else Else
MyBase.ApplyFilter(checkFilterEnabled, skipIfFilterEquals) MyBase.ApplyFilter(checkFilterEnabled, skipIfFilterEquals)
End If End If
End Sub End Sub
Public Function GetDataRowHandles() As List(Of Integer) Public Function GetDataRowHandles() As List(Of Integer)
Dim rowHandles As New List(Of Integer)() Dim rowHandles As New List(Of Integer)()
For i As Integer = 0 To Me.VisibleRowCount - 1 For i As Integer = 0 To Me.VisibleRowCount - 1
Dim rowHandle As Integer = Me.GetRowHandleByVisibleIndex(i) Dim rowHandle As Integer = Me.GetRowHandleByVisibleIndex(i)
If Me.IsGroupRowHandle(rowHandle) Then If Me.IsGroupRowHandle(rowHandle) Then
If Not Me.IsGroupRowExpanded(rowHandle) Then If Not Me.IsGroupRowExpanded(rowHandle) Then
rowHandles.AddRange(GetDataRowHandlesInGroup(rowHandle)) rowHandles.AddRange(GetDataRowHandlesInGroup(rowHandle))
@@ -333,67 +348,49 @@ Public Class tsGridControl
rowHandles.Add(rowHandle) rowHandles.Add(rowHandle)
End If End If
Next Next
Return rowHandles Return rowHandles
End Function End Function
Public Function GetDataRowHandlesInGroup(groupRowHandle As Integer) As List(Of Integer) Public Function GetDataRowHandlesInGroup(groupRowHandle As Integer) As List(Of Integer)
Dim rowHandles As New List(Of Integer)() Dim rowHandles As New List(Of Integer)()
For i As Integer = 0 To Me.GetChildRowCount(groupRowHandle) - 1 For i As Integer = 0 To Me.GetChildRowCount(groupRowHandle) - 1
Dim rowHandle As Integer = Me.GetChildRowHandle(groupRowHandle, i) Dim rowHandle As Integer = Me.GetChildRowHandle(groupRowHandle, i)
If Me.IsGroupRowHandle(rowHandle) Then If Me.IsGroupRowHandle(rowHandle) Then
rowHandles.AddRange(GetDataRowHandlesInGroup(rowHandle)) rowHandles.AddRange(GetDataRowHandlesInGroup(rowHandle))
Else Else
rowHandles.Add(rowHandle) rowHandles.Add(rowHandle)
End If End If
Next Next
Return rowHandles Return rowHandles
End Function End Function
Public Sub New(dcoe As IDataControlOriginationElement) Public Sub New(dcoe As IDataControlOriginationElement)
MyBase.New(dcoe) MyBase.New(dcoe)
' MyBase.New()
End Sub End Sub
'Protected Overrides Sub OnPreviewKeyDown(e As KeyEventArgs)
' Try
' If e.Key = Key.Space AndAlso DirectCast(Me.View, TableView).ShowCheckBoxSelectorColumn Then
' e.Handled = True
' DirectCast(Me.View, TableView).SearchString &= " "
' Debug.WriteLine("ESPACIO")
' ' MyBase.OnPreviewKeyDown(e)
' Else
' MyBase.OnPreviewKeyDown(e)
' End If
' Catch ex As Exception
' MyBase.OnPreviewKeyDown(e)
' End Try
'End Sub
' Private Cargado As Boolean = False
Private ConSeleccion As Boolean = False Private ConSeleccion As Boolean = False
'Private Sub tsGridControl_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
' If Not ConSeleccion AndAlso DirectCast(Me.View, TableView).ShowCheckBoxSelectorColumn AndAlso Me.SelectionMode = MultiSelectMode.MultipleRow Then
' AddHandler SelectionChanged, AddressOf MyGridControl_SelectionChanged
' ElementosSeleccionados = New ObservableCollectionCore(Of Object)()
' AddHandler Me.EndGrouping, AddressOf MyGridControl_EndGrouping
' AddHandler Me.StartGrouping, AddressOf MyGridControl_StartGrouping
' NumeroColumnasAgrupadas = ObtieneNumeroColumnasAgrupadas()
' ConSeleccion = True
' End If
'End Sub
Public Function GetColumnType(ByVal column As GridColumn) As Type Public Function GetColumnType(ByVal column As GridColumn) As Type
Dim columnInfo As DataColumnInfo = DataProviderBase.Columns(column.FieldName) Dim columnInfo As DataColumnInfo = DataProviderBase.Columns(column.FieldName)
If columnInfo Is Nothing Then Return Nothing If columnInfo Is Nothing Then Return Nothing
Return columnInfo.Type Return columnInfo.Type
End Function End Function
Public Shared Sub EstableceFilterPopupModePredeterminados(gr As tsGridControl) Public Shared Sub EstableceFilterPopupModePredeterminados(gr As tsGridControl)
If Not gr.PopupFilterModeInicializado AndAlso gr.ItemsSource IsNot Nothing Then If Not gr.PopupFilterModeInicializado AndAlso gr.ItemsSource IsNot Nothing Then
gr.PopupFilterModeInicializado = True gr.PopupFilterModeInicializado = True
For Each cl In gr.Columns For Each cl In gr.Columns
Dim tipo = gr.GetColumnType(cl) Dim tipo = gr.GetColumnType(cl)
Select Case tipo Select Case tipo
Case GetType(String), GetType(Integer), GetType(Integer?), GetType(Double), GetType(Double?) Case GetType(String), GetType(Integer), GetType(Integer?), GetType(Double), GetType(Double?)
cl.FilterPopupMode = FilterPopupMode.CheckedList cl.FilterPopupMode = FilterPopupMode.CheckedList
Case GetType(Date), GetType(DateTime), GetType(Date?), GetType(DateTime?) Case GetType(Date), GetType(DateTime), GetType(Date?), GetType(DateTime?)
cl.FilterPopupMode = FilterPopupMode.Excel cl.FilterPopupMode = FilterPopupMode.Excel
End Select End Select
@@ -405,13 +402,16 @@ Public Class tsGridControl
EstableceFilterPopupModePredeterminados(sender) EstableceFilterPopupModePredeterminados(sender)
ElementosSeleccionados = New ObservableCollectionCore(Of Object)() ElementosSeleccionados = New ObservableCollectionCore(Of Object)()
End Sub End Sub
Private Property _SeleccionMultiple As Boolean Private Property _SeleccionMultiple As Boolean
Public Property SeleccionMultiple As Boolean Public Property SeleccionMultiple As Boolean
Get Get
Return _SeleccionMultiple Return _SeleccionMultiple
End Get End Get
Set(value As Boolean) Set(value As Boolean)
_SeleccionMultiple = value _SeleccionMultiple = value
If value Then If value Then
Me.SelectionMode = MultiSelectMode.MultipleRow Me.SelectionMode = MultiSelectMode.MultipleRow
Else Else
@@ -421,17 +421,26 @@ Public Class tsGridControl
End Property End Property
Private Sub tsGridControl_PreviewKeyDown(sender As Object, e As KeyEventArgs) Handles Me.PreviewKeyDown Private Sub tsGridControl_PreviewKeyDown(sender As Object, e As KeyEventArgs) Handles Me.PreviewKeyDown
Dim tv = TryCast(Me.View, TableView)
Select Case e.Key Select Case e.Key
Case Key.Add Case Key.Add
If _SeleccionMultiple Then If _SeleccionMultiple Then
Me.SelectAll() Me.SelectAll()
e.Handled = True e.Handled = True
End If End If
Case Key.Subtract Case Key.Subtract
If _SeleccionMultiple Then If _SeleccionMultiple Then
Me.UnselectAll() Me.UnselectAll()
e.Handled = True e.Handled = True
End If End If
Case Key.Space
If tv IsNot Nothing AndAlso tv.ShowCheckBoxSelectorColumn Then
e.Handled = True
End If
Case Key.N Case Key.N
If e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) Then If e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) Then
Me.View.MoveNextRow() Me.View.MoveNextRow()
@@ -439,34 +448,29 @@ Public Class tsGridControl
End If End If
End Select End Select
End Sub End Sub
End Class End Class
Public Class tsGridColumn Public Class tsGridColumn
Inherits DevExpress.Xpf.Grid.GridColumn Inherits DevExpress.Xpf.Grid.GridColumn
Public Property SoloLectura As Boolean Public Property SoloLectura As Boolean
Public Property Imprimible As Boolean = True Public Property Imprimible As Boolean = True
Property ValorMinimo As Nullable(Of Double) Property ValorMinimo As Nullable(Of Double)
Property ValorMaximo As Nullable(Of Double) Property ValorMaximo As Nullable(Of Double)
Public Property MayusculasMinusculas As CharacterCasing? = Nothing Public Property MayusculasMinusculas As CharacterCasing? = Nothing
Public Property CapturarEnter As Boolean Public Property CapturarEnter As Boolean
Private Sub tsGridColumn_Validate(sender As Object, e As DevExpress.Xpf.Grid.GridCellValidationEventArgs) Handles Me.Validate Private Sub tsGridColumn_Validate(sender As Object, e As DevExpress.Xpf.Grid.GridCellValidationEventArgs) Handles Me.Validate
If Not ValorMinimo Is Nothing Then If ValorMinimo IsNot Nothing AndAlso ValorMinimo > e.Value Then
If ValorMinimo > e.Value Then e.IsValid = False
e.IsValid = False e.SetError("Valor Mínimo=" & ValorMinimo.ToString)
e.SetError("Valor Mínimo=" & ValorMinimo.ToString) End If
End If
End If
If Not ValorMaximo Is Nothing Then
If ValorMaximo < e.Value Then
e.IsValid = False
e.SetError("Valor Máximo=" & ValorMaximo.ToString)
End If
End If
End Sub
'Private Function IsColumnCheckBoxSelectorColumn(column As ColumnBase) As Boolean If ValorMaximo IsNot Nothing AndAlso ValorMaximo < e.Value Then
' Return column = DirectCast(Me.View, TableView).VisibleColumns.First() e.IsValid = False
'End Function e.SetError("Valor Máximo=" & ValorMaximo.ToString)
End Class End If
End Sub
End Class

View File

@@ -1034,9 +1034,9 @@ Public MustInherit Class tsUserControl
ObjetosSeleccionables.Add(os) ObjetosSeleccionables.Add(os)
AddHandler tsgc.GotFocus, AddressOf _ObtieneFoco AddHandler tsgc.GotFocus, AddressOf _ObtieneFoco
AddHandler tsgc.PreviewKeyDown, AddressOf _tsgc_PreviewkeyDown AddHandler tsgc.PreviewKeyDown, AddressOf _tsgc_PreviewkeyDown
Dim tv As TableView = tsgc.View Dim tv As TableView = TryCast(tsgc.View, TableView)
AddHandler tv.ValidateRow, AddressOf _tv_ValidateRow If tv IsNot Nothing Then AddHandler tv.ValidateRow, AddressOf _tv_ValidateRow
AddHandler tv.InvalidRowException, AddressOf _tv_InvvalidRowException If tv IsNot Nothing Then AddHandler tv.InvalidRowException, AddressOf _tv_InvvalidRowException
'AddHandler tsgc.PreviewKeyDown, AddressOf ObjetosSeleccionables_PreviewKeyDown 'AddHandler tsgc.PreviewKeyDown, AddressOf ObjetosSeleccionables_PreviewKeyDown
For Each c In tsgc.Columns For Each c In tsgc.Columns
If c.EditSettings Is Nothing Then c.EditSettings = New DevExpress.Xpf.Editors.Settings.TextEditSettings If c.EditSettings Is Nothing Then c.EditSettings = New DevExpress.Xpf.Editors.Settings.TextEditSettings
@@ -1317,7 +1317,7 @@ Public MustInherit Class tsUserControl
Dim mi As MenuItem = sender Dim mi As MenuItem = sender
Dim cm As ContextMenu = mi.Parent Dim cm As ContextMenu = mi.Parent
Dim tsgc As tsGridControl = cm.PlacementTarget Dim tsgc As tsGridControl = cm.PlacementTarget
Dim vista As TableView = tsgc.View Dim vista As DataViewBase = tsgc.View
Try Try
If Not tsgc.LanzaAntesEliminar(tsgc) Then If Not tsgc.LanzaAntesEliminar(tsgc) Then
@@ -1332,7 +1332,11 @@ Public MustInherit Class tsUserControl
Next Next
For Each rw In tsgc.GetSelectedRowHandles For Each rw In tsgc.GetSelectedRowHandles
Try Try
vista.DeleteRow(rw) If vista.GetType = GetType(TableView) Then
DirectCast(vista, TableView).DeleteRow(rw)
Else
DirectCast(vista, CardView).DeleteRow(rw)
End If
Catch ex As Exception Catch ex As Exception
End Try End Try
Next Next
@@ -1348,7 +1352,12 @@ Public MustInherit Class tsUserControl
Catch ex As Exception Catch ex As Exception
Debug.WriteLine(ex.Message) Debug.WriteLine(ex.Message)
End Try End Try
vista.DeleteRow(vista.FocusedRowHandle) If vista.GetType = GetType(TableView) Then
DirectCast(vista, TableView).DeleteRow(vista.FocusedRowHandle)
Else
DirectCast(vista, CardView).DeleteRow(vista.FocusedRowHandle)
End If
If ErroresValidacion.Count > 0 Then ErroresValidacion.RellenaErrores() If ErroresValidacion.Count > 0 Then ErroresValidacion.RellenaErrores()
End If End If
tsgc.RefreshData() tsgc.RefreshData()
@@ -1487,9 +1496,10 @@ Public MustInherit Class tsUserControl
If DirectCast(c, tsGridColumn).Imprimible = False Then c.AllowPrinting = True If DirectCast(c, tsGridColumn).Imprimible = False Then c.AllowPrinting = True
End If End If
Next Next
Dim vista As TableView = tsgc.View Dim vista As DataViewBase = tsgc.View
Dim tv As TableView = TryCast(vista, TableView)
Dim ModoEnum As Boolean = False Dim ModoEnum As Boolean = False
If vista.ShowCheckBoxSelectorColumn AndAlso tsgc.ElementosSeleccionados.Count > 0 AndAlso DXMessageBox.Show("¿Desea exportar solo los elementos seleccionados?", "Atención", MessageBoxButton.YesNo) = MessageBoxResult.Yes Then ModoEnum = True If tv IsNot Nothing AndAlso tv.ShowCheckBoxSelectorColumn AndAlso tsgc.ElementosSeleccionados.Count > 0 AndAlso DXMessageBox.Show("¿Desea exportar solo los elementos seleccionados?", "Atención", MessageBoxButton.YesNo) = MessageBoxResult.Yes Then ModoEnum = True
Dim sfd As New SaveFileDialog Dim sfd As New SaveFileDialog
sfd.FileName = IO.Path.GetDirectoryName("Exportacion") & (tsgc.NombreTablaBase.NothingAVacio & " Exportacion.xlsx").Trim sfd.FileName = IO.Path.GetDirectoryName("Exportacion") & (tsgc.NombreTablaBase.NothingAVacio & " Exportacion.xlsx").Trim
If ModoEnum Then If ModoEnum Then
@@ -1530,38 +1540,34 @@ Public MustInherit Class tsUserControl
Next Next
Dim Cancelar = tsgc.LanzaAntesExportar(tsgc) Dim Cancelar = tsgc.LanzaAntesExportar(tsgc)
If Not Cancelar Then If Not Cancelar Then
Dim vista As TableView = tsgc.View
'Dim tamvista As Single = 0
'For Each c In vista.VisibleColumns
' tamvista += c.ActualWidth
'Next
' Dim factor As Single = 566.92F / tamvista
Try Try
'Dim link As New PrintableControlLink(vista) Dim tv As TableView = TryCast(tsgc.View, TableView)
'link.PaperKind = System.Drawing.Printing.PaperKind.A4 Dim link As New PrintableControlLink(tsgc.View)
'link.Landscape = True link.PaperKind = System.Drawing.Printing.PaperKind.A4
'link.Margins.Left = 0.5 link.Landscape = True
'link.Margins.Right = 0.5 link.Margins.Left = 0.5
'link.Margins.Bottom = 0.5 link.Margins.Right = 0.5
'link.Margins.Top = 0.5 link.Margins.Bottom = 0.5
link.Margins.Top = 0.5
'Dim vi As New ucVisualizadorInformes() Dim vi As New ucVisualizadorInformes()
'link.PageHeaderTemplate = DirectCast(vi.Resources("pageHeaderTemplate"), DataTemplate) link.PageHeaderTemplate = DirectCast(vi.Resources("pageHeaderTemplate"), DataTemplate)
'link.PageFooterTemplate = DirectCast(vi.Resources("pageFooterTemplate"), DataTemplate) link.PageFooterTemplate = DirectCast(vi.Resources("pageFooterTemplate"), DataTemplate)
'link.PageHeaderData = tsgc.PropiedadesTSGC link.PageHeaderData = tsgc.PropiedadesTSGC
'vista.PrintAutoWidth = False If tv IsNot Nothing Then tv.PrintAutoWidth = False
'link.CreateDocument() link.CreateDocument()
'vi.Visualizador.DocumentSource = link vi.Visualizador.DocumentSource = link
'Dim docpanel = New DevExpress.Xpf.Docking.DocumentPanel Dim docpanel = New DevExpress.Xpf.Docking.DocumentPanel
'Dim tabHeaderPrintInfoControl As New TabHeaderPrintInfoControl() With {.TabName = "Exportación " & tsgc.PropiedadesTSGC.Descripcion} Dim tabHeaderPrintInfoControl As New TabHeaderPrintInfoControl() With {.TabName = "Exportación " & tsgc.PropiedadesTSGC.Descripcion}
'docpanel.Caption = tabHeaderPrintInfoControl docpanel.Caption = tabHeaderPrintInfoControl
'docpanel.Content = vi docpanel.Content = vi
'docpanel.ClosingBehavior = DevExpress.Xpf.Docking.ClosingBehavior.ImmediatelyRemove docpanel.ClosingBehavior = DevExpress.Xpf.Docking.ClosingBehavior.ImmediatelyRemove
'Me.GrupoDocumentos.Add(docpanel) Me.GrupoDocumentos.Add(docpanel)
'Comun.dm.DockController.Activate(docpanel) Comun.dm.DockController.Activate(docpanel)

View File

@@ -15,11 +15,13 @@
<RootNamespace>tsWPFCore</RootNamespace> <RootNamespace>tsWPFCore</RootNamespace>
<PackageId>tsWPFCore</PackageId> <PackageId>tsWPFCore</PackageId>
<PackageTags>net8.0-windows, libreria</PackageTags> <PackageTags>net8.0-windows, libreria</PackageTags>
<Version>1.3.11</Version> <Version>1.4.2</Version>
<Authors>Manuel</Authors> <Authors>Manuel</Authors>
<Company>Tecnosis S.A</Company> <Company>Tecnosis S.A</Company>
<Description>Utilidades para aplicaciones WPF.</Description> <Description>Utilidades para aplicaciones WPF.</Description>
<PackageReleaseNotes> <PackageReleaseNotes>
- 2026-07-17 V1.4.2 Se añade compatibilidad con CardView
- 2026-07-17 V1.4.0 Se corrige rutina _Exportar
- 2026-05-22 V1.3.11 tamaño de columnas automatico en ienumerableaexcel - 2026-05-22 V1.3.11 tamaño de columnas automatico en ienumerableaexcel
- 2026-03-12 V1.3.10 Se lanza el evento campoactualizado si se ha lanzado con FuerzaValidarControl - 2026-03-12 V1.3.10 Se lanza el evento campoactualizado si se ha lanzado con FuerzaValidarControl
- 2026-01-19 V1.3.9 Se Corrige hint de previsualizar - 2026-01-19 V1.3.9 Se Corrige hint de previsualizar