137 lines
6.6 KiB
VB.net
137 lines
6.6 KiB
VB.net
Imports System.IO
|
|
Imports DevExpress.Xpf.Bars
|
|
Imports DevExpress.Xpf.Core.Serialization
|
|
Imports DevExpress.Xpf.Grid
|
|
Imports EgtBEAMWALL.Core
|
|
|
|
Public Class FeatureInPartInRawPartListV
|
|
|
|
Private m_FeatureInPartInRawPartListVM As FeatureInPartInRawPartListVM
|
|
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) & "\NewDataGridLayoutFile3.json"
|
|
|
|
For Each Column In FeatureVMList_GridControl.Columns
|
|
Column.[AddHandler](DXSerializer.AllowPropertyEvent,
|
|
New AllowPropertyEventHandler(AddressOf OnAllowProperty))
|
|
Next
|
|
|
|
FeatureVMList_GridControl.Columns("sPriority").Visible = False
|
|
|
|
DXSerializer.AddAllowPropertyHandler(FeatureVMList_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()
|
|
FeatureVMList_GridControl.SaveLayoutToJson(m_sDataGridLayoutPath)
|
|
End Sub
|
|
|
|
Public Sub Me_Loaded() Handles Me.Loaded
|
|
' imposto DataContext
|
|
m_FeatureInPartInRawPartListVM = Me.DataContext
|
|
' imposto riferimento ad action per salvataggio layout tabella
|
|
m_FeatureInPartInRawPartListVM.refFeatureInPartInRawPartListGridControlLayout = AddressOf SaveStatisticGridControlLayout
|
|
' rispristino layout tabella
|
|
If Not IsNothing(m_sDataGridLayoutPath) AndAlso File.Exists(m_sDataGridLayoutPath) Then
|
|
FeatureVMList_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
|
|
FeatureVMList_TableView.ShowGroupFooters = False
|
|
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 = (FeatureVMList_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(FeatureVMList_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(FeatureVMList_TableView.GridMenu.MenuInfo, GridColumnMenuInfo)
|
|
Dim item As ColumnBase = CType(info.Column, ColumnBase)
|
|
item.Width = New GridColumnWidth(1, GridColumnUnitType.Auto)
|
|
FeatureVMList_TableView.UpdateLayout()
|
|
item.Width = item.ActualWidth
|
|
item.AllowResizing = DevExpress.Utils.DefaultBoolean.False
|
|
End Sub
|
|
|
|
' funzione che impedisce di editare le righe che sono gia' in produzione
|
|
Private Sub FeatureInPartInRawPartList_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs)
|
|
If IsNothing(e.Row) Then Return
|
|
Dim RowVM As BTLFeatureVM = DirectCast(e.Row.DataContext, BTLFeatureVM)
|
|
' se in produzione impedisco modifica dei parametri
|
|
If DirectCast(RowVM.BTLFeatureM.ParentPart, PartM).nProductionState > ItemState.ND Then
|
|
'For Each cell In Row.Item
|
|
e.Cancel = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub FeatureList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs)
|
|
If TypeOf sender Is DataGridRow Then
|
|
Dim Row As DataGridRow = DirectCast(sender, DataGridRow)
|
|
If Not IsNothing(Row) AndAlso Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart) Then
|
|
Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|