154 lines
8.2 KiB
VB.net
154 lines
8.2 KiB
VB.net
Imports DevExpress.Data
|
|
Imports DevExpress.Xpf.Bars
|
|
Imports DevExpress.Xpf.Core.Serialization
|
|
Imports DevExpress.Xpf.Grid
|
|
Imports EgtBEAMWALL.Core
|
|
Imports System.IO
|
|
|
|
Public Class StatisticsV
|
|
|
|
Private m_StatisticsVM As StatisticsVM
|
|
Private m_sDataGridLayoutPath As String = ""
|
|
|
|
Sub New()
|
|
|
|
' This call is required by the designer.
|
|
InitializeComponent()
|
|
|
|
' Add any initialization after the InitializeComponent() call.
|
|
m_sDataGridLayoutPath = Path.GetDirectoryName(DataGridColumnsIniFile.m_sDataGridColumnsIniFile) & "\NewDataGridLayoutFile4.json"
|
|
|
|
For Each Column In dgStatistics_GridControl.Columns
|
|
Column.[AddHandler](DXSerializer.AllowPropertyEvent,
|
|
New AllowPropertyEventHandler(AddressOf OnAllowProperty))
|
|
Next
|
|
DXSerializer.AddAllowPropertyHandler(dgStatistics_GridControl, AddressOf OnAddAllowProperty)
|
|
|
|
End Sub
|
|
|
|
' imposto parametri da aggiungere o togliere in Json tabella per i parametri di colonna
|
|
Private Sub OnAllowProperty(sender As Object, e As AllowPropertyEventArgs)
|
|
If e.DependencyProperty Is GridColumn.AllowResizingProperty Then
|
|
e.Allow = True
|
|
End If
|
|
End Sub
|
|
|
|
' imposto parametri da aggiungere o togliere in Json tabella per i parametri generali
|
|
Private Sub OnAddAllowProperty(sender As Object, e As AllowPropertyEventArgs)
|
|
If e.Property.Name = "FilterString" Then
|
|
e.Allow = False
|
|
ElseIf e.Property.Name = "MRUFilters" Then
|
|
e.Allow = False
|
|
ElseIf e.Property.Name = "MRUFilterList" Then
|
|
e.Allow = False
|
|
ElseIf e.Property.Name = "GroupSummarySortInfo" Then
|
|
e.Allow = False
|
|
End If
|
|
End Sub
|
|
|
|
' salvataggio del layout colonne
|
|
Public Sub SaveStatisticGridControlLayout()
|
|
dgStatistics_GridControl.SaveLayoutToJson(m_sDataGridLayoutPath)
|
|
End Sub
|
|
|
|
Public Sub IsVisibleGroupSummary(bValue As Boolean)
|
|
If bValue AndAlso dgStatistics_GridControl.GroupSummary.Count = 0 Then
|
|
dgStatistics_GridControl.GroupSummary.Clear()
|
|
Dim PDNGroupSummaryItem As New GridSummaryItem() With {.FieldName = "nPDN",
|
|
.DisplayFormat = "{0}",
|
|
.SummaryType = SummaryItemType.Count,
|
|
.ShowInGroupColumnFooter = "nPDN"}
|
|
dgStatistics_GridControl.GroupSummary.Add(PDNGroupSummaryItem)
|
|
Dim CNTGroupSummaryItem As New GridSummaryItem() With {.FieldName = "sCNT",
|
|
.DisplayFormat = "{0}",
|
|
.SummaryType = SummaryItemType.Sum,
|
|
.ShowInGroupColumnFooter = "sCNT"}
|
|
dgStatistics_GridControl.GroupSummary.Add(CNTGroupSummaryItem)
|
|
Dim ADDEDGroupSummaryItem As New GridSummaryItem() With {.FieldName = "sADDED",
|
|
.DisplayFormat = "{0}",
|
|
.SummaryType = SummaryItemType.Sum,
|
|
.ShowInGroupColumnFooter = "sADDED"}
|
|
dgStatistics_GridControl.GroupSummary.Add(ADDEDGroupSummaryItem)
|
|
Dim INPRODGroupSummaryItem As New GridSummaryItem() With {.FieldName = "nINPROD",
|
|
.DisplayFormat = "{0}",
|
|
.SummaryType = SummaryItemType.Sum,
|
|
.ShowInGroupColumnFooter = "nINPROD"}
|
|
dgStatistics_GridControl.GroupSummary.Add(INPRODGroupSummaryItem)
|
|
Dim DONEGroupSummaryItem As New GridSummaryItem() With {.FieldName = "nDONE",
|
|
.DisplayFormat = "{0}",
|
|
.SummaryType = SummaryItemType.Sum,
|
|
.ShowInGroupColumnFooter = "nDONE"}
|
|
dgStatistics_GridControl.GroupSummary.Add(DONEGroupSummaryItem)
|
|
End If
|
|
dgStatistics_TableView.ShowGroupFooters = bValue
|
|
End Sub
|
|
|
|
Public Sub Me_Loaded() Handles Me.Loaded
|
|
' imposto DataContext
|
|
m_StatisticsVM = Me.DataContext
|
|
' imposto riferimento ad action per salvataggio layout tabella
|
|
m_StatisticsVM.refSaveStatisticGridControlLayout = AddressOf SaveStatisticGridControlLayout
|
|
' rispristino layout tabella
|
|
If Not IsNothing(m_sDataGridLayoutPath) AndAlso File.Exists(m_sDataGridLayoutPath) Then
|
|
dgStatistics_GridControl.RestoreLayoutFromJson(m_sDataGridLayoutPath)
|
|
End If
|
|
' da gestire chiamandolo quando viene aperto un progetto o aggiunto/rimosso un btl, per evitare che ci sia il GroupSummary se c'e' un solo gruppo
|
|
IsVisibleGroupSummary(False)
|
|
End Sub
|
|
|
|
Private Sub PrintBtn_Click(sender As Object, e As RoutedEventArgs) Handles CopyToClipboardBtn.Click
|
|
m_StatisticsVM = Me.DataContext()
|
|
'ExportToExcelAndCsv(dgStatistics, m_StatisticsVM)
|
|
dgStatistics_GridControl.CopyToClipboard()
|
|
End Sub
|
|
|
|
Private Sub OnShowGridMenu(sender As Object, e As DevExpress.Xpf.Grid.GridMenuEventArgs)
|
|
If e.MenuType = GridMenuType.Column Then
|
|
' rimozione bottoni
|
|
e.Customizations.Add(New RemoveAction() With {.ElementName = DefaultColumnMenuItemNames.GroupBox})
|
|
e.Customizations.Add(New RemoveAction() With {.ElementName = DefaultColumnMenuItemNames.GroupColumn})
|
|
e.Customizations.Add(New RemoveAction() With {.ElementName = DefaultColumnMenuItemNamesBase.ColumnChooser})
|
|
e.Customizations.Add(New RemoveAction() With {.ElementName = DefaultColumnMenuItemNames.BestFit})
|
|
e.Customizations.Add(New RemoveAction() With {.ElementName = DefaultColumnMenuItemNames.BestFitColumns})
|
|
e.Customizations.Add(New RemoveAction() With {.ElementName = DefaultColumnMenuItemNamesBase.FilterEditor})
|
|
|
|
Dim info As GridColumnMenuInfo = CType(e.MenuInfo, GridColumnMenuInfo)
|
|
Dim item As ColumnBase = CType(info.Column, ColumnBase)
|
|
' aggiunta separatore
|
|
Dim separator As BarItemLinkSeparator = New BarItemLinkSeparator()
|
|
e.Customizations.Add(separator)
|
|
' aggiunta bottone AllowResize e Auto Fit
|
|
Dim AllowResize As BarCheckItem = New BarCheckItem() With {.Content = "Allow Resize", .IsChecked = (dgStatistics_TableView.AllowResizing AndAlso (item.AllowResizing = DevExpress.Utils.DefaultBoolean.True OrElse item.AllowResizing = DevExpress.Utils.DefaultBoolean.Default))}
|
|
AddHandler AllowResize.CheckedChanged, AddressOf AllowResize_CheckedChanged
|
|
e.Customizations.Add(AllowResize)
|
|
If item.AllowResizing = DevExpress.Utils.DefaultBoolean.True OrElse item.AllowResizing = DevExpress.Utils.DefaultBoolean.Default Then
|
|
Dim FixAuto As BarButtonItem = New BarCheckItem() With {.Content = "Auto Fit"}
|
|
AddHandler FixAuto.ItemClick, AddressOf FixAuto_ItemClick
|
|
e.Customizations.Add(FixAuto)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
' gestore evento Allow Resize
|
|
Private Sub AllowResize_CheckedChanged(sender As Object, e As ItemClickEventArgs)
|
|
Dim info As GridColumnMenuInfo = TryCast(dgStatistics_TableView.GridMenu.MenuInfo, GridColumnMenuInfo)
|
|
Dim item As ColumnBase = CType(info.Column, ColumnBase)
|
|
If item.AllowResizing = DevExpress.Utils.DefaultBoolean.False Then
|
|
item.AllowResizing = DevExpress.Utils.DefaultBoolean.True
|
|
Else
|
|
item.AllowResizing = DevExpress.Utils.DefaultBoolean.False
|
|
End If
|
|
End Sub
|
|
|
|
' gestore evento Auto Fit
|
|
Private Sub FixAuto_ItemClick(sender As Object, e As ItemClickEventArgs)
|
|
Dim info As GridColumnMenuInfo = TryCast(dgStatistics_TableView.GridMenu.MenuInfo, GridColumnMenuInfo)
|
|
Dim item As ColumnBase = CType(info.Column, ColumnBase)
|
|
item.Width = New GridColumnWidth(1, GridColumnUnitType.Auto)
|
|
dgStatistics_TableView.UpdateLayout()
|
|
item.Width = item.ActualWidth
|
|
item.AllowResizing = DevExpress.Utils.DefaultBoolean.False
|
|
End Sub
|
|
|
|
End Class
|