From fe0db46b69e5f9bd872d82e23ec4e49ab40286da Mon Sep 17 00:00:00 2001 From: Demetrio Cassarino Date: Tue, 24 Oct 2023 18:08:57 +0200 Subject: [PATCH 01/30] Creazione nuova pagina che unisce visualizzatore e ottimizzatore --- EgtBEAMWALL.Core/Constants/ConstDims.vb | 1 + EgtBEAMWALL.Core/Constants/ConstGen.vb | 1 + EgtBEAMWALL.Core/Constants/ConstIni.vb | 2 + .../BTLViewModel/BTLFeatureVM.vb | 4 +- .../BTLViewModel/BTLStructureVM.vb | 20 +- .../BottomPanel/BottomPanelV.xaml | 6 +- .../BottomPanel/BottomPanelVM.vb | 2 + .../EgtBEAMWALL.ViewerOptimizer.vbproj | 22 + .../InstrumentPanel/InstrumentPanelV.xaml | 17 +- .../InstrumentPanel/MyInstrumentPanelVM.vb | 100 + .../ItemParamList/PartParametersV.xaml | 650 +++---- .../LeftPanel/LeftPanelV.xaml | 6 +- .../LeftPanel/LeftPanelVM.vb | 4 +- .../LeftPanel/OnlyProdLeftPanelV.xaml | 159 ++ .../LeftPanel/OnlyProdLeftPanelV.xaml.vb | 3 + .../MainMenu/MainMenuV.xaml | 6 + .../MainMenu/MainMenuVM.vb | 222 ++- .../MainWindow/MainWindowM.vb | 9 + .../MainWindow/MainWindowV.xaml | 4 +- .../MainWindow/MainWindowVM.vb | 45 +- .../OnlyProdManager/OnlyProdManagerV.vb | 3 + .../OnlyProdManager/OnlyProdManagerV.xaml | 72 + .../OnlyProdManager/OnlyProdManagerVM.vb | 1713 +++++++++++++++++ .../OnlyProdProject/OnlyProdProjectV.xaml | 328 ++++ .../OnlyProdProject/OnlyProdProjectV.xaml.vb | 3 + .../OnlyProdProject/OnlyProdProjectVM.vb | 448 +++++ .../OptimizePanel/OptimizePanelVM.vb | 17 +- .../ProdManager/ProdManagerV.xaml | 17 +- .../ProdManager/ProdManagerVM.vb | 7 + .../ProjManager/ProjManagerV.xaml | 1 + .../ProjManager/ProjManagerVM.vb | 6 + .../Project/ProjectV.xaml | 7 +- .../Project/ProjectVM.vb | 138 +- .../SceneHost/MySceneHostVM.vb | 68 +- .../StatisticsTimePanelVM.vb | 2 +- .../TopPanel/TopPanelV.xaml | 2 +- .../Utility/Dictionary.xaml | 1 + EgtBEAMWALL.ViewerOptimizer/Utility/Map.vb | 13 + 38 files changed, 3721 insertions(+), 408 deletions(-) create mode 100644 EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml create mode 100644 EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml.vb create mode 100644 EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerV.vb create mode 100644 EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerV.xaml create mode 100644 EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb create mode 100644 EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml create mode 100644 EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml.vb create mode 100644 EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectVM.vb diff --git a/EgtBEAMWALL.Core/Constants/ConstDims.vb b/EgtBEAMWALL.Core/Constants/ConstDims.vb index 1d56999a..d50342f1 100644 --- a/EgtBEAMWALL.Core/Constants/ConstDims.vb +++ b/EgtBEAMWALL.Core/Constants/ConstDims.vb @@ -9,5 +9,6 @@ Public Const TOPPANEL_OPTIMIZER As String = "TopPanel_Optimizer" Public Const LEFTPANEL_SUPERVISOR As String = "LeftPanel_Supervisor" Public Const PROJECT_SUPERVISOR As String = "Project_Supervisor" + Public Const PROJECT_ONLYPROD As String = "Project_OnlyProd" End Class diff --git a/EgtBEAMWALL.Core/Constants/ConstGen.vb b/EgtBEAMWALL.Core/Constants/ConstGen.vb index ced9eb40..73a94d78 100644 --- a/EgtBEAMWALL.Core/Constants/ConstGen.vb +++ b/EgtBEAMWALL.Core/Constants/ConstGen.vb @@ -33,6 +33,7 @@ Public Module ConstGen CONFIG = 3 INPUTS = 4 OUTPUTS = 5 + ONLYPRODPAGE = 6 End Enum ' Abilitazioni licenza diff --git a/EgtBEAMWALL.Core/Constants/ConstIni.vb b/EgtBEAMWALL.Core/Constants/ConstIni.vb index 1b0bd759..ddb25cc7 100644 --- a/EgtBEAMWALL.Core/Constants/ConstIni.vb +++ b/EgtBEAMWALL.Core/Constants/ConstIni.vb @@ -168,4 +168,6 @@ Public Module ConstIni Public Const K_EXTERNALFILEPATH As String = "ExternalFilePath" Public Const K_REMINDERFREQUENCY As String = "ReminderFrequency" + Public Const K_ONLYPROD As String = "OnlyProd" + End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLFeatureVM.vb b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLFeatureVM.vb index 7ab66f7d..09a28cae 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLFeatureVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLFeatureVM.vb @@ -209,7 +209,7 @@ Public Class BTLFeatureVM m_SelPBTLParam = value If Not IsNothing(m_SelPBTLParam) Then ' imposto path disegno da mostrare in BottomPanel - Map.refBottomPanelVM.SetCurrDraw(m_SelPBTLParam.sDrawPath) + If Not IsNothing(Map.refBottomPanelVM) Then Map.refBottomPanelVM.SetCurrDraw(m_SelPBTLParam.sDrawPath) End If NotifyPropertyChanged(NameOf(SelPBTLParam)) End Set @@ -232,7 +232,7 @@ Public Class BTLFeatureVM End Get Set(value As BTLParamVM) m_SelQParam = value - If Not IsNothing(m_SelQParam) Then + If Not IsNothing(m_SelQParam) AndAlso Not IsNothing(Map.refBottomPanelVM) Then ' imposto path disegno da mostrare in BottomPanel Map.refBottomPanelVM.SetCurrDraw(m_SelQParam.sDrawPath) End If diff --git a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb index e2dd39b6..83fe3388 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb @@ -150,7 +150,7 @@ Public Class BTLStructureVM Select Case e.Action Case NotifyCollectionChangedAction.Add If e.NewItems.Count > 0 AndAlso Not IsNothing(e.NewItems(0)) Then - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso m_SelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso m_SelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso m_SelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then SelectBTLPart(e.NewItems(0)) Else ' SelectionTypes.HIGHLIGHT HighlightBTLPart(e.NewItems(0)) @@ -182,8 +182,8 @@ Public Class BTLStructureVM End Sub Private Sub SelectBTLPart(BtlPart As BTLPartVM) - EgtBeamShowFacesName( False) - EgtBeamShowLoadingSide( False, False) + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) m_SelBTLPart = BtlPart If Map.refMainMenuVM.SelPage = Pages.VIEW Then ' se modalità building, la tolgo @@ -194,10 +194,10 @@ Public Class BTLStructureVM SceneSelPartSelection() ' seleziono pezzo in Db geometrico EgtBeamSetPart(BtlPart.nPartId) - EgtBeamShowFacesName( True) + EgtBeamShowFacesName(True) Dim bLoadingSideShow As Boolean = (nPROJTYPE = BWType.BEAM) - Dim bLeftToRight As Boolean = Not ( CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) - EgtBeamShowLoadingSide( bLoadingSideShow, bLeftToRight) + Dim bLeftToRight As Boolean = Not (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) + EgtBeamShowLoadingSide(bLoadingSideShow, bLeftToRight) ' seleziono pagina BottomPanel Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.PART) '' mostro barra di gestione pezzo @@ -208,7 +208,7 @@ Public Class BTLStructureVM Map.refShowBeamPanelVM.bShowAll = False Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) EgtZoom(ZM.ALL) - ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then ' resetto gruppo di lavorazione corrente EgtResetCurrMachGroup() ' trovo ed evidenzio MachGroup e Duplo di questo pezzo @@ -246,8 +246,8 @@ Public Class BTLStructureVM Map.refProjectVM.BTLStructureVM.ShowSolid(BtlPart.nPartId, False, False) End If If m_SelBTLPart Is BtlPart Then - EgtBeamShowFacesName( False) - EgtBeamShowLoadingSide( False, False) + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) m_SelBTLPart = Nothing NotifyPropertyChanged(NameOf(SelBTLPart)) End If @@ -617,6 +617,8 @@ Public Class BTLStructureVM Return Map.refProjManagerVM.nProjType Case Pages.MACHINING Return Map.refProdManagerVM.nProdType + Case Pages.ONLYPRODPAGE + Return Map.refProdManagerVM.nProdType Case Else Return BWType.NULL End Select diff --git a/EgtBEAMWALL.ViewerOptimizer/BottomPanel/BottomPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/BottomPanel/BottomPanelV.xaml index 89d9455a..c8466cfa 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BottomPanel/BottomPanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/BottomPanel/BottomPanelV.xaml @@ -33,8 +33,8 @@ + Tag="{Binding Tag.SelBTLPart, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:BottomPanelV}}}" + Margin="5"/> + Margin="5"/> diff --git a/EgtBEAMWALL.ViewerOptimizer/BottomPanel/BottomPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/BottomPanel/BottomPanelVM.vb index eb3039ec..ea86d27b 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BottomPanel/BottomPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BottomPanel/BottomPanelVM.vb @@ -23,6 +23,8 @@ Public Class BottomPanelVM Friend Sub SetSelPartFeatureTab(SelPartFeatureTab As PartFeatureTab) If m_SelPartFeatureTab = PartFeatureTab.STATISTICS Then Map.refInstrumentPanelVM.SetStatisticsIsChecked(False) + 'Map.refInstrumentPanelVM.SetVisStatistic_IsChecked(False) + 'Map.refInstrumentPanelVM.SetOtStatistic_IsChecked(False) End If m_SelPartFeatureTab = SelPartFeatureTab NotifyPropertyChanged(NameOf(SelPartFeatureTab)) diff --git a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj index 4138ed9f..0370788c 100644 --- a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj +++ b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj @@ -263,6 +263,13 @@ + + OnlyProdLeftPanelV.xaml + + + OnlyProdManagerV.xaml + + MovePartInRawPartWndV.xaml @@ -328,6 +335,9 @@ + + OnlyProdProjectV.xaml + ProjectTypeWndV.xaml @@ -472,6 +482,14 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -536,6 +554,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml index 2d9d56e2..b71cb984 100644 --- a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml @@ -39,9 +39,24 @@ - + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb index 94982a46..b0482988 100644 --- a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb @@ -19,6 +19,24 @@ Public Class MyInstrumentPanelVM End Get End Property + Public ReadOnly Property Statistic_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property VisStatistic_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property OtStatistic_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + Private m_InstrumentPanel_IsEnabled As Boolean = True Public Property InstrumentPanel_IsEnabled As Boolean Get @@ -79,6 +97,82 @@ Public Class MyInstrumentPanelVM NotifyPropertyChanged(NameOf(Statistics_IsChecked)) End Sub + Private m_VisStatistic_IsEnabled As Boolean = True + Public Property VisStatistic_IsEnabled As Boolean + Get + Return m_VisStatistic_IsEnabled + End Get + Set(value As Boolean) + m_VisStatistic_IsEnabled = value + End Set + End Property + + Private m_VisStatistic_IsChecked As Boolean = False + Public Property VisStatistic_IsChecked As Boolean + Get + Return m_VisStatistic_IsChecked + End Get + Set(value As Boolean) + m_VisStatistic_IsChecked = value + m_OtStatistic_IsChecked = False + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + If value Then + ' salvo pagina precedente + m_PrevBottomPanelPage = Map.refBottomPanelVM.SelPartFeatureTab + ' aggiorno valori totali + Map.refProjectVM.BTLStructureVM.CalcGlobalUpdate() + ' seleziono pagina Statistics + Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STATISTICS) + Else + ' seleziono pagina precedente + Map.refBottomPanelVM.SetSelPartFeatureTab(m_PrevBottomPanelPage) + End If + End If + End Set + End Property + Friend Sub SetVisStatistic_IsChecked(value As Boolean) + m_VisStatistic_IsChecked = value + NotifyPropertyChanged(NameOf(VisStatistic_IsChecked)) + End Sub + + Private m_OtStatistic_IsEnabled As Boolean = True + Public Property OtStatistic_IsEnabled As Boolean + Get + Return m_OtStatistic_IsEnabled + End Get + Set(value As Boolean) + m_OtStatistic_IsEnabled = value + End Set + End Property + + Private m_OtStatistic_IsChecked As Boolean = False + Public Property OtStatistic_IsChecked As Boolean + Get + Return m_OtStatistic_IsChecked + End Get + Set(value As Boolean) + m_OtStatistic_IsChecked = value + m_VisStatistic_IsChecked = False + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + If value Then + ' aggiorno valori totali + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then Map.refProjectVM.MachGroupPanelVM.CalcGlobalUpdate() + ' aggiorno conto materiali usati + If Not IsNothing(Map.refProdManagerVM.CurrProd) Then Map.refStatisticsVM.LoadRawPart() + ' seleziono pagina Statistics + Map.refTopPanelVM.SetSelTab(TopPanelVM.Tabs.STATISTICS) + Else + ' seleziono pagina precedente + Map.refTopPanelVM.SetSelTab(TopPanelVM.Tabs.OPTIMIZATION) + End If + End If + End Set + End Property + Friend Sub SetOtStatistic_IsChecked(value As Boolean) + m_OtStatistic_IsChecked = value + NotifyPropertyChanged(NameOf(OtStatistic_IsChecked)) + End Sub + ' Definizione comandi Private m_cmdData As ICommand Private m_cmdChangeParameter As ICommand @@ -139,10 +233,16 @@ Public Class MyInstrumentPanelVM NotifyPropertyChanged(NameOf(InstrumentPanel_IsEnabled)) If Map.refFreeContourManagerVM.bIsActive Then m_Statistics_IsEnabled = bIsEnabled + m_VisStatistic_IsEnabled = bIsEnabled + m_OtStatistic_IsEnabled = bIsEnabled Else m_Statistics_IsEnabled = True + m_VisStatistic_IsEnabled = True + m_OtStatistic_IsEnabled = True End If NotifyPropertyChanged(NameOf(Statistics_IsEnabled)) + NotifyPropertyChanged(NameOf(VisStatistic_IsEnabled)) + NotifyPropertyChanged(NameOf(OtStatistic_IsEnabled)) End Sub #End Region ' METHODS diff --git a/EgtBEAMWALL.ViewerOptimizer/ItemParamList/PartParametersV.xaml b/EgtBEAMWALL.ViewerOptimizer/ItemParamList/PartParametersV.xaml index 5d157037..dde4a1b5 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ItemParamList/PartParametersV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/ItemParamList/PartParametersV.xaml @@ -18,191 +18,191 @@ - - + + + + + + + + + + + - - + + - - + + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - + + + + + + + + + + + Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:LeftPanelV}}}" + Grid.Row="1"/> @@ -195,7 +195,7 @@ - diff --git a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb index c7980a36..117b7c9b 100644 --- a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb @@ -22,12 +22,12 @@ Public Class LeftPanelVM Public ReadOnly Property ViewPage_Visibility As Visibility Get - Return If(Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed) + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW Or Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) End Get End Property Public ReadOnly Property MachiningPage_Visibility As Visibility Get - Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING, Visibility.Visible, Visibility.Collapsed) + Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING Or Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) End Get End Property diff --git a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml new file mode 100644 index 00000000..d3613d2b --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml.vb new file mode 100644 index 00000000..c991aa65 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdLeftPanelV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuV.xaml b/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuV.xaml index 2a17c782..1e9c1ea1 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuV.xaml @@ -6,11 +6,17 @@ + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb new file mode 100644 index 00000000..4639b550 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb @@ -0,0 +1,1713 @@ +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtBEAMWALL.DataLayer.DatabaseModels +Imports System.Windows.Threading + +Public Class OnlyProdManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + ' Nome file NGE con i pezzi selezionati per effettuare UpdateBTL + Friend Const UPDATEBTL_NGE As String = "UpdateBTL.nge" + + Private m_OpenProj_Timer As New DispatcherTimer + Private m_bOpenProj As Boolean = False + Private m_nProjIdToOpen As Integer = GDB_ID.NULL + + Private m_FullCompleteManager_IsEnabled As Boolean = True + Public ReadOnly Property FullCompleteManager_IsEnabled As Boolean + Get + Return m_FullCompleteManager_IsEnabled + End Get + End Property + Friend Sub SetProdManagerIsEnabled(bIsEnabled As Boolean) + m_FullCompleteManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(FullCompleteManager_IsEnabled)) + End Sub + + Private m_CurrProj As ProjFileVM + Friend Property CurrProj As ProjFileVM + Get + Return m_CurrProj + End Get + Set(value As ProjFileVM) + m_CurrProj = value + End Set + End Property + + Private m_CurrProd As ProdFileVM + Friend Property CurrProd As ProdFileVM + Get + Return m_CurrProd + End Get + Set(value As ProdFileVM) + m_CurrProd = value + End Set + End Property + + Private m_TempCurrProd As ProdFileVM + Friend Property TempCurrProd As ProdFileVM + Get + Return m_TempCurrProd + End Get + Set(value As ProdFileVM) + m_TempCurrProd = value + End Set + End Property + + ' indice progetto in caricamento + Private m_nLoadingProjId As Integer = 0 + Public ReadOnly Property nLoadingProjId As Integer + Get + Return m_nLoadingProjId + End Get + End Property + + Friend m_MruFiles As New MruList + Public ReadOnly Property MruFileNames As ObservableCollection(Of String) + Get + Dim IdAndBTLFileNames As New ObservableCollection(Of String) + For Each FileName In m_MruFiles.FileNames.ToList() + Dim PjId As Integer = 0 + Dim sPjId As String = Path.GetFileNameWithoutExtension(DirectCast(FileName, String).Replace("__", "_")) + Integer.TryParse(sPjId, PjId) + Dim PjFileM = DbControllers.m_ProjController.FindByProjIdConv(PjId) + If IsNothing(PjFileM) Then + m_MruFiles.Remove(FileName) + Else + IdAndBTLFileNames.Add(sPjId & " | " & PjFileM.sBTLFileName) + End If + Next + Return IdAndBTLFileNames + End Get + End Property + + Private m_GoToSupervisor_Visibility As Visibility + Public ReadOnly Property GoToSupervisor_Visibility As Visibility + Get + Return m_GoToSupervisor_Visibility + End Get + End Property + + Private m_UpdateBTL_Visibility As Visibility = Visibility.Collapsed + Public Property UpdateBTL_Visibility As Visibility + Get + Return m_UpdateBTL_Visibility + End Get + Set(value As Visibility) + m_UpdateBTL_Visibility = value + End Set + End Property + + Private m_AddProj_Visibility As Visibility + Public ReadOnly Property AddProj_Visibility As Visibility + Get + Return m_AddProj_Visibility + End Get + End Property + + ' indice ultimo progetto + Private m_nLastProdId As Integer + Friend ReadOnly Property nLastProdId As Integer + Get + Return m_nLastProdId + End Get + End Property + + ' Definizione comandi + Private m_cmdNew As ICommand + Private m_cmdOpen As ICommand + Private m_cmdSave As ICommand + Private m_cmdImportBTL As ICommand + Private m_cmdUpdateBTL As ICommand + Private m_cmdExportProject As ICommand + Private m_cmdImportProject As ICommand + Private m_cmdGoToSupervisor As ICommand + +#Region "ToolTip" + + 'Proprietà ToolTip + Public ReadOnly Property NewToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 1) + End Get + End Property + Public ReadOnly Property OpenToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 2) + End Get + End Property + Public ReadOnly Property SaveToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 3) + End Get + End Property + Public ReadOnly Property SaveAsToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 4) + End Get + End Property + Public ReadOnly Property ImportBTL_ToolTip As String + Get + Return EgtMsg(61840) + End Get + End Property + Public ReadOnly Property UpdateBTL_ToolTip As String + Get + Return EgtMsg(61834) + End Get + End Property + Public ReadOnly Property ImportProject_ToolTip As String + Get + Return EgtMsg(61839) + End Get + End Property + Public ReadOnly Property GoToProd_ToolTip As String + Get + Return EgtMsg(61835) + End Get + End Property + Public ReadOnly Property GoToSupervisor_ToolTip As String + Get + Return EgtMsg(61974) + End Get + End Property + +#End Region ' ToolTip + +#End Region ' Field & Properties + +#Region "CONSTRUCTORS" + + Sub New() + Map.SetRefOnlyProdManagerVM(Me) + ' Leggo ultimo indice di progetto + m_nLastProdId = GetMainPrivateProfileInt(S_GENERAL, K_PROJSINDEX, 1) + ' Impostazioni MruLists + m_MruFiles.Init(S_MRUPROJFILES, 8) + ' leggo attivazione update btl + If GetMainPrivateProfileInt(S_GENERAL, K_UPDATEBTL, 0) > 0 Then + UpdateBTL_Visibility = Visibility.Visible + End If + + ' abilito passaggio a supervisore + If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.SUPERVISOR) Then + m_GoToSupervisor_Visibility = Visibility.Visible + Else + m_GoToSupervisor_Visibility = Visibility.Collapsed + End If + + ' attivo bottone AddProj + If GetMainPrivateProfileInt(S_GENERAL, K_ADDPROJ, 0) = 1 Then + m_AddProj_Visibility = Visibility.Visible + Else + m_AddProj_Visibility = Visibility.Collapsed + End If + ' imposto timer di apertura da ottimizzatore + m_OpenProj_Timer.Interval = TimeSpan.FromMilliseconds(500) + AddHandler m_OpenProj_Timer.Tick, AddressOf OpenProject_Tick + m_OpenProj_Timer.Start() + End Sub + +#End Region ' Constructors + +#Region "METHODS" + + Public Function SetCurrProj(nProjId As Integer) As Boolean + Dim Currproj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nProjId) + If IsNothing(Currproj) Then Return False + m_CurrProj = New ProjFileVM(Currproj) + Return True + End Function + + Private Function InitNewProject(ByRef nProjId As Integer, ByRef sProjectDir As String, nType As BWType, Machine As Machine) As Boolean + ' se non ho ricevuto numero progetto da sovrascrivere + If nProjId = 0 Then + ' richiedo indice nuovo progetto + nProjId = DbControllers.m_ProjController.GetNextIndex(Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + End If + ' salvo data creazione progetto + DbControllers.m_ProjController.Update(New ProjModel() With {.ProjId = nProjId, + .DtCreated = DateTime.Now(), + .PType = nType, + .Machine = If(Not IsNothing(Machine), Machine.Name, Nothing)}) + If nProjId <= 0 Then Return False + sProjectDir = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") + ' creo cartella nuovo progetto + If Not Directory.Exists(sProjectDir) Then + Directory.CreateDirectory(sProjectDir) + Else + Dim di As System.IO.DirectoryInfo = New DirectoryInfo(sProjectDir) + For Each file As FileInfo In di.EnumerateFiles() + file.Delete() + Next + For Each dir As DirectoryInfo In di.EnumerateDirectories() + dir.Delete(True) + Next + End If + Return True + End Function + + Private Sub ReloadBTLStructure() + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(Map.refProjManagerVM.CurrProj.nProjId)) + ' verifico se volume pezzi calcolato + Dim bIsCalculated As Boolean = False + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + If BTLPart.BTLPartM.dVolume > 0 Then Continue For + bIsCalculated = True + BTLPart.CalcBTLPartVolume() + Next + If bIsCalculated Then + Dim CurrProject As String = "" + EgtGetCurrFilePath(CurrProject) + EgtSaveFile(CurrProject, NGE.CMPTEXT) + End If + End Sub + + Public Function SetCurrProd(nProdId As Integer) As Boolean + Dim CurrProdM As ProdFileM = DbControllers.m_ProdController.FindCoreByProdId(nProdId) + If IsNothing(CurrProdM) Then Return False + m_CurrProd = New ProdFileVM(CurrProdM) + Return True + End Function + + Public Sub OpenProject_Tick() + If Not m_bOpenProj Then Return + m_bOpenProj = False + Select Case Map.refMainMenuVM.SelPage + Case Pages.MACHINING + ' recupero progetto da Id + Dim DbProject As ProdFileM + DbProject = DbControllers.m_ProdController.FindCoreByProdId(m_nProjIdToOpen) + Dim ProjectVM As New ProdFileVM(DbProject) + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(Map.refProjManagerVM.CurrProj, ProjectType.PROJ) Then Return + OpenProject(ProjectVM) + Case Pages.VIEW + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(Map.refProjManagerVM.CurrProj, ProjectType.PROJ) Then Return + LoadingWndHelper.OpenLoadingWnd(ActiveIds.GOTOPROD, 3, EgtMsg(63004), EgtMsg(63011), 10) ' Optimization opening ' Loading environment + If Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso (m_nProjIdToOpen <> Map.refProjManagerVM.CurrProj.nProdId OrElse IsNothing(Map.refProdManagerVM.CurrProd)) Then + Map.refProdManagerVM.SetCurrProd(m_nProjIdToOpen) + Map.refProdManagerVM.CurrProd.SetReloadProject(True) + Else + Map.refProdManagerVM.CurrProd.SetReloadProject(False) + End If + ' Ricavo il tipo di Warehouse settato nell'INI + Dim nDefault As Integer = 2 + If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM Then + ' Se di tipo Medium confronto le Sezioni del BTL importato con quelle in Warehouse + WarehouseWndVM.UpdateSectionXMaterial() + End If + ' vado in pagina prod + Map.refMainMenuVM.SetSelPage(Pages.MACHINING, False) + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + LoadingWndHelper.CloseLoadingWnd(ActiveIds.GOTOPROD) + End Select + m_nProjIdToOpen = GDB_ID.NULL + End Sub + +#End Region ' Methods + +#Region "COMMANDS" + +#Region "New" + + ''' + ''' Returns a command that do New. + ''' + Public ReadOnly Property New_Command As ICommand + Get + If m_cmdNew Is Nothing Then + m_cmdNew = New Command(AddressOf NewProject) + End If + Return m_cmdNew + End Get + End Property + + ''' + ''' Execute the New. This method is invoked by the NewCommand. + ''' + Public Sub NewProject() + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + ' se si ha una sola macchina disponibile (non BOTH) setto il nuovo porgetto a quella macchina e al tipo progetto associato + ' altrimenti apro il dialog per scegliere la macchina e il tipo progetto a cui settare il nuovo progetto + Dim Machine As Machine = Nothing + Dim nType As BWType = BWType.NULL + Dim ProjectTypeWndVM As New ProjectTypeWndVM() + If ProjectTypeWndVM.MachineList.Count = 1 AndAlso DirectCast(ProjectTypeWndVM.SelMachine, MyMachine).nType <> MachineType.BOTH Then + Machine = ProjectTypeWndVM.SelMachine + nType = DirectCast(Machine, MyMachine).nType + Else + Dim ProjectTypeWnd As New ProjectTypeWndV(Application.Current.MainWindow, ProjectTypeWndVM) + If ProjectTypeWnd.ShowDialog() Then + Machine = ProjectTypeWndVM.SelMachine + nType = ProjectTypeWndVM.nSelType + Else + Return + End If + End If + ' creo nuovo progetto + If Map.refSceneHostVM.MainController.NewProject() Then + ' inizializzo nuovo progetto + Dim nProjId As Integer = 0 + Dim sProjDir As String = "" + InitNewProject(nProjId, sProjDir, nType, Machine) + SetCurrProj(nProjId) + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + Dim sProjFileName As String = sProjDir & "\" & nProjId.ToString("0000") & ".nge" + ' imposto ProjId di caricamento + m_nLoadingProjId = nProjId + ' creo gruppo BTLinfo + Dim nBTLInfoLayer As Integer = EgtCreateGroup(GDB_ID.ROOT) + EgtSetName(nBTLInfoLayer, BTLINFO) + EgtSetLevel(nBTLInfoLayer, GDB_LV.SYSTEM) + Map.refProjectVM.BTLStructureVM.BTLStructureM.UpdateBTLInfoLayer() + ' scrivo info proj e tipo su layer BtlInfo + EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, nProjId) + EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, nType) + ' salvo il progetto + If EgtSaveFile(sProjFileName, NGE.CMPTEXT) Then + SectionXMaterial.SetType(nType) + Core.ViewPanelVM.UpdateBWType(nType) + Map.refPartManagerVM.LockVisibilityUpdate() + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + DbControllers.m_ProjController.UpdateInfo(nProjId, "Hand made", "Hand made", "", Date.MinValue, nType, Map.refMachinePanelVM.SelectedMachine.Name) + SetCurrProj(nProjId) + End If + Map.refProjectVM.SetOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) + Else + MessageBox.Show(EgtMsg(61876)) + End If + Map.refMainWindowVM.UpdateTitle() + NotifyPropertyChanged(NameOf(MruFileNames)) + End Sub + +#End Region ' New + +#Region "OpenCommand" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property OpenCommand As ICommand + Get + If m_cmdOpen Is Nothing Then + m_cmdOpen = New Command(AddressOf Open) + End If + Return m_cmdOpen + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Open() + ' verifico se progetto modificato, e chiedo se salvare + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return + OpenProject(Nothing) + End Sub + + Friend Sub OpenProject(TempCurrPd As ProdFileVM) + m_TempCurrProd = TempCurrPd + Dim sFilePath As String = "" + ' se la string è vuota + If IsNothing(TempCurrProd) Then + If GetMainPrivateProfileInt(S_GENERAL, K_PROJECTMODE, 0) = 1 Then + Dim OpenProdFileDialogVM As NewOpenProjectFileDialogVM = Nothing + ' apro dialogo di scelta Prod + OpenProdFileDialogVM = New NewOpenProjectFileDialogVM + Dim OpenFile As New NewOpenProjectFileDialogV(Application.Current.MainWindow, OpenProdFileDialogVM) + Dim DialogResult As Boolean? = OpenFile.EgtShowDialog(ProjectType.PROD) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + sFilePath = OpenProdFileDialogVM.SelProject.ProdFileVM.sProdPath + m_TempCurrProd = OpenProdFileDialogVM.SelProject.ProdFileVM + Else + Dim OpenProjectFileDialogVM As OpenProjectFileDialogVM = Nothing + ' apro dialogo di scelta file + OpenProjectFileDialogVM = New OpenProjectFileDialogVM + Dim OpenFile As New OpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = OpenFile.EgtShowDialog(ProjectType.PROD) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + sFilePath = OpenProjectFileDialogVM.SelProject.sProdPath + TempCurrProd = OpenProjectFileDialogVM.SelProject + End If + Else + sFilePath = If(Not IsNothing(TempCurrProd.sProdPath), TempCurrProd.sProdPath, "") + End If + LoadingWndHelper.OpenLoadingWnd(ActiveIds.OPENPROD, 3, EgtMsg(63004), EgtMsg(63001), 50) ' Optimization opening ' Loading project geometries + If File.Exists(sFilePath) Then + ' se la macchina del progetto in apertura non è tra le macchine disponibili lo segnalo e apro un progetto vuoto + If IsNothing(Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refOnlyProdManagerVM.TempCurrProd.sMachine)) Then + ' rimuovo il file in apertura dalla lista degli MRU + Map.refOnlyProdManagerVM.m_MruFiles.Remove(sFilePath) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + Map.refOnlyProdManagerVM.NewProject() + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + Else + If Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) Then + Map.refProjectVM.SetOptimizePanel_Visibility(True) + Map.refTopPanelVM.UpdateQParameterVisibility() + End If + End If + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(TempCurrProd.nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + Else + MessageBox.Show(EgtMsg(61871)) + Map.refSceneHostVM.MainController.NewProject() + Map.refMainWindowVM.SetTitle("New - EgtBEAMWALL") + End If + ' aggiorno lista possibili nesting + Map.refOptimizePanelVM.UpdateOriginTypeList(EgtGetFirstNameInGroup(GDB_ID.ROOT, "RawParts") <> GDB_ID.NULL) + ' aggiorno visibilità bottone Muovi pezzi + Map.refTopPanelVM.UpdateMovePartInRawPartVisibility() + ' resetto eventuale visualizzazione statistiche + Map.refInstrumentPanelVM.ResetStatisticsIsChecked() + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + NotifyPropertyChanged(NameOf(MruFileNames)) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.OPENPROD) + End Sub + +#End Region ' OpenCommand + +#Region "SaveCommand" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property SaveCommand As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf SaveCmd) + End If + Return m_cmdSave + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub SaveCmd() + Save(True) + End Sub + + Public Function Save(Optional bShowLoading As Boolean = False) As Boolean + If IsNothing(CurrProd) Then Return False + If bShowLoading Then LoadingWndHelper.OpenLoadingWnd(ActiveIds.SAVEPROD, 2, EgtMsg(63007), EgtMsg(63012), 70) ' Project saving ' Saving geometry + Dim bOk As Boolean = Map.refSceneHostVM.SaveProject() + If bShowLoading Then LoadingWndHelper.UpdateLoadingWnd(ActiveIds.SAVEPROD, 2, EgtMsg(63013), 70, 100) ' Saving data on Db + Dim MyMachGroupList As New List(Of MyMachGroupM) + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + For Each MachGroup In Map.refProjectVM.MachGroupPanelVM.m_MyMachGroupPanelM.MachGroupMList + MyMachGroupList.Add(MachGroup) + Next + End If + ' aggiorno pezzi su Db + If Not DbControllers.m_ProdController.UpdateMachGroup(CurrProd.nProdId, MyMachGroupList) And bShowLoading Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.SAVEPROD) + Return False + End If + ' verifico se Reset Macchina modificato e nel caso aggiorno DB e CurrProj + If Map.refCALCPanelVM.IsMachineModified() Then + DbControllers.m_ProdController.UpdateMachine(Map.refOnlyProdManagerVM.CurrProd.nProdId, Map.refCALCPanelVM.SelectedMachine.Name) + Map.refOnlyProdManagerVM.CurrProd.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + ' ciclo sulla lista di ProjId associati + For Each ProjId In Map.refOnlyProdManagerVM.CurrProd.nProjIdList + ' aggiorno la Macchina per i ProjId associati sul DB + DbControllers.m_ProjController.UpdateMachine(ProjId, Map.refCALCPanelVM.SelectedMachine.Name) + ' se uno dei Proj interessati equivale al Proj correntemente aperto setto la Macchina dello stesso + ' (poichè il progetto corrente non viene riaperto e riletto dal DB) + If ProjId = Map.refProjManagerVM.CurrProj.nProjId Then Map.refProjManagerVM.CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + Next + Map.refCALCPanelVM.ResetMachineModified() + End If + ' se nuovo progetto + If m_CurrProd.bIsNew Then + ' resetto stato new + ' DbControllers.m_ProdController.Reset(CurrProd.nProjId) + m_CurrProd.bIsNew = False + End If + Map.refMainWindowVM.UpdateTitle() + NotifyPropertyChanged(NameOf(MruFileNames)) + If bShowLoading Then LoadingWndHelper.CloseLoadingWnd(ActiveIds.SAVEPROD) + Return bOk + End Function + +#End Region ' SaveCommand + +#Region "ImportBTL" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property ImportBTL_Command As ICommand + Get + If m_cmdImportBTL Is Nothing Then + m_cmdImportBTL = New Command(AddressOf ImportBTL) + End If + Return m_cmdImportBTL + End Get + End Property + + ''' + ''' Execute the ImportBTL. This method is invoked by the ImportBTLCommand. + ''' + Public Sub ImportBTL(Optional sFile As String = "", Optional bWithDlg As Boolean = True) + If Not ProdFileVM.VerifyProjectModification(CurrProd) Then Return + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir) + If bWithDlg Then + ' apro finestra scelta file + Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".btl", + .Filter = "BTL (*.btl)|*.btl" & + "|BTLX (*.btlx)|*.btlx", + .InitialDirectory = If(Directory.Exists(sDir), sDir, ""), + .CheckFileExists = True, + .ValidateNames = True} + If BTLDlg.ShowDialog() Then + sFile = BTLDlg.FileName + Else + Return + End If + End If + Dim nProjId As Integer = 0 + Dim sProjDir As String = "" + ' verifico se non e' tra i BTL gia' importati + Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sFile) + Dim nAlreadyImported As Integer = DbControllers.m_ProjController.AlreadyImported(sBTLFileName) + If nAlreadyImported > 0 Then + ' recupero progetto con lo stesso nome + Dim ToDeleteProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nAlreadyImported) + ' se esiste gia' un'ottimizzazione + If ToDeleteProj.nProdId > 0 Then + Select Case MessageBox.Show(EgtMsg(61942), "Information", MessageBoxButton.YesNo, MessageBoxImage.Information) ' BTL file already imported and optimized. Do you want to import it again? + Case MessageBoxResult.Yes + ' lo importo, quindi non devo fare nulla + Case MessageBoxResult.No + Return + End Select + Else + ' se non ha ottimizazione, chiedo se sovrascriverlo + Select Case MessageBox.Show(EgtMsg(61943), "Information", MessageBoxButton.YesNoCancel, MessageBoxImage.Information) ' BTL file already imported. Do you want to overwrite it? + Case MessageBoxResult.Yes + ' cancello BTLParts su DB + DbControllers.m_ProjController.UpdateBtlParts(nAlreadyImported, New List(Of BTLPartM)) + ' cancello nome BTL + DbControllers.m_ProjController.UpdateInfo(nAlreadyImported, DateTime.Now.ToString(), DateTime.Now.ToString(), "", DateTime.MinValue, BWType.NULL, "") + nProjId = nAlreadyImported + sProjDir = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") + Case MessageBoxResult.No + ' lo importo, quindi non devo fare nulla + Case MessageBoxResult.Cancel + Return + End Select + End If + End If + ' se si ha una sola macchina disponibile (non BOTH) setto il progetto importato a quella macchina e al tipo progetto associato + ' altrimenti apro il dialog per scegliere la macchina e il tipo progetto a cui settare il progetto importato + Dim Machine As Machine = Nothing + Dim nType As BWType = BWType.NULL + Dim ProjectTypeWndVM As New ProjectTypeWndVM() + If ProjectTypeWndVM.MachineList.Count = 1 AndAlso DirectCast(ProjectTypeWndVM.SelMachine, MyMachine).nType <> MachineType.BOTH Then + Machine = ProjectTypeWndVM.SelMachine + nType = DirectCast(Machine, MyMachine).nType + Else + Dim ProjectTypeWnd As New ProjectTypeWndV(Application.Current.MainWindow, ProjectTypeWndVM) + If ProjectTypeWnd.ShowDialog() Then + Machine = ProjectTypeWndVM.SelMachine + nType = ProjectTypeWndVM.nSelType + Else + Return + End If + End If + LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file + ' inizializzo nuovo progetto + InitNewProject(nProjId, sProjDir, nType, Machine) + SetCurrProj(nProjId) + ' imposto il tipo di parametri Q da utilizzare + BTLIniFile.m_nBTLBWType = nType + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + ' imposto ProjId di caricamento + m_nLoadingProjId = nProjId + ' copio file BTL + Dim sBtlCopyPath As String = sProjDir & "\" & Path.GetFileName(sFile) + Dim bOk = False + Try + File.Copy(sFile, sBtlCopyPath, True) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + ' disattivo temporaneamente bottone assemblato per non prendere il riferimento sbagliato durante importazione + Dim bAssembly As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + Map.refShowBeamPanelVM.ShowBuilding_IsChecked = False + ' importo file + If bOk Then + bOk = Map.refSceneHostVM.MainController.ImportProject(sBtlCopyPath, False) + End If + Dim sProjFileName As String = sProjDir & "\" & nProjId.ToString("0000") & ".nge" + Dim bFirstPart As Boolean = EgtGetFirstPart() <> GDB_ID.NULL + If bOk OrElse bFirstPart Then + ' salvo path di importazione + WriteMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile)) + ' salvo il progetto + bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT) + SectionXMaterial.SetType(nType) + Core.ViewPanelVM.UpdateBWType(nType) + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + Else + EgtOutLog("Errore nell'importazione BTL") + End If + If bOk Then + ' aggiorno Db + Dim ExportDate As DateTime + DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " & + Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate) + DbControllers.m_ProjController.UpdateInfo(nProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Map.refMachinePanelVM.SelectedMachine.Name) + SetCurrProj(nProjId) + ' se progetto pareti e vista ruotata + If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then + ' ruoto le pareti di 180 per raddrizzarle rispetto alla vista + For Each Wall In Map.refProjectVM.BTLStructureVM.BTLPartVMList + Wall.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False) + Next + End If + ' calcolo volumi pezzi + For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList + Part.CalcBTLPartVolume() + Next + Map.refProjectVM.SetOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) + Map.refPartManagerVM.LockVisibilityUpdate() + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63006), 70, 100) ' Loading graphics + Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly + ' mostro tutti i pezzi + Map.refShowBeamPanelVM.ShowAll(True) + Else + Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly + ' elimino da Db + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(nProjId, False) + End If + ' carico filtri di ricerca + Map.refProjectVM.BTLStructureVM.LoadFilters() + ' gestisco log di importazione + ManageImportLog(nProjId, sProjDir) + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL) + End Sub + + Private Sub ManageImportLog(nProjId As Integer, sProjDir As String) + Dim LogFile As New List(Of String) + Using FileStream As FileStream = New FileStream(Map.refMainWindowVM.MainWindowM.sLogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) + Dim StreamReader As New StreamReader(FileStream) + Dim Line As String = StreamReader.ReadLine() + While Not StreamReader.EndOfStream + Line = StreamReader.ReadLine() + LogFile.Add(Line) + End While + StreamReader.Close() + End Using + If LogFile.Count > 0 Then + ' recupero ultima occorrenza di import + Dim sLastImport As String = LogFile.LastOrDefault(Function(x) x.Contains("ImportBtl")) + ' verifico linee successive + Dim nLastImportIndex As Integer = -1 + If Not String.IsNullOrWhiteSpace(sLastImport) Then + nLastImportIndex = LogFile.IndexOf(sLastImport) + End If + Dim sImportMessage As String = sLastImport & Environment.NewLine + Dim sImportLog As New List(Of String)({sLastImport}) + If nLastImportIndex > 0 Then + Dim bGlobalError As Boolean = False + ' ciclo sulle righe successive + For Index = nLastImportIndex + 1 To LogFile.Count - 1 + Dim sLogLine As String = LogFile(Index).Trim() + ' verifico se fanno parte dell'import + Dim bStartWithError As Boolean = sLogLine.StartsWith("Error") + Dim bStartWithInfo As Boolean = sLogLine.StartsWith("Info") + If Not bStartWithError And Not bStartWithInfo Then Exit For + If bStartWithError Then + If Not bGlobalError Then bGlobalError = True + sImportMessage &= sLogLine & Environment.NewLine + End If + sImportLog.Add(sLogLine) + Next + ' salvo file ImportLog nel progetto + Try + File.WriteAllLines(sProjDir & "\" & nProjId.ToString("0000") & "-ImportLog.txt", sImportLog) + Catch ex As Exception + ' + End Try + ' se almeno un errore, mostro log + If bGlobalError Then + MessageBox.Show(Application.Current.MainWindow, sImportMessage, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + End If + End If + End If + End Sub + +#End Region ' ImportBTL + +#Region "UpdateBTL" + + ''' + ''' Returns a command that do UpdateBTL. + ''' + Public ReadOnly Property UpdateBTL_Command As ICommand + Get + If m_cmdUpdateBTL Is Nothing Then + m_cmdUpdateBTL = New Command(AddressOf UpdateBTL) + End If + Return m_cmdUpdateBTL + End Get + End Property + + ''' + ''' Execute the UpdateBTL. This method is invoked by the UpdateBTLCommand. + ''' + Public Sub UpdateBTL(Optional sFile As String = "", Optional bWithDlg As Boolean = True) + If IsNothing(CurrProj) Then Return + ' verifico se progetto modificato, e chiedo se salvare + If CurrProj.bIsNew Or EgtGetModified() OrElse Map.refCALCPanelVM.IsMachineModified() Then + Select Case MessageBox.Show(EgtMsg(61877), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) + Case MessageBoxResult.Yes + Save() + Case MessageBoxResult.Cancel + Return + Case Else ' No + MessageBox.Show(EgtMsg(61892), "", MessageBoxButton.OK, MessageBoxImage.Exclamation) + Return + End Select + End If + + ' se vista tutti i pezzi + Dim bShowBuilding As Boolean = False + Dim bShowSolid As Boolean = False + Dim nSelPartId As Integer = GDB_ID.NULL + If Map.refShowBeamPanelVM.bShowAll Then + ' verifico se assemblato e lo annullo per salvataggio + bShowBuilding = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(False, False) + ' se vista singolo pezzo + Else + bShowSolid = Map.refShowBeamPanelVM.ShowSolid_IsChecked + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False) + ' se pezzo selezionato lo segno e metto vista tutti + nSelPartId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId + Map.refProjectVM.BTLStructureVM.ShowAll(False) + End If + + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, "", sDir) + If bWithDlg Then + ' apro finestra scelta file + Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".btl", + .Filter = "BTL (*.btl)|*.btl" & + "|BTLX (*.btlx)|*.btlx", + .InitialDirectory = If(Directory.Exists(sDir), sDir, ""), + .CheckFileExists = True, + .ValidateNames = True} + If BTLDlg.ShowDialog() Then + sFile = BTLDlg.FileName + Else + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + Return + End If + End If + ' salvo lista pezzi del progetto originale + Dim OrigPartlist As ObservableCollection(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.BTLPartVMList + ' creo un nuovo contesto su cui aprire il file BTL + Dim nCurrCtx As Integer = EgtGetCurrentContext() + Dim nTempCtx As Integer = EgtInitContext() + + ' setto il flag per inizializzazione gestore travi e pareti per importare progetto + Dim nFlag As Integer + Dim sBTLFlag As String + If Map.refProjManagerVM.nProjType = Core.ConstBeam.BWType.BEAM Then + sBTLFlag = K_BTLFLAG + Else + sBTLFlag = K_WALLBTLFLAG + End If + nFlag = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + + ' inizializzo gestore travi e pareti + EgtInitBeamMgr(nFlag) + + Dim bOk As Boolean = nTempCtx <> 0 + If bOk Then + ' importo il file BTL + bOk = bOk AndAlso Map.refSceneHostVM.MainController.ImportProject(sFile, False) + ' carico la lista dei Part importati e rimuovo i parametri generali del BTL + Dim AsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + Dim BtlInfoId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + Dim PartToUpdateList As New List(Of BTLPartToUpdate) + + ' cerco tra i layer BTLInfo + While BtlInfoId <> GDB_ID.NULL + ' verifico se il layer appartiene al ProjId + Dim nBTLInfoLayerProjId As Integer + EgtGetInfo(BtlInfoId, BTL_PRT_PROJ, nBTLInfoLayerProjId) + ' carico la lista con i PDN dei pezzi del BTL importato + Dim nPDN As Integer = 0 + Dim sNAM As String = String.Empty + Dim nUID As Integer = 0 + Dim nPartId As Integer = EgtGetFirstPart() + While nPartId <> GDB_ID.NULL + Dim UIDList As New List(Of Integer) + Dim nIndUID As Integer = 1 + ' se devo filtrare un progetto + If nBTLInfoLayerProjId > 0 Then + ' verifico se il pezzo appartiene al ProjId + Dim nPartProjId As Integer + EgtGetInfo(nPartId, BTL_PRT_PROJ, nPartProjId) + If nPartProjId = nBTLInfoLayerProjId Then + EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) + EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM) + While EgtGetInfo(nPartId, BTL_PRT_UID & nIndUID, nUID) + UIDList.Add(nUID) + nIndUID += 1 + End While + PartToUpdateList.Add(New BTLPartToUpdate(nPartId, nPDN, sNAM, UIDList, OrigPartlist.Any(Function(x) x.nPDN = nPDN))) + End If + Else + ' altrimenti carico tutti + EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) + EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM) + While EgtGetInfo(nPartId, BTL_PRT_UID & nUID, nUID) + UIDList.Add(nUID) + nIndUID += 1 + End While + PartToUpdateList.Add(New BTLPartToUpdate(nPartId, nPDN, sNAM, UIDList, OrigPartlist.Any(Function(x) x.nPDN = nPDN))) + End If + nPartId = EgtGetNextPart(nPartId) + End While + EgtErase(BtlInfoId) + BtlInfoId = EgtGetNextName(BtlInfoId, BTLINFO) + End While + + ' costruisco un dizionario con gli id dei sottonodi di AsseBase del BTL importato e il valore dell'Info N degli stessi + Dim AsseBaseSubNodeDict As New Dictionary(Of Integer, Integer) + Dim nAsseBaseSubNodeId As Integer = EgtGetFirstInGroup(AsseBaseId) + Dim sAsseBaseUID As String = String.Empty + Dim nAsseBaseUID As Integer = 0 + While nAsseBaseSubNodeId <> GDB_ID.NULL + If EgtGetInfo(nAsseBaseSubNodeId, BTL_ASSEBASE_N, sAsseBaseUID) Then + sAsseBaseUID = sAsseBaseUID.Remove(0, 4) + Integer.TryParse(sAsseBaseUID, nAsseBaseUID) + AsseBaseSubNodeDict.Add(nAsseBaseSubNodeId, sAsseBaseUID) + End If + nAsseBaseSubNodeId = EgtGetNext(nAsseBaseSubNodeId) + End While + + ' salvo il file BTL da cui abbiamo rimosso BtlInfo come file NGE + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE, NGE.CMPTEXT) + + Dim bAppend As Boolean = False + ' se UserLevel > 5 e fra i Part importati ce ne sta almeno 1 con PDN uguale ai Part già presenti + ' apro la finestra per chiedere se si vuole aggiornare o accodare + If Map.refMainWindowVM.MainWindowM.nUserLevel > 5 Then + For Each PartToUpdate In PartToUpdateList + Dim bExitFor As Boolean = False + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLStructureM.BTLPartMList + If PartToUpdate.nPDN = BTLPart.nPDN Then + Dim UpdateOrAppendWndVM As New UpdateOrAppendWndVM() + Dim UpdateOrAppendWnd As New UpdateOrAppendWndV(Application.Current.MainWindow, UpdateOrAppendWndVM) + If Not UpdateOrAppendWnd.ShowDialog() Then + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + ' rileggo la struttura BTL + ReloadBTLStructure() + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + Return + End If + ' salvo lo stato del bottone per accodare + bAppend = UpdateOrAppendWndVM.AppendIsChecked + bExitFor = True + Exit For + End If + Next + If bExitFor Then Exit For + Next + End If + + ' se selezionato Append li accodo tutti + If bAppend Then + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + + ' rileggo la struttura BTL del progetto corrente per non avere quella del contesto temporaneo ancora presente + ReloadBTLStructure() + + ' salvo gli id degli AsseBase presenti nel progetto corrente + Dim AsseBaseIdList As New List(Of Integer) + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + AsseBaseIdList.Add(AsseBaseId) + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + End While + + ' calcolo BBox globale del progetto iniziale + Dim b3Parts As New BBox3d + Dim nProjPartId As Integer = EgtGetFirstPart() + Dim nLastProjPartId As Integer = 0 + While nProjPartId <> GDB_ID.NULL + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nProjPartId, GDB_BB.ONLY_VISIBLE, b3Part) + b3Parts.Add(b3Part) + nLastProjPartId = nProjPartId + nProjPartId = EgtGetNextPart(nProjPartId) + End While + ' inserisco il file importato nel progetto corrente + bOk = bOk AndAlso EgtInsertFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE) + ' deseleziono tutto + EgtDeselectAll() + ' ciclo sui pezzi aggiunti + Dim nAddedPartId As Integer = EgtGetNextPart(nLastProjPartId) + Dim bFirstLoop As Boolean = True + Dim LastPartMaxY As Double + Dim nIncrPDN As Integer = 0 + While nAddedPartId <> GDB_ID.NULL + ' incremento il PDN del Part aggiunto rispetto al PDN maggiore attualmente presente + EgtSetInfo(nAddedPartId, BTL_PRT_PDN, Map.refProjectVM.BTLStructureVM.BTLStructureM.NewPDN() + nIncrPDN) + ' recupero layer del box + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nAddedPartId, "Box") + ' recupero box del layer box + Dim b3Box As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + ' ricaviamo il box globale del part appena aggiunto + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + ' sposto il pezzo per distanziarlo dall'ultimo di un offset pari a 500 + bOk = bOk AndAlso EgtMove(nAddedPartId, New Vector3d(0, If(bFirstLoop, b3Parts.Max.y, LastPartMaxY - b3Part.Min.y) + 500, 0)) + bFirstLoop = False + ' ricaviamo il box globale del part appena spostato, salviamo la sua Y massima e lo aggiungiamo al box globale di tutti i part + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + LastPartMaxY = b3Part.Max.y + b3Parts.Add(b3Part) + nAddedPartId = EgtGetNextPart(nAddedPartId) + nIncrPDN += 1 + End While + ' aggiungo i part inseriti alla lista + Dim nNewPartId As Integer = EgtGetNextPart(nLastProjPartId) + While nNewPartId <> GDB_ID.NULL + ' aggiungo dati pezzo + Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nNewPartId) + ' aggiungo pezzo alla lista + Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart) + Dim AddedBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart) + ' verifico se aggiungere sezione alla lista + If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(AddedBTLPart.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Add(AddedBTLPart.Section) + End If + nNewPartId = EgtGetNextPart(nNewPartId) + End While + + ' elimino gli AsseBase del progetto importato + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + Dim CurrAsseBaseId = AsseBaseId + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + If Not AsseBaseIdList.Contains(CurrAsseBaseId) Then EgtErase(CurrAsseBaseId) + End While + + WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile)) + Else + ' altrimenti apro la finestra con l'elenco dei Part da checkare per l'inserimento nel progetto (unica strada se UserLevel <= 5), + ' che prevederà la sovrascrittura di quelli già presenti e l'aggiunta di quelli nuovi + Dim UpdateBTLWndVM As New UpdateBTLWndVM(PartToUpdateList) + Dim UpdateBTLWnd As New UpdateBTLWndV(Application.Current.MainWindow, UpdateBTLWndVM) + If Not UpdateBTLWnd.ShowDialog() Then + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + ' rileggo la struttura BTL + ReloadBTLStructure() + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + Return + End If + If UpdateBTLWndVM.BTLPartList.Count > 0 Then + ' sovrascrivo i Part nel progetto aperto con i Part checkati nella lista + Dim BTLPartToOverwriteWithList As New ObservableCollection(Of BTLPartToUpdate) + ' Elimino dal TempCtx i Part non checkati + For Each BTLPartToOverwriteWith In UpdateBTLWndVM.BTLPartList + If BTLPartToOverwriteWith.bInsert Then + BTLPartToOverwriteWithList.Add(BTLPartToOverwriteWith) + Else + ' elimino pezzo copia + Dim nCurrPartId = EgtGetCurrPart() + EgtErase(BTLPartToOverwriteWith.nPartId) + nCurrPartId = EgtGetCurrPart() + End If + Next + + ' costruisco un nuovo dizionario dei sottonodi di AsseBase contenente solo quelli corrispondenti agli UID contenuti + ' nei soli Part checkati del BTL nella finestra UpdateBTLWnd + Dim NewAsseBaseSubNodeDict As New Dictionary(Of Integer, Integer) + For Each AsseBaseSubNodeItem In AsseBaseSubNodeDict + For Each BTLPartToOverwriteWithItem In BTLPartToOverwriteWithList + Dim bExitFor As Boolean = False + For Each UIDItem In BTLPartToOverwriteWithItem.UIDList + If AsseBaseSubNodeItem.Value = UIDItem Then + NewAsseBaseSubNodeDict.Add(AsseBaseSubNodeItem.Key, AsseBaseSubNodeItem.Value) + bExitFor = True + Exit For + End If + Next + If bExitFor Then Exit For + Next + Next + ' confronto la lista appena costruita con quella originale ed elimino dal contesto i sottonodi con i valori non più presenti + For Each AsseBaseSubNodeItem In AsseBaseSubNodeDict + If Not NewAsseBaseSubNodeDict.ContainsValue(AsseBaseSubNodeItem.Value) Then + EgtErase(AsseBaseSubNodeItem.Key) + End If + Next + + ' salvo il file NGE inserito a cui abbiamo rimosso i Part non checkati e gli AsseBase non più associati + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE, NGE.CMPTEXT) + + ' torno sul contesto corrente + EgtDeleteContext(nTempCtx) + EgtSetCurrentContext(nCurrCtx) + + ' rileggo la struttura BTL del progetto corrente per non avere quella del contesto temporaneo ancora presente + ReloadBTLStructure() + + ' elimino i pezzi da sovrascrivere nel progetto corrente + For Each BTLPartToOverwriteWith In UpdateBTLWndVM.BTLPartList + If BTLPartToOverwriteWith.bInsert Then + Dim BTLPartToUpdate As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPDN = BTLPartToOverwriteWith.nPDN) + ' se BTLPartToUpdate è Nothing significa che il pezzo è nuovo e quindi basta accodarlo senza eliminare nulla + If Not IsNothing(BTLPartToUpdate) Then + Dim nPartToDeleteId As Integer = BTLPartToUpdate.nPartId + Dim nCurrPartId = EgtGetCurrPart() + EgtErase(nPartToDeleteId) + nCurrPartId = EgtGetCurrPart() + ' verifico se rimuovere sezione dalla lista + If Not Map.refProjectVM.BTLStructureVM.BTLPartVMList.Any(Function(x) x IsNot BTLPartToUpdate AndAlso x.Section = BTLPartToUpdate.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Remove(BTLPartToUpdate.Section) + End If + ' rimuovo dalla lista pezzi + Dim Index As Integer = Map.refProjectVM.BTLStructureVM.BTLPartVMList.IndexOf(BTLPartToUpdate) + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Nothing) + Map.refProjectVM.BTLStructureVM.BTLPartVMList.RemoveAt(Index) + End If + End If + Next + + ' salvo gli id degli AsseBase presenti nel progetto corrente + Dim AsseBaseIdList As New List(Of Integer) + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + AsseBaseIdList.Add(AsseBaseId) + ' elimino i sottonodi di AsseBase da sovrascrivere + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + nAsseBaseSubNodeId = EgtGetFirstInGroup(AsseBaseId) + While nAsseBaseSubNodeId <> GDB_ID.NULL + If NewAsseBaseSubNodeDict.ContainsKey(nAsseBaseSubNodeId) Then + ' se sottonodo da cancellare salvo il suo id e ricavo il seguente prima di cancellarlo + Dim nCurrAsseBaseSubNodeId = nAsseBaseSubNodeId + nAsseBaseSubNodeId = EgtGetNext(nCurrAsseBaseSubNodeId) + bOk = EgtErase(nCurrAsseBaseSubNodeId) + Else + ' altrimenti ricavo il seguente e basta + nAsseBaseSubNodeId = EgtGetNext(nAsseBaseSubNodeId) + End If + End While + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + End While + + ' calcolo BBox globale del progetto corrente + Dim b3Parts As New BBox3d + Dim nProjPartId As Integer = EgtGetFirstPart() + Dim nLastProjPartId As Integer = GDB_ID.NULL + While nProjPartId <> GDB_ID.NULL + Dim b3Part As New BBox3d + If EgtGetBBoxGlob(nProjPartId, GDB_BB.ONLY_VISIBLE, b3Part) Then + b3Parts.Add(b3Part) + End If + nLastProjPartId = nProjPartId + nProjPartId = EgtGetNextPart(nProjPartId) + End While + ' se sovrascrivo tutti e bbox esce nullo + If b3Parts.IsEmpty Then + b3Parts = New BBox3d(Point3d.ORIG) + End If + + ' inserisco il file NGE (ricavato dal BTL importato) nel progetto corrente + bOk = bOk AndAlso EgtInsertFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE) + + ' ciclo su tutti gli AsseBase del progetto corrente + Dim nAsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While nAsseBaseId <> GDB_ID.NULL + Dim nAsseBaseProjId As Integer + Dim nAsseBaseToEraseId As Integer = 0 + EgtGetInfo(nAsseBaseId, BTL_PRT_PROJ, nAsseBaseProjId) + ' se AsseBase di questo step del ciclo è nuovo e suo ProjId uguale a quello del progetto corrente + If Not AsseBaseIdList.Contains(nAsseBaseId) AndAlso nAsseBaseProjId = Map.refProjManagerVM.CurrProj.nProjId Then + ' riloco i sottonodi del nuovo AsseBase nell'AsseBase del progetto aperto col medesimo ProjId + Dim AsseBaseSubNodeId As Integer = EgtGetFirstInGroup(nAsseBaseId) + While AsseBaseSubNodeId <> GDB_ID.NULL + ' ciclo su tutti gli AsseBase per trovare l'id di quello con ProjId uguale al progetto corrente + Dim FindAsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While FindAsseBaseId <> GDB_ID.NULL + Dim SameAsseBaseProjId As Integer + EgtGetInfo(FindAsseBaseId, BTL_PRT_PROJ, SameAsseBaseProjId) + ' se l'ho trovato esco dal While (FindAsseBaseId è l'id dell'AsseBase in cui vogliamo rilocare i sottonodi) + If SameAsseBaseProjId = Map.refProjManagerVM.CurrProj.nProjId Then Exit While + FindAsseBaseId = EgtGetNextName(FindAsseBaseId, ASSEBASE) + End While + ' salvo id dell'AsseBase corrente per ottenere il seguente prima di rilocarlo + Dim CurrAsseBaseSubNodeId = AsseBaseSubNodeId + AsseBaseSubNodeId = EgtGetNext(CurrAsseBaseSubNodeId) + bOk = bOk AndAlso EgtRelocate(CurrAsseBaseSubNodeId, FindAsseBaseId, GDB_POS.LAST_SON) + End While + ' salvo id dell'AsseBase per cancellarlo + nAsseBaseToEraseId = nAsseBaseId + End If + ' ricavo id del prossimo AsseBase + nAsseBaseId = EgtGetNextName(nAsseBaseId, ASSEBASE) + ' se salvato id dell'AsseBase per cancellarlo lo cancello + If nAsseBaseToEraseId <> 0 Then bOk = bOk AndAlso EgtErase(nAsseBaseToEraseId) + End While + + ' deseleziono tutto + EgtDeselectAll() + ' ciclo sui pezzi aggiunti + Dim nAddedPartId As Integer = If(nLastProjPartId <> GDB_ID.NULL, EgtGetNextPart(nLastProjPartId), EgtGetFirstPart()) + Dim LastPartMaxY As Double + While nAddedPartId <> GDB_ID.NULL + ' recupero layer del box + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nAddedPartId, "Box") + ' recupero box del layer box + Dim b3Box As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + ' ricaviamo il box globale del part appena aggiunto e ruotato + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + ' salviamo la Y massima del box globale di tutti i part + LastPartMaxY = b3Parts.Max.y + ' sposto il pezzo per distanziarlo dall'ultimo di un offset pari a 500 + bOk = bOk AndAlso EgtMove(nAddedPartId, New Vector3d(0, LastPartMaxY - b3Part.Min.y + 500, 0)) + ' ricaviamo il box globale del part appena spostato e lo aggiungiamo al box globale di tutti i part + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + b3Parts.Add(b3Part) + ' aggiungo dati pezzo + Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nAddedPartId) + ' aggiungo pezzo alla lista + Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart) + Dim AddedBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart) + ' se progetto pareti e vista ruotata + If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then + ' ruoto le pareti di 180 per raddrizzarle rispetto alla vista + AddedBTLPart.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False) + End If + ' verifico se aggiungere sezione alla lista + If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(AddedBTLPart.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Add(AddedBTLPart.Section) + End If + nAddedPartId = EgtGetNextPart(nAddedPartId) + End While + WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile)) + End If + End If + ' copio il file originale scelto nel dialog per l'Update nella cartella Proj del progetto corrente + If File.Exists(sFile) Then + Dim sDestPath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & Path.GetFileNameWithoutExtension(sFile) + While File.Exists(sDestPath & ".btl") + sDestPath = sDestPath & "_1" + End While + File.Copy(sFile, sDestPath & ".btl", False) + End If + End If + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + End Sub + +#End Region ' UpdateBTL + +#Region "ExportProject" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property ExportProject_Command As ICommand + Get + If m_cmdExportProject Is Nothing Then + m_cmdExportProject = New Command(AddressOf ExportProject) + End If + Return m_cmdExportProject + End Get + End Property + + ''' + ''' Execute the Export. This method is invoked by the ExportCommand. + ''' + Public Function ExportProject(Optional sExportFileName As String = Nothing) As String + Select Case Map.refMainMenuVM.SelPage + Case Pages.VIEW + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return Nothing + If IsNothing(CurrProj) Then Return Nothing + Case Pages.MACHINING + If ProdFileVM.VerifyProjectModification(Map.refProdManagerVM.CurrProd) = MessageBoxResult.Cancel Then Return Nothing + If IsNothing(Map.refProdManagerVM.CurrProd) Then Return Nothing + Case Else + Return Nothing + End Select + + ' apro finestra di salvataggio progetto + Dim ExportDlg As New Microsoft.Win32.SaveFileDialog() With {.DefaultExt = ".ngexp", + .Filter = "ProjectExport (*.ngexp)|*.ngexp", + .FileName = CurrProj.nProjId.ToString("0000") & " - " & CurrProj.sBTLFileName & " - ProjectExport"} + If IsNothing(sExportFileName) Then + If ExportDlg.ShowDialog() <> True Then Return Nothing + End If + + LoadingWndHelper.OpenLoadingWnd(ActiveIds.EXPORTPROJECT, 2, EgtMsg(63010), EgtMsg(63016), 30) ' Project exporting ' Adding export info + ' se assemblato me lo segno e lo smonto + Dim bShowBuilding As Boolean = False + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + If Map.refShowBeamPanelVM.bShowAll Then + ' verifico se assemblato e lo annullo per salvataggio + bShowBuilding = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(False, False) + End If + End If + + ' per ogni BTLInfo nel progetto riporto il relativo nome del BTL + Dim nBTLInfoProjId As Integer + Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + ' recupero il ProjId + EgtGetInfo(nBTLInfoLayerId, BTL_PRT_PROJ, nBTLInfoProjId) + If nBTLInfoProjId > 0 Then + ' recupero il BTL file name di questo proj + Dim BTLFileNameProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nBTLInfoProjId) + If Not IsNothing(BTLFileNameProj) Then + EgtSetInfo(nBTLInfoLayerId, BTLFILENAME, BTLFileNameProj.sBTLFileName) + End If + End If + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + ' aggiungo layer per info di export + Dim nImpExpPartId As Integer = EgtCreateGroup(GDB_ID.ROOT) + EgtSetName(nImpExpPartId, EXP_PART) + ' ci scrivo nome macchina e tipo progetto + EgtSetInfo(nImpExpPartId, EXP_MACHINE, CurrProj.sMachine) + EgtSetInfo(nImpExpPartId, BTL_GEN_PROJTYPE, CurrProj.nType) + + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.EXPORTPROJECT, 2, EgtMsg(63017), 30, 100) ' Exporting... + ' salvo info inserite + Map.refSceneHostVM.SaveProject() + ' creo file zip + Dim sZipToCreate As String = If(IsNothing(sExportFileName), ExportDlg.FileName, Map.refMainWindowVM.MainWindowM.sTempDir & "\" & sExportFileName & ".ngexp") + If File.Exists(sZipToCreate) Then + File.Delete(sZipToCreate) + End If + Try + Using zip As New Ionic.Zip.ZipFile(sZipToCreate, Console.Out) + ' impacchetto tutta la cartella del progetto + Dim sProjectDirPath As String = If(CurrProj.nProdId > 0, CurrProj.sProdDirPath, CurrProj.sProjDirPath) + For Each sFile As String In Directory.GetFiles(sProjectDirPath) + zip.AddItem(sFile, "") + Next + ' salvo lo zip + zip.Save() + End Using + Catch ex1 As Exception + EgtOutLog("Exception in zip: " & ex1.ToString()) + MessageBox.Show("Error in export file creation!") + End Try + ' elimino layer di esportazione + EgtErase(nImpExpPartId) + ' salvo eliminazione info inserite + Map.refSceneHostVM.SaveProject() + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.EXPORTPROJECT) + Return sZipToCreate + End Function + +#End Region ' ExportProject + +#Region "ImportProject" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property ImportProject_Command As ICommand + Get + If m_cmdImportProject Is Nothing Then + m_cmdImportProject = New Command(AddressOf ImportProject) + End If + Return m_cmdImportProject + End Get + End Property + + ''' + ''' Execute the Export. This method is invoked by the ExportCommand. + ''' + Public Sub ImportProject() + Dim CurrProd As ProjectFileVM = Map.refProdManagerVM.CurrProd + ' lista di tutti gli errori riscontrati + Dim ErrorList As New List(Of String) + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTNGEXPDIR, "", sDir) + ' apro finestra scelta file + Dim ImportDlg As New Microsoft.Win32.OpenFileDialog() With {.DefaultExt = ".ngexp", + .Filter = "ProjectExport (*.ngexp)|*.ngexp", + .InitialDirectory = If(Directory.Exists(sDir), sDir, ""), + .CheckFileExists = True, + .ValidateNames = True} + If ImportDlg.ShowDialog() <> True Then Return + ' creo cartella temporanea di estrazione in Temp + Dim sProjectimportDir As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\ProjectImport" + If Directory.Exists(sProjectimportDir) Then + Directory.Delete(sProjectimportDir, True) + End If + Directory.CreateDirectory(sProjectimportDir) + Try + Using zip As New Ionic.Zip.ZipFile(ImportDlg.FileName, Console.Out) + ' estraggo file da zip + zip.ExtractAll(sProjectimportDir) + End Using + Catch ex1 As Exception + EgtOutLog("Exception in zip: " & ex1.ToString()) + MessageBox.Show("Impossibile importare file", "Errore") + Return + End Try + LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTPROJECT, 2, EgtMsg(63018), EgtMsg(63019), 30) ' Project importing ' Loading project + ' carico progetto + Dim sProjFromPath() As String = Directory.GetFiles(sProjectimportDir, "*.nge") + Dim bOk = EgtOpenFile(sProjFromPath(0)) + If Not bOk Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show("Impossibile aprire il file", "Errore") + Return + End If + ' recupero e verifico se ho a disposizione la macchina con cui e' stato creato il progetto + Dim nImpExpPartId = EgtGetFirstNameInGroup(GDB_ID.ROOT, EXP_PART) + Dim sMachine As String = "" + EgtGetInfo(nImpExpPartId, EXP_MACHINE, sMachine) + ' se la macchina del progetto in apertura non è tra le macchine disponibili lo segnalo e apro un progetto vuoto + If IsNothing(Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = sMachine)) Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + Return + End If + Dim Machine As Machine = Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = sMachine) + Dim nType As Integer = BWType.NULL + EgtGetInfo(nImpExpPartId, BTL_GEN_PROJTYPE, nType) + If IsNothing(Machine) OrElse nType = BWType.NULL Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + Return + End If + ' elimino part di esportazione + EgtErase(nImpExpPartId) + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTPROJECT, 2, EgtMsg(63020), 30, 100) ' Creating imported project + ' leggo proj e prod presenti dai layer BTLInfo + Dim ImportProjIdList As New List(Of Integer) + Dim NewProjIdList As New List(Of Integer) + Dim BTLInfoIdList As New List(Of Integer) + Dim BTLFileNameList As New List(Of String) + Dim CurrImportProjId As Integer + Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + ' recupero il ProjId + EgtGetInfo(nBTLInfoLayerId, BTL_PRT_PROJ, CurrImportProjId) + If CurrImportProjId > 0 Then + ImportProjIdList.Add(CurrImportProjId) + BTLInfoIdList.Add(nBTLInfoLayerId) + ' recupero nome file BTL Associato + Dim sBTLFileName As String = "" + EgtGetInfo(nBTLInfoLayerId, BTLFILENAME, sBTLFileName) + BTLFileNameList.Add(sBTLFileName) + End If + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + If Not ImportProjIdList.Count > 0 Then + MessageBox.Show("Nessun progetto trovato all'interno del file importato", "Errore") + End If + ' carico i proj + For nProjIndex = 0 To ImportProjIdList.Count - 1 + Dim nImportProjId As Integer = ImportProjIdList(nProjIndex) + ' inizializzo nuovo proj + Dim nNewProjId As Integer = 0 + Dim sNewProjDir As String = "" + InitNewProject(nNewProjId, sNewProjDir, nType, Machine) + NewProjIdList.Add(nNewProjId) + ' imposto ProjId di caricamento + m_nLoadingProjId = nImportProjId + ' costruisco BTLStructure del proj + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(nImportProjId)) + ' scrivo info proj su tutti i pezzi di questo progetto + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + EgtSetInfo(BTLPart.nPartId, BTL_PRT_PROJ, nNewProjId) + Next + ' cambio indicazione proj in gruppo di assemblaggio + Dim AsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + Dim nAsseBaseProj As Integer = 0 + EgtGetInfo(AsseBaseId, BTL_PRT_PROJ, nAsseBaseProj) + If nAsseBaseProj = nImportProjId Then + EgtSetInfo(AsseBaseId, BTL_PRT_PROJ, NewProjIdList(nProjIndex)) + Exit While + End If + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + End While + ' riporto nuovo ProjId nel layer BTLInfo + EgtSetInfo(BTLInfoIdList(nProjIndex), BTL_PRT_PROJ, nNewProjId) + ' resetto tutti gli stati di CALC + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + BTLPart.ResetCalcTotalPart() + Next + ' salvo modifiche fatte al progetto + bOk = bOk AndAlso Map.refSceneHostVM.MainController.SaveProject() + If bOk Then + ' copio file BTL e progetto + Dim sBTLFromPath As String = sProjectimportDir & "\" & BTLFileNameList(nProjIndex) & ".btl" + Dim sProjFileName As String = sNewProjDir & "\" & nNewProjId.ToString("0000") & ".nge" + If sProjFromPath.Count > 0 AndAlso Not String.IsNullOrWhiteSpace(sProjFromPath(0)) Then + Try + If Not String.IsNullOrWhiteSpace(sBTLFromPath) AndAlso File.Exists(sBTLFromPath) Then + Dim sBtlToPath As String = sNewProjDir & "\" & Path.GetFileName(sBTLFromPath) + File.Copy(sBTLFromPath, sBtlToPath) + Else + ErrorList.Add(String.Format("File BTL del progetto {0} non trovato", nImportProjId)) + End If + File.Copy(sProjFromPath(0), sProjFileName) + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show("Impossibile copiare il file del progetto", "Errore") + Return + End Try + End If + ' aggiorno Db + Dim sBTLFileName As String = BTLFileNameList(nProjIndex) + Dim ExportDate As DateTime + DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " & + Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate) + DbControllers.m_ProjController.UpdateInfo(nNewProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Machine.Name) + Else + ' elimino da Db + + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(nNewProjId, False) + End If + ' aggiorno BTLParts su DB + DbControllers.m_ProjController.UpdateBtlParts(nNewProjId, Map.refProjectVM.BTLStructureVM.BTLStructureM.BTLPartMList) + ' resetto stato new + DbControllers.m_ProjController.ResetNew(nNewProjId) + ' resetto lock + DbControllers.m_ProjController.LockByProjId(nNewProjId, False, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + DbControllers.m_ProjController.ResetController() + Next + ' se tutte le operazioni precedenti sono andate a buon fine + If bOk Then + ' sostituisco indicazione nuovi proj nei pezzi + Dim nDuploLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, "DuploBase") + Dim nDuploId As Integer = EgtGetFirstInGroup(nDuploLayerId) + While nDuploId <> GDB_ID.NULL + ' recupero vecchio proj + Dim nOldProjId As Integer + EgtGetInfo(nDuploId, BTL_PRT_PROJ, nOldProjId) + ' lo cerco nella lista + Dim nOldProjIndex As Integer = ImportProjIdList.IndexOf(nOldProjId) + ' lo sostituisco + EgtSetInfo(nDuploId, BTL_PRT_PROJ, NewProjIdList(nOldProjIndex)) + nDuploId = EgtGetNext(nDuploId) + End While + ' resetto CurrProd per evitare di leggere valori produzione dal Db di quel progetto + Map.refProdManagerVM.CurrProd = Nothing + ' carico Machgroup che non verrebbero altrimenti importati + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count > 0 Then + ' inizializzo nuovo progetto PROD + Dim nProdId As Integer = 0 + Dim sProdDir As String = "" + Map.refProdManagerVM.InitNewProject(NewProjIdList(0), nProdId, sProdDir) + ' setto il PType del Prod + DbControllers.m_ProdController.UpdatePType(nProdId, nType) + ' setto la Macchina associata al Prod + DbControllers.m_ProdController.UpdateMachine(nProdId, sMachine) + For Each MachGroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' aggiorno ProdId sui MachGroup + EgtSetInfo(MachGroup.Id, MGR_RPT_PRODID, nProdId) + If Map.refMainWindowVM.MainWindowM.nUserLevel < 5 OrElse GetMainPrivateProfileInt(S_MACH, K_EXPORTBWE, 0) <> 1 Then + ' resetto tutti gli stati di CALC + MachGroup.ResetCalcTotalMachGroup() + End If + Next + If Map.refMainWindowVM.MainWindowM.nUserLevel >= 5 AndAlso GetMainPrivateProfileInt(S_MACH, K_EXPORTBWE, 0) = 1 Then + ' riporto info di futuro aggiornamento machgroup + nBTLInfoLayerId = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + EgtSetInfo(nBTLInfoLayerId, IMP_VERIFYMACHGROUP, True) + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + End If + ' salvo il progetto PROD + EgtSaveFile(sProjFromPath(0), NGE.CMPTEXT) + ' copio file progetto + Dim sProjPath As String = String.Empty + Dim sProdPath As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" + If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then + Try + File.Copy(sProjPath, sProdPath) + 'Map.refSceneHostVM.MainController.OpenProject(sProdPath) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + End If + If Map.refMainWindowVM.MainWindowM.nUserLevel >= 5 AndAlso GetMainPrivateProfileInt(S_MACH, K_EXPORTBWE, 0) = 1 Then + ' copio tutti i bwe + For Each CurrFile In Directory.GetFiles(sProjectimportDir) + If Path.GetExtension(CurrFile) = ".bwe" OrElse Path.GetExtension(CurrFile) = ".html" Then + File.Copy(CurrFile, sProdDir & "\" & Path.GetFileName(CurrFile)) + End If + Next + End If + If bOk Then + ' aggiungo altri proj a prod + For Each nProjId In NewProjIdList + DbControllers.m_ProdController.AddProj(nProdId, nProjId, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + Next + Else + ' elimino da DB + DbControllers.m_ProdController.DeleteProd(nProdId, True) + End If + Dim MyMachGroupList As New List(Of MyMachGroupM) + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + For Each MachGroup In Map.refProjectVM.MachGroupPanelVM.m_MyMachGroupPanelM.MachGroupMList + MyMachGroupList.Add(MachGroup) + Next + End If + ' aggiorno pezzi su Db + DbControllers.m_ProdController.UpdateMachGroup(nProdId, MyMachGroupList) + ' resetto lock + DbControllers.m_ProdController.LockByProdId(nProdId, False, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + End If + DbControllers.m_ProdController.ResetController() + End If + ' imposto progetto corrente + If NewProjIdList.Count > 0 Then + SetCurrProj(NewProjIdList(0)) + OpenProject(CurrProd) ' Da controllare + End If + ' ripristino eventuale CurrProd precedente + Map.refProdManagerVM.CurrProd = CurrProd + WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEXPDIR, Path.GetDirectoryName(ImportDlg.FileName)) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + End Sub + +#End Region ' ImportProject + +#Region "GoToSupervisor" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property GoToSupervisor_Command As ICommand + Get + If m_cmdGoToSupervisor Is Nothing Then + m_cmdGoToSupervisor = New Command(AddressOf GoToSupervisor) + End If + Return m_cmdGoToSupervisor + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub GoToSupervisor() + If IsNothing(m_CurrProd) Then Return + ' apro supervisore + Dim sSupervisorName As String = "EgtBEAMWALL.SupervisorR32" + ' recupero processo del supervisore + Dim localProc As Process() = Process.GetProcessesByName(sSupervisorName) + If localProc.Length > 0 Then + For Each p As Process In localProc + ' porto in primo piano il Supervisor + BringWindowToFront(p.MainWindowHandle) + Exit For + Next + Else + Dim sSupervisorPath As String = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory) & "\" & sSupervisorName & ".exe" + Try + Process.Start(sSupervisorPath, "1 " & CurrProd.nProdId) + Catch ex As Exception + EgtOutLog("Error: impossible starting supervisor from path " & sSupervisorPath) + End Try + End If + ' mando richiesta di apertura progetto in supervisore + 'Dim x = DbControllers.m_StatusMapController.GetProd + DbControllers.m_StatusMapController.UpdateAction(DbControllers.m_SupervisorId, Map.refOnlyProdManagerVM.CurrProd.nProdId, Map.refOnlyProdManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ChangeProdInSupervisorRequest, "") + End Sub + +#End Region ' GoToSupervisor + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml new file mode 100644 index 00000000..42ce3c54 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml.vb new file mode 100644 index 00000000..b60c4a3d --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdProjectV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectVM.vb b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectVM.vb new file mode 100644 index 00000000..fdbc48c9 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectVM.vb @@ -0,0 +1,448 @@ +Imports System.Windows.Threading +Imports EgtBEAMWALL.Core +Imports EgtWPFLib5 +Imports EgtUILib +Imports System.Collections.ObjectModel + +Public Class OnlyProdProjectVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_Calc_Timer As New DispatcherTimer + + Private Property m_GridDims As New ObservableCollection(Of GridDimension) + Public Property GridDims As ObservableCollection(Of GridDimension) + Get + Return m_GridDims + End Get + Set + m_GridDims = Value + NotifyPropertyChanged(NameOf(GridDims)) + End Set + End Property + + Private m_BTLStructureVM As BTLStructureVM + Public Property BTLStructureVM As BTLStructureVM + Get + Return m_BTLStructureVM + End Get + Set(value As BTLStructureVM) + m_BTLStructureVM = value + NotifyPropertyChanged(NameOf(BTLStructureVM)) + End Set + End Property + + Private m_MachGroupPanelVM As MyMachGroupPanelVM + Public Property MachGroupPanelVM As MyMachGroupPanelVM + Get + Return m_MachGroupPanelVM + End Get + Set(value As MyMachGroupPanelVM) + m_MachGroupPanelVM = value + NotifyPropertyChanged(NameOf(MachGroupPanelVM)) + End Set + End Property + + Private m_bCalcRunning As Boolean = False + Public ReadOnly Property bCalcRunning As Boolean + Get + Return m_bCalcRunning + End Get + End Property + Private m_bLockUX As Boolean = False + + Private m_LeftPanel_Visibility As Boolean = True + Public Property LeftPanel_Visibility As Visibility + Get + Return If(m_LeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_LeftPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetLeftPanel_Visibility(IsVisible As Boolean) + m_LeftPanel_Visibility = IsVisible + End Sub + + Private m_TopPanel_Visibility As Boolean = False + Public Property TopPanel_Visibility As Visibility + Get + Return If(m_TopPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_TopPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetTopPanel_Visibility(IsVisible As Boolean) + m_TopPanel_Visibility = IsVisible + End Sub + + Private m_BottomPanel_Visibility As Boolean = True + Public Property BottomPanel_Visibility As Visibility + Get + Return If(m_BottomPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_BottomPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetBottomPanel_Visibility(IsVisible As Boolean) + m_BottomPanel_Visibility = IsVisible + End Sub + + Private m_PartManager_Visibility As Boolean = True + Public ReadOnly Property PartManager_Visibility As Visibility + Get + 'Return If(Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso Not Map.refFreeContourManagerVM.bIsActive, Visibility.Visible, Visibility.Collapsed) + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso Not Map.refFreeContourManagerVM.bIsActive) Then + Return Visibility.Visible + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Return Visibility.Visible + Else + Return Visibility.Collapsed + End If + End Get + End Property + + Private m_FeatureManager_Visibility As Boolean = True + Public Property FeatureManager_Visibility As Visibility + Get + Return If(m_FeatureManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_FeatureManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetFeatureManager_Visibility(IsVisible As Boolean) + m_FeatureManager_Visibility = IsVisible + End Sub + + Private m_ShowBeamPanel_Visibility As Boolean = True + Public Property ShowBeamPanel_Visibility As Visibility + Get + Return If(m_ShowBeamPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ShowBeamPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetShowBeamPanel_Visibility(IsVisible As Boolean) + m_ShowBeamPanel_Visibility = IsVisible + End Sub + + Private m_ProjManager_Visibility As Boolean = True + Public Property ProjManager_Visibility As Visibility + Get + Return If(m_ProjManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ProjManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetProjManager_Visibility(IsVisible As Boolean) + m_ProjManager_Visibility = IsVisible + Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) + End Sub + + Private m_ProdManager_Visibility As Boolean = True + Public Property ProdManager_Visibility As Visibility + Get + Return If(m_ProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ProdManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetProdManager_Visibility(IsVisible As Boolean) + m_ProdManager_Visibility = IsVisible + Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.GoToProj_Visibility)) + End Sub + + Private m_FullCompleteManager_Visibility As Boolean = True + Public Property FullCompleteManager_Visibility As Visibility + Get + Return If(m_FullCompleteManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_FullCompleteManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetFullCompleteManager_Visibility(IsVisible As Boolean) + m_FullCompleteManager_Visibility = IsVisible + Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) + End Sub + + Private m_OptimizePanel_Visibility As Boolean = True + Public Property OptimizePanel_Visibility As Visibility + Get + Return If(m_OptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OptimizePanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOptimizePanel_Visibility(IsVisible As Boolean) + m_OptimizePanel_Visibility = IsVisible + NotifyPropertyChanged(NameOf(OptimizePanel_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility)) + End Sub + + Friend Sub NotifyCalcPanel_Visibility() + Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.ViewPage_Visibility)) + Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.Edit_Visibility)) + End Sub + + Private m_FreeContourManager_Visibility As Boolean = False + Public Property FreeContourManager_Visibility As Visibility + Get + Return If(m_FreeContourManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_FreeContourManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetFreeContourManager_Visibility(IsVisible As Boolean) + m_FreeContourManager_Visibility = IsVisible + NotifyPropertyChanged("FreeContourManager_Visibility") + End Sub + + Friend Sub NotifyAllPanelVisibility() + NotifyPropertyChanged("LeftPanel_Visibility") + NotifyPropertyChanged("TopPanel_Visibility") + NotifyPropertyChanged("BottomPanel_Visibility") + NotifyPropertyChanged("PartManager_Visibility") + NotifyPropertyChanged("FeatureManager_Visibility") + NotifyPropertyChanged("ShowBeamPanel_Visibility") + NotifyPropertyChanged("ProjManager_Visibility") + NotifyPropertyChanged("ProdManager_Visibility") + NotifyPropertyChanged("FullCompleteManager_Visibility") + NotifyCalcPanel_Visibility() + End Sub + +#End Region ' FIELDS & PROPERTIES + +#Region "Messages" + + Public ReadOnly Property ProduceRawPart_ToolTip As String + Get + Return EgtMsg(61912) + End Get + End Property + + Public ReadOnly Property ResetCALCRawPart_ToolTip As String + Get + Return EgtMsg(61924) + End Get + End Property + + Public ReadOnly Property ProduceAllRawPart_ToolTip As String + Get + Return EgtMsg(61913) + End Get + End Property + + Public ReadOnly Property CopyRawPart_ToolTip As String + Get + Return EgtMsg(61914) + End Get + End Property + + Public ReadOnly Property RemoveRawPart_ToolTip As String + Get + Return EgtMsg(61915) + End Get + End Property + + Public ReadOnly Property RemoveAllRawPart_ToolTip As String + Get + Return EgtMsg(61976) + End Get + End Property + + Public ReadOnly Property ReOrderPart_ToolTip As String + Get + Return EgtMsg(61916) + End Get + End Property + + Public ReadOnly Property MoveUpPart_ToolTip As String + Get + Return EgtMsg(61917) + End Get + End Property + + Public ReadOnly Property MoveDownPart_ToolTip As String + Get + Return EgtMsg(61918) + End Get + End Property + + Public ReadOnly Property RemovePart_ToolTip As String + Get + Return EgtMsg(61919) + End Get + End Property + + Public ReadOnly Property MovePartInRawPart_ToolTip As String + Get + Return EgtMsg(61944) + End Get + End Property + +#End Region ' Messages + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefProjectVM(Me) + ' imposto timer per aggiornamenti Calc + m_Calc_Timer.Interval = TimeSpan.FromMilliseconds(500) + AddHandler m_Calc_Timer.Tick, AddressOf Calc_Timer_Tick + ' imposto dimensioni colonne/righe della Grid + DimensionsIniFile.ReadGridDimensions(ConstDims.PROJECT_VIEW, GridDims) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Sub SetCalcRunning(value As Boolean) + If value Then m_Calc_Timer.Start() + m_bCalcRunning = value + End Sub + + Friend Sub ManageIsEnabled(bIsEnabled As Boolean) + Map.refInstrumentPanelVM.SetInstrumentPanelIsEnabled(bIsEnabled) + Map.refCALCPanelVM.SetCalcPanelIsEnabled(bIsEnabled) + Map.refMainMenuVM.SetMainMenuIsEnabled(bIsEnabled) + Map.refPartManagerVM.SetPartManagerIsEnabled(bIsEnabled) + Map.refLeftPanelVM.SetLeftPanelIsEnabled(bIsEnabled) + Map.refProjManagerVM.SetProjManagerIsEnabled(bIsEnabled) + Map.refProdManagerVM.SetProdManagerIsEnabled(bIsEnabled) + Map.refTopPanelVM.SetTopPanelIsEnabled(bIsEnabled) + Map.refOptimizePanelVM.SetOptimizePanelIsEnabled(bIsEnabled) + Map.refFeatureManagerVM.SetFeatureManagerIsEnabled(bIsEnabled) + End Sub + + Private Sub Calc_Timer_Tick() + If m_bCalcRunning <> m_bLockUX Then + ' se calcolo iniziato + If m_bCalcRunning Then + ManageIsEnabled(False) + ' aggiungere gestione colonne editabili delle tabelle + If Not IsNothing(Map.refPartListVM.colPart_Do) Then + Map.refPartListVM.colPart_Do.IsReadOnly = True + End If + If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then + Map.refFeatureListVM.colFeature_Do.IsReadOnly = True + End If + If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then + Map.refPParameterListVM.colPParam_Value.IsReadOnly = True + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then + Map.refQParameterListVM.colQParam_Value.IsReadOnly = True + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then + Map.refQParameterListVM.colQParam_Custom.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then + Map.refRawPartListVM.colRawPart_StartCut.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then + Map.refRawPartListVM.colRawPart_W.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then + Map.refRawPartListVM.colRawPart_L.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then + Map.refRawPartListVM.colRawPart_PosZ.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then + Map.refPartInRawPartListVM.colPartInRawPart_Offset.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then + Map.refPartInRawPartListVM.colPartInRawPart_Rot.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then + Map.refPartInRawPartListVM.colPartInRawPart_Flip.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosX.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosY.IsReadOnly = True + End If + If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then + Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.IsReadOnly = True + End If + m_bLockUX = True + ' se calcolo finito + Else + ManageIsEnabled(True) + ' aggiungere gestione colonne editabili delle tabelle + If Not IsNothing(Map.refPartListVM.colPart_Do) Then + Map.refPartListVM.colPart_Do.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then + Map.refFeatureListVM.colFeature_Do.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then + Map.refPParameterListVM.colPParam_Value.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then + Map.refQParameterListVM.colQParam_Value.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then + Map.refQParameterListVM.colQParam_Custom.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then + Map.refRawPartListVM.colRawPart_StartCut.ResetToOrigIsReadOnly() + End If + If m_BTLStructureVM.nPROJTYPE <> BWType.BEAM AndAlso Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then + Map.refRawPartListVM.colRawPart_W.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then + Map.refRawPartListVM.colRawPart_L.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then + Map.refRawPartListVM.colRawPart_PosZ.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then + Map.refPartInRawPartListVM.colPartInRawPart_Offset.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then + Map.refPartInRawPartListVM.colPartInRawPart_Rot.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then + Map.refPartInRawPartListVM.colPartInRawPart_Flip.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosX.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosY.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then + Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.ResetToOrigIsReadOnly() + End If + ' fermo il timer + If Not m_bCalcRunning Then + m_Calc_Timer.Stop() + m_bLockUX = False + End If + End If + End If + + End Sub + +#End Region ' METHODS + +End Class + diff --git a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb index de3a9c17..9897a81f 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb @@ -113,9 +113,18 @@ Public Class OptimizePanelVM End Property Public ReadOnly Property Optimize_Visibility As Visibility Get - Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso - (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse - (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))), Visibility.Visible, Visibility.Collapsed) + 'Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso + ' (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse + ' (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))), Visibility.Visible, Visibility.Collapsed) + + If Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse + (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))) Then + Return Visibility.Visible + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Return Visibility.Visible + End If + + Return Visibility.Collapsed End Get End Property @@ -132,7 +141,7 @@ Public Class OptimizePanelVM End Property Public ReadOnly Property MachiningPage_Visibility As Visibility Get - Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING, Visibility.Visible, Visibility.Collapsed) + Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING Or Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) End Get End Property diff --git a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerV.xaml b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerV.xaml index 7c4ae8d4..48b0db7a 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerV.xaml @@ -6,7 +6,7 @@ IsRightDockable="False" IsEnabled="{Binding ProdManager_IsEnabled}" Style="{StaticResource ToolBar_EgtFloatingPanel}"> - + diff --git a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb index 0ab55fd2..e90a07ba 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb @@ -84,6 +84,12 @@ Public Class ProdManagerVM End Get End Property + Public ReadOnly Property GoToProj_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Collapsed, Visibility.Visible) + End Get + End Property + Private m_AddProj_Visibility As Visibility Public ReadOnly Property AddProj_Visibility As Visibility Get @@ -143,6 +149,7 @@ Public Class ProdManagerVM Else m_GoToSupervisor_Visibility = Visibility.Collapsed End If + ' attivo bottone AddProj If GetMainPrivateProfileInt(S_GENERAL, K_ADDPROJ, 0) = 1 Then m_AddProj_Visibility = Visibility.Visible diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerV.xaml b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerV.xaml index 02f5924c..d317c5e4 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerV.xaml @@ -74,6 +74,7 @@ diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb index 6d66aba7..92a786f1 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb @@ -104,6 +104,12 @@ Public Class ProjManagerVM End Set End Property + Public ReadOnly Property GoToProd_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Collapsed, Visibility.Visible) + End Get + End Property + ' Definizione comandi Private m_cmdNew As ICommand Private m_cmdOpen As ICommand diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml index 28ae79e8..68f3c305 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml @@ -3,7 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating;assembly=EgtWPFLib5" xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5" - xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer"> + xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer" + DataContext="{StaticResource ProjectVM}"> @@ -79,8 +80,8 @@ + DataContext="{StaticResource FreeContourInputVM}" + Visibility="{Binding DataContext.FreeContourManager_Visibility, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:ProjectV}}}"/> BWType.BEAM) + If Not IsNothing(Map.refTopPanelVM) Then + Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> BWType.BEAM) + Else + Map.refProjectVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> BWType.BEAM) + End If Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) - If Not IsNothing(Map.refProdManagerVM.TempCurrProd) Then Map.refProdManagerVM.CurrProd = Map.refProdManagerVM.TempCurrProd - DbControllers.m_ProdController.LockByProdId(Map.refProdManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) - ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel - Map.refCALCPanelVM.LoadMachineList() - End If - If Map.refMainMenuVM.SelPage = Pages.VIEW Then + If Not IsNothing(Map.refProdManagerVM.TempCurrProd) Then + 'Map.refProdManagerVM.CurrProd = Map.refProdManagerVM.TempCurrProd + CurrProd = Map.refProdManagerVM.TempCurrProd + ElseIf Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) Then + 'Map.refFullCompleteManagerVM.CurrProd = Map.refFullCompleteManagerVM.TempCurrProd + CurrProd = Map.refOnlyProdManagerVM.TempCurrProd + End If + 'DbControllers.m_ProdController.LockByProdId(Map.refProdManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + DbControllers.m_ProdController.LockByProdId(CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + End If + If Map.refMainMenuVM.SelPage = Pages.VIEW Then LoadingWndHelper.UpdateLoadingWnd(ActiveIds.OPENPROJ, 3, EgtMsg(63006), 70, 100) ' Loading graphics ' mostro tutti i pezzi Map.refShowBeamPanelVM.ShowAll(True) - ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then ' recupero indice di modifica progetto quando caricato Dim CommIndex As Integer = -1 Dim ActiveSessionList As List(Of StatusMapModel) = DbControllers.m_StatusMapController.GetProd(m_SupervisorId) For Each ActiveSession In ActiveSessionList - If Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso ActiveSession.ItemId = Map.refProdManagerVM.CurrProd.nProdId Then + 'If Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso ActiveSession.ItemId = Map.refProdManagerVM.CurrProd.nProdId Then + If Not IsNothing(CurrProd) AndAlso ActiveSession.ItemId = CurrProd.nProdId Then CommIndex = ActiveSession.Index End If Next @@ -593,9 +617,17 @@ Public Class MySceneHostVM ' carico gruppi di lavorazione Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) ' fisso indice sessione di comunicazione + 'If CommIndex > -1 Then + ' Map.refProdManagerVM.CurrProd.SetModificationIndex(CommIndex) + 'End If If CommIndex > -1 Then - Map.refProdManagerVM.CurrProd.SetModificationIndex(CommIndex) + If Not IsNothing(Map.refProdManagerVM.CurrProd) Then + Map.refProdManagerVM.CurrProd.SetModificationIndex(CommIndex) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then + Map.refOnlyProdManagerVM.CurrProd.SetModificationIndex(CommIndex) + End If End If + ' seleziono primo gruppo If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count > 0 Then Map.refProjectVM.MachGroupPanelVM.SelFirstMachGroup() @@ -616,7 +648,7 @@ Public Class MySceneHostVM If ProjectType = ProjectType.PROD Then Map.refProdManagerVM.m_MruFiles.Remove(sFile) MessageBox.Show(EgtMsg(10003) & " '" & sFile & "'", EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error opening file Map.refProjManagerVM.NewProject() - If Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) End If End If diff --git a/EgtBEAMWALL.ViewerOptimizer/StatisticsTimePanel/StatisticsTimePanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/StatisticsTimePanel/StatisticsTimePanelVM.vb index f8215cb7..caa75b3e 100644 --- a/EgtBEAMWALL.ViewerOptimizer/StatisticsTimePanel/StatisticsTimePanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/StatisticsTimePanel/StatisticsTimePanelVM.vb @@ -17,7 +17,7 @@ Public Class StatisticsTimePanelVM End Property Public ReadOnly Property MachiningPage_Visibility As Visibility Get - Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING, Visibility.Visible, Visibility.Collapsed) + Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) End Get End Property diff --git a/EgtBEAMWALL.ViewerOptimizer/TopPanel/TopPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/TopPanel/TopPanelV.xaml index 38c7e88a..2b617bd5 100644 --- a/EgtBEAMWALL.ViewerOptimizer/TopPanel/TopPanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/TopPanel/TopPanelV.xaml @@ -31,7 +31,7 @@ + HorizontalAlignment="Right"> - - + - + + + + @@ -143,16 +151,16 @@ Margin="5,5,2.5,5"> - + - + @@ -169,7 +177,7 @@ - + @@ -185,27 +193,27 @@ + Tag="{Binding DataContext.MachGroupPanelVM.SelectedMachGroup.SelPart, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdProjectV}}}"/> + Height="3" + HorizontalAlignment="Stretch" + Visibility="{Binding QParSplitter_Visibility}"/> + DataContext="{StaticResource DuploQParameterListVM}" + Tag="{Binding DataContext.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdProjectV}}}"/> + Text="{Binding DataContext.MachGroupPanelVM.SelectedMachGroup.sCALC_MSG, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdProjectV}}}" + Margin="5,0,5,0" + Foreground="{Binding DataContext.MachGroupPanelVM.SelectedMachGroup.Calc_Background, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdProjectV}}}"/> + Text="{Binding DataContext.MachGroupPanelVM.SelectedMachGroup.SelPart.sCALC_MSG, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdProjectV}}}" + Margin="5,0,5,0" + Foreground="{Binding DataContext.MachGroupPanelVM.SelectedMachGroup.SelPart.Calc_Background, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdProjectV}}}"/> + Text="{Binding DataContext.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM.sCALC_MSG, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdProjectV}}}" + Margin="5,0,5,0" + Foreground="{Binding DataContext.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM.Calc_Background, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdProjectV}}}"/> diff --git a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml new file mode 100644 index 00000000..a0c7a695 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml.vb new file mode 100644 index 00000000..6127d0fd --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml.vb @@ -0,0 +1,11 @@ +Public Class OnlyProdOptimizePanelV + + Private Sub OptimizeBtn_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) + Dim OptimizeBtn = TryCast(sender, FrameworkElement) + + If OptimizeBtn IsNot Nothing Then + OptimizeBtn.ContextMenu.IsOpen = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb index 9897a81f..1427c827 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb @@ -113,18 +113,18 @@ Public Class OptimizePanelVM End Property Public ReadOnly Property Optimize_Visibility As Visibility Get - 'Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso - ' (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse - ' (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))), Visibility.Visible, Visibility.Collapsed) + Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso + (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse + (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))), Visibility.Visible, Visibility.Collapsed) - If Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse - (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))) Then - Return Visibility.Visible - ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then - Return Visibility.Visible - End If + 'If Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse + ' (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))) Then + ' Return Visibility.Visible + 'ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' Return Visibility.Visible + 'End If - Return Visibility.Collapsed + 'Return Visibility.Collapsed End Get End Property diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb index 493476e8..53e5fcf0 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb @@ -11,6 +11,18 @@ Public Class ProjectVM Private m_Calc_Timer As New DispatcherTimer + ' Selezione Tab Prod / Proj + Private m_SelProdProj As ProdProj + Public Property SelProdProj As Integer + Get + Return m_SelProdProj + End Get + Set(value As Integer) + m_SelProdProj = value + NotifyPropertyChanged(NameOf(SelProdProj)) + End Set + End Property + Private Property m_GridDims As New ObservableCollection(Of GridDimension) Public Property GridDims As ObservableCollection(Of GridDimension) Get @@ -142,7 +154,7 @@ Public Class ProjectVM End Property Friend Sub SetProjManager_Visibility(IsVisible As Boolean) m_ProjManager_Visibility = IsVisible - Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) + If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) End Sub Private m_ProdManager_Visibility As Boolean = True @@ -156,21 +168,7 @@ Public Class ProjectVM End Property Friend Sub SetProdManager_Visibility(IsVisible As Boolean) m_ProdManager_Visibility = IsVisible - Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.GoToProj_Visibility)) - End Sub - - Private m_OnlyProdManager_Visibility As Boolean = True - Public Property OnlyProdManager_Visibility As Visibility - Get - Return If(m_OnlyProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) - End Get - Set(value As Visibility) - m_OnlyProdManager_Visibility = (value = Visibility.Visible) - End Set - End Property - Friend Sub SetOnlyProdManager_Visibility(IsVisible As Boolean) - m_OnlyProdManager_Visibility = IsVisible - Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) + If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.GoToProj_Visibility)) End Sub Private m_OptimizePanel_Visibility As Boolean = True @@ -212,7 +210,93 @@ Public Class ProjectVM NotifyPropertyChanged("FreeContourManager_Visibility") End Sub -#End Region ' FIELDS & PROPERTIES + ' OnlyProdProject + + Private m_OnlyProdManager_Visibility As Boolean = True + Public Property OnlyProdManager_Visibility As Visibility + Get + Return If(m_OnlyProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OnlyProdManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOnlyProdManager_Visibility(IsVisible As Boolean) + m_OnlyProdManager_Visibility = IsVisible + End Sub + + Private m_OnlyProdLeftPanel_Visibility As Boolean = True + Public Property OnlyProdLeftPanel_Visibility As Visibility + Get + Return If(m_OnlyProdLeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OnlyProdLeftPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOnlyProdLeftPanel_Visibility(IsVisible As Boolean) + m_OnlyProdLeftPanel_Visibility = IsVisible + End Sub + + Private m_OnlyProdOptimizePanel_Visibility As Boolean = True + Public Property OnlyProdOptimizePanel_Visibility As Visibility + Get + Return If(m_OnlyProdOptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OnlyProdOptimizePanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOnlyProdOptimizePanel_Visibility(IsVisible As Boolean) + m_OnlyProdOptimizePanel_Visibility = IsVisible + NotifyPropertyChanged(NameOf(OnlyProdOptimizePanel_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility)) + End Sub + + Private m_CopyFeature_IsEnabled As Boolean = False + Public Property CopyFeature_IsEnabled As Boolean + Get + Return m_CopyFeature_IsEnabled + End Get + Set(value As Boolean) + m_CopyFeature_IsEnabled = value + NotifyPropertyChanged(NameOf(CopyFeature_IsEnabled)) + End Set + End Property + + Private m_MacroFeature_IsEnabled As Boolean = False + Public Property MacroFeature_IsEnabled As Boolean + Get + Return m_MacroFeature_IsEnabled + End Get + Set(value As Boolean) + m_MacroFeature_IsEnabled = value + NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) + End Set + End Property + + ' Definizione Comandi + Private m_cmdCopyFeature As ICommand + Private m_cmdMacroFeature As ICommand + Private m_cmdAddFeature As ICommand + Private m_cmdRemoveFeature As ICommand + Private m_cmdProduceAllRawPart As ICommand + Private m_cmdProduceRawPart As ICommand + Private m_cmdCopyRawPart As ICommand + Private m_cmdRemoveRawPart As ICommand + Private m_cmdRemoveAllRawPart As ICommand + Private m_cmdRemovePart As ICommand + Private m_cmdMoveUpPart As ICommand + Private m_cmdMoveDownPart As ICommand + Private m_cmdReOrderPart As ICommand + Private m_cmdMovePartInRawPart As ICommand + +#End Region ' Fields & Properties #Region "Messages" @@ -282,6 +366,31 @@ Public Class ProjectVM End Get End Property + Public ReadOnly Property CopyFeature_ToolTip As String + Get + Return EgtMsg(61908) + End Get + End Property + + Public ReadOnly Property MacroFeature_ToolTip As String + Get + Return EgtMsg(61909) + End Get + End Property + + Public ReadOnly Property AddFeature_ToolTip As String + Get + Return EgtMsg(61910) + End Get + End Property + + Public ReadOnly Property RemoveFeature_ToolTip As String + Get + Return EgtMsg(61911) + End Get + End Property + + #End Region ' Messages #Region "CONSTRUCTOR" @@ -297,7 +406,7 @@ Public Class ProjectVM DimensionsIniFile.ReadGridDimensions(ProjectGridDim, GridDims) End Sub -#End Region ' CONSTRUCTOR +#End Region ' Constructor #Region "METHODS" @@ -458,7 +567,589 @@ Public Class ProjectVM NotifyCalcPanel_Visibility() End Sub -#End Region ' METHODS +#End Region ' Methods + +#Region "COMMAND" + +#Region "CopyFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property CopyFeature_Command As ICommand + Get + If m_cmdCopyFeature Is Nothing Then + m_cmdCopyFeature = New Command(AddressOf CopyFeature) + End If + Return m_cmdCopyFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub CopyFeature() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart + If IsNothing(SelPart) Then Return + Dim SelFeature As BTLFeatureVM = SelPart.SelBTLFeatureVM + If IsNothing(SelFeature) Then Return + ' creo copia + Dim NewFeature = SelFeature.Copy() + If Not IsNothing(NewFeature) Then + SelPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeature) + EgtDuploSetModified(SelPart.nPartId) + End If + SelPart.ResetCalcPart() + End Sub + +#End Region ' CopyFeature + +#Region "MacroFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MacroFeature_Command As ICommand + Get + If m_cmdMacroFeature Is Nothing Then + m_cmdMacroFeature = New Command(AddressOf MacroFeature) + End If + Return m_cmdMacroFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MacroFeature() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return + ' apro finestra di creazione macro + Dim MacroFeatureWndVM As New MacroFeatureWndVM() + Dim MacroFeatureWnd As New MacroFeatureWndV(Application.Current.MainWindow, MacroFeatureWndVM) + If MacroFeatureWnd.ShowDialog() Then + + End If + End Sub + +#End Region ' MacroFeature + +#Region "AddFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property AddFeature_Command As ICommand + Get + If m_cmdAddFeature Is Nothing Then + m_cmdAddFeature = New Command(AddressOf AddFeature) + End If + Return m_cmdAddFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub AddFeature(ByVal param As Object) + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return + ' apro finestra di definizione nuova feature + Dim AddFeatureWndVM As New AddFeatureWndVM() + Dim AddFeatureWnd As New AddFeatureWndV(Application.Current.MainWindow, AddFeatureWndVM) + If AddFeatureWnd.ShowDialog() Then + Dim NewFeat As BTLFeatureM + Dim nNewFeatureId As Integer = 0 + Dim bMacroFlag As Boolean = False + ' verifico se una Macro è selezionata + If AddFeatureWndVM.MacroList.Count > 0 AndAlso AddFeatureWndVM.nSelMacro >= 0 Then + ' Creo nuova feature sulla base della Macro selezionata + ' Creo table e setto variabili + EgtLuaCreateGlobTable("MACRO") + EgtLuaSetGlobNumVar("MACRO.L", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlL) + EgtLuaSetGlobNumVar("MACRO.W", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW) + EgtLuaSetGlobNumVar("MACRO.H", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH) + EgtLuaSetGlobIntVar("MACRO.PROCID", Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId()) + Dim bOk = EgtLuaExecFile(AddFeatureWndVM.m_MacroFilePathList(AddFeatureWndVM.nSelMacro)) + ' Leggo variabili + EgtLuaGetGlobIntVar("MACRO.FEATUREID", nNewFeatureId) + ' Reset lua + EgtLuaResetGlobVar("MACRO") + If Not bOk Then + MessageBox.Show(EgtMsg(61869), EgtMsg(30007)) + Return + End If + bMacroFlag = True + Else + ' Creo nuova feature (Macro non selezionata) + NewFeat = BTLFeatureM.CreateBTLFeature(AddFeatureWndVM.nSelPRC.nPRC, AddFeatureWndVM.nSelPRC.nGRP, AddFeatureWndVM.nSelPRC.nSIDE) + NewFeat.SetDefaultValues() + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + Dim vParQ() As String = Nothing + NewFeat.CalcParamArray(vPar, sPar, vParQ) + ' aggiorno la feature con nuovo valore + EgtBeamSetPart(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + nNewFeatureId = EgtBeamAddProcess(NewFeat.nSelGRP, NewFeat.nPRC, NewFeat.nSelSIDE, "", + Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId(), + New Frame3d(), vPar, sPar, vParQ, GDB_ID.NULL, GDB_ID.NULL) + bMacroFlag = False + End If + ' se è stata creata + If nNewFeatureId <> GDB_ID.NULL Then + EgtDuploSetModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + ' la aggiungo a struttura BTL corrente + NewFeat = BTLFeatureM.CreateBTLFeature(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM, nNewFeatureId) + If Not bMacroFlag Then NewFeat.SetDefaultValues() + Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.AddBTLFeature(NewFeat) + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeat) + Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() + End If + End If + End Sub + +#End Region ' AddFeature + +#Region "RemoveFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemoveFeature_Command As ICommand + Get + If m_cmdRemoveFeature Is Nothing Then + m_cmdRemoveFeature = New Command(AddressOf RemoveFeature) + End If + Return m_cmdRemoveFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemoveFeature() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then Return + If EgtBeamEraseProcess(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.nFeatureId) Then + EgtDuploSetModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + ' rimuovo dalla lista feature + Dim Index As Integer = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.IndexOf(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) + If Index = 0 Then + If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 0 Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(0) + Else + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing + End If + ElseIf Index = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 1 Then + If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 1 Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 2) + Else + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing + End If + Else + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Index - 1) + End If + Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.RemoveAt(Index) + EgtDraw() + Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() + End If + End Sub + +#End Region ' RemoveFeature + +#Region "ProduceRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ProduceRawPart_Command As ICommand + Get + If m_cmdProduceRawPart Is Nothing Then + m_cmdProduceRawPart = New Command(AddressOf ProduceRawPart) + End If + Return m_cmdProduceRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ProduceRawPart() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + Dim ErrorMsg As String = "" + ' se attiva opzione e non ancora calcolato + If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.NOTCALCULATED Then + Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCE) + Map.refCALCPanelVM.Verify() + Return + End If + If Not Produce(Map.refMachGroupPanelVM.SelectedMachGroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then + MessageBox.Show(ErrorMsg) + End If + End Sub + + Private Function Produce(MachGroup As MyMachGroupVM, ByRef ErrorMsg As String) As Boolean + If IsNothing(MachGroup) Then Return False + ' se barra gia' assegnata a supervisore, esco + If MachGroup.nProduction_State >= ItemState.Assigned Then Return False + If MachGroup.nGlobalState = CalcStates.OK Or MachGroup.nGlobalState = CalcStates.INFO Then + ' se ci sono modifiche, salvo il pogetto + If EgtGetModified() Then + Map.refOnlyProdManagerVM.Save() + End If + ' mando al supervisore + DbControllers.m_MachGroupController.UpdateOrder(Map.refOnlyProdManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_MachGroupController.GetMinIndex(Map.refOnlyProdManagerVM.CurrProd.nProdId) + 1) + DbControllers.m_MachGroupController.UpdateSupervisor(Map.refOnlyProdManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_SupervisorId) + MachGroup.SentToSupervisor() + For Each Part As PartVM In MachGroup.PartVMList + DbControllers.m_PartController.UpdateStatus(Map.refOnlyProdManagerVM.CurrProd.nProdId, MachGroup.Id, Part.nPartId, ItemState.Assigned) + Part.nProduction_State = ItemState.Assigned + Part.NotifyPropertyChanged(NameOf(Part.Background)) + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + ' blocco modifica del pezzo + EgtDuploSetLocked(Part.nPartId) + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + Next + Return True + Else + ErrorMsg = String.Format("Impossible sending {0} to supervisor because not machinable!", MachGroup.Name) + 'MessageBox.Show(String.Format("Impossible sending {0} to supervisor because it is not machinable!", MachGroup.Name)) + Return False + End If + End Function + +#End Region ' ProduceRawPart + +#Region "ProduceAllRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ProduceAllRawPart_Command As ICommand + Get + If m_cmdProduceAllRawPart Is Nothing Then + m_cmdProduceAllRawPart = New Command(AddressOf ProduceAllRawPart) + End If + Return m_cmdProduceAllRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ProduceAllRawPart() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + ' se attiva opzione e non ancora calcolato + If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) x.nProduction_State = ItemState.ND AndAlso x.nGlobalState = CalcStates.NOTCALCULATED) Then + Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCEALL) + Map.refCALCPanelVM.VerifyAll() + Return + End If + If Map.refMachGroupPanelVM.MachGroupVMList.Count > 0 Then + Dim MachgroupErrorList As New List(Of MachGroupVM) + For Each Machgroup In Map.refMachGroupPanelVM.MachGroupVMList + Dim ErrorMsg As String = "" + If Not Produce(Machgroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then + MachgroupErrorList.Add(Machgroup) + End If + Next + If MachgroupErrorList.Count > 0 Then + Dim sMachGroups As String = "" + For Each MachGroup In MachgroupErrorList + sMachGroups &= " " & MachGroup.Name & "," + Next + sMachGroups = sMachGroups.Trim({" "c, ","c}) + MessageBox.Show(String.Format("Impossible sending {0} to supervisor because not machinable!", sMachGroups)) + End If + End If + End Sub + +#End Region ' ProduceAllRawPart + +#Region "CopyRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property CopyRawPart_Command As ICommand + Get + If m_cmdCopyRawPart Is Nothing Then + m_cmdCopyRawPart = New Command(AddressOf CopyRawPart) + End If + Return m_cmdCopyRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub CopyRawPart() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + Dim nQty As Integer = 1 + ' se premuto shift + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + Dim MultiCopyRawPartWndVM As New MultiCopyRawPartWndVM() + Dim MultiCopyRawPartWnd As New MultiCopyRawPartWndV(Application.Current.MainWindow, MultiCopyRawPartWndVM) + If Not MultiCopyRawPartWnd.ShowDialog() Then Return + nQty = MultiCopyRawPartWndVM.nQuantity + End If + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' creo copia + Dim NewMachGroup As MyMachGroupVM = SelMachGroup.Copy(nQty) + If Not IsNothing(NewMachGroup) Then + ' lo seleziono + Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = NewMachGroup + End If + End Sub + +#End Region ' CopyRawPart + +#Region "RemoveRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemoveRawPart_Command As ICommand + Get + If m_cmdRemoveRawPart Is Nothing Then + m_cmdRemoveRawPart = New Command(AddressOf RemoveRawPartCmd) + End If + Return m_cmdRemoveRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemoveRawPartCmd() + RemoveRawPart() + End Sub + + Public Sub RemoveRawPart(Optional bAll As Boolean = False) + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + ' se tutti + If bAll Then + ' cancello tutti + For Index = Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 To 0 Step -1 + Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(Index) + ' se barra gia' assegnata a supervisore, esco + If CurrMachGroup.nProduction_State >= ItemState.Assigned Then Continue For + CurrMachGroup.DeleteMachGroup(True) + Next + Else + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + SelMachGroup.DeleteMachGroup() + End If + EgtDraw() + ' se nessun grezzo, rimetto tutti i pezzi invisibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.HideAll(True) + End If + End Sub + +#End Region ' RemoveRawPart + +#Region "RemoveAllRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemoveAllRawPart_Command As ICommand + Get + If m_cmdRemoveAllRawPart Is Nothing Then + m_cmdRemoveAllRawPart = New Command(AddressOf RemoveAllRawPart) + End If + Return m_cmdRemoveAllRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemoveAllRawPart() + RemoveRawPart(True) + End Sub + +#End Region ' RemoveRawPart + +#Region "RemovePart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemovePart_Command As ICommand + Get + If m_cmdRemovePart Is Nothing Then + m_cmdRemovePart = New Command(AddressOf RemovePart) + End If + Return m_cmdRemovePart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemovePart() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + SelPart.DeletePart() + SelMachGroup.UpdateUsage() + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' RemovePart + +#Region "MoveUpPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MoveUpPart_Command As ICommand + Get + If m_cmdMoveUpPart Is Nothing Then + m_cmdMoveUpPart = New Command(AddressOf MoveUpPart) + End If + Return m_cmdMoveUpPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MoveUpPart() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + If SelMachGroup.nType = MachineType.BEAM Then + SelMachGroup.MoveBeam(SelPart, MoveDirections.UP) + EgtDraw() + ' riseleziono trave + SelMachGroup.SelPart = SelPart + End If + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' MoveUpPart + +#Region "MoveDownPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MoveDownPart_Command As ICommand + Get + If m_cmdMoveDownPart Is Nothing Then + m_cmdMoveDownPart = New Command(AddressOf MoveDownPart) + End If + Return m_cmdMoveDownPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MoveDownPart() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + If SelMachGroup.nType = MachineType.BEAM Then + SelMachGroup.MoveBeam(SelPart, MoveDirections.DOWN) + EgtDraw() + ' riseleziono trave + SelMachGroup.SelPart = SelPart + End If + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' MoveDownPart + +#Region "ReOrderPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ReOrderPart_Command As ICommand + Get + If m_cmdReOrderPart Is Nothing Then + m_cmdReOrderPart = New Command(AddressOf ReOrderPart) + End If + Return m_cmdReOrderPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ReOrderPart() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + If SelMachGroup.nType = MachineType.BEAM Then + SelMachGroup.ReorderBeam() + EgtDraw() + ' riseleziono trave + If Not IsNothing(SelPart) Then + SelMachGroup.SelPart = SelPart + End If + End If + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' ReOrderPart + +#Region "MovePartInRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MovePartInRawPart_Command As ICommand + Get + If m_cmdMovePartInRawPart Is Nothing Then + m_cmdMovePartInRawPart = New Command(AddressOf MovePartInRawPart) + End If + Return m_cmdMovePartInRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MovePartInRawPart() + If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return + Dim MovePartInRawPartWndVM As New MovePartInRawPartWndVM() + Dim MovePartInRawPartWnd As New MovePartInRawPartWndV(Application.Current.MainWindow, MovePartInRawPartWndVM) + If Not MovePartInRawPartWnd.ShowDialog() Then Return + End Sub + +#End Region ' MovePartInRawPart + + +#End Region ' Command End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb index 9fec89cf..22adf72d 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb @@ -154,17 +154,22 @@ Public Class ProdFileVM Directory.Delete(sProjectDirPath, True) Catch ex As Exception End Try - Map.refProdManagerVM.m_MruFiles.Remove(CurrProject.sProdPath) - Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.m_MruFiles.Remove(CurrProject.sProdPath) + Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.m_MruFiles.Remove(CurrProject.sProdPath) + Map.refOnlyProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + End If DbControllers.m_ProdController.DeleteProd(CurrProject.nProdId, False) - If CurrProject.nProdId = Map.refProjManagerVM.CurrProj.nProdId Then + If CurrProject.nProdId = Map.refProjManagerVM.CurrProj.nProdId OrElse CurrProject.nProdId = Map.refOnlyProdManagerVM.CurrProj.nProdId Then ' reset prod in path proj Map.refProjManagerVM.UpdateCurrProj() End If Map.refProdManagerVM.CurrProd = Nothing - EgtResetModified() - Return MessageBoxResult.No - End If + EgtResetModified() + Return MessageBoxResult.No + End If End Select Else EgtResetModified() diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectTypeWnd/ProjectTypeWndVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectTypeWnd/ProjectTypeWndVM.vb index 63c1e102..2e211a36 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjectTypeWnd/ProjectTypeWndVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectTypeWnd/ProjectTypeWndVM.vb @@ -35,8 +35,10 @@ Public Class ProjectTypeWndVM End Property ' Se la Macchina selezionata è di tipo BOTH verrà mostrata anche la selezione del Tipo - Private m_IsBoth_Visibility As Visibility = If(Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso - DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + 'Private m_IsBoth_Visibility As Visibility = If (Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso + ' DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + Private m_IsBoth_Visibility As Visibility = If(Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso + DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH OrElse Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProd), Visibility.Visible, Visibility.Collapsed) Public Property IsBoth_Visibility As Visibility Get Return m_IsBoth_Visibility @@ -57,7 +59,7 @@ Public Class ProjectTypeWndVM End Property ' Se la Macchina selezionata è di tipo BOTH verrà selezionato di default il Tipo del progetto corrente - Private m_nSelType As BWType = If(Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso + Private m_nSelType As BWType = If(Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProj) AndAlso DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, Map.refProjManagerVM.CurrProj.nType, Nothing) Public Property nSelType As BWType Get diff --git a/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb index df7e779b..8ac7c03e 100644 --- a/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb @@ -557,9 +557,9 @@ Public Class MySceneHostVM Map.refCALCPanelVM.LoadMachineList() ElseIf ProjectType = ProjectType.PROD Then ' se salvato, carico progetto in lista mru - If Not IsNothing(Map.refProdManagerVM.TempCurrProd) AndAlso Not Map.refProdManagerVM.TempCurrProd.bIsNew Then + If Not IsNothing(Map.refProdManagerVM) AndAlso Not IsNothing(Map.refProdManagerVM.TempCurrProd) AndAlso Not Map.refProdManagerVM.TempCurrProd.bIsNew Then Map.refProdManagerVM.m_MruFiles.Add(sFile) - ElseIf Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) AndAlso Not Map.refOnlyProdManagerVM.TempCurrProd.bIsNew Then + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) AndAlso Not Map.refOnlyProdManagerVM.TempCurrProd.bIsNew Then Map.refOnlyProdManagerVM.m_MruFiles.Add(sFile) End If ' imposto macchina del progetto @@ -571,9 +571,9 @@ Public Class MySceneHostVM Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine), Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProjManagerVM.CurrProj.sMachine)) ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then - Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refProdManagerVM.TempCurrProd), - Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine), - Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refOnlyProdManagerVM.CurrProd.sMachine)) + Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refOnlyProdManagerVM.CurrProd.sMachine), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine)) End If SectionXMaterial.SetType(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) Core.ViewPanelVM.UpdateBWType(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) @@ -582,16 +582,16 @@ Public Class MySceneHostVM Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) If Not IsNothing(Map.refTopPanelVM) Then Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> BWType.BEAM) - Else - Map.refProjectVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> BWType.BEAM) + 'Else + ' Map.refProjectVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> BWType.BEAM) End If Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) - If Not IsNothing(Map.refProdManagerVM.TempCurrProd) Then - 'Map.refProdManagerVM.CurrProd = Map.refProdManagerVM.TempCurrProd - CurrProd = Map.refProdManagerVM.TempCurrProd - ElseIf Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) Then - 'Map.refFullCompleteManagerVM.CurrProd = Map.refFullCompleteManagerVM.TempCurrProd - CurrProd = Map.refOnlyProdManagerVM.TempCurrProd + If Not IsNothing(Map.refProdManagerVM) AndAlso Not IsNothing(Map.refProdManagerVM.TempCurrProd) Then + 'Map.refProdManagerVM.CurrProd = Map.refProdManagerVM.TempCurrProd + CurrProd = Map.refProdManagerVM.TempCurrProd + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) Then + 'Map.refFullCompleteManagerVM.CurrProd = Map.refFullCompleteManagerVM.TempCurrProd + CurrProd = Map.refOnlyProdManagerVM.TempCurrProd End If 'DbControllers.m_ProdController.LockByProdId(Map.refProdManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) DbControllers.m_ProdController.LockByProdId(CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) @@ -689,7 +689,13 @@ Public Class MySceneHostVM If Not IsNothing(PjFileVM.ProjFileM) AndAlso Not IsNothing(PjFileVM.sProjPath) Then Map.refProjManagerVM.m_MruFiles.Add(PjFileVM.sProjPath) End If End If - If ProjectType = ProjectType.PROD Then Map.refProdManagerVM.m_MruFiles.Add(sFile) + If ProjectType = ProjectType.PROD Then + If Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.m_MruFiles.Add(sFile) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.m_MruFiles.Add(sFile) + End If + End If ' Salvo nome ultimo file WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile) End Sub @@ -737,12 +743,16 @@ Public Class MySceneHostVM ' scrivo info proj e type su layer BtlInfo Dim nBTLInfoLayer As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) - EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, Map.refProjManagerVM.CurrProj.nType) + If Not IsNothing(Map.refProjManagerVM.CurrProj) Then + EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, Map.refProjManagerVM.CurrProj.nType) + Else + EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, Map.refOnlyProdManagerVM.CurrProd.nType) + End If ' scrivo info proj su layer AsseBase Dim nAsseBaseLayer As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) - EgtSetInfo(nAsseBaseLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) - Else - Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file + EgtSetInfo(nAsseBaseLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) + Else + Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error Map.refProjManagerVM.NewProject() End If diff --git a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb index c1b7a909..33995a19 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb @@ -170,7 +170,7 @@ Public Class ShowBeamPanelVM Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.NULL) Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) ' mostro in parte bassa dati BTL - Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STRUCTURE_) + If Not IsNothing(Map.refBottomPanelVM) Then Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STRUCTURE_) ' mostro tutti i pezzi Map.refProjectVM.BTLStructureVM.ShowAll(False) ' deseleziono tutto From 91d943d0a701c4ad3742937b1f2bddf0fea28ab5 Mon Sep 17 00:00:00 2001 From: Demetrio Cassarino Date: Mon, 30 Oct 2023 12:28:58 +0100 Subject: [PATCH 03/30] Aggiunta tab vuoto a tab prod/proj e controllo pulsanti --- EgtBEAMWALL.Core/Constants/ConstGen.vb | 5 +- .../ItemParamList/BTLPartListV.xaml.vb | 2 + .../MachGroupPanel/MyMachGroupVM.vb | 6 +- .../OnlyProdManager/OnlyProdManagerVM.vb | 190 ++++++++++-------- .../OnlyProdProject/OnlyProdProjectV.xaml | 1 + .../Project/ProjectVM.vb | 6 +- .../ProjectFileVM/ProdFileVM.vb | 22 +- .../ProjectFileVM/ProjFileVM.vb | 25 ++- .../SceneHost/MySceneHostVM.vb | 48 +++-- .../Utility/LuaExec.vb | 6 +- 10 files changed, 187 insertions(+), 124 deletions(-) diff --git a/EgtBEAMWALL.Core/Constants/ConstGen.vb b/EgtBEAMWALL.Core/Constants/ConstGen.vb index aadcd7d3..3cb0d9a2 100644 --- a/EgtBEAMWALL.Core/Constants/ConstGen.vb +++ b/EgtBEAMWALL.Core/Constants/ConstGen.vb @@ -48,8 +48,9 @@ Public Module ConstGen ' Selezione Tab Prod / Proj Public Enum ProdProj As Integer - PROJ = 0 - PROD = 1 + NULL = 0 + PROJ = 1 + PROD = 2 End Enum ' File di log generale diff --git a/EgtBEAMWALL.ViewerOptimizer/ItemParamList/BTLPartListV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/ItemParamList/BTLPartListV.xaml.vb index 8f40ee05..9e6a9191 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ItemParamList/BTLPartListV.xaml.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ItemParamList/BTLPartListV.xaml.vb @@ -1,4 +1,5 @@ Imports System.Reflection +Imports EgtBEAMWALL.Core.ConstGen Public Class BTLPartListV @@ -46,6 +47,7 @@ Public Class BTLPartListV e.Handled = True ElseIf e.ChangedButton = m_HighlightBtn Then Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT) + Map.refProjectVM.SelProdProj = ProdProj.NULL End If End If 'If e.ChangedButton = Input.MouseButton.Left Then diff --git a/EgtBEAMWALL.ViewerOptimizer/MachGroupPanel/MyMachGroupVM.vb b/EgtBEAMWALL.ViewerOptimizer/MachGroupPanel/MyMachGroupVM.vb index 161e2aad..54c94e11 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MachGroupPanel/MyMachGroupVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/MachGroupPanel/MyMachGroupVM.vb @@ -369,7 +369,11 @@ Public Class MyMachGroupVM Dim sCurrMachGroupName As String = "" EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName) ' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione - EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, Map.refProdManagerVM.CurrProd.nProdId) + If Not IsNothing(Map.refProdManagerVM) Then + EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, Map.refProdManagerVM.CurrProd.nProdId) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, Map.refOnlyProdManagerVM.CurrProd.nProdId) + End If EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, sMATERIAL) EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup) ' scrivo dati costruzione grezzo in gruppo di lavorazione diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb index 31cd2d83..f101918f 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb @@ -316,7 +316,7 @@ Public Class OnlyProdManagerVM If Not m_bOpenProj Then Return m_bOpenProj = False Select Case Map.refMainMenuVM.SelPage - Case Pages.MACHINING + Case Pages.MACHINING OrElse Pages.ONLYPRODPAGE ' recupero progetto da Id Dim DbProject As ProdFileM DbProject = DbControllers.m_ProdController.FindCoreByProdId(m_nProjIdToOpen) @@ -349,6 +349,94 @@ Public Class OnlyProdManagerVM m_nProjIdToOpen = GDB_ID.NULL End Sub + Private Sub InitProd() + ' inizializzo nuovo progetto PROD + Dim nProdId As Integer = 0 + Dim sProdDir As String = "" + InitNewProjectPROD(m_CurrProj.nProjId, nProdId, sProdDir) + ' setto il PType del Prod + DbControllers.m_ProdController.UpdatePType(nProdId, CurrProj.nType) + ' setto la Macchina associata al Prod + DbControllers.m_ProdController.UpdateMachine(nProdId, CurrProj.sMachine) + ' copio file progetto + Dim sProjPath As String = String.Empty + Dim bOk = False + Dim sProdPath As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" + If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then + Try + File.Copy(sProjPath, sProdPath) + 'Map.refSceneHostVM.MainController.OpenProject(sProdPath) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + End If + If bOk Then + ' aggiorno path proj + Map.refOnlyProdManagerVM.UpdateCurrProj() + ' imposto currprod + Map.refOnlyProdManagerVM.SetCurrProd(nProdId) + ' imposto TempCurrProd + Map.refOnlyProdManagerVM.TempCurrProd = Map.refOnlyProdManagerVM.CurrProd + ' setto flag nuovo progetto in prod + Map.refOnlyProdManagerVM.CurrProd.bIsNew = True + Else + ' elimino da DB + DbControllers.m_ProdController.DeleteProd(nProdId, True) + End If + End Sub + + Private Sub ManageImportLog(nProjId As Integer, sProjDir As String) + Dim LogFile As New List(Of String) + Using FileStream As FileStream = New FileStream(Map.refMainWindowVM.MainWindowM.sLogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) + Dim StreamReader As New StreamReader(FileStream) + Dim Line As String = StreamReader.ReadLine() + While Not StreamReader.EndOfStream + Line = StreamReader.ReadLine() + LogFile.Add(Line) + End While + StreamReader.Close() + End Using + If LogFile.Count > 0 Then + ' recupero ultima occorrenza di import + Dim sLastImport As String = LogFile.LastOrDefault(Function(x) x.Contains("ImportBtl")) + ' verifico linee successive + Dim nLastImportIndex As Integer = -1 + If Not String.IsNullOrWhiteSpace(sLastImport) Then + nLastImportIndex = LogFile.IndexOf(sLastImport) + End If + Dim sImportMessage As String = sLastImport & Environment.NewLine + Dim sImportLog As New List(Of String)({sLastImport}) + If nLastImportIndex > 0 Then + Dim bGlobalError As Boolean = False + ' ciclo sulle righe successive + For Index = nLastImportIndex + 1 To LogFile.Count - 1 + Dim sLogLine As String = LogFile(Index).Trim() + ' verifico se fanno parte dell'import + Dim bStartWithError As Boolean = sLogLine.StartsWith("Error") + Dim bStartWithInfo As Boolean = sLogLine.StartsWith("Info") + If Not bStartWithError And Not bStartWithInfo Then Exit For + If bStartWithError Then + If Not bGlobalError Then bGlobalError = True + sImportMessage &= sLogLine & Environment.NewLine + End If + sImportLog.Add(sLogLine) + Next + ' salvo file ImportLog nel progetto + Try + File.WriteAllLines(sProjDir & "\" & nProjId.ToString("0000") & "-ImportLog.txt", sImportLog) + Catch ex As Exception + ' + End Try + ' se almeno un errore, mostro log + If bGlobalError Then + MessageBox.Show(Application.Current.MainWindow, sImportMessage, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + End If + End If + End If + End Sub + #End Region ' Methods #Region "COMMANDS" @@ -423,42 +511,8 @@ Public Class OnlyProdManagerVM SetCurrProj(nProjId) End If Map.refProjectVM.SetOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) - ' inizializzo nuovo progetto PROD - Dim nProdId As Integer = 0 - Dim sProdDir As String = "" - InitNewProjectPROD(m_CurrProj.nProjId, nProdId, sProdDir) - ' setto il PType del Prod - DbControllers.m_ProdController.UpdatePType(nProdId, CurrProj.nType) - ' setto la Macchina associata al Prod - DbControllers.m_ProdController.UpdateMachine(nProdId, CurrProj.sMachine) - ' copio file progetto - Dim sProjPath As String = String.Empty - Dim bOk = False - Dim sProdPath As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" - If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then - Try - File.Copy(sProjPath, sProdPath) - 'Map.refSceneHostVM.MainController.OpenProject(sProdPath) - bOk = True - Catch ex As Exception - EgtOutLog("Impossibile copiare il file") - bOk = False - End Try - End If - If bOk Then - ' aggiorno path proj - Map.refOnlyProdManagerVM.UpdateCurrProj() - ' imposto currprod - Map.refOnlyProdManagerVM.SetCurrProd(nProdId) - ' imposto TempCurrProd - Map.refOnlyProdManagerVM.TempCurrProd = Map.refOnlyProdManagerVM.CurrProd - ' setto flag nuovo progetto in prod - Map.refOnlyProdManagerVM.CurrProd.bIsNew = True - Else - ' elimino da DB - DbControllers.m_ProdController.DeleteProd(nProdId, True) - End If + InitProd() Else MessageBox.Show(EgtMsg(61876)) End If @@ -781,6 +835,8 @@ Public Class OnlyProdManagerVM ' CheckMe impostata come cancellazione FISICA dal DB... DbControllers.m_ProjController.DeleteProj(nProjId, False) End If + ' inizializzo nuovo progetto PROD + InitProd() ' carico filtri di ricerca Map.refProjectVM.BTLStructureVM.LoadFilters() ' gestisco log di importazione @@ -790,56 +846,6 @@ Public Class OnlyProdManagerVM LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL) End Sub - Private Sub ManageImportLog(nProjId As Integer, sProjDir As String) - Dim LogFile As New List(Of String) - Using FileStream As FileStream = New FileStream(Map.refMainWindowVM.MainWindowM.sLogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) - Dim StreamReader As New StreamReader(FileStream) - Dim Line As String = StreamReader.ReadLine() - While Not StreamReader.EndOfStream - Line = StreamReader.ReadLine() - LogFile.Add(Line) - End While - StreamReader.Close() - End Using - If LogFile.Count > 0 Then - ' recupero ultima occorrenza di import - Dim sLastImport As String = LogFile.LastOrDefault(Function(x) x.Contains("ImportBtl")) - ' verifico linee successive - Dim nLastImportIndex As Integer = -1 - If Not String.IsNullOrWhiteSpace(sLastImport) Then - nLastImportIndex = LogFile.IndexOf(sLastImport) - End If - Dim sImportMessage As String = sLastImport & Environment.NewLine - Dim sImportLog As New List(Of String)({sLastImport}) - If nLastImportIndex > 0 Then - Dim bGlobalError As Boolean = False - ' ciclo sulle righe successive - For Index = nLastImportIndex + 1 To LogFile.Count - 1 - Dim sLogLine As String = LogFile(Index).Trim() - ' verifico se fanno parte dell'import - Dim bStartWithError As Boolean = sLogLine.StartsWith("Error") - Dim bStartWithInfo As Boolean = sLogLine.StartsWith("Info") - If Not bStartWithError And Not bStartWithInfo Then Exit For - If bStartWithError Then - If Not bGlobalError Then bGlobalError = True - sImportMessage &= sLogLine & Environment.NewLine - End If - sImportLog.Add(sLogLine) - Next - ' salvo file ImportLog nel progetto - Try - File.WriteAllLines(sProjDir & "\" & nProjId.ToString("0000") & "-ImportLog.txt", sImportLog) - Catch ex As Exception - ' - End Try - ' se almeno un errore, mostro log - If bGlobalError Then - MessageBox.Show(Application.Current.MainWindow, sImportMessage, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error - End If - End If - End If - End Sub - #End Region ' ImportBTL #Region "UpdateBTL" @@ -1658,7 +1664,11 @@ Public Class OnlyProdManagerVM nDuploId = EgtGetNext(nDuploId) End While ' resetto CurrProd per evitare di leggere valori produzione dal Db di quel progetto - Map.refProdManagerVM.CurrProd = Nothing + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.CurrProd = Nothing + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.CurrProd = Nothing + End If ' carico Machgroup che non verrebbero altrimenti importati Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count > 0 Then @@ -1737,7 +1747,11 @@ Public Class OnlyProdManagerVM OpenProject(CurrProd) ' Da controllare End If ' ripristino eventuale CurrProd precedente - Map.refProdManagerVM.CurrProd = CurrProd + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.CurrProd = CurrProd + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.CurrProd = CurrProd + End If WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEXPDIR, Path.GetDirectoryName(ImportDlg.FileName)) LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) End Sub diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml index f48ca579..358e16d2 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml @@ -76,6 +76,7 @@ + diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb index 53e5fcf0..084ceb91 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb @@ -421,9 +421,9 @@ Public Class ProjectVM Map.refMainMenuVM.SetMainMenuIsEnabled(bIsEnabled) Map.refPartManagerVM.SetPartManagerIsEnabled(bIsEnabled) Map.refLeftPanelVM.SetLeftPanelIsEnabled(bIsEnabled) - Map.refProjManagerVM.SetProjManagerIsEnabled(bIsEnabled) - Map.refProdManagerVM.SetProdManagerIsEnabled(bIsEnabled) - Map.refTopPanelVM.SetTopPanelIsEnabled(bIsEnabled) + If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.SetProjManagerIsEnabled(bIsEnabled) + If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.SetProdManagerIsEnabled(bIsEnabled) + If Not IsNothing(Map.refTopPanelVM) Then Map.refTopPanelVM.SetTopPanelIsEnabled(bIsEnabled) Map.refOptimizePanelVM.SetOptimizePanelIsEnabled(bIsEnabled) Map.refFeatureManagerVM.SetFeatureManagerIsEnabled(bIsEnabled) End Sub diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb index 22adf72d..a60bcc93 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb @@ -2,6 +2,7 @@ Imports EgtBEAMWALL.Core Imports EgtUILib Imports EgtWPFLib5 +Imports Org.BouncyCastle.Crypto.Engines Public Class ProdFileVM Inherits Core.ProdFileVM @@ -142,7 +143,11 @@ Public Class ProdFileVM Select Case VerifyResult Case MessageBoxResult.Yes ' salvo proj - Map.refProdManagerVM.Save() + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.Save() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.Save() + End If Case MessageBoxResult.Cancel Return MessageBoxResult.Cancel Case Else ' No @@ -162,14 +167,21 @@ Public Class ProdFileVM Map.refOnlyProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) End If DbControllers.m_ProdController.DeleteProd(CurrProject.nProdId, False) - If CurrProject.nProdId = Map.refProjManagerVM.CurrProj.nProdId OrElse CurrProject.nProdId = Map.refOnlyProdManagerVM.CurrProj.nProdId Then + If Not IsNothing(Map.refProjManagerVM) AndAlso CurrProject.nProdId = Map.refProjManagerVM.CurrProj.nProdId Then ' reset prod in path proj Map.refProjManagerVM.UpdateCurrProj() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso CurrProject.nProdId = Map.refOnlyProdManagerVM.CurrProj.nProdId Then + ' reset prod in path proj + Map.refOnlyProdManagerVM.UpdateCurrProj() End If - Map.refProdManagerVM.CurrProd = Nothing - EgtResetModified() - Return MessageBoxResult.No + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.CurrProd = Nothing + 'ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + ' Map.refOnlyProdManagerVM.CurrProd = Nothing End If + EgtResetModified() + Return MessageBoxResult.No + End If End Select Else EgtResetModified() diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProjFileVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProjFileVM.vb index 68cc9840..ddf43503 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProjFileVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProjFileVM.vb @@ -128,7 +128,11 @@ Public Class ProjFileVM Select Case MessageBox.Show(EgtMsg(61875), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) Case MessageBoxResult.Yes ' salvo proj - Map.refProjManagerVM.Save() + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.Save() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.Save() + End If Map.refCALCPanelVM.IsMachineApplied = False Case MessageBoxResult.Cancel Return False @@ -141,12 +145,21 @@ Public Class ProjFileVM If Directory.Exists(sProjectDirPath) Then Directory.Delete(sProjectDirPath, True) End If - Map.refProjManagerVM.m_MruFiles.Remove(CurrProject.sProjPath) - Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.m_MruFiles.Remove(CurrProject.sProjPath) + Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.m_MruFiles.Remove(CurrProject.sProjPath) + Map.refOnlyProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + End If - ' CheckMe impostata come cancellazione FISICA dal DB... - DbControllers.m_ProjController.DeleteProj(CurrProject.nProjId, False) - Map.refProjManagerVM.CurrProj = Nothing + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(CurrProject.nProjId, False) + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.CurrProj = Nothing + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.CurrProj = Nothing + End If EgtResetModified() Return True End If diff --git a/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb index 8ac7c03e..d50a1007 100644 --- a/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb @@ -290,7 +290,7 @@ Public Class MySceneHostVM Case Pages.VIEW If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then If Map.refFreeContourManagerVM.bIsActive AndAlso - ( Map.refFreeContourManagerVM.SelType = FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES Or + (Map.refFreeContourManagerVM.SelType = FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES Or Map.refFreeContourManagerVM.bIsOpeningCurveCompo) Then ' passo entità selezionata Map.refFreeContourManagerVM.OnMouseSelectedObj(EgtGetFirstSelectedObj(), True) @@ -572,8 +572,8 @@ Public Class MySceneHostVM Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProjManagerVM.CurrProj.sMachine)) ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd), - Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refOnlyProdManagerVM.CurrProd.sMachine), - Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine)) + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refOnlyProdManagerVM.TempCurrProd.sMachine), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refOnlyProdManagerVM.CurrProd.sMachine)) End If SectionXMaterial.SetType(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) Core.ViewPanelVM.UpdateBWType(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) @@ -592,13 +592,13 @@ Public Class MySceneHostVM ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) Then 'Map.refFullCompleteManagerVM.CurrProd = Map.refFullCompleteManagerVM.TempCurrProd CurrProd = Map.refOnlyProdManagerVM.TempCurrProd - End If - 'DbControllers.m_ProdController.LockByProdId(Map.refProdManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) - DbControllers.m_ProdController.LockByProdId(CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) - ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel - Map.refCALCPanelVM.LoadMachineList() End If - If Map.refMainMenuVM.SelPage = Pages.VIEW Then + 'DbControllers.m_ProdController.LockByProdId(Map.refProdManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + DbControllers.m_ProdController.LockByProdId(CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + End If + If Map.refMainMenuVM.SelPage = Pages.VIEW Then LoadingWndHelper.UpdateLoadingWnd(ActiveIds.OPENPROJ, 3, EgtMsg(63006), 70, 100) ' Loading graphics ' mostro tutti i pezzi Map.refShowBeamPanelVM.ShowAll(True) @@ -703,7 +703,7 @@ Public Class MySceneHostVM Private Sub OnImportingProject(sender As Object, nType As Integer, ByRef nFlag As Integer) If nType = FT.BTL Or nType = FT.BTLX Then Dim sBTLFlag As String - If Map.refProjManagerVM.nProjType = Core.ConstBeam.BWType.BEAM Then + If Not IsNothing(Map.refProjManagerVM) AndAlso Map.refProjManagerVM.nProjType = Core.ConstBeam.BWType.BEAM OrElse Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Map.refOnlyProdManagerVM.nProjType = Core.ConstBeam.BWType.BEAM Then sBTLFlag = K_BTLFLAG Else sBTLFlag = K_WALLBTLFLAG @@ -723,7 +723,11 @@ Public Class MySceneHostVM Dim nPartId As Integer = EgtGetFirstPart() While nPartId <> GDB_ID.NULL ' scrivo in ogni pezzo ProjId - EgtSetInfo(nPartId, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) + If Not IsNothing(Map.refProjManagerVM) Then + EgtSetInfo(nPartId, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + EgtSetInfo(nPartId, BTL_PRT_PROJ, Map.refOnlyProdManagerVM.nLoadingProjId) + End If nPartId = EgtGetNextPart(nPartId) ' scrivo Id negli outline Dim nPRId As Integer = 1 @@ -742,21 +746,29 @@ Public Class MySceneHostVM End While ' scrivo info proj e type su layer BtlInfo Dim nBTLInfoLayer As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) - EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) - If Not IsNothing(Map.refProjManagerVM.CurrProj) Then + If Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(Map.refProjManagerVM.CurrProj) Then + EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, Map.refProjManagerVM.CurrProj.nType) - Else + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProj) Then + EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, Map.refOnlyProdManagerVM.nLoadingProjId) EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, Map.refOnlyProdManagerVM.CurrProd.nType) End If ' scrivo info proj su layer AsseBase Dim nAsseBaseLayer As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + If Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(Map.refProjManagerVM.CurrProj) Then EgtSetInfo(nAsseBaseLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) - Else - Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProj) Then + EgtSetInfo(nAsseBaseLayer, BTL_PRT_PROJ, Map.refOnlyProdManagerVM.nLoadingProjId) + End If + Else + Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error - Map.refProjManagerVM.NewProject() + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.NewProject() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.NewProject() + End If End If - MainScene.SetStatusNull() End Sub diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/LuaExec.vb b/EgtBEAMWALL.ViewerOptimizer/Utility/LuaExec.vb index a8e3328c..9ed55b5a 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Utility/LuaExec.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/LuaExec.vb @@ -118,7 +118,11 @@ Module LuaExec EgtLuaSetGlobNumVar("NEST.CORNER", nNestCorner) EgtLuaSetGlobStringVar("NEST.MATERIAL", PartList(0).sMATERIAL) EgtLuaSetGlobNumVar("NEST.TIME", nNestTime) - EgtLuaSetGlobNumVar("NEST.PRODID", Map.refProdManagerVM.CurrProd.nProdId) + If Not IsNothing(Map.refProdManagerVM) AndAlso Not IsNothing(Map.refProdManagerVM.CurrProd) Then + EgtLuaSetGlobNumVar("NEST.PRODID", Map.refProdManagerVM.CurrProd.nProdId) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then + EgtLuaSetGlobNumVar("NEST.PRODID", Map.refOnlyProdManagerVM.CurrProd.nProdId) + End If EgtLuaCreateGlobTable("PART") For PartIndex = 0 To PartList.Count - 1 EgtLuaSetGlobIntVar("PART." & PartList(PartIndex).nPartId.ToString(), PartList(PartIndex).m_nCNT + PartList(PartIndex).m_nADDED - PartList(PartIndex).nINPROD) From 2c3e3f74f97d3c343e35c791096a93e1c1e25e0c Mon Sep 17 00:00:00 2001 From: Demetrio Cassarino Date: Mon, 6 Nov 2023 16:48:49 +0100 Subject: [PATCH 04/30] Modifica pagina onlyprod --- .../MainMenu/MainMenuVM.vb | 12 ++----- .../OnlyProdManager/OnlyProdManagerVM.vb | 8 +++-- .../OnlyProdProject/OnlyProdProjectV.xaml | 32 +++++++++---------- .../ShowBeamPanel/ShowBeamPanelVM.vb | 2 +- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb b/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb index 8e39ae00..5f8b2911 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb @@ -64,13 +64,7 @@ Public Class MainMenuVM Return m_SelPage = Pages.ONLYPRODPAGE End Get Set(value As Boolean) - If value Then - If Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso - Map.refProjManagerVM.CurrProj.nProdId = Map.refProdManagerVM.CurrProd.nProdId Then - Map.refProdManagerVM.CurrProd.SetReloadProject(False) - End If - SelPage = Pages.ONLYPRODPAGE - End If + If value Then SelPage = Pages.ONLYPRODPAGE End Set End Property @@ -541,7 +535,7 @@ Public Class MainMenuVM If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) - Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE <> BWType.BEAM) + If Not IsNothing(Map.refTopPanelVM) Then Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE <> BWType.BEAM) Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) Else Map.refRawPartListVM.UpdateColumns(BWType.BEAM) @@ -695,7 +689,7 @@ Public Class MainMenuVM Private Function ExitONLYPRODPAGE(bVerifyModification As Boolean) As Boolean ' verifico se progetto modificato, e chiedo se salvare If bVerifyModification Then - If ProdFileVM.VerifyProjectModification(Map.refProdManagerVM.CurrProd) = MessageBoxResult.Cancel Then + If ProdFileVM.VerifyProjectModification(Map.refOnlyProdManagerVM.CurrProd) = MessageBoxResult.Cancel Then Return False End If End If diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb index f101918f..039ff8f9 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb @@ -657,7 +657,7 @@ Public Class OnlyProdManagerVM DbControllers.m_ProjController.UpdateMachine(ProjId, Map.refCALCPanelVM.SelectedMachine.Name) ' se uno dei Proj interessati equivale al Proj correntemente aperto setto la Macchina dello stesso ' (poichè il progetto corrente non viene riaperto e riletto dal DB) - If ProjId = Map.refProjManagerVM.CurrProj.nProjId Then Map.refProjManagerVM.CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + If ProjId = Map.refOnlyProdManagerVM.CurrProj.nProjId Then Map.refOnlyProdManagerVM.CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) Next Map.refCALCPanelVM.ResetMachineModified() End If @@ -1675,7 +1675,11 @@ Public Class OnlyProdManagerVM ' inizializzo nuovo progetto PROD Dim nProdId As Integer = 0 Dim sProdDir As String = "" - Map.refProdManagerVM.InitNewProject(NewProjIdList(0), nProdId, sProdDir) + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.InitNewProject(NewProjIdList(0), nProdId, sProdDir) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.InitNewProjectPROD(NewProjIdList(0), nProdId, sProdDir) + End If ' setto il PType del Prod DbControllers.m_ProdController.UpdatePType(nProdId, nType) ' setto la Macchina associata al Prod diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml index 358e16d2..9a3d392e 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml @@ -102,31 +102,31 @@ diff --git a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb index 33995a19..e14b5d43 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb @@ -176,7 +176,7 @@ Public Class ShowBeamPanelVM ' deseleziono tutto Map.refProjectVM.BTLStructureVM.SelBTLParts.Clear() ' se attivata opzione, li assemblo - Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW, ShowBuilding_IsChecked, False), False) + Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, ShowBuilding_IsChecked, False), False) If bDraw Then EgtDraw() End Sub From 5017e96cde8a64d32eff67b6c49f2f9149111b90 Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Thu, 9 Nov 2023 08:28:55 +0100 Subject: [PATCH 05/30] - correzioni ProjectManager - correzioni selezione pezzi e machgroup --- .../BTLViewModel/BTLStructureVM.vb | 135 ++++++++++++-- .../ItemParamList/BTLPartListV.xaml.vb | 2 + .../LeftPanel/LeftPanelVM.vb | 4 +- .../LeftPanel/OnlyProdLeftPanelV.xaml | 10 -- .../MachGroupPanel/MyMachGroupPanelVM.vb | 2 + .../MainMenu/MainMenuVM.vb | 2 +- .../MainWindow/MainWindowVM.vb | 6 +- .../OnlyProdManager/OnlyProdManagerVM.vb | 164 +++++++++++------- .../Project/ProjectVM.vb | 23 ++- .../SceneHost/MySceneHostVM.vb | 19 +- 10 files changed, 253 insertions(+), 114 deletions(-) diff --git a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb index 48f6b7da..af962d09 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb @@ -66,8 +66,12 @@ Public Class BTLStructureVM End Get End Property Friend Sub SetSelectionType(value As SelectionTypes) + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If m_PrevSelectionType = m_SelectionType - If value = m_SelectionType Then Return + If value = m_SelectionType And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART Then Return m_SelectionType = value Select Case m_SelectionType Case SelectionTypes.SELECT_ @@ -91,7 +95,7 @@ Public Class BTLStructureVM ' mostro pezzi selezionati Map.refProjectVM.BTLStructureVM.ShowAll(False) ' se attivata opzione, li assemblo - Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW, Map.refShowBeamPanelVM.ShowBuilding_IsChecked, False), False) + Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Map.refShowBeamPanelVM.ShowBuilding_IsChecked, False), False) ' nascondo barra di gestione pezzo Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) End Select @@ -149,11 +153,15 @@ Public Class BTLStructureVM End Sub Private Sub SelBTLParts_CollectionChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If If m_bOnlySelectItem Then Return Select Case e.Action Case NotifyCollectionChangedAction.Add If e.NewItems.Count > 0 AndAlso Not IsNothing(e.NewItems(0)) Then - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso m_SelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso m_SelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso m_SelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then SelectBTLPart(e.NewItems(0)) Else ' SelectionTypes.HIGHLIGHT HighlightBTLPart(e.NewItems(0)) @@ -161,14 +169,14 @@ Public Class BTLStructureVM End If Case NotifyCollectionChangedAction.Remove If e.OldItems.Count > 0 AndAlso Not IsNothing(e.OldItems(0)) Then - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then DeselectBTLPart(e.OldItems(0)) Else ' SelectionTypes.HIGHLIGHT DeHighlightBTLPart(e.OldItems(0)) End If End If Case NotifyCollectionChangedAction.Reset - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then If Not IsNothing(m_SelBTLPart) Then DeselectBTLPart(m_SelBTLPart) End If @@ -185,10 +193,10 @@ Public Class BTLStructureVM End Sub Private Sub SelectBTLPart(BtlPart As BTLPartVM) - EgtBeamShowFacesName(False) - EgtBeamShowLoadingSide(False, False) m_SelBTLPart = BtlPart - If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) Map.refProjectVM.MacroFeature_IsEnabled = True ' se modalità building, la tolgo If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then @@ -210,13 +218,15 @@ Public Class BTLStructureVM 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) ' deseleziono le feature If Not IsNothing(BtlPart.SelBTLFeatureVM) Then SelBTLPart.SelBTLFeatureVM = Nothing - ' aggiorno stato selezionato tutto - Map.refShowBeamPanelVM.bShowAll = False - Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) - EgtZoom(ZM.ALL) - ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then - ' resetto gruppo di lavorazione corrente - EgtResetCurrMachGroup() + ' aggiorno stato selezionato tutto + Map.refShowBeamPanelVM.bShowAll = False + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) ' trovo ed evidenzio MachGroup e Duplo di questo pezzo If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then Dim MachGroupList As New List(Of MyMachGroupVM) @@ -241,6 +251,52 @@ Public Class BTLStructureVM SceneSelPartSelection() Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) EgtZoom(ZM.ALL) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) + Map.refProjectVM.MacroFeature_IsEnabled = True + ' se modalità building, la tolgo + If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + ShowBuilding(False, False) + End If + ' seleziono pezzo nella scena + SceneSelPartSelection() + ' seleziono pezzo in Db geometrico + EgtBeamSetPart(BtlPart.nPartId) + EgtBeamShowFacesName(True) + Dim bLoadingSideShow As Boolean = (nPROJTYPE = BWType.BEAM) + Dim bLeftToRight As Boolean = Not (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) + EgtBeamShowLoadingSide(bLoadingSideShow, bLeftToRight) + ' deseleziono le feature + If Not IsNothing(BtlPart.SelBTLFeatureVM) Then SelBTLPart.SelBTLFeatureVM = Nothing + ' aggiorno stato selezionato tutto + Map.refShowBeamPanelVM.bShowAll = False + ' trovo ed evidenzio MachGroup e Duplo di questo pezzo + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + Dim MachGroupList As New List(Of MyMachGroupVM) + For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + Dim bFound As Boolean = False + For Each Part As PartVM In Machgroup.PartVMList + If EgtDuploGetOriginal(Part.nPartId) = BtlPart.nPartId Then + Part.SetSearchFound() + bFound = True + Else + Part.ResetSearchFound() + End If + Next + If bFound Then + Machgroup.SetSearchFound() + Else + Machgroup.ResetSearchFound() + End If + Next + End If + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) End If NotifyPropertyChanged(NameOf(SelBTLPart)) End Sub @@ -278,7 +334,7 @@ Public Class BTLStructureVM End While End If ' seleziono pagina BottomPanel - Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.NULL) + If Not IsNothing(Map.refBottomPanelVM) Then Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.NULL) EgtDraw() End Sub Private Sub DeHighlightBTLPart(BtlPart As BTLPartVM, Optional bDraw As Boolean = True) @@ -314,6 +370,10 @@ Public Class BTLStructureVM Return m_SelBTLPart End Get Set(value As BTLPartVM) + If Map.refMainMenuVM.SelPage = Pages.MACHINING Or (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If If Not IsNothing(m_SelBTLPart) Then ' se necessario tolgo solido dal precedentemente selezionato If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then @@ -345,8 +405,6 @@ Public Class BTLStructureVM Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) EgtZoom(ZM.ALL) ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then - ' resetto gruppo di lavorazione corrente - EgtResetCurrMachGroup() ' trovo ed evidenzio MachGroup e Duplo di questo pezzo If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then Dim MachGroupList As New List(Of MyMachGroupVM) @@ -371,6 +429,45 @@ Public Class BTLStructureVM SceneSelPartSelection() Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) EgtZoom(ZM.ALL) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' se modalità building, la tolgo + If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + ShowBuilding(False, False) + End If + ' seleziono pezzo nella scena + SceneSelPartSelection() + ' seleziono pezzo in Db geometrico + EgtBeamSetPart(m_SelBTLPart.nPartId) + ' seleziono pagina BottomPanel + Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.PART) + ' mostro barra di gestione pezzo + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + ' deseleziono le feature + If Not IsNothing(m_SelBTLPart.SelBTLFeatureVM) Then SelBTLPart.SelBTLFeatureVM = Nothing + ' aggiorno stato selezionato tutto + Map.refShowBeamPanelVM.bShowAll = False + ' trovo ed evidenzio MachGroup e Duplo di questo pezzo + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + Dim MachGroupList As New List(Of MyMachGroupVM) + For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + Dim bFound As Boolean = False + For Each Part As PartVM In Machgroup.PartVMList + If EgtDuploGetOriginal(Part.nPartId) = m_SelBTLPart.nPartId Then + Part.SetSearchFound() + bFound = True + Else + Part.ResetSearchFound() + End If + Next + If bFound Then + Machgroup.SetSearchFound() + Else + Machgroup.ResetSearchFound() + End If + Next + End If + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) End If End If NotifyPropertyChanged(NameOf(SelBTLPart)) @@ -1336,7 +1433,7 @@ Public Class BTLStructureVM End Property Public Sub DeletePart() - If Map.refMainMenuVM.SelPage = Pages.VIEW Then Map.refLeftPanelVM.RemovePartCmd() + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refLeftPanelVM.RemovePartCmd() End Sub #End Region ' DeletePart diff --git a/EgtBEAMWALL.ViewerOptimizer/ItemParamList/BTLPartListV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/ItemParamList/BTLPartListV.xaml.vb index 9e6a9191..db68854f 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ItemParamList/BTLPartListV.xaml.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ItemParamList/BTLPartListV.xaml.vb @@ -85,6 +85,8 @@ Public Class BTLPartListV ' m_MainWindowVM.SetMouseButton("Highlight") 'End If End If + ' imposto tipo di grid selezionata + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.MACHGROUP) End Sub Public Shared Function FindVisualParent(Of T As DependencyObject)(ByVal child As DependencyObject) As T diff --git a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb index e934198f..04151e11 100644 --- a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb @@ -22,12 +22,12 @@ Public Class LeftPanelVM Public ReadOnly Property ViewPage_Visibility As Visibility Get - Return If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed) End Get End Property Public ReadOnly Property MachiningPage_Visibility As Visibility Get - Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING, Visibility.Visible, Visibility.Collapsed) End Get End Property diff --git a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml index e256301b..4d4c074c 100644 --- a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/OnlyProdLeftPanelV.xaml @@ -82,70 +82,60 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + --> diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb index e813597d..e057bd71 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb @@ -36,13 +36,28 @@ Public Class ConfigurationPageVM End Get Set(value As Integer) m_SelConfigSubPage = value + If m_SelConfigSubPage = ConfigSubPages.GENERAL Then + m_bGeneral_Visibility = Visibility.Visible + m_bParameterQ_Visibility = Visibility.Collapsed + m_bMachine_Visibility = Visibility.Collapsed + ElseIf m_SelConfigSubPage = ConfigSubPages.QPARAMETERS Then + m_bParameterQ_Visibility = Visibility.Visible + m_bGeneral_Visibility = Visibility.Collapsed + m_bMachine_Visibility = Visibility.Collapsed + ElseIf m_SelConfigSubPage = ConfigSubPages.MACHINE Then + m_bMachine_Visibility = Visibility.Visible + m_bGeneral_Visibility = Visibility.Collapsed + m_bParameterQ_Visibility = Visibility.Collapsed + End If + NotifyPropertyChanged(NameOf(General_Visibility)) + NotifyPropertyChanged(NameOf(ParameterQ_Visibility)) + NotifyPropertyChanged(NameOf(Machine_Visibility)) End Set End Property ' flag modifica parametri Macchina Friend bModifyMachParam As Boolean - Public ReadOnly Property MachinePanelVM As MachinePanelVM Get Return Map.refMachinePanelVM @@ -218,6 +233,39 @@ Public Class ConfigurationPageVM End Set End Property + Private m_bGeneral_Visibility As Visibility = Visibility.Visible + Public Property General_Visibility As Visibility + Get + Return m_bGeneral_Visibility + End Get + Set(value As Visibility) + m_bGeneral_Visibility = value + NotifyPropertyChanged(NameOf(General_Visibility)) + End Set + End Property + + Private m_bParameterQ_Visibility As Visibility = Visibility.Collapsed + Public Property ParameterQ_Visibility As Visibility + Get + Return m_bParameterQ_Visibility + End Get + Set(value As Visibility) + m_bParameterQ_Visibility = value + NotifyPropertyChanged(NameOf(ParameterQ_Visibility)) + End Set + End Property + + Private m_bMachine_Visibility As Visibility = Visibility.Collapsed + Public Property Machine_Visibility As Visibility + Get + Return m_bMachine_Visibility + End Get + Set(value As Visibility) + m_bMachine_Visibility = value + NotifyPropertyChanged(NameOf(Machine_Visibility)) + End Set + End Property + ' Definizione comandi Private m_cmdSave As ICommand Private m_cmdChooseExternalBackupFolderPath As ICommand @@ -357,6 +405,24 @@ Public Class ConfigurationPageVM End Get End Property + Public ReadOnly Property General_Msg As String + Get + Return EgtMsg(62535) + End Get + End Property + + Public ReadOnly Property ParameterQ_Msg As String + Get + Return EgtMsg(62536) + End Get + End Property + + Public ReadOnly Property Machine_Msg As String + Get + Return EgtMsg(62537) + End Get + End Property + #End Region ' Messages #Region "Constructor" diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml new file mode 100644 index 00000000..49cc3924 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Core/ConfigurationPage/ConfigurationPageV.xaml.vb b/EgtBEAMWALL.Core/ConfigurationPage/ConfigurationPageV.xaml.vb new file mode 100644 index 00000000..1d11796c --- /dev/null +++ b/EgtBEAMWALL.Core/ConfigurationPage/ConfigurationPageV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ConfigurationPageV + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Core/ConfigurationPage/General_ConfigurationPageV.xaml b/EgtBEAMWALL.Core/ConfigurationPage/General_ConfigurationPageV.xaml new file mode 100644 index 00000000..cb1967d0 --- /dev/null +++ b/EgtBEAMWALL.Core/ConfigurationPage/General_ConfigurationPageV.xaml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Core/MachinePanel/MachinePanelV.xaml.vb b/EgtBEAMWALL.Core/MachinePanel/MachinePanelV.xaml.vb new file mode 100644 index 00000000..83a5832c --- /dev/null +++ b/EgtBEAMWALL.Core/MachinePanel/MachinePanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class MachinePanelV + +End Class diff --git a/EgtBEAMWALL.Core/MachinePanel/MachinePanelVM.vb b/EgtBEAMWALL.Core/MachinePanel/MachinePanelVM.vb new file mode 100644 index 00000000..88351e28 --- /dev/null +++ b/EgtBEAMWALL.Core/MachinePanel/MachinePanelVM.vb @@ -0,0 +1,357 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class MachinePanelVM + Inherits EgtWPFLib5.MachinePanelVM + +#Region "FIELDS & PROPERTIES" + + ' Radice del direttorio delle macchine + Private m_sMachinesRoot As String + + ' Macchina correntemente selezionata e quindi attiva + Private m_SelectedMachine As Machine = Nothing + Public Overrides Property SelectedMachine As Machine + Get + Return m_SelectedMachine + End Get + Set(value As Machine) + If value IsNot m_SelectedMachine Then + ' imposto macchina in DbGeometrico + If Not IsNothing(value) AndAlso EgtSetCurrMachine(value.Name) Then + m_SelectedMachine = value + End If + ' Salvo impostazione macchina corrente + SaveCurrentMachine() + NotifyPropertyChanged(NameOf(SelectedMachine)) + ' inizializzo la macchina selezionata come macchina corrente + Dim nMachType As MachineType = DirectCast(m_SelectedMachine, MyMachine).nType + SectionXMaterial.SetType(nMachType) + If Not IsNothing(value) Then + InitCurrentMachine(Map.refMainWindowVM.MainWindowM.sMachinesRoot, value.Name, nMachType) + Else + InitCurrentMachine(Map.refMainWindowVM.MainWindowM.sMachinesRoot, m_SelectedMachine.Name, nMachType) + End If + ' mostro bottone tabella beam o wall a seconda del tipo + m_BeamTable_Visibility = If(nMachType = MachineType.BEAM OrElse nMachType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + m_WallTable_Visibility = If(nMachType = MachineType.WALL OrElse nMachType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + NotifyPropertyChanged(NameOf(BeamTable_Visibility)) + NotifyPropertyChanged(NameOf(WallTable_Visibility)) + ' carico i Parametri Q da mostrare (Beam, Wall o entrambi) in base al tipo di macchina selezionata + If Not IsNothing(Map.refConfigurationPageVM) Then + ' carico i parametri Q dei Process letti dall'ini + Map.refConfigurationPageVM.GetQParamsList() + ' carico la lista di tutti i parametri Q ciclando su ogni Process di PRCList + If Not IsNothing(Map.refConfigurationPageVM.QBTLParamVMList) Then + Map.refConfigurationPageVM.QBTLParamVMList.Clear() + End If + For Each PRCItem In Map.refConfigurationPageVM.PRCList + For Each QBTLParam In PRCItem.QBTLParamVMList + Map.refConfigurationPageVM.QBTLParamVMList.Add(QBTLParam) + Next + Next + NotifyPropertyChanged(NameOf(Map.refConfigurationPageVM.QBTLParamVMList)) + End If + ' aggiorno nome macchina in statusbar + Map.refMyStatusBarVM.RefreshMachName() + End If + End Set + End Property + + Private m_MachPanel_IsEnabled As Boolean = True + Public Property MachPanel_IsEnabled As Boolean + Get + Return m_MachPanel_IsEnabled + End Get + Set(value As Boolean) + m_MachPanel_IsEnabled = value + NotifyPropertyChanged("MachPanel_IsEnabled") + End Set + End Property + + Private m_BeamTable_Visibility As Visibility + Public ReadOnly Property BeamTable_Visibility As Visibility + Get + Return m_BeamTable_Visibility + End Get + End Property + + Private m_WallTable_Visibility As Visibility + Public ReadOnly Property WallTable_Visibility As Visibility + Get + Return m_WallTable_Visibility + End Get + End Property + + Public ReadOnly Property SetUp_Visibility As Visibility + Get + Return If(Map.refMainWindowVM.MainWindowM.bModifySetup, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + +#Region "Messages" + + Public ReadOnly Property ToolDBMsg As String + Get + Return EgtMsg(MSG_MACHINEPAGEUC + 6) + End Get + End Property + Public ReadOnly Property MachiningDbMsg As String + Get + Return EgtMsg(MSG_MACHINEPAGEUC + 7) + End Get + End Property + Public ReadOnly Property SetUpMsg As String + Get + Return EgtMsg(MSG_ALARMSPAGEUC + 33) + End Get + End Property + +#End Region ' Messages + +#Region "ToolTip" + + Public ReadOnly Property ToolDBToolTip As String + Get + Return EgtMsg(5003) + End Get + End Property + Public ReadOnly Property MachiningDbToolTip As String + Get + Return EgtMsg(5004) + End Get + End Property + Public ReadOnly Property SetUpToolTip As String + Get + Return EgtMsg(31501) + End Get + End Property + +#End Region ' ToolTip + + ' Definizione comandi + Private m_cmdBeamTable As ICommand + Private m_cmdWallTable As ICommand + +#End Region 'FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefMachinePanelVM(Me) + ' recupero cartella radice delle macchine + m_sMachinesRoot = Map.refMainWindowVM.MainWindowM.sMachinesRoot + ' Carica macchine da cartella delle macchine + MyMachine.MachineListInit(m_sMachinesRoot, MachineList) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Sub LoadCurrentMachine() + If MachineList.Count = 0 Then Return + Dim CurrMachine As Machine = Nothing + Dim CurrMachineName As String = String.Empty + GetMainPrivateProfileString(S_MACH, K_CURRMACH, String.Empty, CurrMachineName) + Dim bFound As Boolean = False + If Not String.IsNullOrEmpty(CurrMachineName) Then + For Each Mach In MachineList + If Mach.Name = CurrMachineName Then + bFound = True + CurrMachine = Mach + Exit For + End If + Next + End If + If Not bFound And MachineList.Count > 0 Then + CurrMachine = MachineList(0) + End If + If Not IsNothing(CurrMachine) Then + If EgtSetCurrMachine(CurrMachine.Name) Then + SelectedMachine = CurrMachine + End If + End If + End Sub + + Friend Sub SaveCurrentMachine() + If IsNothing(m_SelectedMachine) Then Return + WriteMainPrivateProfileString(S_MACH, K_CURRMACH, SelectedMachine.Name) + End Sub + + Friend Sub UpdateCurrentMachine() + 'EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + Dim sMachName As String = String.Empty + If EgtGetCurrMachineName(sMachName) Then + For Each Mach In MachineList + If Mach.Name = sMachName Then + SelectedMachine = Mach + Exit For + End If + Next + End If + End Sub + + Friend Function BeamMachDb() As Boolean + ' Assegno le path + Dim sBaseDir As String = m_sMachinesRoot & "\" & m_SelectedMachine.Name & "\" & "Beam" + ' verifico se ci sono i file ini + Dim sMachTypePath As String = sBaseDir & "\MachiningTypes.ini" + Dim sTabTemplPath As String = sBaseDir & "\BeamTableTemplate.ini" + If File.Exists(sMachTypePath) AndAlso File.Exists(sTabTemplPath) Then + ' apro finestra di gestione lavorazioni travi + Dim sTitle = EgtMsg(9000) 'Tabelle delle lavorazioni delle travi + Dim BeamMchsWinVM As New MyBeamMachiningsWindowVM(sTitle, sBaseDir, sMachTypePath, sTabTemplPath) + Dim BeamMchsWinV As New BeamMachiningsWindowV(Application.Current.MainWindow, BeamMchsWinVM) + BeamMchsWinV.ShowDialog() + Else + ' Impossibile aprire l'Editor delle lavorazioni delle travi.
Mancano i file di configurazione. - Errore + MessageBox.Show(EgtMsg(9009), EgtMsg(9008), MessageBoxButton.OK, MessageBoxImage.Stop) + End If + Return True + End Function + + Friend Function WallMachDb() As Boolean + ' Assegno le path + Dim sBaseDir As String = m_sMachinesRoot & "\" & m_SelectedMachine.Name & "\" & "Wall" + ' verifico se ci sono i file ini + Dim sMachTypePath As String = sBaseDir & "\MachiningTypes.ini" + Dim sTabTemplPath As String = sBaseDir & "\WallTableTemplate.ini" + If File.Exists(sMachTypePath) AndAlso File.Exists(sTabTemplPath) Then + ' apro finestra di gestione lavorazioni pareti + Dim sTitle = EgtMsg(9010) 'Tabelle delle lavorazioni delle pareti + Dim WallMchsWinVM As New MyBeamMachiningsWindowVM(sTitle, sBaseDir, sMachTypePath, sTabTemplPath, False) + Dim WallMchsWinV As New BeamMachiningsWindowV(Application.Current.MainWindow, WallMchsWinVM) + WallMchsWinV.ShowDialog() + Else + ' Impossibile aprire l'Editor delle lavorazioni delle pareti.
Mancano i file di configurazione. - Errore + MessageBox.Show(EgtMsg(9011), EgtMsg(9008), MessageBoxButton.OK, MessageBoxImage.Stop) + End If + Return True + End Function + + Public Overrides Sub ToolDb(ByVal param As Object) + If Not VerifyMachinesDir(m_sMachinesRoot) Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtTdbReload() Then + EgtOutLog("Impossible reloading tool Db") + MessageBox.Show(EgtMsg(MSG_TOOLDBERRORS + 30), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + + Dim ToolDbWindowVM As New MyToolDbWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Beam") + Dim ToolDbWindowV As New ToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM) + If ToolDbWindowVM.MatType <> 0 Then + ToolDbWindowV.Height = 640 + ToolDbWindowV.Width = 1024 + ToolDbWindowV.ShowDialog() + Else + Exit Sub + End If + + End Sub + + Public Overrides Sub MachDb(ByVal param As Object) + If Not VerifyMachinesDir(m_sMachinesRoot) Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtMdbReload() Then + EgtOutLog("Impossible reloading machining Db") + MessageBox.Show(EgtMsg(MSG_MACHININGDBERRORS + 8), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + Dim MachDbWindowVM As New EgtWPFLib5.MachiningDbWindowVM(CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Stone") + Dim MachDbWindowV As New EgtWPFLib5.MachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM) + + If EgtWPFLib5.MachiningTreeViewItem.m_MatType <> 0 Then + MachDbWindowV.Height = 768 + MachDbWindowV.Width = 1024 + MachDbWindowV.ShowDialog() + Else + Exit Sub + End If + + End Sub + + Public Overrides Sub SetUp(ByVal param As Object) + ' verifico che il file di configurazione attrezzaggio (lua) della macchina esista + If Not File.Exists(CurrentMachine.sMachDir & "\Scripts\" & SETUP_LUA) Then + EgtOutLog("SetUp error: SetUp configuration file doesn't exist ") + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato, + ' e testa e uscita dell'utensile attrezzato + EgtLuaExecFile(CurrentMachine.sMachDir & "\Scripts\" & SETUP_LUA) + ' verifico che le teste riportate in configurazione esistano + Dim Index As Integer = 1 + Dim nErr As Integer = 0 + While nErr = 0 + Dim sHead As String = String.Empty + nErr = 999 + EgtLuaSetGlobIntVar("STU.INDEX", Index) + EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos") + ' Leggo variabili + EgtLuaGetGlobStringVar("STU.HEAD", sHead) + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr = 0 Then + If EgtGetHeadExitCount(sHead) = 0 Then + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + End If + Index += 1 + End While + ' Reset lua + EgtLuaResetGlobVar("STU") + + Dim SetUpWindow As New SetUpWindowV(Application.Current.MainWindow, New SetUpWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachineName)) + SetUpWindow.Height = 614 + SetUpWindow.Width = 1024 + SetUpWindow.ShowDialog() + + End Sub + +#End Region + +#Region "COMMANDS" + +#Region "BeamTable" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property BeamTable_Command As ICommand + Get + If m_cmdBeamTable Is Nothing Then + m_cmdBeamTable = New Command(AddressOf BeamMachDb) + End If + Return m_cmdBeamTable + End Get + End Property + +#End Region ' BeamTable + +#Region "WallTable" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property WallTable_Command As ICommand + Get + If m_cmdWallTable Is Nothing Then + m_cmdWallTable = New Command(AddressOf WallMachDb) + End If + Return m_cmdWallTable + End Get + End Property + +#End Region ' WallTable + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Core/Resources/ProjectManager/Save.png b/EgtBEAMWALL.Core/Resources/ProjectManager/Save.png new file mode 100644 index 0000000000000000000000000000000000000000..0eca26039c38c97a380275d355f192ef802a4768 GIT binary patch literal 610 zcmV-o0-gPdP)~pMU@Vf!LzljGU~@j2=Md0a6{s0CG^^p|=7s{z)HEvV-OP z!>=4q9=v1FR|Xl!{XvS4ad4!m;sf^>F5dk>ewv~-U}j=unCPL-peN5ecyiz2H-8v< zKQS}JU;Z{)PK`PW4u1Y2znSy#*FV}gYQ>eWWI5=}lV1$`KK-V=n!yI9J^9XXN%pVX=QaDiLj{xa~t`%RN*Bg;`eI(!Va3hWH`-u)$7k2D_>L+Yo0 z45g<&Fg*G5kGhV^lHp{~5ocq_-20y4-1k33J4%LyiJ{4mkD*eBmm&MYN9rbYTRBdK zO*g-S9puISAB^>x2;M1& literal 0 HcmV?d00001 diff --git a/EgtBEAMWALL.Supervisor/BeamMachiningsWindow/BeamMachiningsWindowV.xaml b/EgtBEAMWALL.Supervisor/BeamMachiningsWindow/BeamMachiningsWindowV.xaml new file mode 100644 index 00000000..02bcbf79 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/BeamMachiningsWindow/BeamMachiningsWindowV.xaml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb index e057bd71..8d43b4c3 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb @@ -4,11 +4,7 @@ Imports EgtUILib Imports EgtWPFLib5 Imports EgtBEAMWALL.Core Imports MS.Internal -Imports Org.BouncyCastle.X509 Imports Ionic.Zip -Imports Org.BouncyCastle.Bcpg -Imports Microsoft.VisualBasic.ApplicationServices -Imports Renci.SshNet.Security Public Class ConfigurationPageVM Inherits VMBase diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml index 49cc3924..1a271f72 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml @@ -64,7 +64,7 @@ + Margin="0,2,0,5"> @@ -114,5 +114,5 @@
- + diff --git a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj index c46c1fec..82644cf7 100644 --- a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj +++ b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj @@ -264,15 +264,6 @@ ChangeMaterialWndV.xaml
- - General_ConfigurationPageV.xaml - - - Machine_ConfigurationPageV.xaml - - - QParameter_ConfigurationPageV.xaml - @@ -280,6 +271,7 @@ FeatureListManagerV.xaml + PartInRawPartManagerWndV.xaml @@ -328,7 +320,6 @@ BeamMachiningsWindowV.xaml - BlockedWndV.xaml @@ -484,10 +475,6 @@ ConfigurationPageV.xaml - - MachinePanelV.xaml - - OptimizePanelV.xaml @@ -552,18 +539,6 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -784,10 +759,6 @@ MSBuild:Compile Designer - - MSBuild:Compile - Designer - Designer MSBuild:Compile diff --git a/EgtBEAMWALL.ViewerOptimizer/MachinePanel/MachinePanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/MachinePanel/MachinePanelV.xaml index 1e325112..6d211b1e 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MachinePanel/MachinePanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/MachinePanel/MachinePanelV.xaml @@ -2,7 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating;assembly=EgtWPFLib5" - IsEnabled="{Binding MachPanel_IsEnabled}"> + IsEnabled="{Binding MachPanel_IsEnabled}" + Background="Green"> diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/CurrentMachine.vb b/EgtBEAMWALL.ViewerOptimizer/Utility/CurrentMachine.vb index 1c78294f..2962d1ac 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Utility/CurrentMachine.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/CurrentMachine.vb @@ -242,9 +242,9 @@ Public Module CurrentMachine EgtLuaResetGlobVar("GWD") ' aggiorno parametro in gestore viste Core.ViewPanelVM.UpdateMachParam(m_nViewDir) - + End If ' leggo parametri macchina da WallData - ElseIf nType = MachineType.WALL Then + If nType = MachineType.WALL OrElse nType = MachineType.BOTH Then ' Assegno i dati EgtLuaCreateGlobTable("GWD") EgtLuaSetGlobStringVar("GWD.BASEDIR", Map.refMainWindowVM.MainWindowM.sWallRoot) From a6ef84ab328bc391b4f97ace5517ca013e00796c Mon Sep 17 00:00:00 2001 From: Demetrio Cassarino Date: Wed, 13 Dec 2023 16:17:49 +0100 Subject: [PATCH 25/30] -Aggiunto PrintLabel_Msg al ConfigurationPageV del Supervisore --- .../ConfigurationPage/ConfigurationPageVM.vb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb index 2fb406b1..1feb8961 100644 --- a/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb +++ b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb @@ -346,6 +346,12 @@ Public Class ConfigurationPageVM End Get End Property + Public ReadOnly Property PrintLabel_Msg As String + Get + Return EgtMsg(61894) + End Get + End Property + #End Region ' Messages #Region "Constructor" From 20357a3ebcdf1e38d468fb06a61b0502e23d287d Mon Sep 17 00:00:00 2001 From: Demetrio Cassarino Date: Thu, 14 Dec 2023 14:42:42 +0100 Subject: [PATCH 26/30] -portato BeamMachiningsWindowV in Core --- .../BeamMachiningsWindowV.xaml | 26 +++++++++---------- EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj | 7 +++++ .../EgtBEAMWALL.Supervisor.vbproj | 7 ----- .../Utility/Dictionary.xaml | 4 +-- .../EgtBEAMWALL.ViewerOptimizer.vbproj | 7 ----- .../Utility/Dictionary.xaml | 4 +-- 6 files changed, 24 insertions(+), 31 deletions(-) diff --git a/EgtBEAMWALL.Core/BeamMachiningsWindow/BeamMachiningsWindowV.xaml b/EgtBEAMWALL.Core/BeamMachiningsWindow/BeamMachiningsWindowV.xaml index e0a034bb..cfa320aa 100644 --- a/EgtBEAMWALL.Core/BeamMachiningsWindow/BeamMachiningsWindowV.xaml +++ b/EgtBEAMWALL.Core/BeamMachiningsWindow/BeamMachiningsWindowV.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5" - xmlns:EgtBEAMWALLCORE="clr-namespace:EgtBEAMWALL.Core;assembly=EgtBEAMWALL.Core" + xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.Core" Title="{Binding Title}" Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}" WindowStyle="None" ResizeMode="NoResize" @@ -24,17 +24,17 @@ Margin="5,0,5,0" Style="{StaticResource TabControl_OnlyHeaders}"/> - + - --> + + + + - + - +