diff --git a/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs b/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs index 23ffef99..7be1450e 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using EgtBEAMWALL.DataLayer.DatabaseModels; +using static EgtBEAMWALL.Core.ConstBeam; namespace EgtBEAMWALL.DataLayer.Controllers @@ -33,6 +34,17 @@ namespace EgtBEAMWALL.DataLayer.Controllers #region Protected Methods + /// + /// Helper conversione modelli + /// + /// + /// + protected Core.ProdFileM coreConv(ProdModel currProd) + { + Core.ProdFileM answ = Core.ProdFileM.CreateProdFileM(currProd.ProdId, ProjIdByProd(currProd.ProdId), currProd.DtCreated, currProd.Description, currProd.PType); + return answ; + } + /// /// Get LAST paginated data from DB (DESC ordered) /// @@ -503,6 +515,25 @@ namespace EgtBEAMWALL.DataLayer.Controllers return currData; } + /// + /// Update record su DB x PType + /// + /// + /// + /// + public Core.ProdFileM UpdatePType(int ProdId, BWType PType) + { + var currData = FindByProdId(ProdId); + // aggiorno valore BTL + currData.PType = PType; + + // Commit changes + dbCtx.SaveChanges(); + ResetController(); + + return coreConv(currData); + } + #endregion Public Methods } } \ No newline at end of file diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml index 82c4e61b..50227138 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml @@ -5,225 +5,269 @@ xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5" xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer"> - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - + + - - + - - + - - + - - - - + - - - + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb index e6f9ddea..b3f17615 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb @@ -124,6 +124,18 @@ Public Class ConfigurationPageVM End Set End Property + ' lista delle colonne con le relative proprietà della DataGrid + Private m_DGColumnsList_View As CollectionView = Nothing + Protected m_DGColumnsList As New ObservableCollection(Of IniDataGridColumn) + Public Property DGColumnsList As ObservableCollection(Of IniDataGridColumn) + Get + Return m_DGColumnsList + End Get + Set(value As ObservableCollection(Of IniDataGridColumn)) + m_DGColumnsList = value + End Set + End Property + #Region "Messages" Public ReadOnly Property L_Msg As String @@ -203,6 +215,48 @@ Public Class ConfigurationPageVM End Get End Property + Public ReadOnly Property DisplayIndex_Msg As String + Get + Return EgtMsg(61842) + End Get + End Property + + Public ReadOnly Property ColumnName_Msg As String + Get + Return EgtMsg(61843) + End Get + End Property + + Public ReadOnly Property CanUserReorder_Msg As String + Get + Return EgtMsg(61844) + End Get + End Property + + Public ReadOnly Property CanUserResize_Msg As String + Get + Return EgtMsg(61845) + End Get + End Property + + Public ReadOnly Property CanUserSort_Msg As String + Get + Return EgtMsg(61846) + End Get + End Property + + Public ReadOnly Property IsReadOnly_Msg As String + Get + Return EgtMsg(61847) + End Get + End Property + + Public ReadOnly Property Visible_Msg As String + Get + Return EgtMsg(61848) + End Get + End Property + #End Region ' Messages #Region "Constructor" @@ -255,6 +309,11 @@ Public Class ConfigurationPageVM m_QBTLParamVMList_View = CollectionViewSource.GetDefaultView(m_QBTLParamVMList) m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.GroupType))) m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.ghDesc))) + ' carico la lista delle colonne delle DataGrid in ConfigurationPage + LoadConfigDGColumns() + ' setto il grouping ad 1 livello per la DataGrid + m_DGColumnsList_View = CollectionViewSource.GetDefaultView(m_DGColumnsList) + m_DGColumnsList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(IniDataGridColumn.ParentDataGridName))) End Sub #End Region ' Constructor @@ -279,6 +338,7 @@ Public Class ConfigurationPageVM Public Sub Save() WriteMachParams() WriteProcessParams(PRCList.ToList()) + WriteDataGridColumns() WriteMainPrivateProfileString(S_GENERAL, K_MESSAGES, m_SelectedLanguage.Name) WriteMainPrivateProfileString(S_SCENE, K_MMUNITS, SelMeasureUnit.ToString()) WriteMainPrivateProfileString(S_NEST, K_SECTIONTIME, DoubleToString(m_SectionTime, 5)) @@ -368,6 +428,19 @@ Public Class ConfigurationPageVM Next NotifyPropertyChanged(NameOf(QBTLParamVMList)) End If + ' verifico se i valori delle colonne DataGrid sono stati modificati + For Each DGColumnItem In DGColumnsList + If DGColumnItem.IsModified Then + If MessageBox.Show(EgtMsg(61882), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + ' scrivo i valori delle colonne DataGrid modificate + WriteDataGridColumns() + Else + ' se da non salvare li resetto ed esco dai For + LoadConfigDGColumns() + Exit For + End If + End If + Next End Sub ' funzione che verifica l'inserimento della password quando si edita un parametro Macchina @@ -442,6 +515,45 @@ Public Class ConfigurationPageVM Next End Sub + ' funzione che carica la DataGrid di configurazione delle colonne delle EgtDataGrid + Public Sub LoadConfigDGColumns() + DGColumnsList.Clear() + GetPrivateProfileColumns(S_FEATURELIST, DGColumnsList) + GetPrivateProfileColumns(S_OPENPROJFILEDLG_PROJ, DGColumnsList) + GetPrivateProfileColumns(S_OPENPROJFILEDLG_PROD, DGColumnsList) + GetPrivateProfileColumns(S_RAWPARTLIST_BEAM, DGColumnsList) + GetPrivateProfileColumns(S_RAWPARTLIST_WALL, DGColumnsList) + GetPrivateProfileColumns(S_PARTINRAWPARTLIST_BEAM, DGColumnsList) + GetPrivateProfileColumns(S_PARTINRAWPARTLIST_WALL, DGColumnsList) + End Sub + + ' funzione per calcolare e scrivere la stringhe dei parametri delle colonne relative ad una ParentDataGridName nell'INI + Public Sub SaveDataGridColumns(ParentDataGridName As String, DGColumnsList As ObservableCollection(Of IniDataGridColumn)) + For Each ColumnItem In DGColumnsList + If ColumnItem.ParentDataGridName = ParentDataGridName Then + Dim sColumnParams = String.Empty + sColumnParams = ColumnItem.Name & "," & If(ColumnItem.CanUserReorder, 1, 0) & "," & If(ColumnItem.CanUserResize, 1, 0) & "," & + If(ColumnItem.CanUserSort, 1, 0) & "," & If(ColumnItem.IsReadOnly, 1, 0) & "," & DoubleToString(ColumnItem.Width.Value, 6) & "," & + ColumnItem.Width.UnitType & "," & If(ColumnItem.Visible, 1, 0) & "," & If(ColumnItem.CanUserEditVisible, 1, 0) + WriteColumnPrivateProfileParam(ParentDataGridName, ColumnItem.m_DisplayIndex, sColumnParams) + End If + Next + End Sub + + ' funzione che scrive i valori delle proprietà delle colonne customizzate delle EgtDataGrid nell'INI + Public Sub WriteDataGridColumns() + SaveDataGridColumns(S_FEATURELIST, DGColumnsList) + SaveDataGridColumns(S_OPENPROJFILEDLG_PROJ, DGColumnsList) + SaveDataGridColumns(S_OPENPROJFILEDLG_PROD, DGColumnsList) + SaveDataGridColumns(S_RAWPARTLIST_BEAM, DGColumnsList) + SaveDataGridColumns(S_RAWPARTLIST_WALL, DGColumnsList) + SaveDataGridColumns(S_PARTINRAWPARTLIST_BEAM, DGColumnsList) + SaveDataGridColumns(S_PARTINRAWPARTLIST_WALL, DGColumnsList) + For Each DGColumnItem In DGColumnsList + DGColumnItem.IsModifiedReset() + Next + End Sub + #End Region ' Methods End Class @@ -635,6 +747,225 @@ Public Class MachTable End Class +Public Class IniDataGridColumn + + Private Property m_ParentDataGridName As String + Public Property ParentDataGridName As String + Get + Return m_ParentDataGridName + End Get + Set(value As String) + m_ParentDataGridName = value + End Set + End Property + + Private Property m_Name As String + Public Property Name As String + Get + Return m_Name + End Get + Set(value As String) + m_Name = value + End Set + End Property + + Private Property m_Width As DataGridLength + Public Property Width As DataGridLength + Get + Return m_Width + End Get + Set(value As DataGridLength) + m_Width = value + End Set + End Property + + Private m_IsModifiedDisplayIndex + Friend Property m_DisplayIndex As Integer + Public Property DisplayIndex As Integer + Get + Return If(Visible, m_DisplayIndex, -1) + End Get + Set(value As Integer) + m_DisplayIndex = value + m_IsModifiedDisplayIndex = (m_Name <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.NAME)) + ' se DisplayIndex viene settato ad un valore che corrisponde a quello che aveva inizialmente aggiorno gli IsModified + ' delle altre proprietà utilizzando il DisplayIndex attuale + If Not m_IsModifiedDisplayIndex Then + m_IsModifiedIsReadOnly = (m_IsReadOnly <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.ISREADONLY)) + m_IsModifiedCanUserReorder = (m_CanUserReorder <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.REORDER)) + m_IsModifiedCanUserResize = (m_CanUserResize <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.RESIZE)) + m_IsModifiedCanUserSort = (m_CanUserSort <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.SORT)) + m_IsModifiedVisible = (m_Visible <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.VISIBLE)) + End If + End Set + End Property + + Private m_IsModifiedIsReadOnly As Boolean = False + Private Property m_IsReadOnly As Boolean = True + Public Property IsReadOnly As Boolean + Get + Return m_IsReadOnly + End Get + Set(value As Boolean) + m_IsReadOnly = value + m_IsModifiedIsReadOnly = (m_IsReadOnly <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.ISREADONLY)) + End Set + End Property + + Private m_IsModifiedCanUserReorder As Boolean = False + Private m_CanUserReorder As Boolean + Public Property CanUserReorder As Boolean + Get + Return m_CanUserReorder + End Get + Set(value As Boolean) + m_CanUserReorder = value + m_IsModifiedCanUserReorder = (m_CanUserReorder <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.REORDER)) + End Set + End Property + + Private m_IsModifiedCanUserResize As Boolean = False + Private m_CanUserResize As Boolean + Public Property CanUserResize As Boolean + Get + Return m_CanUserResize + End Get + Set(value As Boolean) + m_CanUserResize = value + m_IsModifiedCanUserResize = (m_CanUserResize <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.RESIZE)) + End Set + End Property + + Private m_IsModifiedCanUserSort As Boolean = False + Private m_CanUserSort As Boolean + Public Property CanUserSort As Boolean + Get + Return m_CanUserSort + End Get + Set(value As Boolean) + m_CanUserSort = value + m_IsModifiedCanUserSort = (m_CanUserSort <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.SORT)) + End Set + End Property + + Private m_IsModifiedVisible As Boolean = False + Private m_Visible As Boolean + Public Property Visible As Boolean + Get + Return m_Visible + End Get + Set(value As Boolean) + m_Visible = value + ' Utilizzo OldDGIndex e NewDGIndex per muovere la Column tra il gruppo dei Visible (in alto) o il gruppo + ' dei non Visible (in basso): in ambo i casi verrà sempre spostata in mezzo ai due raggruppamenti + Dim OldDGIndex As Integer = Map.refConfigurationPageVM.DGColumnsList.IndexOf(Me) + If value Then + Dim NewDGIndex As Integer = Map.refConfigurationPageVM.DGColumnsList.IndexOf(Map.refConfigurationPageVM.DGColumnsList.FirstOrDefault( + Function(x) x.ParentDataGridName = ParentDataGridName AndAlso + x.Visible = False)) + ' se NewDGIndex = -1 (ovvero ho settato l'ultima Column rimasta non Visible a Visible) oppure + ' se il nuovo indice è subito dopo il vecchio non la sposto altrimenti viene spostata in maniera sbagliata + If NewDGIndex <> -1 AndAlso NewDGIndex <> OldDGIndex + 1 Then Map.refConfigurationPageVM.DGColumnsList.Move(OldDGIndex, NewDGIndex) + Else + Dim NewDGIndex As Integer = Map.refConfigurationPageVM.DGColumnsList.IndexOf(Map.refConfigurationPageVM.DGColumnsList.FirstOrDefault( + Function(x) x.ParentDataGridName = ParentDataGridName AndAlso + x.Visible = False AndAlso + x.Name <> Name)) + ' se NewDGIndex = -1 vuol dire che erano tutte settate a Visible perciò devo calcolare l'indice + ' dell'ultima Column con quel ParentDataGridName e spostarlo lì + If NewDGIndex = -1 Then + Dim FirstIndex As Integer = Map.refConfigurationPageVM.DGColumnsList.IndexOf(Map.refConfigurationPageVM.DGColumnsList.FirstOrDefault( + Function(x) x.ParentDataGridName = ParentDataGridName)) + Dim LastIndex = FirstIndex + While LastIndex < Map.refConfigurationPageVM.DGColumnsList.Count AndAlso Map.refConfigurationPageVM.DGColumnsList(LastIndex).ParentDataGridName = ParentDataGridName + LastIndex += 1 + End While + NewDGIndex = LastIndex + End If + Map.refConfigurationPageVM.DGColumnsList.Move(OldDGIndex, NewDGIndex - 1) + End If + ' aggiorno i DisplayIndex di ciascuna Column della ParentDataGridName in questione + Dim index = 0 + For Each DGColumnItem In Map.refConfigurationPageVM.DGColumnsList + If DGColumnItem.ParentDataGridName = ParentDataGridName Then + DGColumnItem.DisplayIndex = index + index += 1 + End If + Next + ' uso il Move col medesimo valore per i 2 argomenti per refreshare i DisplayIndex delle Column + ' della ParentDataGridName in questione appena riordinate + For index = 0 To Map.refConfigurationPageVM.DGColumnsList.Count - 1 + If Map.refConfigurationPageVM.DGColumnsList(index).ParentDataGridName = ParentDataGridName Then + Map.refConfigurationPageVM.DGColumnsList.Move(index, index) + End If + Next + ' setto se il valore è stato modificato, a partire dalla verifica che il Nome e DisplayIndex combacino (altrimenti è per forza modificato) + m_IsModifiedVisible = (m_Name <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.NAME)) OrElse + (If(m_Visible, 1, 0) <> + GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.VISIBLE)) + End Set + End Property + + Private m_CanUserEditVisible As Boolean + Public Property CanUserEditVisible As Boolean + Get + Return m_CanUserEditVisible + End Get + Set(value As Boolean) + m_CanUserEditVisible = value + End Set + End Property + + Public ReadOnly Property IsModified() As Boolean + Get + Return m_IsModifiedDisplayIndex OrElse + m_IsModifiedIsReadOnly OrElse + m_IsModifiedCanUserReorder OrElse + m_IsModifiedCanUserResize OrElse + m_IsModifiedCanUserSort OrElse + m_IsModifiedVisible + End Get + End Property + + Public Sub IsModifiedReset() + m_IsModifiedDisplayIndex = False + m_IsModifiedIsReadOnly = False + m_IsModifiedCanUserReorder = False + m_IsModifiedCanUserResize = False + m_IsModifiedCanUserSort = False + m_IsModifiedVisible = False + End Sub + + Sub New(sName As String) + m_Name = sName + End Sub + + Sub New(sParentDG As String, nDisplayIndex As Integer, sName As String, bCanUserReorder As Boolean, bCanUserResize As Boolean, bCanUserSort As Boolean, bIsReadOnly As Boolean, Width As DataGridLength, bVisible As Boolean, bCanUserEditVisible As Boolean) + m_ParentDataGridName = sParentDG + m_DisplayIndex = nDisplayIndex + m_Name = sName + m_CanUserReorder = bCanUserReorder + m_CanUserResize = bCanUserResize + m_CanUserSort = bCanUserSort + m_IsReadOnly = bIsReadOnly + m_Width = Width + m_Visible = bVisible + m_CanUserEditVisible = bCanUserEditVisible + End Sub + +End Class + ' Tipo parametro nel file di configurazione Macchina Public Enum MachParamType As Integer DOUBLE_ = 1 diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/DGColumnsListV.xaml b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/DGColumnsListV.xaml new file mode 100644 index 00000000..3c6d3ce0 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/DGColumnsListV.xaml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/DGColumnsListV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/DGColumnsListV.xaml.vb new file mode 100644 index 00000000..c06af363 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/DGColumnsListV.xaml.vb @@ -0,0 +1,3 @@ +Public Class DGColumnsListV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj index 7dd8707f..6522def1 100644 --- a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj +++ b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj @@ -178,6 +178,9 @@ CalcPanelV.xaml + + DGColumnsListV.xaml + @@ -360,6 +363,9 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer Designer diff --git a/EgtBEAMWALL.ViewerOptimizer/MachinePanel/MachinePanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/MachinePanel/MachinePanelVM.vb index 606efe5a..24c47ccd 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MachinePanel/MachinePanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/MachinePanel/MachinePanelVM.vb @@ -45,13 +45,27 @@ Public Class MachinePanelVM End If NotifyPropertyChanged(NameOf(BeamTable_Visibility)) NotifyPropertyChanged(NameOf(WallTable_Visibility)) - ' resetto Proj e Prod correnti, BTLStructure e MachGroupPanel - Map.refProjManagerVM.ResetCurrProj() - Map.refProdManagerVM.ResetCurrProd() - If Not IsNothing(Map.refProjectVM) Then - Map.refProjectVM.BTLStructureVM = Nothing - Map.refProjectVM.MachGroupPanelVM = Nothing - EgtNewFile() + ' se il tipo della macchina selezionata non è congruo al tipo progetto del Proj o del Prod correnti + ' resetto quello non congruo di questi due, assieme a BTLStructure e MachGroupPanel + Dim bReset As Boolean = False + If Not IsNothing(Map.refProjectVM) AndAlso + Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso + nMachType <> 3 Then + If Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso + nMachType <> Map.refProjManagerVM.CurrProj.nType Then + Map.refProjManagerVM.ResetCurrProj() + bReset = True + End If + If Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso + nMachType <> Map.refProdManagerVM.CurrProd.nType Then + Map.refProdManagerVM.ResetCurrProd() + bReset = True + End If + If bReset AndAlso Not IsNothing(Map.refProjectVM) Then + Map.refProjectVM.BTLStructureVM = Nothing + Map.refProjectVM.MachGroupPanelVM = Nothing + EgtNewFile() + End If End If ' aggiorno nome macchina in statusbar Map.refMyStatusBarVM.RefreshMachName() diff --git a/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb b/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb index 07dac11a..4f3b87e8 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb @@ -156,7 +156,7 @@ Public Class MainMenuVM Map.refProjectVM.NotifyAllPanelVisibility() ' apro progetto proj If Not IsNothing(Map.refProjManagerVM.CurrProj) Then - If IsNothing(Map.refProjManagerVM.CurrProj) OrElse Map.refProjManagerVM.CurrProj.bReloadProject Then + If Map.refProjManagerVM.CurrProj.bReloadProject Then Map.refProjManagerVM.OpenProject(Map.refProjManagerVM.CurrProj) ' aggiorno le colonne in base al tipo progetto If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then @@ -289,6 +289,8 @@ Public Class MainMenuVM Private Function InitCONFIG() As Boolean Map.refMainWindowVM.NotifyPropertyChanged("nSelTabPage") + ' ricarico la lista delle colonne delle DataGrid in ConfigurationPage + If Not IsNothing(Map.refConfigurationPageVM) Then Map.refConfigurationPageVM.LoadConfigDGColumns() Return True End Function @@ -296,6 +298,16 @@ Public Class MainMenuVM Map.refConfigurationPageVM.VerifyConfigPageModification() ' resetto flag inserimento password Map.refConfigurationPageVM.bModifyMachParam = False + ' ricarico le EgtDataGrid del programma con le colonne customizzate + Map.refFeatureListVM.FeatureColumns.Clear() + GetPrivateProfileColumns(S_FEATURELIST, Map.refFeatureListVM.FeatureColumns) + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + Else + Map.refRawPartListVM.UpdateColumns(BWType.BEAM) + Map.refPartInRawPartListVM.UpdateColumns(BWType.BEAM) + End If Return True End Function diff --git a/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogV.xaml.vb index 05d4a74c..b4a3068e 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogV.xaml.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogV.xaml.vb @@ -54,8 +54,8 @@ Public Class OpenProjectFileDialogV Private Sub Calendar_SelectedDatesChanged(sender As Object, e As SelectionChangedEventArgs) Dim cal As System.Windows.Controls.Calendar = sender - Map.refOpenProjectFileDialogVM.m_SearchDate = cal.SelectedDates - Map.refOpenProjectFileDialogVM.m_ProjectList_View.Refresh() + m_OpenProjFileDialogVM.m_SearchDate = cal.SelectedDates + m_OpenProjFileDialogVM.m_ProjectList_View.Refresh() End Sub End Class \ No newline at end of file diff --git a/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb index a96306ba..a3d0d6e3 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb @@ -235,8 +235,6 @@ Public Class OpenProjectFileDialogVM Private m_cmdDelete As ICommand Public Function Init(ProjectType As ProjectType, Optional CurrProjectList As List(Of ProjectFileVM) = Nothing) As Boolean? - ' imposto riferimento in Map - Map.SetRefOpenProjectFileDialogVM(Me) m_ProjectType = ProjectType ' carico colonne LoadColumns(ProjectType) diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb index a90568cb..d24bb9bc 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb @@ -171,6 +171,8 @@ Public Class ProjManagerVM Dim nProdId As Integer = 0 Dim sProdDir As String = "" Map.refProdManagerVM.InitNewProject(m_CurrProj.nProjId, nProdId, sProdDir) + ' setto il PType del Prod + DbControllers.m_ProdController.UpdatePType(nProdId, CurrProj.nType) ' copio file progetto Dim sProjPath As String = String.Empty Dim bOk = False @@ -493,7 +495,7 @@ Public Class ProjManagerVM DbControllers.m_ProjController.ResetNew(CurrProj.nProjId) m_CurrProj.bIsNew = False End If - ' se assemplato lo ripristino + ' se assemblato lo ripristino If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) ' aggiorno titolo Map.refMainWindowVM.UpdateTitle() diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFileVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFileVM.vb index 8177717d..f7e0b651 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFileVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFileVM.vb @@ -83,6 +83,12 @@ Public Class ProjectFileVM End Get End Property + Public ReadOnly Property nType As BWType + Get + Return m_ProjectFileM.nType + End Get + End Property + ' variabile che indica se ricaricare il progetto Private m_bReloadProject As Boolean = True Friend ReadOnly Property bReloadProject As Boolean diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/DataGridColumnsIniFile.vb b/EgtBEAMWALL.ViewerOptimizer/Utility/DataGridColumnsIniFile.vb index dae24cd1..4dcb432e 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Utility/DataGridColumnsIniFile.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/DataGridColumnsIniFile.vb @@ -6,13 +6,14 @@ Friend Module DataGridColumnsIniFile Public m_sDataGridColumnsIniFile As String + ' funzione per ottenere dal file INI le colonne da caricare nelle EgtDataGrid del programma Public Function GetPrivateProfileColumns(ParentDGName As String, ByRef ocColumns As ObservableCollection(Of EgtDataGridColumn)) As Boolean Dim colIndex As Integer = 0 Dim str = String.Empty While EgtUILib.GetPrivateProfileString(ParentDGName, colIndex, String.Empty, str, m_sDataGridColumnsIniFile) > 0 Dim sColumnParams() As String = str.Split(","c) ' verifico numero minimo di parametri - If sColumnParams.Count >= 7 Then + If sColumnParams.Count >= 9 Then ' cancello spazi For index = 0 To sColumnParams.Count - 1 sColumnParams(index) = sColumnParams(index).Trim() @@ -27,15 +28,81 @@ Friend Module DataGridColumnsIniFile Dim WidthType As DataGridLengthUnitType StringToDouble(sColumnParams(5), Width) Integer.TryParse(sColumnParams(6), WidthType) - ocColumns.Add(New EgtDataGridColumn(ParentDGName, sName, bReorder, bResize, bSort, bIsReadOnly, New DataGridLength(Width, WidthType))) + Dim bVisible As Boolean = sColumnParams(7).Equals("1") + Dim bCanUserEditVisible As Boolean = sColumnParams(8).Equals("1") + If bVisible Then + ocColumns.Add(New EgtDataGridColumn(ParentDGName, sName, bReorder, bResize, bSort, bIsReadOnly, New DataGridLength(Width, WidthType), bVisible, bCanUserEditVisible)) + Else + Exit While + End If End If colIndex += 1 End While Return ocColumns.Count > 0 End Function + ' funzione per ottenere dal file INI le colonne da caricare nella DataGrid usata per customizzare le proprietà delle colonne delle EgtDataGrid del programma + Public Function GetPrivateProfileColumns(ParentDGName As String, ByRef ocColumns As ObservableCollection(Of IniDataGridColumn)) As Boolean + Dim colIndex As Integer = 0 + Dim str = String.Empty + While EgtUILib.GetPrivateProfileString(ParentDGName, colIndex, String.Empty, str, m_sDataGridColumnsIniFile) > 0 + Dim sColumnParams() As String = str.Split(","c) + ' verifico numero minimo di parametri + If sColumnParams.Count >= 9 Then + ' cancello spazi + For index = 0 To sColumnParams.Count - 1 + sColumnParams(index) = sColumnParams(index).Trim() + Next + ' creo colonna + Dim sName = sColumnParams(0) + Dim bReorder As Boolean = sColumnParams(1).Equals("1") + Dim bResize As Boolean = sColumnParams(2).Equals("1") + Dim bSort As Boolean = sColumnParams(3).Equals("1") + Dim bIsReadOnly As Boolean = sColumnParams(4).Equals("1") + Dim Width As Double + Dim WidthType As DataGridLengthUnitType + StringToDouble(sColumnParams(5), Width) + Integer.TryParse(sColumnParams(6), WidthType) + Dim bVisible As Boolean = sColumnParams(7).Equals("1") + Dim bCanUserEditVisible As Boolean = sColumnParams(8).Equals("1") + ocColumns.Add(New IniDataGridColumn(ParentDGName, colIndex, sName, bReorder, bResize, bSort, bIsReadOnly, New DataGridLength(Width, WidthType), bVisible, bCanUserEditVisible)) + End If + colIndex += 1 + End While + Return ocColumns.Count > 0 + End Function + + ' funzione che ottiene dal file INI la singola proprietà legata ad una specifica colonna + Public Function GetPrivateProfileColumnProperty(ParentDGName As String, ocColumns As ObservableCollection(Of IniDataGridColumn), DisplayIndex As Integer, PropertyIndex As EgtDGColumnProperty) As String + Dim str = String.Empty + If EgtUILib.GetPrivateProfileString(ParentDGName, DisplayIndex, String.Empty, str, m_sDataGridColumnsIniFile) > 0 Then + Dim sColumnParams() As String = str.Split(","c) + ' verifico numero minimo di parametri + If sColumnParams.Count >= 9 Then + ' cancello spazi + For index = 0 To sColumnParams.Count - 1 + sColumnParams(index) = sColumnParams(index).Trim() + Next + If PropertyIndex > -1 AndAlso PropertyIndex < sColumnParams.Count Then Return sColumnParams(PropertyIndex) + End If + End If + Return "" + End Function + Public Function WriteColumnPrivateProfileParam(ParentDataGridName As String, DisplayIndex As String, sColumnParams As String) As Boolean Return WritePrivateProfileString(ParentDataGridName, DisplayIndex, sColumnParams, m_sDataGridColumnsIniFile) End Function + Public Enum EgtDGColumnProperty + NAME = 0 + REORDER = 1 + RESIZE = 2 + SORT = 3 + ISREADONLY = 4 + WIDTH = 5 + WIDTHTYPE = 6 + VISIBLE = 7 + EDITVISIBLE = 8 + End Enum + End Module \ No newline at end of file diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/EgtDataGrid.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/Utility/EgtDataGrid.xaml.vb index a3d6515d..07975bed 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Utility/EgtDataGrid.xaml.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/EgtDataGrid.xaml.vb @@ -39,9 +39,13 @@ Public Class EgtDataGrid If newItems IsNot Nothing Then For Index = 0 To newItems.Count - 1 - Dim col As DataGridColumn = context.FindResource(newItems(Index).Name) - newItems(Index).InitColumn(col) - context.Columns.Add(col) + Try + Dim col As DataGridColumn = context.FindResource(newItems(Index).Name) + newItems(Index).InitColumn(col) + context.Columns.Add(col) + Catch ex As Exception + MessageBox.Show(String.Format(EgtMsg(61883), newItems(Index).Name, newItems(Index).ParentDataGridName), EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) + End Try Next AddHandler newItems.CollectionChanged, AddressOf context.collectionChanged @@ -55,12 +59,16 @@ Public Class EgtDataGrid If e.NewItems IsNot Nothing Then For Each one As EgtDataGridColumn In e.NewItems - Dim col As DataGridColumn = CurrDataGrid.FindResource(one.Name) - one.InitColumn(col) - CurrDataGrid.Columns.Insert(e.NewStartingIndex, col) - If col.DisplayIndex <> e.NewStartingIndex Then - CurrDataGrid.Columns(e.NewStartingIndex).DisplayIndex = e.NewStartingIndex - End If + Try + Dim col As DataGridColumn = CurrDataGrid.FindResource(one.Name) + one.InitColumn(col) + CurrDataGrid.Columns.Insert(e.NewStartingIndex, col) + If col.DisplayIndex <> e.NewStartingIndex Then + CurrDataGrid.Columns(e.NewStartingIndex).DisplayIndex = e.NewStartingIndex + End If + Catch ex As Exception + MessageBox.Show(String.Format(EgtMsg(61883), one.Name, one.ParentDataGridName), EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) + End Try Next End If @@ -99,7 +107,10 @@ Public Class EgtDataGrid Private Sub Cell_SizedChanged(sender As Object, e As SizeChangedEventArgs) ' ad ogni ridimensionamento della cella del ColumnHeader salvo le nuove dimensioni nell'ini If Not IsNothing(e.OriginalSource.Column) AndAlso Not IsNothing(BindingColumns(e.OriginalSource.Column.DisplayIndex)) Then - BindingColumns(e.OriginalSource.Column.DisplayIndex).SaveDataGridColumn() + ' se la colonna corrente è Star ed è preceduta da una colonna Pixel non scrivo le modifiche + If Not (e.OriginalSource.Column.Width.IsStar) Then + BindingColumns(e.OriginalSource.Column.DisplayIndex).SaveDataGridColumn() + End If End If End Sub @@ -237,11 +248,44 @@ Public Class EgtDataGridColumn End Set End Property + Private m_Visible As Boolean + Public Property Visible As Boolean + Get + Return m_Visible + End Get + Set(value As Boolean) + m_Visible = value + ColumnVisibility = If(m_Visible, Visibility.Visible, Visibility.Collapsed) + SaveDataGridColumn() + End Set + End Property + + Private m_ColumnVisibility As Visibility + Public Property ColumnVisibility As Visibility + Get + Return If(m_Visible, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ColumnVisibility = value + End Set + End Property + + Private m_CanUserEditVisible As Boolean + Public Property CanUserEditVisible As Boolean + Get + Return m_CanUserEditVisible + End Get + Set(value As Boolean) + m_CanUserEditVisible = value + SaveDataGridColumn() + End Set + End Property + Sub New(sName As String) m_Name = sName End Sub - Sub New(sParentDG As String, sName As String, bCanUserReorder As Boolean, bCanUserResize As Boolean, bCanUserSort As Boolean, bIsReadOnly As Boolean, Width As DataGridLength) + Sub New(sParentDG As String, sName As String, bCanUserReorder As Boolean, bCanUserResize As Boolean, bCanUserSort As Boolean, bIsReadOnly As Boolean, Width As DataGridLength, bVisible As Boolean, bCanUserEditVisible As Boolean) m_ParentDataGridName = sParentDG m_Name = sName m_CanUserReorder = bCanUserReorder @@ -249,6 +293,8 @@ Public Class EgtDataGridColumn m_CanUserSort = bCanUserSort m_IsReadOnly = bIsReadOnly m_Width = Width + m_Visible = bVisible + m_CanUserEditVisible = bCanUserEditVisible End Sub Friend Sub InitColumn(dgColumn As DataGridColumn) @@ -259,13 +305,14 @@ Public Class EgtDataGridColumn m_dgColumn.IsReadOnly = m_IsReadOnly 'm_dgColumn.DisplayIndex = m_DisplayIndex m_dgColumn.Width = m_Width + m_dgColumn.Visibility = m_ColumnVisibility End Sub ' funzione per calcolare e scrivere la stringa dei parametri della colonna nell'INI Public Function SaveDataGridColumn() As Boolean Dim bOk As Boolean Dim sColumnParams = String.Empty - sColumnParams = Name & "," & If(CanUserReorder, 1, 0) & "," & If(CanUserResize, 1, 0) & "," & If(CanUserSort, 1, 0) & "," & If(IsReadOnly, 1, 0) & "," & DoubleToString(Width.Value, 6) & "," & Width.UnitType + sColumnParams = Name & "," & If(CanUserReorder, 1, 0) & "," & If(CanUserResize, 1, 0) & "," & If(CanUserSort, 1, 0) & "," & If(IsReadOnly, 1, 0) & "," & DoubleToString(Width.Value, 6) & "," & Width.UnitType & "," & If(Visible, 1, 0) & "," & If(CanUserEditVisible, 1, 0) bOk = WriteColumnPrivateProfileParam(ParentDataGridName, DisplayIndex, sColumnParams) Return bOk End Function diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/Map.vb b/EgtBEAMWALL.ViewerOptimizer/Utility/Map.vb index 9a695de1..24e4fabf 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Utility/Map.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/Map.vb @@ -25,7 +25,7 @@ Module Map Private m_refInstrumentPanelVM As InstrumentPanelVM Private m_refTopPanelVM As TopPanelVM Private m_refOptimizePanelVM As OptimizePanelVM - Private m_refOpenProjectFileDialogVM As OpenProjectFileDialogVM + 'Private m_refOpenProjectFileDialogVM As OpenProjectFileDialogVM 'Private m_refRawPartTabVM As RawPartTabVM 'Private m_refNestingTabVM As NestingTabVM 'Private m_refMachiningTabVM As MachiningTabVM @@ -178,11 +178,11 @@ Module Map End Get End Property - Public ReadOnly Property refOpenProjectFileDialogVM As OpenProjectFileDialogVM - Get - Return m_refOpenProjectFileDialogVM - End Get - End Property + 'Public ReadOnly Property refOpenProjectFileDialogVM As OpenProjectFileDialogVM + ' Get + ' Return m_refOpenProjectFileDialogVM + ' End Get + 'End Property 'Public ReadOnly Property refOptionPanelVM As OptionPanelVM ' Get @@ -345,10 +345,10 @@ Module Map Return Not IsNothing(m_refOptimizePanelVM) End Function - Friend Function SetRefOpenProjectFileDialogVM(OpenProjectFileDialogVM As OpenProjectFileDialogVM) As Boolean - m_refOpenProjectFileDialogVM = OpenProjectFileDialogVM - Return Not IsNothing(m_refOpenProjectFileDialogVM) - End Function + 'Friend Function SetRefOpenProjectFileDialogVM(OpenProjectFileDialogVM As OpenProjectFileDialogVM) As Boolean + ' m_refOpenProjectFileDialogVM = OpenProjectFileDialogVM + ' Return Not IsNothing(m_refOpenProjectFileDialogVM) + 'End Function 'Friend Function SetRefOptionPanelVM(OptionPanelVM As OptionPanelVM) As Boolean ' m_refOptionPanelVM = OptionPanelVM @@ -413,8 +413,7 @@ Module Map Not IsNothing(m_refFreeContourManagerVM) AndAlso Not IsNothing(m_refFreeContourInputVM) AndAlso Not IsNothing(m_refInstrumentPanelVM) AndAlso Not IsNothing(m_refTopPanelVM) AndAlso Not IsNothing(m_refPartManagerVM) AndAlso Not IsNothing(m_refOptimizePanelVM) AndAlso - Not IsNothing(m_refShowBeamPanelVM) AndAlso Not IsNothing(m_refOpenProjectFileDialogVM) AndAlso - LibMap.EndInit() + Not IsNothing(m_refShowBeamPanelVM) AndAlso LibMap.EndInit() End Function #End Region ' Init