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">