diff --git a/EgtBEAMWALL.Core/BTLModel/BTLFeatureM.vb b/EgtBEAMWALL.Core/BTLModel/BTLFeatureM.vb index 60c01a53..faa073af 100644 --- a/EgtBEAMWALL.Core/BTLModel/BTLFeatureM.vb +++ b/EgtBEAMWALL.Core/BTLModel/BTLFeatureM.vb @@ -548,7 +548,7 @@ Public Class BTLFeatureM EgtSetInfo( nFeatureId, BTL_FTR_PRIORITY, nPriority) SetFeatureId(nFeatureId) ' imposto modificato per copie - EgtDuploSetModified(ParentPart.nPartId) + MyMachGroupPanelM.SetDuploModified(ParentPart.nPartId) bOk = True Else ' Impossibile creare una feature con questi valori - ERRORE diff --git a/EgtBEAMWALL.Core/BTLModel/BTLPartM.vb b/EgtBEAMWALL.Core/BTLModel/BTLPartM.vb index 919f817b..0e3b5383 100644 --- a/EgtBEAMWALL.Core/BTLModel/BTLPartM.vb +++ b/EgtBEAMWALL.Core/BTLModel/BTLPartM.vb @@ -1242,7 +1242,7 @@ Public Class BTLPartM m_nROTATED = If(dNewRotation >= 0, dNewRotation, 360 + dNewRotation) EgtSetInfo(nPartId, BTL_PRT_ROTATED, m_nROTATED) ' imposto modificato per copie - EgtDuploSetModified(nPartId) + MyMachGroupPanelM.SetDuploModified(nPartId) End If ' se era invertito If bInverted Then @@ -1275,7 +1275,7 @@ Public Class BTLPartM m_nINVERTED = If(m_nINVERTED = 0, 180, 0) EgtSetInfo(nPartId, BTL_PRT_INVERTED, m_nINVERTED) ' imposto modificato per copie - EgtDuploSetModified(nPartId) + MyMachGroupPanelM.SetDuploModified(nPartId) End If End Sub diff --git a/EgtBEAMWALL.Core/BTLViewModel/BTLFeatureVM.vb b/EgtBEAMWALL.Core/BTLViewModel/BTLFeatureVM.vb index cf17786b..0e472a10 100644 --- a/EgtBEAMWALL.Core/BTLViewModel/BTLFeatureVM.vb +++ b/EgtBEAMWALL.Core/BTLViewModel/BTLFeatureVM.vb @@ -264,6 +264,9 @@ Public Class BTLFeatureVM End If End Sub + Public Overridable Sub RefreshFeature() + End Sub + #End Region ' METHODS End Class diff --git a/EgtBEAMWALL.Core/BeamMachiningsWindow/BeamMachiningsWindowV.xaml b/EgtBEAMWALL.Core/BeamMachiningsWindow/BeamMachiningsWindowV.xaml new file mode 100644 index 00000000..cfa320aa --- /dev/null +++ b/EgtBEAMWALL.Core/BeamMachiningsWindow/BeamMachiningsWindowV.xaml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Core/ConfigurationPage/ConfigurationPageV.xaml.vb b/EgtBEAMWALL.Core/ConfigurationPage/ConfigurationPageV.xaml.vb new file mode 100644 index 00000000..1d11796c --- /dev/null +++ b/EgtBEAMWALL.Core/ConfigurationPage/ConfigurationPageV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ConfigurationPageV + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Core/ConfigurationPage/General_ConfigurationPageV.xaml b/EgtBEAMWALL.Core/ConfigurationPage/General_ConfigurationPageV.xaml new file mode 100644 index 00000000..cb1967d0 --- /dev/null +++ b/EgtBEAMWALL.Core/ConfigurationPage/General_ConfigurationPageV.xaml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Core/MachinePanel/MachinePanelV.xaml.vb b/EgtBEAMWALL.Core/MachinePanel/MachinePanelV.xaml.vb new file mode 100644 index 00000000..83a5832c --- /dev/null +++ b/EgtBEAMWALL.Core/MachinePanel/MachinePanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class MachinePanelV + +End Class diff --git a/EgtBEAMWALL.Core/MachinePanel/MachinePanelVM.vb b/EgtBEAMWALL.Core/MachinePanel/MachinePanelVM.vb new file mode 100644 index 00000000..88351e28 --- /dev/null +++ b/EgtBEAMWALL.Core/MachinePanel/MachinePanelVM.vb @@ -0,0 +1,357 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class MachinePanelVM + Inherits EgtWPFLib5.MachinePanelVM + +#Region "FIELDS & PROPERTIES" + + ' Radice del direttorio delle macchine + Private m_sMachinesRoot As String + + ' Macchina correntemente selezionata e quindi attiva + Private m_SelectedMachine As Machine = Nothing + Public Overrides Property SelectedMachine As Machine + Get + Return m_SelectedMachine + End Get + Set(value As Machine) + If value IsNot m_SelectedMachine Then + ' imposto macchina in DbGeometrico + If Not IsNothing(value) AndAlso EgtSetCurrMachine(value.Name) Then + m_SelectedMachine = value + End If + ' Salvo impostazione macchina corrente + SaveCurrentMachine() + NotifyPropertyChanged(NameOf(SelectedMachine)) + ' inizializzo la macchina selezionata come macchina corrente + Dim nMachType As MachineType = DirectCast(m_SelectedMachine, MyMachine).nType + SectionXMaterial.SetType(nMachType) + If Not IsNothing(value) Then + InitCurrentMachine(Map.refMainWindowVM.MainWindowM.sMachinesRoot, value.Name, nMachType) + Else + InitCurrentMachine(Map.refMainWindowVM.MainWindowM.sMachinesRoot, m_SelectedMachine.Name, nMachType) + End If + ' mostro bottone tabella beam o wall a seconda del tipo + m_BeamTable_Visibility = If(nMachType = MachineType.BEAM OrElse nMachType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + m_WallTable_Visibility = If(nMachType = MachineType.WALL OrElse nMachType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + NotifyPropertyChanged(NameOf(BeamTable_Visibility)) + NotifyPropertyChanged(NameOf(WallTable_Visibility)) + ' carico i Parametri Q da mostrare (Beam, Wall o entrambi) in base al tipo di macchina selezionata + If Not IsNothing(Map.refConfigurationPageVM) Then + ' carico i parametri Q dei Process letti dall'ini + Map.refConfigurationPageVM.GetQParamsList() + ' carico la lista di tutti i parametri Q ciclando su ogni Process di PRCList + If Not IsNothing(Map.refConfigurationPageVM.QBTLParamVMList) Then + Map.refConfigurationPageVM.QBTLParamVMList.Clear() + End If + For Each PRCItem In Map.refConfigurationPageVM.PRCList + For Each QBTLParam In PRCItem.QBTLParamVMList + Map.refConfigurationPageVM.QBTLParamVMList.Add(QBTLParam) + Next + Next + NotifyPropertyChanged(NameOf(Map.refConfigurationPageVM.QBTLParamVMList)) + End If + ' aggiorno nome macchina in statusbar + Map.refMyStatusBarVM.RefreshMachName() + End If + End Set + End Property + + Private m_MachPanel_IsEnabled As Boolean = True + Public Property MachPanel_IsEnabled As Boolean + Get + Return m_MachPanel_IsEnabled + End Get + Set(value As Boolean) + m_MachPanel_IsEnabled = value + NotifyPropertyChanged("MachPanel_IsEnabled") + End Set + End Property + + Private m_BeamTable_Visibility As Visibility + Public ReadOnly Property BeamTable_Visibility As Visibility + Get + Return m_BeamTable_Visibility + End Get + End Property + + Private m_WallTable_Visibility As Visibility + Public ReadOnly Property WallTable_Visibility As Visibility + Get + Return m_WallTable_Visibility + End Get + End Property + + Public ReadOnly Property SetUp_Visibility As Visibility + Get + Return If(Map.refMainWindowVM.MainWindowM.bModifySetup, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + +#Region "Messages" + + Public ReadOnly Property ToolDBMsg As String + Get + Return EgtMsg(MSG_MACHINEPAGEUC + 6) + End Get + End Property + Public ReadOnly Property MachiningDbMsg As String + Get + Return EgtMsg(MSG_MACHINEPAGEUC + 7) + End Get + End Property + Public ReadOnly Property SetUpMsg As String + Get + Return EgtMsg(MSG_ALARMSPAGEUC + 33) + End Get + End Property + +#End Region ' Messages + +#Region "ToolTip" + + Public ReadOnly Property ToolDBToolTip As String + Get + Return EgtMsg(5003) + End Get + End Property + Public ReadOnly Property MachiningDbToolTip As String + Get + Return EgtMsg(5004) + End Get + End Property + Public ReadOnly Property SetUpToolTip As String + Get + Return EgtMsg(31501) + End Get + End Property + +#End Region ' ToolTip + + ' Definizione comandi + Private m_cmdBeamTable As ICommand + Private m_cmdWallTable As ICommand + +#End Region 'FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefMachinePanelVM(Me) + ' recupero cartella radice delle macchine + m_sMachinesRoot = Map.refMainWindowVM.MainWindowM.sMachinesRoot + ' Carica macchine da cartella delle macchine + MyMachine.MachineListInit(m_sMachinesRoot, MachineList) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Sub LoadCurrentMachine() + If MachineList.Count = 0 Then Return + Dim CurrMachine As Machine = Nothing + Dim CurrMachineName As String = String.Empty + GetMainPrivateProfileString(S_MACH, K_CURRMACH, String.Empty, CurrMachineName) + Dim bFound As Boolean = False + If Not String.IsNullOrEmpty(CurrMachineName) Then + For Each Mach In MachineList + If Mach.Name = CurrMachineName Then + bFound = True + CurrMachine = Mach + Exit For + End If + Next + End If + If Not bFound And MachineList.Count > 0 Then + CurrMachine = MachineList(0) + End If + If Not IsNothing(CurrMachine) Then + If EgtSetCurrMachine(CurrMachine.Name) Then + SelectedMachine = CurrMachine + End If + End If + End Sub + + Friend Sub SaveCurrentMachine() + If IsNothing(m_SelectedMachine) Then Return + WriteMainPrivateProfileString(S_MACH, K_CURRMACH, SelectedMachine.Name) + End Sub + + Friend Sub UpdateCurrentMachine() + 'EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + Dim sMachName As String = String.Empty + If EgtGetCurrMachineName(sMachName) Then + For Each Mach In MachineList + If Mach.Name = sMachName Then + SelectedMachine = Mach + Exit For + End If + Next + End If + End Sub + + Friend Function BeamMachDb() As Boolean + ' Assegno le path + Dim sBaseDir As String = m_sMachinesRoot & "\" & m_SelectedMachine.Name & "\" & "Beam" + ' verifico se ci sono i file ini + Dim sMachTypePath As String = sBaseDir & "\MachiningTypes.ini" + Dim sTabTemplPath As String = sBaseDir & "\BeamTableTemplate.ini" + If File.Exists(sMachTypePath) AndAlso File.Exists(sTabTemplPath) Then + ' apro finestra di gestione lavorazioni travi + Dim sTitle = EgtMsg(9000) 'Tabelle delle lavorazioni delle travi + Dim BeamMchsWinVM As New MyBeamMachiningsWindowVM(sTitle, sBaseDir, sMachTypePath, sTabTemplPath) + Dim BeamMchsWinV As New BeamMachiningsWindowV(Application.Current.MainWindow, BeamMchsWinVM) + BeamMchsWinV.ShowDialog() + Else + ' Impossibile aprire l'Editor delle lavorazioni delle travi.
Mancano i file di configurazione. - Errore + MessageBox.Show(EgtMsg(9009), EgtMsg(9008), MessageBoxButton.OK, MessageBoxImage.Stop) + End If + Return True + End Function + + Friend Function WallMachDb() As Boolean + ' Assegno le path + Dim sBaseDir As String = m_sMachinesRoot & "\" & m_SelectedMachine.Name & "\" & "Wall" + ' verifico se ci sono i file ini + Dim sMachTypePath As String = sBaseDir & "\MachiningTypes.ini" + Dim sTabTemplPath As String = sBaseDir & "\WallTableTemplate.ini" + If File.Exists(sMachTypePath) AndAlso File.Exists(sTabTemplPath) Then + ' apro finestra di gestione lavorazioni pareti + Dim sTitle = EgtMsg(9010) 'Tabelle delle lavorazioni delle pareti + Dim WallMchsWinVM As New MyBeamMachiningsWindowVM(sTitle, sBaseDir, sMachTypePath, sTabTemplPath, False) + Dim WallMchsWinV As New BeamMachiningsWindowV(Application.Current.MainWindow, WallMchsWinVM) + WallMchsWinV.ShowDialog() + Else + ' Impossibile aprire l'Editor delle lavorazioni delle pareti.
Mancano i file di configurazione. - Errore + MessageBox.Show(EgtMsg(9011), EgtMsg(9008), MessageBoxButton.OK, MessageBoxImage.Stop) + End If + Return True + End Function + + Public Overrides Sub ToolDb(ByVal param As Object) + If Not VerifyMachinesDir(m_sMachinesRoot) Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtTdbReload() Then + EgtOutLog("Impossible reloading tool Db") + MessageBox.Show(EgtMsg(MSG_TOOLDBERRORS + 30), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + + Dim ToolDbWindowVM As New MyToolDbWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Beam") + Dim ToolDbWindowV As New ToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM) + If ToolDbWindowVM.MatType <> 0 Then + ToolDbWindowV.Height = 640 + ToolDbWindowV.Width = 1024 + ToolDbWindowV.ShowDialog() + Else + Exit Sub + End If + + End Sub + + Public Overrides Sub MachDb(ByVal param As Object) + If Not VerifyMachinesDir(m_sMachinesRoot) Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtMdbReload() Then + EgtOutLog("Impossible reloading machining Db") + MessageBox.Show(EgtMsg(MSG_MACHININGDBERRORS + 8), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + Dim MachDbWindowVM As New EgtWPFLib5.MachiningDbWindowVM(CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Stone") + Dim MachDbWindowV As New EgtWPFLib5.MachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM) + + If EgtWPFLib5.MachiningTreeViewItem.m_MatType <> 0 Then + MachDbWindowV.Height = 768 + MachDbWindowV.Width = 1024 + MachDbWindowV.ShowDialog() + Else + Exit Sub + End If + + End Sub + + Public Overrides Sub SetUp(ByVal param As Object) + ' verifico che il file di configurazione attrezzaggio (lua) della macchina esista + If Not File.Exists(CurrentMachine.sMachDir & "\Scripts\" & SETUP_LUA) Then + EgtOutLog("SetUp error: SetUp configuration file doesn't exist ") + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato, + ' e testa e uscita dell'utensile attrezzato + EgtLuaExecFile(CurrentMachine.sMachDir & "\Scripts\" & SETUP_LUA) + ' verifico che le teste riportate in configurazione esistano + Dim Index As Integer = 1 + Dim nErr As Integer = 0 + While nErr = 0 + Dim sHead As String = String.Empty + nErr = 999 + EgtLuaSetGlobIntVar("STU.INDEX", Index) + EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos") + ' Leggo variabili + EgtLuaGetGlobStringVar("STU.HEAD", sHead) + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr = 0 Then + If EgtGetHeadExitCount(sHead) = 0 Then + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + End If + Index += 1 + End While + ' Reset lua + EgtLuaResetGlobVar("STU") + + Dim SetUpWindow As New SetUpWindowV(Application.Current.MainWindow, New SetUpWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachineName)) + SetUpWindow.Height = 614 + SetUpWindow.Width = 1024 + SetUpWindow.ShowDialog() + + End Sub + +#End Region + +#Region "COMMANDS" + +#Region "BeamTable" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property BeamTable_Command As ICommand + Get + If m_cmdBeamTable Is Nothing Then + m_cmdBeamTable = New Command(AddressOf BeamMachDb) + End If + Return m_cmdBeamTable + End Get + End Property + +#End Region ' BeamTable + +#Region "WallTable" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property WallTable_Command As ICommand + Get + If m_cmdWallTable Is Nothing Then + m_cmdWallTable = New Command(AddressOf WallMachDb) + End If + Return m_cmdWallTable + End Get + End Property + +#End Region ' WallTable + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Core/Resources/ProjectManager/Save.png b/EgtBEAMWALL.Core/Resources/ProjectManager/Save.png new file mode 100644 index 00000000..0eca2603 Binary files /dev/null and b/EgtBEAMWALL.Core/Resources/ProjectManager/Save.png differ diff --git a/EgtBEAMWALL.Core/Utility/Configuration.vb b/EgtBEAMWALL.Core/Utility/Configuration.vb new file mode 100644 index 00000000..78012045 --- /dev/null +++ b/EgtBEAMWALL.Core/Utility/Configuration.vb @@ -0,0 +1,24 @@ +Public Module Configuration + + Private m_bOnlyProd As Boolean + Public ReadOnly Property bOnlyProd As Boolean + Get + Return m_bOnlyProd + End Get + End Property + Public Sub SetOnlyProd(value As Boolean) + m_bOnlyProd = value + End Sub + + Private m_bModifySetup As Boolean + Public ReadOnly Property bModifySetup As Boolean + Get + Return m_bModifySetup + End Get + End Property + Public Sub SetModifySetup(value As Boolean) + m_bModifySetup = value + End Sub + + +End Module diff --git a/EgtBEAMWALL.Core/Utility/Enum.vb b/EgtBEAMWALL.Core/Utility/Enum.vb index 15b04bf5..cba6bb7a 100644 --- a/EgtBEAMWALL.Core/Utility/Enum.vb +++ b/EgtBEAMWALL.Core/Utility/Enum.vb @@ -63,6 +63,7 @@ Public Enum StatusMapOpType ChangeProdInProdRequest = 16 OpenPageInViewOptimRequest = 17 MachGroupValidationUpdate = 18 + ChangeProdInOnlyProdRequest = 19 End Enum Public Enum DimensionType diff --git a/EgtBEAMWALL.Supervisor/BeamMachiningsWindow/BeamMachiningsWindowV.xaml b/EgtBEAMWALL.Supervisor/BeamMachiningsWindow/BeamMachiningsWindowV.xaml new file mode 100644 index 00000000..02bcbf79 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/BeamMachiningsWindow/BeamMachiningsWindowV.xaml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/BTLPartManager/BTLPartManagerV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/BTLPartManager/BTLPartManagerV.xaml.vb new file mode 100644 index 00000000..5ff604d0 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/BTLPartManager/BTLPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class BTLPartManagerV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/BTLPartManager/BTLPartManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/BTLPartManager/BTLPartManagerVM.vb new file mode 100644 index 00000000..6d941a7d --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/BTLPartManager/BTLPartManagerVM.vb @@ -0,0 +1,1202 @@ +Imports EgtWPFLib5 +Imports EgtUILib +Imports System.IO +Imports EgtBEAMWALL.Core + +Public Class BTLPartManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Public ReadOnly Property ViewPage_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property MachiningPage_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Private m_BTLPartManager_IsEnabled As Boolean = True + Public ReadOnly Property BTLPartManager_IsEnabled As Boolean + Get + Return m_BTLPartManager_IsEnabled + End Get + End Property + + Public ReadOnly Property CopyPart_IsEnabled As Boolean + Get + Return m_BTLPartManager_IsEnabled AndAlso Not IsNothing(Map.refShowBeamPanelVM) AndAlso Not Map.refShowBeamPanelVM.bShowAll AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not Map.refProjectVM.BTLStructureVM.SelBTLPartsCnt > 1 + End Get + End Property + + Public ReadOnly Property RotatePart_IsEnabled As Boolean + Get + Return m_BTLPartManager_IsEnabled AndAlso Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelBTLParts.Count > 1 + End Get + End Property + + Public ReadOnly Property RemovePart_IsEnabled As Boolean + Get + Return m_BTLPartManager_IsEnabled + End Get + End Property + + + ' Definizione comandi + Private m_cmdNewRawPart As ICommand + Private m_cmdNewRawPartLast As ICommand + Private m_cmdAddToRawPart As ICommand + Private m_cmdCopyPart As ICommand + Private m_cmdAddPart As ICommand + Private m_cmdRemovePart As ICommand + Private m_cmdInvert As ICommand + Private m_cmdBackRotation As ICommand + Private m_cmdForwardRotation As ICommand + +#Region "Messages" + + Public ReadOnly Property NewRawPart_ToolTip As String + Get + Return EgtMsg(61903) + End Get + End Property + + Public ReadOnly Property NewRawPartLast_ToolTip As String + Get + Return EgtMsg(61977) + End Get + End Property + + Public ReadOnly Property AddToRawPart_ToolTip As String + Get + Return EgtMsg(61904) + End Get + End Property + + Public ReadOnly Property CopyPart_ToolTip As String + Get + Return EgtMsg(61905) + End Get + End Property + + Public ReadOnly Property AddPart_ToolTip As String + Get + Return EgtMsg(61906) + End Get + End Property + + Public ReadOnly Property RemovePart_ToolTip As String + Get + Return EgtMsg(61907) + End Get + End Property + + Public ReadOnly Property AddFeature_ToolTip As String + Get + Return EgtMsg(61910) + End Get + End Property + + Public ReadOnly Property RemoveFeature_ToolTip As String + Get + Return EgtMsg(61911) + End Get + End Property + + Public ReadOnly Property BackRotation_ToolTip As String + Get + Return EgtMsg(61996) + End Get + End Property + + Public ReadOnly Property ForwardRotation_ToolTip As String + Get + Return EgtMsg(61997) + End Get + End Property + + Public ReadOnly Property InvertSx_ToolTip As String + Get + Return EgtMsg(61998) + End Get + End Property + + Public ReadOnly Property InvertDx_ToolTip As String + Get + Return EgtMsg(61999) + End Get + End Property + +#End Region ' Messages + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + Map.SetRefBTLPartManagerVM(Me) + End Sub + +#End Region ' Constructor + +#Region "METHODS" + + Friend Sub UpdateView() + NotifyPropertyChanged(NameOf(ViewPage_Visibility)) + NotifyPropertyChanged(NameOf(MachiningPage_Visibility)) + End Sub + + Friend Sub SetBTLPartManagerIsEnabled(bIsEnabled As Boolean) + m_BTLPartManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(BTLPartManager_IsEnabled)) + NotifyPropertyChanged(NameOf(CopyPart_IsEnabled)) + NotifyPropertyChanged(NameOf(RemovePart_IsEnabled)) + End Sub + + Friend Sub PartShowAllChanged() + NotifyPropertyChanged(NameOf(CopyPart_IsEnabled)) + NotifyPropertyChanged(NameOf(RotatePart_IsEnabled)) + NotifyPropertyChanged(NameOf(RemovePart_IsEnabled)) + End Sub + +#End Region ' Methods + +#Region "COMMANDS" + +#Region "NewRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property NewRawPart_Command As ICommand + Get + If m_cmdNewRawPart Is Nothing Then + m_cmdNewRawPart = New Command(AddressOf NewRawPartCmd) + End If + Return m_cmdNewRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub NewRawPartCmd() + NewRawPart(False) + End Sub + + Public Sub NewRawPart(bLast As Boolean) + 'If IsNothing(Map.refProdManagerVM) OrElse IsNothing(ProjectManagerVM.CurrProd) Then Return + If Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso IsNothing(Map.refProdManagerVM) Then + Return + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso IsNothing(Map.refOnlyProdManagerVM) Then + Return + End If + 'Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart + Dim SelParts As List(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.SelBTLParts.ToList() + If IsNothing(SelParts) OrElse SelParts.Count <= 0 Then Return + ' verifico che abbiano tutti la stessa sezione + Dim dHSection As Double = SelParts(0).dH + Dim dWSection As Double = SelParts(0).dW + For PartIndex = 0 To SelParts.Count - 1 + Dim Part As BTLPartVM = SelParts(PartIndex) + If Not IsNothing(Part) Then + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + If Part.dH <> dHSection OrElse Part.dW <> dWSection Then + MessageBox.Show(EgtMsg(61970), EgtMsg(30007)) + Return + End If + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL Then + If Part.dH <> dHSection Then + MessageBox.Show(EgtMsg(61970), EgtMsg(30007)) + Return + End If + End If + Else + SelParts.Remove(Part) + End If + Next + ' se pareti e piu' di uno selezionato, esco + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL And SelParts.Count > 1 Then + MessageBox.Show(EgtMsg(61971), EgtMsg(30007)) + Return + End If + ' se nessun grezzo, rendo tutti i pezzi visibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.ShowAll(False) + End If + ' verifico se sono gia' stati messi tutti i pezzi richiesti + If Not VerifyPartCount(SelParts) Then Return + Dim dRawL As Double = SelParts(0).dL + Dim dRawW As Double = SelParts(0).dW + Dim dStartOffset As Double = 0 + Dim dKerf As Double = 0 + Dim dOffset As Double = WarehouseHelper.GetOffset(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + ' se tipo di definizione grezzo esplicito + If WarehouseHelper.GetRawPartDef = 1 OrElse ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift AndAlso WarehouseHelper.GetWarehouseType = WarehouseType.BASIC) Then + ' chiedo lunghezza grezzo + Dim sWarehouseIniPath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + dStartOffset = WarehouseHelper.GetStartOffset() + dRawL += dStartOffset + Else + dKerf = WarehouseHelper.GetKerf() + dRawL += 2 * dKerf + dRawW += 2 * dKerf + End If + Dim AddRawPartWndVM As New AddRawPartWndVM(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dRawL, dRawW, dStartOffset) + Dim AddRawPartWnd As New AddRawPartWndV(Application.Current.MainWindow, AddRawPartWndVM) + If Not AddRawPartWnd.ShowDialog() Then Return + dRawL = AddRawPartWndVM.VariableList(0).dValue + dRawW = AddRawPartWndVM.VariableList(1).dValue + dStartOffset = AddRawPartWndVM.VariableList(1).dValue + ' se altrimenti definizione grezzo da warehouse + Else + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + dStartOffset = WarehouseHelper.GetStartOffset() + Else + dKerf = WarehouseHelper.GetKerf() + End If + ' se warehouse basic + Select Case WarehouseHelper.GetWarehouseType() + Case WarehouseType.BASIC + WarehouseHelper.GetCurrentDimensions(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dRawW, dRawL) + Case WarehouseType.MEDIUM + Dim SectionList As List(Of SParam) = WarehouseHelper.GetSectionList() + Dim SParamlist As List(Of SParam) = SectionList.FindAll(Function(x) x.SectXMat = SelParts(0).Section) + If bLast Then + Dim LastMaterial As SParam = WarehouseHelper.GetLastMaterial(SelParts(0).Section) + If Not IsNothing(LastMaterial) Then + dRawL = LastMaterial.dL + dRawW = LastMaterial.dW + ElseIf SParamlist.Count > 0 Then + dRawL = SParamlist(0).dL + dRawW = SParamlist(0).dW + Else + MessageBox.Show(EgtMsg(61975), EgtMsg(30007)) + Return + End If + Else + If SParamlist.Count = 0 Then + ' se pareti aumento dimensioni del kerf + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL Then + dRawW += (2 * dKerf) + dRawL += (2 * dKerf) + End If + ' apro finestra con solo edit + If AddRawPartWnd(AddRawPartWndVM.EditTypes.ONLY_TEXT, SParamlist, dRawW, dRawL, dStartOffset, dOffset, dKerf) Then + WarehouseHelper.SetOffset(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dOffset) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + WarehouseHelper.SetStartOffset(dStartOffset) + Else + WarehouseHelper.SetKerf(dKerf) + End If + Else + Return + End If + ElseIf SParamlist.Count > 0 Then + ' imposto finestra con anche edit + If AddRawPartWnd(AddRawPartWndVM.EditTypes.TEXT_AND_COMBO, SParamlist, dRawW, dRawL, dStartOffset, dOffset, dKerf) Then + WarehouseHelper.SetOffset(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dOffset) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + WarehouseHelper.SetStartOffset(dStartOffset) + Else + WarehouseHelper.SetKerf(dKerf) + End If + Else + Return + End If + End If + End If + End Select + End If + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' verifico se lunghezza barra e' maggiore della lunghezza dei pezzi + Dim dTotLen As Double = WarehouseHelper.GetStartOffset() + For PartIndex = 0 To SelParts.Count - 1 + If PartIndex <> 0 Then + dTotLen += WarehouseHelper.GetOffset(BWType.BEAM) + End If + dTotLen += SelParts(PartIndex).dL + Next + If dTotLen > dRawL Then + MessageBox.Show(EgtMsg(61972), EgtMsg(30007)) + Return + End If + End If + ' creo nuovo gruppo di lavorazione + Map.refMachGroupPanelVM.AddMachGroup() + Dim nCurrMachGroup As Integer = EgtGetCurrMachGroup() + Dim sCurrMachGroupName As String = "" + EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName) + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + ' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione + If Map.refMainMenuVM.SelPage = Pages.MACHINING Then + EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, ProjectManagerVM.CurrProd.nProdId) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, Map.refOnlyProdManagerVM.CurrProd.nProdId) + End If + EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' ordino i pezzi per lunghezza + SelParts = SelParts.OrderBy(Function(x) x.dL).ToList + ' creo copie dei pezzi + Dim nPartDuploIdList As New List(Of Integer) + For Each Part In SelParts + Dim nDuploId As Integer = EgtDuploNew(Part.nPartId) + ' elimino valori calcolo dell'originale + MyMachGroupPanelVM.DuploRemoveProjCalc(nDuploId) + ' lo rendo std + EgtSetMode(nDuploId, GDB_MD.STD) + nPartDuploIdList.Add(nDuploId) + Next + ' scrivo dati costruzione grezzo in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_BARLEN, dRawL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, SelParts(0).sMATERIAL) + ' scrivo dati di tutti i pezzi + Dim dPosX As Double = WarehouseHelper.GetStartOffset() + ' ciclo sui pezzi + For nIndex = 0 To nPartDuploIdList.Count - 1 + ' se non è primo, aggiungo offset tra barre standard + If nIndex <> 0 Then + dPosX += WarehouseHelper.GetOffset(BWType.BEAM) + End If + EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & nIndex + 1, nPartDuploIdList(nIndex) & "," & DoubleToString(dPosX, 3)) + ' incremento posizione della sua lunghezza + dPosX += SelParts(nIndex).dL + Next + Dim BeamMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.GetLastMachGroup() + ' eseguo script creazione grezzo + Dim nERR As Integer = 0 + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + ' elimino duplo e gruppo di lavorazione + For Each nDuploId In nPartDuploIdList + EgtErase(nDuploId) + Next + BeamMachGroup.DeleteMachGroup() + If File.Exists(sLogPath) Then + Dim LogFile As String() = File.ReadAllLines(sLogPath) + If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then + MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + Else + MessageBox.Show(EgtMsg(61973), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + ' se nessun grezzo, rimetto tutti i pezzi invisibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.HideAll() + End If + Return + End If + For nDuploIndex = 0 To SelParts.Count - 1 + EgtSetInfo(nPartDuploIdList(nDuploIndex), MGR_PRT_ROT, SelParts(nDuploIndex).nROTATED) + EgtSetInfo(nPartDuploIdList(nDuploIndex), MGR_PRT_FLIP, SelParts(nDuploIndex).nINVERTED) + Next + ' aggiorno contatore pezzi usati in Prod + For Each SelPart In SelParts + SelPart.RefreshPartInProd() + Next + 'aggiorno lista pezzi + BeamMachGroup.MyMachGroupM.RefreshPartList() + BeamMachGroup.MyMachGroupM.RefreshGroupData() + ' aggiorno dati utilizzo barra + BeamMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + Dim nPartDuploId As Integer = EgtDuploNew(SelParts(0).nPartId) + ' scrivo dati in gruppo di lavorazione + Dim dPosX As Double = dKerf + Dim dPosY As Double = dKerf + EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELLEN, dRawL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELWIDTH, dRawW) + EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, SelParts(0).sMATERIAL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & 1, + nPartDuploId & "," & DoubleToString(dPosX, 3) & "," & DoubleToString(dPosY, 3) & ",0,0") + Dim WallMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(Map.refMachGroupPanelVM.MachGroupVMList.Count - 1) + ' eseguo script creazione grezzo + If Not ExecWall(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False, False) Then + ' elimino duplo e gruppo di lavorazione + EgtErase(nPartDuploId) + WallMachGroup.DeleteMachGroup() + If File.Exists(sLogPath) Then + Dim LogFile As String() = File.ReadAllLines(sLogPath) + If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then + MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + Else + MessageBox.Show(EgtMsg(61973), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + ' se nessun grezzo, rimetto tutti i pezzi invisibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.HideAll(True) + End If + Return + End If + ' scrivo dati pezzo + EgtSetInfo(nPartDuploId, MGR_PRT_POSX, dPosX) + EgtSetInfo(nPartDuploId, MGR_PRT_POSY, dPosY) + EgtSetInfo(nPartDuploId, MGR_PRT_ROT, SelParts(0).nROTATED) + EgtSetInfo(nPartDuploId, MGR_PRT_FLIP, SelParts(0).nINVERTED) + ' aggiorno contatore pezzi usati in Prod + SelParts(0).RefreshPartInProd() + ' aggiorno lista pezzi + WallMachGroup.MyMachGroupM.RefreshPartList() + WallMachGroup.MyMachGroupM.RefreshGroupData() + ' aggiorno dati ultilizzo barra + WallMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.TOP, False) + End If + EgtZoom(ZM.ALL) + End Sub + + ' funzione che apre finestra di scelta dimensioni grezzo + Private Function AddRawPartWnd(EditType As AddRawPartWndVM.EditTypes, SParamlist As List(Of SParam), ByRef dRawW As Double, ByRef dRawL As Double, + ByRef dStartOffset As Double, ByRef dOffset As Double, ByRef dKerf As Double) As Boolean + ' apro finestra con solo edit + Dim AddRawPartWndVM As New AddRawPartWndVM(EditType, Map.refProjectVM.BTLStructureVM.nPROJTYPE, SParamlist, dRawL, dRawW, dStartOffset, dOffset, dKerf) + Dim AddRawPartWndV As New AddRawPartWndV(Application.Current.MainWindow, AddRawPartWndVM) + If Not AddRawPartWndV.ShowDialog() Then Return False + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case BWType.BEAM + dRawL = AddRawPartWndVM.VariableList(0).dValue + dStartOffset = AddRawPartWndVM.VariableList(1).dValue + dOffset = AddRawPartWndVM.VariableList(2).dValue + Case BWType.WALL + dRawW = AddRawPartWndVM.VariableList(0).dValue + dRawL = AddRawPartWndVM.VariableList(1).dValue + dKerf = AddRawPartWndVM.VariableList(2).dValue + dOffset = AddRawPartWndVM.VariableList(3).dValue + End Select + ' verifico se il materiale esiste in magazzino o devo aggiungerlo + Dim CurrSParam As SParam = Nothing + Select Case EditType + Case AddRawPartWndVM.EditTypes.ONLY_TEXT + ' lo aggiungo a lista materiali in magazzino + CurrSParam = AddRawMaterial(dRawW, dRawL) + Case AddRawPartWndVM.EditTypes.ONLY_COMBO + ' non faccio nulla + Case AddRawPartWndVM.EditTypes.TEXT_AND_COMBO + ' verifico se lunghezza testo corrisponde a materiale + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + CurrSParam = SParamlist.FirstOrDefault(Function(x) x.dL = AddRawPartWndVM.VariableList(0).dValue) + Else + CurrSParam = SParamlist.FirstOrDefault(Function(x) x.dL = AddRawPartWndVM.VariableList(1).dValue AndAlso x.dW = AddRawPartWndVM.VariableList(0).dValue) + End If + If IsNothing(CurrSParam) Then + ' lo aggiungo a lista materiali in magazzino + CurrSParam = AddRawMaterial(dRawW, dRawL) + End If + End Select + ' imposto il materiale selezionato come ultimo utilizzato + SetLastMaterial(CurrSParam.SectXMat, CurrSParam) + Return True + End Function + + Private Function AddRawMaterial(dRawW As Double, ByRef dRawL As Double) As SParam + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + Dim nQuantity As Integer = GetMainPrivateProfileInt(S_WAREHOUSE, K_DEFAULTQUANTITY, 1) + Dim CurrSParam = Nothing + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' creo sParam + If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLParts(0)) Then CurrSParam = New SParam(Map.refProjectVM.BTLStructureVM.SelBTLParts(0).Section, dRawL, nQuantity, False) + Dim sL As String = String.Empty + sL = LenToString(CurrSParam.dL, 3) + ' ricavo l'indice del SecionXMaterial dalla Beam_List + Dim SectXMatIndex As Integer = GetSectIndexFromSection(MachineType.BEAM, CurrSParam.SectXMat) + ' ricavo nuovo indice materiale + Dim ParamIndex As Integer = 1 + Dim sParam As String = "" + While GetPrivateProfileString(S_BEAM, K_L & ParamIndex, "", sParam, sWarehousePath) > 0 + ParamIndex += 1 + End While + If SectXMatIndex > 0 Then + ' lo aggiungo in warehouse + WritePrivateProfileString(S_BEAM, K_L & ParamIndex, + SectXMatIndex & "," & sL & "," & CurrSParam.nQuantity & "," & If(CurrSParam.bActive, 1, 0), + sWarehousePath) + Else + EgtOutLog("Error in material creation, section not found!") + End If + Return CurrSParam + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + ' creo sParam + If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then CurrSParam = New SParam(Map.refProjectVM.BTLStructureVM.SelBTLPart.Section, dRawW, dRawL, nQuantity, False) + Dim sW As String = String.Empty + Dim sL As String = String.Empty + sW = LenToString(CurrSParam.dW, 3) + sL = LenToString(CurrSParam.dL, 3) + ' ricavo l'indice del SecionXMaterial dalla Wall_List + Dim SectXMatIndex As Integer = GetSectIndexFromSection(MachineType.WALL, CurrSParam.SectXMat) + ' ricavo nuovo indice materiale + Dim ParamIndex As Integer = 1 + Dim sParam As String = "" + While GetPrivateProfileString(S_WALL, K_S & ParamIndex, "", sParam, sWarehousePath) > 0 + ParamIndex += 1 + End While + ' lo aggiungo in warehouse + WritePrivateProfileString(S_WALL, K_S & ParamIndex, + SectXMatIndex & "," & sW & "," & sL & "," & CurrSParam.nQuantity & "," & If(CurrSParam.bActive, 1, 0), + sWarehousePath) + Return CurrSParam + End If + + Return Nothing + End Function + + Private Function VerifyPartCount(SelParts As List(Of BTLPartVM)) As Boolean + ' verifico se ci sono pezzi da aggiungere + Dim ToAddList As New List(Of String) + Dim ToAddVM As New List(Of BTLPartVM) + For Each SelPart In SelParts + If Not SelPart.CanAddPartToCount Then + ToAddList.Add(SelPart.nCNT & EgtMsg(61864) & SelPart.nADDED & EgtMsg(61865)) + ToAddVM.Add(SelPart) + End If + Next + ' se non ci sono, chiedo se aggiungerne uno nuovo + If ToAddList.Count > 0 Then + Dim sMessage As String = EgtMsg(61863) & Environment.NewLine + For Each sPart In ToAddList + sMessage &= " - " & sPart & Environment.NewLine + Next + If MessageBox.Show(sMessage & EgtMsg(61893), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + For Each PartVM In ToAddVM + PartVM.AddNewPartToAdded() + Next + Else + Return False + End If + End If + Return True + End Function + +#End Region ' NewRawPart + +#Region "NewRawPartLast" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property NewRawPartLast_Command As ICommand + Get + If m_cmdNewRawPartLast Is Nothing Then + m_cmdNewRawPartLast = New Command(AddressOf NewRawPartLast) + End If + Return m_cmdNewRawPartLast + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub NewRawPartLast() + NewRawPart(True) + End Sub + +#End Region ' NewRawPartLast + +#Region "AddToRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property AddToRawPart_Command As ICommand + Get + If m_cmdAddToRawPart Is Nothing Then + m_cmdAddToRawPart = New Command(AddressOf AddToRawPart) + End If + Return m_cmdAddToRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub AddToRawPart() + 'If IsNothing(ProjectManagerVM.CurrProd) Then Return + If Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso IsNothing(Map.refProdManagerVM) Then + Return + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso IsNothing(Map.refOnlyProdManagerVM) Then + Return + End If + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLParts(0) + Dim SelParts As List(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.SelBTLParts.ToList() + For Index = 0 To SelParts.Count() - 1 + If IsNothing(SelParts(Index)) Then + SelParts.RemoveAt(Index) + End If + Next + If IsNothing(SelPart) Then Return + If IsNothing(SelParts) OrElse SelParts.Count <= 0 Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se pareti e piu' di uno selezionato, esco + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL And SelParts.Count > 1 Then + MessageBox.Show(EgtMsg(61971), EgtMsg(30007)) + Return + End If + ' se MachGroup gia' mandato in produzione, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + ' verifico se sono gia' stati messi tutti i pezzi richiesti + If Not VerifyPartCount(SelParts) Then Return + ' verifico se impostato gruppo di lavorazione + Dim nCurrMachgroupId As Integer = EgtGetCurrMachGroup() + ' se nullo o diverso da quello selezionato in lista + If nCurrMachgroupId = GDB_ID.NULL OrElse nCurrMachgroupId <> SelMachGroup.Id Then + ' lo imposto + EgtSetCurrMachGroup(SelMachGroup.Id) + End If + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + Dim BeamMachGroup As MyMachGroupVM = SelMachGroup + ' verifico sezione e materiale + For Each Part In SelParts + If Part.Section <> BeamMachGroup.Section Then + MessageBox.Show(EgtMsg(61866), EgtMsg(30007)) + Return + End If + Next + ' verifico lunghezza totale + If Not VerifyTotLength(BeamMachGroup, SelParts) Then + MessageBox.Show(EgtMsg(61867), EgtMsg(30007)) + Return + End If + If AddPartToBeam(BeamMachGroup, SelParts) Then + ' aggiorno contatore pezzi usati in Prod + For Each Part In SelParts + Part.RefreshPartInProd() + Next + ' resetto stato di calc + SelMachGroup.ResetCalcMachGroup() + End If + ' aggiorno dati ultilizzo barra + BeamMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + Dim WallMachGroup As MyMachGroupVM = SelMachGroup + ' verifico spessore + If SelPart.Section <> WallMachGroup.Section Then + MessageBox.Show(EgtMsg(61868), EgtMsg(30007)) + Return + End If + If AddPartToWall(WallMachGroup, SelPart) Then + ' aggiorno contatore pezzi usati in Prod + SelPart.RefreshPartInProd() + ' resetto stato di calc + SelMachGroup.ResetCalcMachGroup() + End If + ' aggiorno dati ultilizzo barra + WallMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.TOP, False) + End If + EgtZoom(ZM.ALL) + End Sub + + Friend Function VerifyTotLength(BeamMachGroup As MyMachGroupVM, PartsToAdd As List(Of BTLPartVM)) As Boolean + Dim dNewPartPos As Double = 0 + If BeamMachGroup.PartVMList.Count > 0 Then + Dim LastPart As PartVM = BeamMachGroup.PartVMList(BeamMachGroup.PartVMList.Count - 1) + dNewPartPos += LastPart.dPOSX + LastPart.dL + End If + For Each Part In PartsToAdd + dNewPartPos += WarehouseHelper.GetOffset(BeamMachGroup.nType) + Part.dL + Next + Return dNewPartPos < BeamMachGroup.dL + End Function + + Friend Function AddPartToBeam(BeamMachGroup As MyMachGroupVM, PartsToAdd As List(Of BTLPartVM)) As Boolean + ' ordino i pezzi da aggiungere + PartsToAdd = PartsToAdd.OrderBy(Function(x) x.dL).ToList() + ' creo copie dei pezzi + Dim nPartDuploIdList As New List(Of Integer) + For Each Part In PartsToAdd + Dim nDuploId As Integer = EgtDuploNew(Part.nPartId) + ' elimino valori calcolo dell'originale + MyMachGroupPanelVM.DuploRemoveProjCalc(nDuploId) + ' lo rendo std + EgtSetMode(nDuploId, GDB_MD.STD) + nPartDuploIdList.Add(nDuploId) + Next + ' calcolo posizione nuovo pezzo per rispettare ordine lunghezze + Dim nInsertIndex As Integer + ' scrivo dati di tutti i pezzi + Dim dPosX As Double = BeamMachGroup.dStartCut + Dim nPartIndex As Integer = 0 + Dim nIndex As Integer + ' ciclo sui pezzi + For nIndex = 0 To BeamMachGroup.PartVMList.Count - 1 + For PartsToAddIndex = nPartIndex To PartsToAdd.Count - 1 + Dim Part As BTLPartVM = PartsToAdd(PartsToAddIndex) + ' se non ancora aggiunto e lunghezza minore del pezzo corrente, lo aggiungo + If nPartIndex < nPartDuploIdList.Count() AndAlso BeamMachGroup.PartVMList(nIndex).dL > Part.dL Then + ' se non è primo, aggiungo offset tra barre standard + If nIndex <> 0 OrElse nPartIndex <> 0 Then + dPosX += WarehouseHelper.GetOffset(BeamMachGroup.nType) + End If + EgtSetInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + nPartIndex + 1, nPartDuploIdList(nPartIndex) & "," & DoubleToString(dPosX, 3)) + ' incremento posizione della sua lunghezza + dPosX += Part.dL + ' conservo indice d'inserimento + nInsertIndex = nIndex + nPartIndex += 1 + Else + Exit For + End If + Next + ' se non è primo, aggiungo offset del pezzo + If nIndex <> 0 Then + dPosX += BeamMachGroup.PartVMList(nIndex).dOffset + ' se sono a indice primo ed è stato aggiunto pezzo nuovo + ElseIf nIndex = 0 AndAlso nPartIndex > 0 Then + ' aggiungo offset tra barre standard + dPosX += WarehouseHelper.GetOffset(BeamMachGroup.nType) + End If + EgtSetInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + nPartIndex + 1, BeamMachGroup.PartVMList(nIndex).nPartId & "," & DoubleToString(dPosX, 3)) + ' incremento posizione della sua lunghezza + dPosX += BeamMachGroup.PartVMList(nIndex).dL + Next + ' se non è ancora stato aggiunto + For PartsToAddIndex = nPartIndex To PartsToAdd.Count - 1 + ' aggiungo offset tra barre standard + dPosX += WarehouseHelper.GetOffset(BeamMachGroup.nType) + ' lo aggiungo in fondo + EgtSetInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + nPartIndex + 1, nPartDuploIdList(nPartIndex) & "," & DoubleToString(dPosX, 3)) + ' incremento posizione della sua lunghezza + dPosX += PartsToAdd(nPartIndex).dL + ' conservo indice d'inserimento + nInsertIndex = nIndex + nPartIndex += 1 + Next + ' elimino vecchio grezzo ed eseguo script creazione nuovo + Dim nRawId As Integer = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + EgtRemoveRawPart(nRawId) + nRawId = EgtGetFirstRawPart() + End While + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + Return False + End If + For nDuploIndex = 0 To PartsToAdd.Count - 1 + EgtSetInfo(nPartDuploIdList(nDuploIndex), MGR_PRT_ROT, PartsToAdd(nDuploIndex).nROTATED) + EgtSetInfo(nPartDuploIdList(nDuploIndex), MGR_PRT_FLIP, PartsToAdd(nDuploIndex).nINVERTED) + Next + ' aggiorno lista pezzi + BeamMachGroup.MyMachGroupM.RefreshPartList() + ' seleziono pezzo aggiunto + If BeamMachGroup.PartVMList.Count > nInsertIndex Then BeamMachGroup.SelPart = BeamMachGroup.PartVMList(nInsertIndex) + Return True + End Function + + Friend Function AddPartToWall(WallMachGroup As MyMachGroupVM, PartToAdd As BTLPartVM) As Boolean + ' creo copia del pezzo + Dim nPartDuploId As Integer = EgtDuploNew(PartToAdd.nPartId) + ' lo rendo std + EgtSetMode(nPartDuploId, GDB_MD.STD) + ' Posizione di inserimento + Dim dPosX As Double = WarehouseHelper.GetKerf() + Dim dPosY As Double = WarehouseHelper.GetKerf() + ' Se ci sono pezzi già inseriti + If WallMachGroup.PartVMList.Count > 0 Then + Dim LastWall As PartVM = WallMachGroup.PartVMList(WallMachGroup.PartVMList.Count - 1) + Dim LastWallPosX As Double = LastWall.dPOSX + Dim LastWallPosY As Double = LastWall.PartM.dPOSY + ' converto posizione ultimo pezzo nel riferimento BL + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL + LastWallPosY = WallMachGroup.dW - LastWall.dW - LastWall.PartM.dPOSY + Case MCH_CR.BL + Case MCH_CR.TR + LastWallPosX = WallMachGroup.dL - LastWall.dL - LastWall.dPOSX + LastWallPosY = WallMachGroup.dW - LastWall.dW - LastWall.PartM.dPOSY + Case MCH_CR.BR + LastWallPosX = WallMachGroup.dL - LastWall.dL - LastWall.dPOSX + End Select + ' verifico se posso metterlo sopra in Y + Dim NextPosY = LastWallPosY + LastWall.dW + WarehouseHelper.GetOffset(WallMachGroup.nType) + If WallMachGroup.dW - NextPosY > PartToAdd.dW + 10 Then + dPosX = LastWallPosX + dPosY = NextPosY + Else + ' altrimenti lo affianco in X + dPosX = 10 + For i As Integer = 0 To WallMachGroup.PartVMList.Count - 1 + Dim CurrWall As PartVM = WallMachGroup.PartVMList(i) + Dim CurrWallPosX As Double = CurrWall.dPOSX + ' converto posizione pezzo corrente nel riferimento BL + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL + Case MCH_CR.BL + Case MCH_CR.TR + CurrWallPosX = WallMachGroup.dL - CurrWall.dL - CurrWall.dPOSX + Case MCH_CR.BR + CurrWallPosX = WallMachGroup.dL - CurrWall.dL - CurrWall.dPOSX + End Select + Dim NextPosX = CurrWallPosX + CurrWall.dL + WarehouseHelper.GetOffset(WallMachGroup.nType) + If NextPosX > dPosX Then + dPosX = NextPosX + End If + Next + dPosY = 10 + End If + End If + ' converto posizione trovata da riferimento BL a quello corrente + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL + dPosY = WallMachGroup.dW - PartToAdd.dW - dPosY + Case MCH_CR.BL + Case MCH_CR.TR + dPosX = WallMachGroup.dL - PartToAdd.dL - dPosX + dPosY = WallMachGroup.dW - PartToAdd.dW - dPosY + Case MCH_CR.BR + dPosX = WallMachGroup.dL - PartToAdd.dL - dPosX + End Select + ' aggiungo il pezzo al grezzo + If EgtAddPartToRawPart(nPartDuploId, New Point3d(dPosX, dPosY, 0), WallMachGroup.MyMachGroupM.nRawPartId) Then + EgtSetInfo(nPartDuploId, MGR_PRT_POSX, dPosX) + EgtSetInfo(nPartDuploId, MGR_PRT_POSY, dPosY) + EgtSetInfo(nPartDuploId, MGR_PRT_ROT, PartToAdd.nROTATED) + EgtSetInfo(nPartDuploId, MGR_PRT_FLIP, PartToAdd.nINVERTED) + Else + Return False + End If + 'aggiorno lista pezzi + WallMachGroup.MyMachGroupM.RefreshPartList() + ' seleziono pezzo aggiunto + If WallMachGroup.PartVMList.Count > 0 Then WallMachGroup.SelPart = WallMachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nPartDuploId) + Return True + End Function + +#End Region ' AddToRawPart + +#Region "CopyPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property CopyPart_Command As ICommand + Get + If m_cmdCopyPart Is Nothing Then + m_cmdCopyPart = New Command(AddressOf CopyPart) + End If + Return m_cmdCopyPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub CopyPart() + 'If IsNothing(ProjectManagerVM.CurrProj) Then Return + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso IsNothing(Map.refProjManagerVM) AndAlso IsNothing(ProjectManagerVM.CurrProj) Then + Return + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso IsNothing(Map.refOnlyProdManagerVM) AndAlso IsNothing(ProjectManagerVM.CurrProj) Then + Return + End If + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart + If IsNothing(SelPart) Then Return + ' creo copia + Dim NewPart As BTLPartM = SelPart.Copy() + If Not IsNothing(NewPart) Then + ' selezione ultimo che e' quello appena creato + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList(Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count - 1), False, True) + End If + End Sub + +#End Region ' CopyPart + +#Region "AddPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property AddPart_Command As ICommand + Get + If m_cmdAddPart Is Nothing Then + m_cmdAddPart = New Command(AddressOf AddPart) + End If + Return m_cmdAddPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub AddPart(ByVal param As Object) + 'If IsNothing(ProjectManagerVM.CurrProj) Then Return + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso IsNothing(Map.refProjManagerVM) Then + Return + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso IsNothing(Map.refOnlyProdManagerVM) Then + Return + End If + ' apro finestra di definizione nuovo part + Dim AddPartWndVM As New AddPartWndVM() + Dim AddPartWnd As New AddPartWndV(Application.Current.MainWindow, AddPartWndVM) + If AddPartWnd.ShowDialog() Then + ' creo nuovo part + Dim nNewPartId As Integer = EgtBeamCreatePart() + ' scrivo info proj + 'EgtSetInfo(nNewPartId, BTL_PRT_PROJ, ProjectManagerVM.CurrProj.nProjId) + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso IsNothing(Map.refProjManagerVM) Then + EgtSetInfo(nNewPartId, BTL_PRT_PROJ, ProjectManagerVM.CurrProj.nProjId) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso IsNothing(Map.refOnlyProdManagerVM) Then + EgtSetInfo(nNewPartId, BTL_PRT_PROJ, Map.refOnlyProdManagerVM.CurrProd.nProdId) + End If + EgtBeamSetPartProdNbr(AddPartWndVM.nPDN) + If Not IsNothing(AddPartWndVM.sNAM) Then EgtBeamSetPartName(AddPartWndVM.sNAM) + EgtBeamSetPartCount(AddPartWndVM.nCNT) + EgtBeamSetPartBox(AddPartWndVM.dL, AddPartWndVM.dH, AddPartWndVM.dW) + ' 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 + 'NewPart.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, 180, False) + ' recupero il box del pezzo + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nNewPartId, "Box") + Dim b3Solid As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Solid) + Dim bOk As Boolean = EgtRotate(nNewPartId, b3Solid.Center, Vector3d.Z_AX, 180, GDB_RT.GLOB) + If bOk Then + EgtSetInfo(nNewPartId, BTL_PRT_ROTATED, 180) + End If + End If + ' aggiungo dati pezzo + Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nNewPartId) + ' aggiungo pezzo alla lista + Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart) + Dim NewPartVM As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart) + If Not IsNothing(NewPartVM) Then + EgtZoom(ZM.ALL) + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(NewPartVM, False, True) + ' verifico se aggiungere sezione alla lista + If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(NewPartVM.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Add(NewPartVM.Section) + End If + End If + End If + + End Sub + +#End Region ' AddPart + +#Region "RemovePart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemovePart_Command As ICommand + Get + If m_cmdRemovePart Is Nothing Then + m_cmdRemovePart = New Command(AddressOf RemovePartCmd) + End If + Return m_cmdRemovePart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemovePartCmd() + 'If IsNothing(ProjectManagerVM.CurrProj) Then Return + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso IsNothing(Map.refProjManagerVM) Then + Return + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso IsNothing(Map.refOnlyProdManagerVM) Then + Return + End If + If Map.refProjectVM.BTLStructureVM.SelBTLParts.Count > 0 Then + Dim CurrSelBTLParts As List(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.SelBTLParts.ToList() + For RemoveIndex = CurrSelBTLParts.Count - 1 To 0 Step -1 + RemovePart(CurrSelBTLParts(RemoveIndex), RemoveIndex = 0) + ' imposto vista tutti i pezzi + 'Map.refShowBeamPanelVM.ShowAll(RemoveIndex = 0) + Next + End If + End Sub + + Public Sub RemovePart(BTLPartToDelete As BTLPartVM, bSelPrevious As Boolean) + ' verifico se ci sono già copie in grezzi + Dim nDuploCount As Integer = 0 + If EgtDuploCount(BTLPartToDelete.nPartId, nDuploCount) AndAlso nDuploCount > 0 Then + ' avviso che il pezzo non è cancellabile perchè in produzione + MessageBox.Show(String.Format(EgtMsg(61929), nDuploCount), EgtMsg(15003), MessageBoxButton.OK, MessageBoxImage.Warning) + Return + End If + ' verifico se rimuovere sezione dalla lista + If Not Map.refProjectVM.BTLStructureVM.BTLPartVMList.Any(Function(x) x IsNot BTLPartToDelete AndAlso x.Section = BTLPartToDelete.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Remove(BTLPartToDelete.Section) + Map.refProjectVM.BTLStructureVM.SelSection = SectionXMaterial.Empty + End If + ' Eseguo cancellazione + EgtBeamSetPart(BTLPartToDelete.nPartId) + If EgtBeamErasePart() Then + ' seleziono elemento precedente + Dim Index As Integer = Map.refProjectVM.BTLStructureVM.BTLPartVMList.IndexOf(BTLPartToDelete) + Dim FilteredIndex As Integer = Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.IndexOf(BTLPartToDelete) + Map.refProjectVM.BTLStructureVM.SelBTLParts.Remove(BTLPartToDelete) + If bSelPrevious Then + If FilteredIndex = 0 Then + If Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.Count > 1 Then + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList_View(1)) + Else + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Nothing) + End If + ElseIf FilteredIndex = Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.Count - 1 Then + If Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.Count > 1 Then + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList_View(Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.Count - 2)) + Else + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Nothing) + End If + Else + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList_View(FilteredIndex - 1)) + End If + End If + ' rimuovo dalla lista pezzi + Map.refProjectVM.BTLStructureVM.BTLPartVMList.RemoveAt(Index) + End If + End Sub + +#End Region ' RemovePart + +#Region "Invert" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property Invert_Command As ICommand + Get + If m_cmdInvert Is Nothing Then + m_cmdInvert = New Command(AddressOf Invert) + End If + Return m_cmdInvert + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub Invert() + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso IsNothing(Map.refProjManagerVM) AndAlso IsNothing(ProjectManagerVM.CurrProj)) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then + Return + ElseIf (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso IsNothing(Map.refOnlyProdManagerVM) AndAlso IsNothing(ProjectManagerVM.CurrProj)) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then + Return + End If + ' se modalita' assemblato + Dim bShowBuilding As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + Configuration.AssembledMode(bShowBuilding) + 'If bShowBuilding AndAlso Map.refShowBeamPanelVM.bShowAll Then + ' ' devo smontarlo prima di ruotare le travi + ' Map.refProjectVM.BTLStructureVM.ShowBuilding(False, False) + 'End If + ' inverto i pezzi selezionati + For Each Part In Map.refProjectVM.BTLStructureVM.SelBTLParts + Part.Invert() + Next + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + End Sub + +#End Region ' Invert + +#Region "BackRotation" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property BackRotation_Command As ICommand + Get + If m_cmdBackRotation Is Nothing Then + m_cmdBackRotation = New Command(AddressOf BackRotation) + End If + Return m_cmdBackRotation + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub BackRotation() + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso IsNothing(Map.refProjManagerVM) AndAlso IsNothing(ProjectManagerVM.CurrProj)) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then + Return + ElseIf (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso IsNothing(Map.refOnlyProdManagerVM) AndAlso IsNothing(ProjectManagerVM.CurrProj)) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then + Return + End If + ' salvo sezione impostata + Dim CurrSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SelSection + ' se modalita' assemblato + Dim bShowBuilding As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + Configuration.AssembledMode(bShowBuilding) + 'If bShowBuilding AndAlso Map.refShowBeamPanelVM.bShowAll Then + ' ' devo smontarlo prima di ruotare le travi + ' Map.refProjectVM.BTLStructureVM.ShowBuilding(False, False) + 'End If + ' ruoto i pezzi selezionati + For Each Part In Map.refProjectVM.BTLStructureVM.SelBTLParts + Part.BackRotation(False, False) + Next + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + ' se progetto travi e sezione precedente diversa da vuota (tutti i pezzi) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM AndAlso CurrSection <> SectionXMaterial.Empty Then + ' se esiste, imposto sezione inversa + Dim InverseSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SectionList.FirstOrDefault(Function(x) x.dH = CurrSection.dW AndAlso x.dW = CurrSection.dH AndAlso x.sMaterial(0) = CurrSection.sMaterial(0)) + If Not IsNothing(InverseSection) Then Map.refProjectVM.BTLStructureVM.SetSelSection(InverseSection) + End If + EgtDraw() + End Sub + +#End Region ' BackRotation + +#Region "ForwardRotation" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ForwardRotation_Command As ICommand + Get + If m_cmdForwardRotation Is Nothing Then + m_cmdForwardRotation = New Command(AddressOf ForwardRotation) + End If + Return m_cmdForwardRotation + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ForwardRotation() + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso IsNothing(Map.refProjManagerVM) AndAlso IsNothing(ProjectManagerVM.CurrProj)) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then + Return + ElseIf (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso IsNothing(Map.refOnlyProdManagerVM) AndAlso IsNothing(ProjectManagerVM.CurrProj)) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then + Return + End If + ' salvo sezione impostata + Dim CurrSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SelSection + ' se modalita' assemblato + Dim bShowBuilding As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + Configuration.AssembledMode(bShowBuilding) + 'If bShowBuilding AndAlso Map.refShowBeamPanelVM.bShowAll Then + ' ' devo smontarlo prima di ruotare le travi + ' Map.refProjectVM.BTLStructureVM.ShowBuilding(False, False) + 'End If + ' ruoto i pezzi selezionati + For Each Part In Map.refProjectVM.BTLStructureVM.SelBTLParts + Part.ForwardRotation(False, False) + Next + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + ' se progetto travi e sezione precedente diversa da vuota (tutti i pezzi) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM AndAlso CurrSection <> SectionXMaterial.Empty Then + ' se esiste, imposto sezione inversa + Dim InverseSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SectionList.FirstOrDefault(Function(x) x.dH = CurrSection.dW AndAlso x.dW = CurrSection.dH AndAlso x.sMaterial(0) = CurrSection.sMaterial(0)) + If Not IsNothing(InverseSection) Then Map.refProjectVM.BTLStructureVM.SetSelSection(InverseSection) + End If + EgtDraw() + End Sub + +#End Region ' ForwardRotation + +#End Region ' COMMANDS + + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLFeatureVM.vb b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLFeatureVM.vb index 7ab66f7d..dc0ab084 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLFeatureVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLFeatureVM.vb @@ -126,9 +126,9 @@ Public Class BTLFeatureVM ' setto feature da ricalcolare ResetCalcFeature() ' se in View - If Map.refMainMenuVM.SelPage = Pages.VIEW Then + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then ' imposto modificato per copie - EgtDuploSetModified(m_BTLPartM.nPartId) + MyMachGroupPanelM.SetDuploModified(m_BTLPartM.nPartId) End If End If End If @@ -163,9 +163,10 @@ Public Class BTLFeatureVM ' setto feature da ricalcolare ResetCalcFeature() ' se in View - If Map.refMainMenuVM.SelPage = Pages.VIEW Then + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(m_BTLPartM)) Then ' imposto modificato per copie - EgtDuploSetModified(m_BTLPartM.nPartId) + Dim cc = Map.refMachGroupPanelVM.MachGroupVMList + MyMachGroupPanelM.SetDuploModified(m_BTLPartM.nPartId) End If NotifyPropertyChanged(NameOf(bDO)) ' aggiorno messaggio su context menu @@ -209,7 +210,9 @@ 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 End If NotifyPropertyChanged(NameOf(SelPBTLParam)) End Set @@ -232,7 +235,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 @@ -403,6 +406,28 @@ Public Class BTLFeatureVM Return Nothing End Function + Public Overrides Sub RefreshFeature() + ' leggo gruppo, numero feature, lato e priorità + EgtGetInfo(nFeatureId, BTL_FTR_GRP, m_BTLFeatureM.nSelGRP) + EgtGetInfo(nFeatureId, BTL_FTR_PRC, m_BTLFeatureM.nPRC) + EgtGetInfo(nFeatureId, BTL_FTR_SIDE, m_BTLFeatureM.nSelSIDE) + EgtGetInfo(nFeatureId, BTL_FTR_PRIORITY, m_BTLFeatureM.nPriority) + Dim nDO As Integer = 1 + If EgtGetInfo(nFeatureId, BTL_FTR_DO, nDO) Then + m_BTLFeatureM.bDO = (nDO <> 0) + Else + m_BTLFeatureM.bDO = True + End If + NotifyPropertyChanged(NameOf(bDO)) + ' leggo des,prid e frame + EgtGetInfo(nFeatureId, BTL_FTR_DES, m_BTLFeatureM.sDES) + EgtGetInfo(nFeatureId, BTL_FTR_PRID, m_BTLFeatureM.nPRID) + EgtGetInfo(nFeatureId, BTL_FTR_FRAME, m_BTLFeatureM.frFRAME) + + ' aggiorno parametri della feature + + End Sub + #End Region ' METHODS #Region "COMMANDS" @@ -419,7 +444,7 @@ Public Class BTLFeatureVM End Property Public Sub DeleteFeature() - If Map.refMainMenuVM.SelPage = Pages.VIEW Then Map.refLeftPanelVM.RemoveFeature() + If Map.refMainMenuVM.SelPage = Pages.VIEW Then Map.refFeatureListManagerVM.RemoveFeature() End Sub #End Region ' DeleteFeature diff --git a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLPartVM.vb b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLPartVM.vb index 878e496d..3a20cde9 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLPartVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLPartVM.vb @@ -19,21 +19,21 @@ Public Class BTLPartVM End Property Private m_BTLStructureM As BTLStructureM - Private m_IsSelected As Boolean - Public Property IsSelected As Boolean - Get - Return m_IsSelected - End Get - Set(value As Boolean) - m_IsSelected = value - Map.refProjectVM.BTLStructureVM.UpdateSelBTLParts() - End Set - End Property - Friend Sub SetIsSelected(value As Boolean, Optional bByOptim As Boolean = False) - m_IsSelected = value - Map.refProjectVM.BTLStructureVM.UpdateSelBTLParts(False, bByOptim) - NotifyPropertyChanged(NameOf(IsSelected)) - End Sub + 'Private m_IsSelected As Boolean + 'Public Property IsSelected As Boolean + ' Get + ' Return m_IsSelected + ' End Get + ' Set(value As Boolean) + ' m_IsSelected = value + ' Map.refProjectVM.BTLStructureVM.UpdateSelBTLParts() + ' End Set + 'End Property + 'Friend Sub SetIsSelected(value As Boolean, Optional bByOptim As Boolean = False) + ' m_IsSelected = value + ' Map.refProjectVM.BTLStructureVM.UpdateSelBTLParts(False, bByOptim) + ' NotifyPropertyChanged(NameOf(IsSelected)) + 'End Sub Public ReadOnly Property nPartId As Integer Get @@ -96,8 +96,13 @@ Public Class BTLPartVM If nMachgroupId = GDB_ID.NULL Then EgtOutLog("Trovato Duplo Ghost") Else - Dim MachGroupModel = DbControllers.m_MachGroupController.FindByMachGroupId(Map.refProjManagerVM.CurrProj.nProdId, nMachgroupId) - If MachGroupModel.State > ItemState.ND Then + Dim MachGroupModel = Nothing + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjManagerVM) Then + MachGroupModel = DbControllers.m_MachGroupController.FindByMachGroupId(ProjectManagerVM.CurrProj.nProdId, nMachgroupId) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(Map.refOnlyProdManagerVM) Then + MachGroupModel = DbControllers.m_MachGroupController.FindByMachGroupId(Map.refOnlyProdManagerVM.CurrProj.nProdId, nMachgroupId) + End If + If Not IsNothing(MachGroupModel) AndAlso MachGroupModel.State > ItemState.ND Then bDuploInProduction = True Exit For End If @@ -112,6 +117,7 @@ Public Class BTLPartVM ' avviso che tutti i pezzi verranno tolti dai grezzi e chiedo di confermare If MessageBox.Show(String.Format(EgtMsg(61851), nDuploCount), EgtMsg(15003), MessageBoxButton.YesNo, MessageBoxImage.Information) = MessageBoxResult.Yes Then MyMachGroupPanelM.DuploSetToDelete(m_BTLPartM.nPartId) + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then DeleteDuplo_OnlyProdPage(DuploList) Else ' reimposto vecchio valore Return False @@ -127,7 +133,7 @@ Public Class BTLPartVM If Not EgtBeamSetPartBox(dBtlL, dBtlH, dBtlW, False) Then Return False ' imposto modificato per copie - EgtDuploSetModified(m_BTLPartM.nPartId) + MyMachGroupPanelM.SetDuploModified(m_BTLPartM.nPartId) ' ricalcolo tutte le feature contenute UpdateFeatures() ' setto part da ricalcolare @@ -144,6 +150,34 @@ Public Class BTLPartVM Return True End Function + Private Sub DeleteDuplo_OnlyProdPage(DuploList As List(Of Integer)) + For Each nDuploId In DuploList + ' recupero grezzo cui appartiene + Dim nRawPartId As Integer = MyMachGroupPanelM.DuploGetRawPart(nDuploId) + ' recupero gruppo di lavorazione + Dim nMachGroupId As Integer = EgtGetParent(EgtGetParent(nRawPartId)) + ' lo setto come corrente + EgtSetCurrMachGroup(nMachGroupId) + ' elimino pezzo copia + EgtRemovePartFromRawPart(nDuploId) + EgtErase(nDuploId) + '' recupero gruppo di lavorazione e trave dell'interfaccia + Dim BeamMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = nMachGroupId) + If Not IsNothing(BeamMachGroup) Then + Dim Beam As PartVM = BeamMachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nDuploId) + EgtSetCurrMachGroup(BeamMachGroup.Id) + Beam.DeletePart() + End If + ' reset necessario per poter ottenere nMachGroupId corretto + EgtResetCurrMachGroup() + ' aggiorno dati utilizzo barra + BeamMachGroup.UpdateUsage() + Next + ' aggiorno quantita' in prod + Dim BTLPart As BTLPartVM = CALCPanelVM.GetBTLPartVMFromBTLPartId(m_BTLPartM.nPartId) + BTLPart.RefreshPartInProd() + End Sub + Private Function GetOrigFrameGroup(nPartId As Integer) As Integer Dim nCOP As Integer = GDB_ID.NULL Dim nBAS As Integer = GDB_ID.NULL @@ -1521,13 +1555,15 @@ Public Class BTLPartVM End Get Set(value As BTLFeatureVM) m_SelBTLFeatureVM = value - If Map.refMainMenuVM.SelPage = Pages.VIEW Then + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART) Then If Not IsNothing(m_SelBTLFeatureVM) Then DirectCast(m_SelBTLFeatureVM, BTLFeatureVM).SelGeomFeature() - ' imposto path disegno da mostrare in BottomPanel - Map.refBottomPanelVM.SetCurrDraw(DirectCast(m_SelBTLFeatureVM, BTLFeatureVM).sDrawPath) - ' seleziono pagina BottomPanel - Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.FEATURE) + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + ' imposto path disegno da mostrare in BottomPanel + Map.refBottomPanelVM.SetCurrDraw(DirectCast(m_SelBTLFeatureVM, BTLFeatureVM).sDrawPath) + ' seleziono pagina BottomPanel + Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.FEATURE) + End If ' deseleziono i parametri If Not IsNothing(SelBTLFeatureVM.SelPBTLParam) Then SelBTLFeatureVM.SelPBTLParam = Nothing ' rinfresco bottoni freecontour @@ -1538,7 +1574,12 @@ Public Class BTLPartVM Else EgtDeselectAll() End If - Map.refLeftPanelVM.FeatureSelectionChanged() + 'Map.refLeftPanelVM.FeatureSelectionChanged() + If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.FeatureSelectionChanged() + End If + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + EgtResetCurrMachGroup() + ResetSearchFound() End If EgtDraw() NotifyPropertyChanged(NameOf(SelBTLFeatureVM)) @@ -1552,6 +1593,27 @@ Public Class BTLPartVM End Get End Property + Private m_bSearchFound As Boolean + Public ReadOnly Property bSearchFound As Boolean + Get + Return m_bSearchFound + End Get + End Property + Friend Sub SetSearchFound() + m_bSearchFound = True + NotifyPropertyChanged(NameOf(Search_Background)) + End Sub + Friend Sub ResetSearchFound() + m_bSearchFound = False + NotifyPropertyChanged(NameOf(Search_Background)) + End Sub + + Public ReadOnly Property Search_Background As SolidColorBrush + Get + Return If(m_bSearchFound AndAlso Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Brushes.Purple, Brushes.Transparent) + End Get + End Property + ' Definizione comandi Private m_cmdInvert As ICommand Private m_cmdBackRotation As ICommand @@ -1768,7 +1830,11 @@ Public Class BTLPartVM Dim nNewPartId As Integer = EgtBeamCreatePart() If nNewPartId = GDB_ID.NULL Then Return Nothing ' scrivo info proj - EgtSetInfo(nNewPartId, BTL_PRT_PROJ, Map.refProjManagerVM.CurrProj.nProjId) + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjManagerVM) Then + EgtSetInfo(nNewPartId, BTL_PRT_PROJ, ProjectManagerVM.CurrProj.nProjId) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(Map.refOnlyProdManagerVM) Then + EgtSetInfo(nNewPartId, BTL_PRT_PROJ, Map.refOnlyProdManagerVM.CurrProd.nProdId) + End If EgtBeamSetPartProdNbr(m_BTLStructureM.NewPDN()) EgtBeamSetPartName(m_BTLPartM.sNAM) EgtBeamSetPartCount(m_BTLPartM.nCNT) @@ -2065,7 +2131,7 @@ Public Class BTLPartVM ' eseguo rotazione di 90 gradi If EgtRotate(nPartId, b3Solid.Center, vtAxes, 90, GDB_RT.GLOB) Then ' imposto modificato per copie - EgtDuploSetModified(nPartId) + MyMachGroupPanelM.SetDuploModified(nPartId) End If ' aggiorno visualizzazione dimensioni NotifyPropertyChanged(NameOf(sW)) @@ -2167,7 +2233,7 @@ Public Class BTLPartVM CalcGlobalUpdate(True) ' imposto path disegno da mostrare in BottomPanel Dim SelPBTLParam As BTLParamVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam - If Not IsNothing(SelPBTLParam) Then Map.refBottomPanelVM.SetCurrDraw(SelPBTLParam.sDrawPath) + If Not IsNothing(Map.refBottomPanelVM) AndAlso Not IsNothing(SelPBTLParam) Then Map.refBottomPanelVM.SetCurrDraw(SelPBTLParam.sDrawPath) Case NameOf(sender.bDO), NameOf(sender.sPriority) NotifyPropertyChanged(NameOf(bDOALL)) ' setto pezzo da ricalcolare diff --git a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb index e84da41f..fdde01ce 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BTLViewModel/BTLStructureVM.vb @@ -66,21 +66,44 @@ Public Class BTLStructureVM End Get End Property Friend Sub SetSelectionType(value As SelectionTypes) + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' rimuovo selezione da pezzo in MachGroup + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup) Then + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart) Then + Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart = Nothing + End If + End If + End If m_PrevSelectionType = m_SelectionType - If value = m_SelectionType Then Return + If value = m_SelectionType And (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART Or Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST) Then Return m_SelectionType = value Select Case m_SelectionType Case SelectionTypes.SELECT_ + ' imposto modalita' proj su vista feature + 'Map.refProjectVM.SelProdProj = ProdProj.PROJ + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProdProjManagerVM.SelProdProj = ProdProj.PROJ + ' rendo enable bottone parameters + Map.refLeftPanelVM.SetParametersIsEnabled(True) ' verifico reset mark su tutti i pezzi For Each BTLPart In m_BTLPartVMList EgtResetMark(BTLPart.nPartId) Next ' mostro barra di gestione pezzo - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) Case SelectionTypes.HIGHLIGHT + ' imposto modalita' nulla su vista feature + 'Map.refProjectVM.SelProdProj = ProdProj.NULL + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProdProjManagerVM.SelProdProj = ProdProj.NULL + ' rendo disable bottone parameters + Map.refLeftPanelVM.SetParametersIsEnabled(False) If m_PrevSelectionType = SelectionTypes.SELECT_ Then - EgtBeamShowFacesName( False) - EgtBeamShowLoadingSide( False, False) + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) End If If Not IsNothing(m_SelBTLPart) Then m_SelBTLPart = Nothing @@ -89,15 +112,21 @@ Public Class BTLStructureVM ' mostro pezzi selezionati Map.refProjectVM.BTLStructureVM.ShowAll(False) ' se attivata opzione, li assemblo - Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW, Map.refShowBeamPanelVM.ShowBuilding_IsChecked, False), False) + Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Map.refShowBeamPanelVM.ShowBuilding_IsChecked, False), False) ' nascondo barra di gestione pezzo - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) End Select ' aggiornamento grafica - Map.refLeftPanelVM.PartShowAllChanged() - Map.refLeftPanelVM.FeatureSelectionChanged() + 'Map.refLeftPanelVM.PartShowAllChanged() + Configuration.UpdateGraphics() + 'If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.PartShowAllChanged() + 'If Not IsNothing(Map.refBTLPartManagerVM) Then Map.refBTLPartManagerVM.PartShowAllChanged() + 'Map.refLeftPanelVM.FeatureSelectionChanged() + If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.FeatureSelectionChanged() Map.refCALCPanelVM.SetIsEnabledForSelPart() - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) End Sub Private m_SelBTLParts As New PartsObservableCollection(Of BTLPartVM) @@ -113,44 +142,52 @@ Public Class BTLStructureVM Return m_SelBTLPartsCnt End Get End Property - Friend Sub UpdateSelBTLParts(Optional bFromSelPart As Boolean = False, Optional bByOptim As Boolean = False) - Dim nOldSelCount As Integer = m_SelBTLPartsCnt - Dim nSelCount As Integer = BTLPartVMList.LongCount(Function(x) x.IsSelected) - m_SelBTLPartsCnt = nSelCount - If Not bByOptim AndAlso (nOldSelCount <> nSelCount AndAlso (nOldSelCount = 1 OrElse nSelCount = 1)) OrElse bFromSelPart Then - Map.refLeftPanelVM.PartShowAllChanged() - Map.refLeftPanelVM.FeatureSelectionChanged() - Map.refCALCPanelVM.SetIsEnabledForSelPart() - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) - End If - If nSelCount = 1 Then - If bByOptim Then - m_SelBTLPart = BTLPartVMList.FirstOrDefault(Function(x) x.IsSelected) - Else - SelBTLPart = BTLPartVMList.FirstOrDefault(Function(x) x.IsSelected) - End If - Else - If bByOptim Then - m_SelBTLPart = Nothing - Else - SelBTLPart = Nothing - ' mostro in parte bassa dati BTL - Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STRUCTURE_) - ' mostro pezzi selezionati - Map.refProjectVM.BTLStructureVM.ShowAll(False, True) - Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) - EgtZoom(ZM.ALL) - End If - NotifyPropertyChanged(NameOf(SelBTLPart)) - End If - End Sub + + 'Friend Sub UpdateSelBTLParts(Optional bFromSelPart As Boolean = False, Optional bByOptim As Boolean = False) + ' Dim nOldSelCount As Integer = m_SelBTLPartsCnt + ' Dim nSelCount As Integer = BTLPartVMList.LongCount(Function(x) x.IsSelected) + ' m_SelBTLPartsCnt = nSelCount + ' If Not bByOptim AndAlso (nOldSelCount <> nSelCount AndAlso (nOldSelCount = 1 OrElse nSelCount = 1)) OrElse bFromSelPart Then + ' 'Map.refLeftPanelVM.PartShowAllChanged() + ' If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.PartShowAllChanged() + ' If Not IsNothing(Map.refBTLPartManagerVM) Then Map.refBTLPartManagerVM.PartShowAllChanged() + ' Map.refFeatureListManagerVM.FeatureSelectionChanged() + ' 'Map.refLeftPanelVM.FeatureSelectionChanged() + ' Map.refCALCPanelVM.SetIsEnabledForSelPart() + ' Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + ' End If + ' If nSelCount = 1 Then + ' If bByOptim Then + ' m_SelBTLPart = BTLPartVMList.FirstOrDefault(Function(x) x.IsSelected) + ' Else + ' SelBTLPart = BTLPartVMList.FirstOrDefault(Function(x) x.IsSelected) + ' End If + ' Else + ' If bByOptim Then + ' m_SelBTLPart = Nothing + ' Else + ' SelBTLPart = Nothing + ' ' mostro in parte bassa dati BTL + ' Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STRUCTURE_) + ' ' mostro pezzi selezionati + ' Map.refProjectVM.BTLStructureVM.ShowAll(False, True) + ' Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) + ' EgtZoom(ZM.ALL) + ' End If + ' NotifyPropertyChanged(NameOf(SelBTLPart)) + ' End If + 'End Sub Private Sub SelBTLParts_CollectionChanged(sender As Object, e As NotifyCollectionChangedEventArgs) If m_bOnlySelectItem Then Return Select Case e.Action Case NotifyCollectionChangedAction.Add + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If 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 OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso m_SelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then SelectBTLPart(e.NewItems(0)) Else ' SelectionTypes.HIGHLIGHT HighlightBTLPart(e.NewItems(0)) @@ -158,14 +195,14 @@ Public Class BTLStructureVM End If Case NotifyCollectionChangedAction.Remove If e.OldItems.Count > 0 AndAlso Not IsNothing(e.OldItems(0)) Then - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then DeselectBTLPart(e.OldItems(0)) Else ' SelectionTypes.HIGHLIGHT DeHighlightBTLPart(e.OldItems(0)) End If End If Case NotifyCollectionChangedAction.Reset - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then If Not IsNothing(m_SelBTLPart) Then DeselectBTLPart(m_SelBTLPart) End If @@ -178,28 +215,35 @@ Public Class BTLStructureVM SelBTLPart = Nothing End Select ' aggiornamento grafica - Map.refLeftPanelVM.PartShowAllChanged() + 'Map.refLeftPanelVM.PartShowAllChanged() + Configuration.UpdateGraphics() + 'If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.PartShowAllChanged() + 'If Not IsNothing(Map.refBTLPartManagerVM) Then Map.refBTLPartManagerVM.PartShowAllChanged() End Sub Private Sub SelectBTLPart(BtlPart As BTLPartVM) - EgtBeamShowFacesName( False) - EgtBeamShowLoadingSide( False, False) m_SelBTLPart = BtlPart If Map.refMainMenuVM.SelPage = Pages.VIEW Then - ' se modalità building, la tolgo - If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then - ShowBuilding(False, False) - End If - ' seleziono pezzo nella scena - SceneSelPartSelection() - ' seleziono pezzo in Db geometrico - EgtBeamSetPart(BtlPart.nPartId) - EgtBeamShowFacesName( True) - Dim bLoadingSideShow As Boolean = (nPROJTYPE = BWType.BEAM) - Dim bLeftToRight As Boolean = Not ( CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) - EgtBeamShowLoadingSide( bLoadingSideShow, bLeftToRight) + Configuration.SelectedPieces(BtlPart.nPartId, Me) + 'EgtBeamShowFacesName(False) + 'EgtBeamShowLoadingSide(False, False) + 'Map.refProjectVM.MacroFeature_IsEnabled = True + '' se modalità building, la tolgo + 'If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + ' ShowBuilding(False, False) + 'End If + '' seleziono pezzo nella scena + 'SceneSelPartSelection() + '' seleziono pezzo in Db geometrico + 'EgtBeamSetPart(BtlPart.nPartId) + 'EgtBeamShowFacesName(True) + 'Dim bLoadingSideShow As Boolean = (nPROJTYPE = BWType.BEAM) + 'Dim bLeftToRight As Boolean = Not (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) + 'EgtBeamShowLoadingSide(bLoadingSideShow, bLeftToRight) ' seleziono pagina BottomPanel - Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.PART) + If Not IsNothing(Map.refBottomPanelVM) Then + Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.PART) + End If '' mostro barra di gestione pezzo 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) ' deseleziono le feature @@ -211,48 +255,121 @@ Public Class BTLStructureVM ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then ' resetto gruppo di lavorazione corrente EgtResetCurrMachGroup() + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) ' trovo ed evidenzio MachGroup e Duplo di questo pezzo - If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then - Dim MachGroupList As New List(Of MyMachGroupVM) - For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList - Dim bFound As Boolean = False - For Each Part As PartVM In Machgroup.PartVMList - If EgtDuploGetOriginal(Part.nPartId) = BtlPart.nPartId Then - Part.SetSearchFound() - bFound = True - Else - Part.ResetSearchFound() - End If - Next - If bFound Then - Machgroup.SetSearchFound() - Else - Machgroup.ResetSearchFound() - End If - Next - End If + Configuration.SetSearchPiece(BtlPart.nPartId) + 'If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + ' Dim MachGroupList As New List(Of MyMachGroupVM) + ' For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' Dim bFound As Boolean = False + ' For Each Part As PartVM In Machgroup.PartVMList + ' If EgtDuploGetOriginal(Part.nPartId) = BtlPart.nPartId Then + ' Part.SetSearchFound() + ' bFound = True + ' Else + ' Part.ResetSearchFound() + ' End If + ' Next + ' If bFound Then + ' Machgroup.SetSearchFound() + ' Else + ' Machgroup.ResetSearchFound() + ' End If + ' Next + 'End If ' seleziono pezzo nella scena SceneSelPartSelection() Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) EgtZoom(ZM.ALL) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' deseleziono eventuale MachGroup selezionato + If Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Map.refMachGroupPanelVM.SelectedMachGroup = Nothing + End If + If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If + Configuration.SelectedPieces(BtlPart.nPartId, Me) + 'EgtBeamShowFacesName(False) + 'EgtBeamShowLoadingSide(False, False) + 'Map.refProjectVM.MacroFeature_IsEnabled = True + '' se modalità building, la tolgo + 'If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + ' ShowBuilding(False, False) + 'End If + '' seleziono pezzo nella scena + 'SceneSelPartSelection() + '' seleziono pezzo in Db geometrico + 'EgtBeamSetPart(BtlPart.nPartId) + 'EgtBeamShowFacesName(True) + 'Dim bLoadingSideShow As Boolean = (nPROJTYPE = BWType.BEAM) + 'Dim bLeftToRight As Boolean = Not (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) + 'EgtBeamShowLoadingSide(bLoadingSideShow, bLeftToRight) + ' seleziono la prima feature + If Not IsNothing(BtlPart.BTLFeatureVMList) AndAlso BtlPart.BTLFeatureVMList.Count > 0 Then SelBTLPart.SelBTLFeatureVM = BtlPart.BTLFeatureVMList(0) + ' aggiorno stato selezionato tutto + Map.refShowBeamPanelVM.bShowAll = False + '' trovo ed evidenzio MachGroup e Duplo di questo pezzo + 'If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + ' Dim MachGroupList As New List(Of MyMachGroupVM) + ' For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' Dim bFound As Boolean = False + ' For Each Part As PartVM In Machgroup.PartVMList + ' If EgtDuploGetOriginal(Part.nPartId) = BtlPart.nPartId Then + ' Part.SetSearchFound() + ' bFound = True + ' Else + ' Part.ResetSearchFound() + ' End If + ' Next + ' If bFound Then + ' Machgroup.SetSearchFound() + ' Else + ' Machgroup.ResetSearchFound() + ' End If + ' Next + 'End If + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) End If NotifyPropertyChanged(NameOf(SelBTLPart)) End Sub Private Sub DeselectBTLPart(BtlPart As BTLPartVM) ' se necessario tolgo solido dal precedentemente selezionato - If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then - ' tolgo eventuale indicazione solido rimasta da pezzo precedente - Map.refShowBeamPanelVM.SetShowSolid(False) - Map.refProjectVM.BTLStructureVM.ShowSolid(BtlPart.nPartId, False, False) - End If + Configuration.DeselectSolid(BtlPart.nPartId, True) + 'If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then + ' ' tolgo eventuale indicazione solido rimasta da pezzo precedente + ' Map.refShowBeamPanelVM.SetShowSolid(False) + ' 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 ' disabilito eventuale feature selezionata If Not IsNothing(BtlPart.m_SelBTLFeatureVM) Then BtlPart.SelBTLFeatureVM = Nothing + '' deevidenzio MachGroup e Duplo di questo pezzo + 'If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + ' Dim MachGroupList As New List(Of MyMachGroupVM) + ' For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' Dim bFound As Boolean = False + ' For Each Part As PartVM In Machgroup.PartVMList + ' Dim i = EgtDuploGetOriginal(Part.nPartId) + ' If EgtDuploGetOriginal(Part.nPartId) = BtlPart.nPartId Then + ' Part.ResetSearchFound() + ' bFound = True + ' End If + ' Next + ' If bFound Then + ' Machgroup.ResetSearchFound() + ' End If + ' Next + 'End If + EgtResetCurrMachGroup() EgtDraw() End Sub Private Sub HighlightBTLPart(BtlPart As BTLPartVM) @@ -271,15 +388,38 @@ Public Class BTLStructureVM nNextPartId = EgtGetNext(nNextPartId) End While End If + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' trovo ed evidenzio MachGroup e Duplo di questo pezzo + Configuration.SetSearchPiece(BtlPart.nPartId) + 'If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + ' Dim MachGroupList As New List(Of MyMachGroupVM) + ' For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' Dim bFound As Boolean = False + ' For Each Part As PartVM In Machgroup.PartVMList + ' If EgtDuploGetOriginal(Part.nPartId) = BtlPart.nPartId Then + ' Part.SetSearchFound() + ' bFound = True + ' Else + ' Part.ResetSearchFound() + ' End If + ' Next + ' If bFound Then + ' Machgroup.SetSearchFound() + ' Else + ' Machgroup.ResetSearchFound() + ' End If + ' Next + 'End If + End If ' seleziono pagina BottomPanel - Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.NULL) + If Not IsNothing(Map.refBottomPanelVM) Then Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.NULL) EgtDraw() End Sub Private Sub DeHighlightBTLPart(BtlPart As BTLPartVM, Optional bDraw As Boolean = True) EgtResetMark(BtlPart.nPartId) ' se modalità building If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then - ' evidenzio anche copie + ' deevidenzio anche copie Dim nNextPartId As Integer = EgtGetNext(BtlPart.nPartId) While nNextPartId <> GDB_ID.NULL Dim nOrigId As Integer = GDB_ID.NULL @@ -291,16 +431,34 @@ Public Class BTLStructureVM nNextPartId = EgtGetNext(nNextPartId) End While End If + ' deevidenzio MachGroup e Duplo di questo pezzo + Configuration.ResetSearchPiece(BtlPart.nPartId) + 'If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + ' Dim MachGroupList As New List(Of MyMachGroupVM) + ' For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' Dim bFound As Boolean = False + ' For Each Part As PartVM In Machgroup.PartVMList + ' Dim i = EgtDuploGetOriginal(Part.nPartId) + ' If EgtDuploGetOriginal(Part.nPartId) = BtlPart.nPartId Then + ' Part.ResetSearchFound() + ' bFound = True + ' End If + ' Next + ' If bFound Then + ' Machgroup.ResetSearchFound() + ' End If + ' Next + 'End If ' seleziono pagina BottomPanel 'Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.NULL) If bDraw Then EgtDraw() End Sub - Friend ReadOnly Property SelBTLPartList As List(Of BTLPartVM) - Get - Return m_BTLPartVMList.Where(Function(x) x.IsSelected).ToList() - End Get - End Property + 'Friend ReadOnly Property SelBTLPartList As List(Of BTLPartVM) + ' Get + ' Return m_BTLPartVMList.Where(Function(x) x.IsSelected).ToList() + ' End Get + 'End Property Private m_SelBTLPart As BTLPartVM = Nothing Public Property SelBTLPart As BTLPartVM @@ -308,11 +466,17 @@ Public Class BTLStructureVM Return m_SelBTLPart End Get Set(value As BTLPartVM) + If Map.refMainMenuVM.SelPage = Pages.MACHINING Or (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) AndAlso + Not IsNothing(value) Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If If Not IsNothing(m_SelBTLPart) Then ' se necessario tolgo solido dal precedentemente selezionato - If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then - Map.refShowBeamPanelVM.SetShowSolid(False) - End If + Configuration.DeselectSolid() + 'If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then + ' Map.refShowBeamPanelVM.SetShowSolid(False) + 'End If ' disabilito eventuale feature selezionata If Not IsNothing(m_SelBTLPart.m_SelBTLFeatureVM) Then m_SelBTLPart.SelBTLFeatureVM = Nothing End If @@ -331,7 +495,8 @@ Public Class BTLStructureVM ' seleziono pagina BottomPanel Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.PART) ' mostro barra di gestione pezzo - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) ' deseleziono le feature If Not IsNothing(m_SelBTLPart.SelBTLFeatureVM) Then SelBTLPart.SelBTLFeatureVM = Nothing ' aggiorno stato selezionato tutto @@ -339,30 +504,70 @@ Public Class BTLStructureVM Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) EgtZoom(ZM.ALL) ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then - ' resetto gruppo di lavorazione corrente - EgtResetCurrMachGroup() ' trovo ed evidenzio MachGroup e Duplo di questo pezzo - If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then - Dim MachGroupList As New List(Of MyMachGroupVM) - For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList - Dim bFound As Boolean = False - For Each Part As PartVM In Machgroup.PartVMList - If EgtDuploGetOriginal(Part.nPartId) = m_SelBTLPart.nPartId Then - Part.SetSearchFound() - bFound = True - Else - Part.ResetSearchFound() - End If - Next - If bFound Then - Machgroup.SetSearchFound() - Else - Machgroup.ResetSearchFound() - End If - Next + Configuration.SetSearchPiece(m_SelBTLPart.nPartId) + 'If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + ' Dim MachGroupList As New List(Of MyMachGroupVM) + ' For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' Dim bFound As Boolean = False + ' For Each Part As PartVM In Machgroup.PartVMList + ' If EgtDuploGetOriginal(Part.nPartId) = m_SelBTLPart.nPartId Then + ' Part.SetSearchFound() + ' bFound = True + ' Else + ' Part.ResetSearchFound() + ' End If + ' Next + ' If bFound Then + ' Machgroup.SetSearchFound() + ' Else + ' Machgroup.ResetSearchFound() + ' End If + ' Next + 'End If + ' seleziono pezzo nella scena + SceneSelPartSelection() + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' se modalità building, la tolgo + If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + ShowBuilding(False, False) End If ' seleziono pezzo nella scena SceneSelPartSelection() + ' seleziono pezzo in Db geometrico + EgtBeamSetPart(m_SelBTLPart.nPartId) + ' seleziono pagina BottomPanel + Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.PART) + ' mostro barra di gestione pezzo + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + ' deseleziono le feature + If Not IsNothing(m_SelBTLPart.SelBTLFeatureVM) Then SelBTLPart.SelBTLFeatureVM = Nothing + ' aggiorno stato selezionato tutto + Map.refShowBeamPanelVM.bShowAll = False + ' trovo ed evidenzio MachGroup e Duplo di questo pezzo + Configuration.ResetSearchPiece(m_SelBTLPart.nPartId) + 'If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + ' Dim MachGroupList As New List(Of MyMachGroupVM) + ' For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' Dim bFound As Boolean = False + ' For Each Part As PartVM In Machgroup.PartVMList + ' If EgtDuploGetOriginal(Part.nPartId) = m_SelBTLPart.nPartId Then + ' Part.SetSearchFound() + ' bFound = True + ' Else + ' Part.ResetSearchFound() + ' End If + ' Next + ' If bFound Then + ' Machgroup.SetSearchFound() + ' Else + ' Machgroup.ResetSearchFound() + ' End If + ' Next + 'End If Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) EgtZoom(ZM.ALL) End If @@ -618,6 +823,8 @@ Public Class BTLStructureVM Return Map.refProjManagerVM.nProjType Case Pages.MACHINING Return Map.refProdManagerVM.nProdType + Case Pages.ONLYPRODPAGE + Return Map.refOnlyProdManagerVM.nProdType Case Else Return BWType.NULL End Select @@ -638,7 +845,7 @@ Public Class BTLStructureVM End Get Set(value As String) If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_LISTNAME, value) Then - DbControllers.m_ProjController.UpdateListName(Map.refProjManagerVM.CurrProj.nProjId, value) + DbControllers.m_ProjController.UpdateListName(ProjectManagerVM.CurrProj.nProjId, value) m_BTLStructureM.m_sLISTNAME = value Else NotifyPropertyChanged("sLISTNAME") @@ -1021,7 +1228,7 @@ Public Class BTLStructureVM Next End Sub - Private Sub SceneSelPartSelection() + Friend Sub SceneSelPartSelection() ' deseleziono tutto EgtDeselectAll() ' disabilito impostazione modificato @@ -1044,9 +1251,10 @@ Public Class BTLStructureVM Dim DisableMgr As New DisableModifiedMgr If Not IsNothing(SelBTLPart) Then ' se pezzo solido, lo riporto normale - If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then - Map.refShowBeamPanelVM.SetShowSolid(False) - End If + Configuration.DeselectSolid() + 'If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then + ' Map.refShowBeamPanelVM.SetShowSolid(False) + 'End If ' tolgo pezzo selezionato SelBTLPart.SelBTLFeatureVM = Nothing End If @@ -1059,7 +1267,8 @@ Public Class BTLStructureVM Dim nGeomPartId As Integer = EgtGetFirstPart() While nGeomPartId <> GDB_ID.NULL Dim CurrPart As BTLPartVM = BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nGeomPartId) - If Not IsNothing(CurrPart) AndAlso (Not bOnlySelected OrElse (bOnlySelected AndAlso CurrPart.IsSelected)) Then + ' If Not IsNothing(CurrPart) AndAlso (Not bOnlySelected OrElse (bOnlySelected AndAlso CurrPart.IsSelected)) Then + If Not IsNothing(CurrPart) AndAlso Not bOnlySelected Then Dim nMode As Integer EgtGetMode(CurrPart.nPartId, nMode) If nMode <> GDB_MD.STD Then @@ -1083,10 +1292,11 @@ Public Class BTLStructureVM Dim DisableMgr As New DisableModifiedMgr If Not IsNothing(SelBTLPart) Then ' se pezzo solido, lo riporto normale - If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then - ShowSolid(GDB_ID.NULL, False, False) - Map.refShowBeamPanelVM.SetShowSolid(False) - End If + Configuration.DeselectSolid(GDB_ID.NULL, True) + 'If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then + ' ShowSolid(GDB_ID.NULL, False, False) + ' Map.refShowBeamPanelVM.SetShowSolid(False) + 'End If ' tolgo pezzo selezionato SelBTLPart.SelBTLFeatureVM = Nothing End If @@ -1225,7 +1435,7 @@ Public Class BTLStructureVM bSearchTextOk = False End If Dim bResult As Boolean = bSectionOk AndAlso bGroupOk AndAlso bSubGroupOk AndAlso bSearchTextOk - If Not bResult And CurrBTLPart.IsSelected Then CurrBTLPart.IsSelected = False + ' If Not bResult And CurrBTLPart.IsSelected Then CurrBTLPart.IsSelected = False Return bResult End Function @@ -1329,7 +1539,7 @@ Public Class BTLStructureVM End Property Public Sub DeletePart() - If Map.refMainMenuVM.SelPage = Pages.VIEW Then Map.refLeftPanelVM.RemovePartCmd() + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refBTLPartManagerVM.RemovePartCmd() End Sub #End Region ' DeletePart diff --git a/EgtBEAMWALL.ViewerOptimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml b/EgtBEAMWALL.ViewerOptimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml index d9e60e43..e0a034bb 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml @@ -2,7 +2,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5" - xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer" xmlns:EgtBEAMWALLCORE="clr-namespace:EgtBEAMWALL.Core;assembly=EgtBEAMWALL.Core" Title="{Binding Title}" Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}" diff --git a/EgtBEAMWALL.ViewerOptimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml.vb index a619e14b..eeda3889 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml.vb @@ -1,4 +1,6 @@ -Public Class BeamMachiningsWindowV +Imports EgtBEAMWALL.Core + +Public Class BeamMachiningsWindowV Private WithEvents m_BeamMachiningsWindowVM As MyBeamMachiningsWindowVM diff --git a/EgtBEAMWALL.ViewerOptimizer/BlockedWnd/BlockedWndVM.vb b/EgtBEAMWALL.ViewerOptimizer/BlockedWnd/BlockedWndVM.vb index a5892e5c..880baf11 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BlockedWnd/BlockedWndVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BlockedWnd/BlockedWndVM.vb @@ -100,7 +100,7 @@ Public Class BlockedWndVM NotifyPropertyChanged(NameOf(Buttons_Visibility)) NotifyPropertyChanged(NameOf(Msg_Text)) ' mando messaggio di blocco avvenuto - DbControllers.m_StatusMapController.UpdateAction("", Map.refProdManagerVM.CurrProd.nProdId, Map.refProdManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ViewOptimStoped, "") + DbControllers.m_StatusMapController.UpdateAction("", ProjectManagerVM.CurrProd.nProdId, ProjectManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ViewOptimStoped, "") 'ElseIf m_nIndex > 17 Then ' 'If m_Waiting_Timer.IsEnabled Then m_Waiting_Timer.Stop() ' If Not SupervisorCommThread.bViewerOptimizerBlocked Then @@ -136,7 +136,7 @@ Public Class BlockedWndVM ' salvo progetto Map.refProdManagerVM.Save() ' mando messaggio di blocco avvenuto - DbControllers.m_StatusMapController.UpdateAction("", Map.refProdManagerVM.CurrProd.nProdId, Map.refProdManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ViewOptimStoped, "") + DbControllers.m_StatusMapController.UpdateAction("", ProjectManagerVM.CurrProd.nProdId, ProjectManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ViewOptimStoped, "") End Sub #End Region ' Save @@ -160,7 +160,7 @@ Public Class BlockedWndVM ''' Public Sub DoNotSave() ' mando messaggio di blocco avvenuto - DbControllers.m_StatusMapController.UpdateAction("", Map.refProdManagerVM.CurrProd.nProdId, Map.refProdManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ViewOptimStoped, "") + DbControllers.m_StatusMapController.UpdateAction("", ProjectManagerVM.CurrProd.nProdId, ProjectManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ViewOptimStoped, "") End Sub #End Region ' DoNotSave 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/CALCPanel/CALCPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb index 59219489..1cd33656 100644 --- a/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb @@ -4,6 +4,7 @@ Imports EgtWPFLib5 Imports EgtBEAMWALL.Core Imports System.Collections.ObjectModel Imports System.Windows.Threading +Imports System.Data.Entity.Core.Metadata.Edm Public Class CALCPanelVM Inherits VMBase @@ -45,6 +46,16 @@ Public Class CALCPanelVM End Set End Property + Private m_VerifyAll_IsEnabled As Boolean = True + Public Property VerifyAll_IsEnabled As Boolean + Get + Return m_VerifyAll_IsEnabled + End Get + Set(value As Boolean) + m_VerifyAll_IsEnabled = value + End Set + End Property + Private m_ChooseMachineBtn_Visibility As Boolean = True Public Property ChooseMachineBtn_Visibility As Visibility Get @@ -207,16 +218,25 @@ Public Class CALCPanelVM Friend Sub SetCalcPanelIsEnabled(bIsEnabled As Boolean) m_CALCPanel_IsEnabled = bIsEnabled + m_VerifyAll_IsEnabled = bIsEnabled NotifyPropertyChanged(NameOf(CALCPanel_IsEnabled)) + NotifyPropertyChanged(NameOf(VerifyAll_IsEnabled)) NotifyPropertyChanged(NameOf(Verify_IsEnabled)) NotifyPropertyChanged(NameOf(Simulate_IsEnabled)) NotifyPropertyChanged(NameOf(Edit_IsEnabled)) End Sub Friend Sub SetIsEnabledForSelPart() NotifyPropertyChanged(NameOf(Verify_IsEnabled)) + m_VerifyAll_IsEnabled = False + NotifyPropertyChanged(NameOf(VerifyAll_IsEnabled)) NotifyPropertyChanged(NameOf(Simulate_IsEnabled)) NotifyPropertyChanged(NameOf(Edit_IsEnabled)) End Sub + Friend Sub SetVerifyIsEnabled(bIsEnabled As Boolean) + m_CALCPanel_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(CALCPanel_IsEnabled)) + NotifyPropertyChanged(NameOf(Verify_IsEnabled)) + End Sub Private Sub Calc_ProcessResult(sender As Object, e As CalcResultEventArgs) ProcessResults(e.m_Result) @@ -249,9 +269,9 @@ Public Class CALCPanelVM If m_FromProduce <> ProduceType.NULL Then Select Case m_FromProduce Case ProduceType.PRODUCE - Map.refTopPanelVM.ProduceRawPart() + Map.refRawPartManagerVM.ProduceRawPart() Case ProduceType.PRODUCEALL - Map.refTopPanelVM.ProduceAllRawPart() + Map.refRawPartManagerVM.ProduceAllRawPart() End Select m_FromProduce = ProduceType.NULL End If @@ -266,7 +286,7 @@ Public Class CALCPanelVM EgtGetCurrFilePath(sCurrFilePath) EgtOpenFile(sCurrFilePath) ' imposto duplo modificato - EgtDuploSetModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + MyMachGroupPanelM.SetDuploModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) ' riseleziono il pezzo precedentemente selezionato Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.SelBTLPart) Map.refMyStatusBarVM.SetOutputMessage("Modified file reloaded", 1) @@ -276,7 +296,7 @@ Public Class CALCPanelVM End Sub Friend Shared Sub ProcessResults(MachGroupId As MyMachGroupVM) - ProcessResults(Map.refProdManagerVM.CurrProd.sProdDirPath & "/" & MachGroupId.nName & ".txt", ProjectType.PROD, MachGroupId.Id) + ProcessResults(ProjectManagerVM.CurrProd.sProdDirPath & "/" & MachGroupId.nName & ".txt", ProjectType.PROD, MachGroupId.Id) End Sub Private Shared Sub ProcessResults(Bar As Bar) @@ -574,14 +594,15 @@ Public Class CALCPanelVM Dim sMachineName As String = "" If Map.refMainMenuVM.SelPage = Pages.VIEW Then nProjType = Map.refProjManagerVM.nProjType - sMachineName = If(Not IsNothing(Map.refProjManagerVM.CurrProj), Map.refProjManagerVM.CurrProj.sMachine, "") + sMachineName = If(Not IsNothing(ProjectManagerVM.CurrProj), ProjectManagerVM.CurrProj.sMachine, "") ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then nProjType = Map.refProdManagerVM.nProdType - sMachineName = If(Not IsNothing(Map.refProdManagerVM.CurrProd), Map.refProdManagerVM.CurrProd.sMachine, "") + sMachineName = If(Not IsNothing(ProjectManagerVM.CurrProd), ProjectManagerVM.CurrProd.sMachine, "") End If If nMachType = nProjType OrElse - (nMachType = 3 And Map.refMainMenuVM.SelPage = Pages.VIEW And Not IsNothing(Map.refProjManagerVM.CurrProj)) OrElse - (nMachType = 3 And Map.refMainMenuVM.SelPage = Pages.MACHINING And Not IsNothing(Map.refProdManagerVM.CurrProd)) Then + (nMachType = 3 And Map.refMainMenuVM.SelPage = Pages.VIEW And Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProj)) OrElse + (nMachType = 3 And Map.refMainMenuVM.SelPage = Pages.MACHINING And Not IsNothing(Map.refProdManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProd)) OrElse + (nMachType = 3 And Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProd)) Then MachineList.Add(Machine) ' Se il nome Macchina coincide setto la macchina selezionata con la macchina associata al progetto If Machine.Name = sMachineName Then @@ -645,19 +666,40 @@ Public Class CALCPanelVM ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub Verify() - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(Map.refProjManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) OrElse - (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(Map.refProdManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM)))) Then Return + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM))) OrElse + (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) OrElse + (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso (IsNothing(Map.refOnlyProdManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) Then Return Dim ProjType As BWType + Dim BarList() As EgtBEAMWALL.Core.Bar = Nothing If Map.refMainMenuVM.SelPage = Pages.VIEW Then - ProjType = Map.refProjManagerVM.CurrProj.nType - Else - ProjType = Map.refProdManagerVM.CurrProd.nType + ProjType = ProjectManagerVM.CurrProj.nType + If Not CreateBarToVerify(Pages.VIEW, ProjType, BarList) Then Return + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ProjType = ProjectManagerVM.CurrProd.nType + If Not CreateBarToVerify(Pages.MACHINING, ProjType, BarList) Then Return + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ProjType = Map.refOnlyProdManagerVM.CurrProd.nType + If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART Then + If Not CreateBarToVerify(Pages.VIEW, ProjType, BarList) Then Return + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refOnlyProdManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) + ElseIf Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + If Not CreateBarToVerify(Pages.MACHINING, ProjType, BarList) Then Return + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refOnlyProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + End If End If - Dim BarList() As EgtBEAMWALL.Core.Bar - If Map.refMainMenuVM.SelPage = Pages.VIEW Then + End Sub + + Private Function CreateBarToVerify(SelPage As Pages, ProjType As BWType, ByRef BarList As Bar()) As Boolean + If SelPage = Pages.VIEW Then If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Dim TempBarList(0) As EgtBEAMWALL.Core.Bar - If Not Map.refProjectVM.BTLStructureVM.SelBTLPart.bDO Then Return + If Not Map.refProjectVM.BTLStructureVM.SelBTLPart.bDO Then Return False Dim Bar As New EgtBEAMWALL.Core.Bar With {.nBarId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId, .nProgramPage = ProjectType.PROJ, .nProjType = ProjType, @@ -669,7 +711,7 @@ Public Class CALCPanelVM Bar.nCmdType = CalcIntegration.CmdTypes.GENERATE Case Else If Map.refProjectVM.BTLStructureVM.SelBTLPart.nGlobalState = CalcStates.NOTCALCULATED OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.nFeaturesGlobalState > CalcStates.INFO Then - Dim sBTLPartFilePath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & Map.refProjectVM.BTLStructureVM.SelBTLPart.nPDN.ToString() & ".ori.bwe" + Dim sBTLPartFilePath As String = ProjectManagerVM.CurrProj.sProjDirPath & "\" & Map.refProjectVM.BTLStructureVM.SelBTLPart.nPDN.ToString() & ".ori.bwe" If File.Exists(sBTLPartFilePath) Then File.Delete(sBTLPartFilePath) End If Bar.nCmdType = CalcIntegration.CmdTypes.CHECKGEN @@ -677,18 +719,15 @@ Public Class CALCPanelVM TempBarList(0) = Bar BarList = TempBarList Else - Return + Return False End If ' disabilito interfaccia Map.refProjectVM.SetCalcRunning(True) - ' lancio calcolo - EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) - - ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ElseIf SelPage = Pages.MACHINING Then If Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup ' se barra gia' assegnata a supervisore, esco - If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return False Dim TempBarList(0) As EgtBEAMWALL.Core.Bar Dim MachineName As String = "" EgtGetMachGroupMachineName(SelMachGroup.Id, MachineName) @@ -703,7 +742,7 @@ Public Class CALCPanelVM Bar.nCmdType = CalcIntegration.CmdTypes.GENERATE Case Else If SelMachGroup.nGlobalState = CalcStates.NOTCALCULATED OrElse (SelMachGroup.nPartsGlobalState > CalcStates.INFO) Then - Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe" + Dim sMachGroupFilePath As String = ProjectManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe" If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath) End If Bar.nCmdType = CalcIntegration.CmdTypes.CHECKGEN @@ -711,14 +750,13 @@ Public Class CALCPanelVM TempBarList(0) = Bar BarList = TempBarList Else - Return + Return False End If ' disabilito interfaccia Map.refProjectVM.SetCalcRunning(True) - ' lancio calcolo - EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) End If - End Sub + Return True + End Function ' funzione che gestisce risposta da thread di verifica, aggiorna progress e segnala comando di interruzione Private Sub ManageCalc(dProgress As Double, sProgress As String, ByRef bCancel As Boolean) @@ -760,21 +798,43 @@ Public Class CALCPanelVM ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub VerifyAll() - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(Map.refProjManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) OrElse - (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(Map.refProdManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM)))) Then Return + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM))) OrElse + (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) OrElse + (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) Then Return ' se modalita' assemblato - If Map.refShowBeamPanelVM.ShowBuilding_IsChecked AndAlso Map.refShowBeamPanelVM.bShowAll Then - ' devo smontarlo prima di calcolare le travi, altrimenti non trova i pezzi - Map.refProjectVM.BTLStructureVM.ShowBuilding(False, False) - End If + Configuration.AssembledMode(Map.refShowBeamPanelVM.ShowBuilding_IsChecked) + 'If Map.refShowBeamPanelVM.ShowBuilding_IsChecked AndAlso Map.refShowBeamPanelVM.bShowAll Then + ' ' devo smontarlo prima di calcolare le travi, altrimenti non trova i pezzi + ' Map.refProjectVM.BTLStructureVM.ShowBuilding(False, False) + 'End If + Dim BarList() As EgtBEAMWALL.Core.Bar = Nothing Dim ProjType As BWType If Map.refMainMenuVM.SelPage = Pages.VIEW Then - ProjType = Map.refProjManagerVM.CurrProj.nType - Else - ProjType = Map.refProdManagerVM.CurrProd.nType + ProjType = ProjectManagerVM.CurrProj.nType + If Not CreateBarListToVerify(Pages.VIEW, ProjType, BarList) Then Return + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ProjType = ProjectManagerVM.CurrProd.nType + If Not CreateBarListToVerify(Pages.MACHINING, ProjType, BarList) Then Return + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ProjType = ProjectManagerVM.CurrProd.nType + If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART OrElse Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST Then + If Not CreateBarListToVerify(Pages.VIEW, ProjType, BarList) Then Return + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) + ElseIf Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + If Not CreateBarListToVerify(Pages.MACHINING, ProjType, BarList) Then Return + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + End If End If - Dim BarList() As EgtBEAMWALL.Core.Bar - If Map.refMainMenuVM.SelPage = Pages.VIEW Then + End Sub + + Private Function CreateBarListToVerify(SelPage As Pages, ProjType As BWType, ByRef BarList As Bar()) As Boolean + If SelPage = Pages.VIEW Then Dim TempBarList As New List(Of EgtBEAMWALL.Core.Bar) For PartIndex = 0 To Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count - 1 Dim CurrPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList(PartIndex) @@ -790,7 +850,7 @@ Public Class CALCPanelVM Bar.nCmdType = CalcIntegration.CmdTypes.GENERATE Case Else If CurrPart.nGlobalState = CalcStates.NOTCALCULATED OrElse CurrPart.nFeaturesGlobalState > CalcStates.INFO Then - Dim sBTLPartFilePath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & CurrPart.nPDN.ToString() & ".ori.bwe" + Dim sBTLPartFilePath As String = ProjectManagerVM.CurrProj.sProjDirPath & "\" & CurrPart.nPDN.ToString() & ".ori.bwe" If File.Exists(sBTLPartFilePath) Then File.Delete(sBTLPartFilePath) End If Bar.nCmdType = CalcIntegration.CmdTypes.CHECKGEN @@ -800,9 +860,7 @@ Public Class CALCPanelVM BarList = TempBarList.ToArray() ' disabilito interfaccia Map.refProjectVM.SetCalcRunning(True) - ' lancio calcolo - EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) - ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ElseIf SelPage = Pages.MACHINING Then Dim TempBarList As New List(Of EgtBEAMWALL.Core.Bar) For PartIndex = 0 To Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(PartIndex) @@ -821,21 +879,20 @@ Public Class CALCPanelVM Bar.nCmdType = CalcIntegration.CmdTypes.GENERATE Case Else If CurrMachGroup.nGlobalState = CalcStates.NOTCALCULATED OrElse (CurrMachGroup.nPartsGlobalState > CalcStates.INFO) Then - Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & CurrMachGroup.Name.ToString() & ".ori.bwe" + Dim sMachGroupFilePath As String = ProjectManagerVM.CurrProd.sProdDirPath & "\" & CurrMachGroup.Name.ToString() & ".ori.bwe" If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath) End If Bar.nCmdType = CalcIntegration.CmdTypes.CHECKGEN End Select TempBarList.Add(Bar) Next - If TempBarList.Count = 0 Then Return + If TempBarList.Count = 0 Then Return False BarList = TempBarList.ToArray() ' disabilito interfaccia Map.refProjectVM.SetCalcRunning(True) - ' lancio calcolo - EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) End If - End Sub + Return True + End Function #End Region ' VerifyAll @@ -857,9 +914,10 @@ Public Class CALCPanelVM ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub ResetCalc() - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(Map.refProjManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) OrElse - (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(Map.refProdManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM)))) Then Return - If Map.refMainMenuVM.SelPage = Pages.VIEW Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM))) OrElse + (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) OrElse + (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) Then Return + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART OrElse Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST)) Then If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList If Part.nGlobalState <> CalcStates.NOTCALCULATED Then @@ -868,11 +926,11 @@ Public Class CALCPanelVM End If Next ElseIf Map.refProjectVM.BTLStructureVM.SelBTLPartsCnt > 1 Then - For Each SelPart In Map.refProjectVM.BTLStructureVM.SelBTLPartList - If Not IsNothing(SelPart) AndAlso SelPart.nGlobalState <> CalcStates.NOTCALCULATED Then - SelPart.ResetCalcTotalPart() - End If - Next + 'For Each SelPart In Map.refProjectVM.BTLStructureVM.SelBTLPartList + ' If Not IsNothing(SelPart) AndAlso SelPart.nGlobalState <> CalcStates.NOTCALCULATED Then + ' SelPart.ResetCalcTotalPart() + ' End If + 'Next Else Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart If IsNothing(SelPart) Then Return @@ -880,7 +938,7 @@ Public Class CALCPanelVM SelPart.ResetCalcTotalPart() End If End If - ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) Then If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then For Each MachGroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList If MachGroup.nProduction_State >= ItemState.Assigned Then Continue For @@ -920,16 +978,37 @@ Public Class CALCPanelVM ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub Simulate() - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(Map.refProjManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) OrElse - (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(Map.refProdManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM)))) Then Return + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM))) OrElse + (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) OrElse + (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) Then Return Dim ProjType As BWType + Dim BarList() As EgtBEAMWALL.Core.Bar = Nothing If Map.refMainMenuVM.SelPage = Pages.VIEW Then - ProjType = Map.refProjManagerVM.CurrProj.nType - Else - ProjType = Map.refProdManagerVM.CurrProd.nType + ProjType = ProjectManagerVM.CurrProj.nType + If Not CreateBarToSimulate(Pages.VIEW, ProjType, BarList) Then Return + ' lancio simulazione + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ProjType = ProjectManagerVM.CurrProd.nType + If Not CreateBarToSimulate(Pages.MACHINING, ProjType, BarList) Then Return + ' lancio simulazione + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ProjType = Map.refOnlyProdManagerVM.CurrProd.nType + If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART Then + If Not CreateBarToSimulate(Pages.VIEW, ProjType, BarList) Then Return + ' lancio simulazione + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) + ElseIf Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + If Not CreateBarToSimulate(Pages.MACHINING, ProjType, BarList) Then Return + ' lancio simulazione + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + End If End If - Dim BarList() As EgtBEAMWALL.Core.Bar - If Map.refMainMenuVM.SelPage = Pages.VIEW Then + End Sub + + Private Function CreateBarToSimulate(SelPage As Pages, ProjType As BWType, ByRef BarList As Bar()) As Boolean + If SelPage = Pages.VIEW Then If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Dim TempBarList(0) As EgtBEAMWALL.Core.Bar Dim Bar As New EgtBEAMWALL.Core.Bar With {.nBarId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId, @@ -940,19 +1019,17 @@ Public Class CALCPanelVM .nCmdType = CalcIntegration.CmdTypes.SIMULATE, .nGlobState = Map.refProjectVM.BTLStructureVM.SelBTLPart.nGlobalState} If Map.refProjectVM.BTLStructureVM.SelBTLPart.nGlobalState = CalcStates.NOTCALCULATED Then - Dim sBTLPartFilePath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & Map.refProjectVM.BTLStructureVM.SelBTLPart.nPDN.ToString() & ".ori.bwe" + Dim sBTLPartFilePath As String = ProjectManagerVM.CurrProj.sProjDirPath & "\" & Map.refProjectVM.BTLStructureVM.SelBTLPart.nPDN.ToString() & ".ori.bwe" If File.Exists(sBTLPartFilePath) Then File.Delete(sBTLPartFilePath) End If TempBarList(0) = Bar BarList = TempBarList Else - Return + Return False End If ' disabilito interfaccia Map.refProjectVM.SetCalcRunning(True) - ' lancio simulazione - EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) - ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ElseIf SelPage = Pages.MACHINING Then If Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup Dim TempBarList(0) As EgtBEAMWALL.Core.Bar @@ -966,20 +1043,19 @@ Public Class CALCPanelVM .nCmdType = CalcIntegration.CmdTypes.SIMULATE, .nGlobState = SelMachGroup.nGlobalState} If SelMachGroup.nGlobalState = CalcStates.NOTCALCULATED Then - Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe" + Dim sMachGroupFilePath As String = ProjectManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe" If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath) End If TempBarList(0) = Bar BarList = TempBarList Else - Return + Return False End If ' disabilito interfaccia Map.refProjectVM.SetCalcRunning(True) - ' lancio simulazione - EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) End If - End Sub + Return True + End Function #End Region ' Simulate @@ -1001,12 +1077,12 @@ Public Class CALCPanelVM ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub Edit() - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(Map.refProjManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) Then Return + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) Then Return Dim ProjType As BWType If Map.refMainMenuVM.SelPage = Pages.VIEW Then - ProjType = Map.refProjManagerVM.CurrProj.nType + ProjType = ProjectManagerVM.CurrProj.nType Else - ProjType = Map.refProdManagerVM.CurrProd.nType + ProjType = ProjectManagerVM.CurrProd.nType End If Dim BarList() As EgtBEAMWALL.Core.Bar If Map.refMainMenuVM.SelPage = Pages.VIEW Then @@ -1029,7 +1105,7 @@ Public Class CALCPanelVM ' disabilito interfaccia Map.refProjectVM.SetCalcRunning(True) ' lancio edit - EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) End If End Sub @@ -1054,7 +1130,7 @@ Public Class CALCPanelVM ''' Friend Sub ChooseMachine() ' rendo visibile la CmBx per la scelta e il pulsante di conferma solo se il Proj corrente non ha associato alcun Prod - If Map.refProjManagerVM.CurrProj.nProdId > 0 Then + If ProjectManagerVM.CurrProj.nProdId > 0 Then MessageBox.Show(EgtMsg(61929), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Exclamation) Else SetChooseMachine_Visibility(True) @@ -1086,7 +1162,7 @@ Public Class CALCPanelVM m_IsMachineApplied = True SetChooseMachine_Visibility(False) ' resetto i parametri errori integration ciclando su ogni Part e per ogni Part ogni Feature - Dim ProjId = Map.refProjManagerVM.CurrProj.nProjId + Dim ProjId = ProjectManagerVM.CurrProj.nProjId Dim TempList As New List(Of BTLPartM) Dim nPartId As Integer = EgtGetFirstPart() While nPartId <> GDB_ID.NULL diff --git a/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CalcPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CalcPanelV.xaml index 70b86bac..79f1f7c7 100644 --- a/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CalcPanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CalcPanelV.xaml @@ -18,7 +18,7 @@ ToolTip="{Binding VerifyAll_ToolTip}" Style="{StaticResource ToolBar_Button}" Command="{Binding VerifyAll_Command}" - IsEnabled="{Binding CALCPanel_IsEnabled}"> + IsEnabled="{Binding VerifyAll_IsEnabled}"> + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -287,13 +74,13 @@ - + --> diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb index 6f2ec03b..52f333bf 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb @@ -5,11 +5,7 @@ Imports EgtWPFLib5 Imports EgtBEAMWALL.Core Imports System.Linq.Expressions Imports MS.Internal -Imports Org.BouncyCastle.X509 Imports Ionic.Zip -Imports Org.BouncyCastle.Bcpg -Imports Microsoft.VisualBasic.ApplicationServices -Imports Renci.SshNet.Security Public Class ConfigurationPageVM Inherits VMBase @@ -37,13 +33,28 @@ Public Class ConfigurationPageVM End Get Set(value As Integer) m_SelConfigSubPage = value + If m_SelConfigSubPage = ConfigSubPages.GENERAL Then + m_bGeneral_Visibility = Visibility.Visible + m_bParameterQ_Visibility = Visibility.Collapsed + m_bMachine_Visibility = Visibility.Collapsed + ElseIf m_SelConfigSubPage = ConfigSubPages.QPARAMETERS Then + m_bParameterQ_Visibility = Visibility.Visible + m_bGeneral_Visibility = Visibility.Collapsed + m_bMachine_Visibility = Visibility.Collapsed + ElseIf m_SelConfigSubPage = ConfigSubPages.MACHINE Then + m_bMachine_Visibility = Visibility.Visible + m_bGeneral_Visibility = Visibility.Collapsed + m_bParameterQ_Visibility = Visibility.Collapsed + End If + NotifyPropertyChanged(NameOf(General_Visibility)) + NotifyPropertyChanged(NameOf(ParameterQ_Visibility)) + NotifyPropertyChanged(NameOf(Machine_Visibility)) End Set End Property ' flag modifica parametri Macchina Friend bModifyMachParam As Boolean - Public ReadOnly Property MachinePanelVM As MachinePanelVM Get Return Map.refMachinePanelVM @@ -219,6 +230,39 @@ Public Class ConfigurationPageVM End Set End Property + Private m_bGeneral_Visibility As Visibility = Visibility.Visible + Public Property General_Visibility As Visibility + Get + Return m_bGeneral_Visibility + End Get + Set(value As Visibility) + m_bGeneral_Visibility = value + NotifyPropertyChanged(NameOf(General_Visibility)) + End Set + End Property + + Private m_bParameterQ_Visibility As Visibility = Visibility.Collapsed + Public Property ParameterQ_Visibility As Visibility + Get + Return m_bParameterQ_Visibility + End Get + Set(value As Visibility) + m_bParameterQ_Visibility = value + NotifyPropertyChanged(NameOf(ParameterQ_Visibility)) + End Set + End Property + + Private m_bMachine_Visibility As Visibility = Visibility.Collapsed + Public Property Machine_Visibility As Visibility + Get + Return m_bMachine_Visibility + End Get + Set(value As Visibility) + m_bMachine_Visibility = value + NotifyPropertyChanged(NameOf(Machine_Visibility)) + End Set + End Property + ' Definizione comandi Private m_cmdSave As ICommand Private m_cmdChooseExternalBackupFolderPath As ICommand @@ -370,6 +414,24 @@ Public Class ConfigurationPageVM End Get End Property + Public ReadOnly Property General_Msg As String + Get + Return EgtMsg(62535) + End Get + End Property + + Public ReadOnly Property ParameterQ_Msg As String + Get + Return EgtMsg(62536) + End Get + End Property + + Public ReadOnly Property Machine_Msg As String + Get + Return EgtMsg(62537) + End Get + End Property + #End Region ' Messages #Region "Constructor" diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml new file mode 100644 index 00000000..1a271f72 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/General_ConfigurationPageV.xaml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/FeatureListManager/FeatureListManagerV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/FeatureListManager/FeatureListManagerV.xaml.vb new file mode 100644 index 00000000..4796b51e --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/FeatureListManager/FeatureListManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class FeatureListManagerV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/FeatureListManager/FeatureListManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/FeatureListManager/FeatureListManagerVM.vb new file mode 100644 index 00000000..29334087 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/FeatureListManager/FeatureListManagerVM.vb @@ -0,0 +1,316 @@ +Imports EgtBEAMWALL.Core +Imports EgtUILib.EgtInterface +Imports EgtWPFLib5 + +Public Class FeatureListManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Public ReadOnly Property ViewPage_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property PartIsSelected As Boolean + Get + Return Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) + End Get + End Property + + Public ReadOnly Property FeatureIsSelected As Boolean + Get + Return PartIsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) + End Get + End Property + + + Public ReadOnly Property CopyFeature_IsEnabled As Boolean + Get + Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected + End Get + End Property + + Public ReadOnly Property MacroFeature_IsEnabled As Boolean + Get + Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected + End Get + End Property + + Public ReadOnly Property AddFeature_IsEnabled As Boolean + Get + Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not Map.refProjectVM.BTLStructureVM.SelBTLPartsCnt > 1 + End Get + End Property + + Public ReadOnly Property RemoveFeature_IsEnabled As Boolean + Get + Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected + End Get + End Property + + + Private m_cmdCopyFeature As ICommand + Private m_cmdMacroFeature As ICommand + Private m_cmdAddFeature As ICommand + Private m_cmdRemoveFeature As ICommand + +#End Region ' Fields & Properties + +#Region "Messages" + + Public ReadOnly Property CopyFeature_ToolTip As String + Get + Return EgtMsg(61908) + End Get + End Property + + Public ReadOnly Property MacroFeature_ToolTip As String + Get + Return EgtMsg(61909) + End Get + End Property + + Public ReadOnly Property AddFeature_ToolTip As String + Get + Return EgtMsg(61910) + End Get + End Property + + Public ReadOnly Property RemoveFeature_ToolTip As String + Get + Return EgtMsg(61911) + End Get + End Property + + +#End Region ' Messages + +#Region "CONSTRUCTOR" + + Sub New() + Map.SetRefFeatureListManagerVM(Me) + End Sub + +#End Region ' Constructor + +#Region "METHODS" + + Friend Sub UpdateView() + NotifyPropertyChanged(NameOf(ViewPage_Visibility)) + End Sub + + Friend Sub SetLeftPanelIsEnabled(bIsEnabled As Boolean) + NotifyPropertyChanged(NameOf(CopyFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(AddFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(RemoveFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) + End Sub + + Friend Sub PartShowAllChanged() + NotifyPropertyChanged(NameOf(AddFeature_IsEnabled)) + End Sub + + + Friend Sub FeatureSelectionChanged() + NotifyPropertyChanged(NameOf(CopyFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(RemoveFeature_IsEnabled)) + End Sub + +#End Region ' Methods + +#Region "COMMANDS" + +#Region "CopyFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property CopyFeature_Command As ICommand + Get + If m_cmdCopyFeature Is Nothing Then + m_cmdCopyFeature = New Command(AddressOf CopyFeature) + End If + Return m_cmdCopyFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub CopyFeature() + If IsNothing(ProjectManagerVM.CurrProj) Then Return + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart + If IsNothing(SelPart) Then Return + Dim SelFeature As BTLFeatureVM = SelPart.SelBTLFeatureVM + If IsNothing(SelFeature) Then Return + ' creo copia + Dim NewFeature = SelFeature.Copy() + If Not IsNothing(NewFeature) Then + SelPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeature) + MyMachGroupPanelM.SetDuploModified(SelPart.nPartId) + End If + SelPart.ResetCalcPart() + End Sub + +#End Region ' CopyFeature + +#Region "MacroFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MacroFeature_Command As ICommand + Get + If m_cmdMacroFeature Is Nothing Then + m_cmdMacroFeature = New Command(AddressOf MacroFeature) + End If + Return m_cmdMacroFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MacroFeature() + If IsNothing(ProjectManagerVM.CurrProj) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return + ' apro finestra di creazione macro + Dim MacroFeatureWndVM As New MacroFeatureWndVM() + Dim MacroFeatureWnd As New MacroFeatureWndV(Application.Current.MainWindow, MacroFeatureWndVM) + If MacroFeatureWnd.ShowDialog() Then + + End If + End Sub + +#End Region ' MacroFeature + +#Region "AddFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property AddFeature_Command As ICommand + Get + If m_cmdAddFeature Is Nothing Then + m_cmdAddFeature = New Command(AddressOf AddFeature) + End If + Return m_cmdAddFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub AddFeature(ByVal param As Object) + If IsNothing(ProjectManagerVM.CurrProj) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return + ' apro finestra di definizione nuova feature + Dim AddFeatureWndVM As New AddFeatureWndVM() + Dim AddFeatureWnd As New AddFeatureWndV(Application.Current.MainWindow, AddFeatureWndVM) + If AddFeatureWnd.ShowDialog() Then + Dim NewFeat As BTLFeatureM + Dim nNewFeatureId As Integer = 0 + Dim bMacroFlag As Boolean = False + ' verifico se una Macro è selezionata + If AddFeatureWndVM.MacroList.Count > 0 AndAlso AddFeatureWndVM.nSelMacro >= 0 Then + ' Creo nuova feature sulla base della Macro selezionata + ' Creo table e setto variabili + EgtLuaCreateGlobTable("MACRO") + EgtLuaSetGlobNumVar("MACRO.L", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlL) + EgtLuaSetGlobNumVar("MACRO.W", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW) + EgtLuaSetGlobNumVar("MACRO.H", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH) + EgtLuaSetGlobIntVar("MACRO.PROCID", Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId()) + Dim bOk = EgtLuaExecFile(AddFeatureWndVM.m_MacroFilePathList(AddFeatureWndVM.nSelMacro)) + ' Leggo variabili + EgtLuaGetGlobIntVar("MACRO.FEATUREID", nNewFeatureId) + ' Reset lua + EgtLuaResetGlobVar("MACRO") + If Not bOk Then + MessageBox.Show(EgtMsg(61869), EgtMsg(30007)) + Return + End If + bMacroFlag = True + Else + ' Creo nuova feature (Macro non selezionata) + NewFeat = BTLFeatureM.CreateBTLFeature(AddFeatureWndVM.nSelPRC.nPRC, AddFeatureWndVM.nSelPRC.nGRP, AddFeatureWndVM.nSelPRC.nSIDE) + NewFeat.SetDefaultValues() + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + Dim vParQ() As String = Nothing + NewFeat.CalcParamArray(vPar, sPar, vParQ) + ' aggiorno la feature con nuovo valore + EgtBeamSetPart(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + nNewFeatureId = EgtBeamAddProcess(NewFeat.nSelGRP, NewFeat.nPRC, NewFeat.nSelSIDE, "", + Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId(), + New Frame3d(), vPar, sPar, vParQ, GDB_ID.NULL, GDB_ID.NULL) + bMacroFlag = False + End If + ' se è stata creata + If nNewFeatureId <> GDB_ID.NULL Then + MyMachGroupPanelM.SetDuploModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + ' la aggiungo a struttura BTL corrente + NewFeat = BTLFeatureM.CreateBTLFeature(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM, nNewFeatureId) + If Not bMacroFlag Then NewFeat.SetDefaultValues() + Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.AddBTLFeature(NewFeat) + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeat) + Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() + End If + End If + End Sub + +#End Region ' AddFeature + +#Region "RemoveFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemoveFeature_Command As ICommand + Get + If m_cmdRemoveFeature Is Nothing Then + m_cmdRemoveFeature = New Command(AddressOf RemoveFeature) + End If + Return m_cmdRemoveFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemoveFeature() + If IsNothing(ProjectManagerVM.CurrProj) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then Return + If EgtBeamEraseProcess(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.nFeatureId) Then + MyMachGroupPanelM.SetDuploModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + ' rimuovo dalla lista feature + Dim Index As Integer = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.IndexOf(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) + If Index = 0 Then + If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 0 Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(0) + Else + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing + End If + ElseIf Index = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 1 Then + If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 1 Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 2) + Else + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing + End If + Else + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Index - 1) + End If + Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.RemoveAt(Index) + EgtDraw() + Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() + End If + End Sub + +#End Region ' RemoveFeature + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/FreeContourManager/FreeContourManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/FreeContourManager/FreeContourManagerVM.vb index d5172fcb..08f1b725 100644 --- a/EgtBEAMWALL.ViewerOptimizer/FreeContourManager/FreeContourManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/FreeContourManager/FreeContourManagerVM.vb @@ -321,7 +321,8 @@ Public Class FreeContourManagerVM nSideAngTextLayer = GDB_ID.NULL SideAngValues.Clear() ' nascondo PartManager - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) ' verifico se solido attivo m_bPrevShowSolid = Map.refShowBeamPanelVM.ShowSolid_IsChecked If m_bPrevShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False) @@ -437,9 +438,11 @@ Public Class FreeContourManagerVM ' attivo bottoni save e cancel SelFeature.RefreshFCMBtnVisibility() ' nascondo Part Manager - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) ' attivo pannello Map.refProjectVM.SetFreeContourManager_Visibility(True) + Map.refProjWndVM.SetFreeContourManager_Visibility(True) EgtDraw() End Sub @@ -528,6 +531,7 @@ Public Class FreeContourManagerVM End If ' disattivo pannello Map.refProjectVM.SetFreeContourManager_Visibility(False) + Map.refProjWndVM.SetFreeContourManager_Visibility(False) ' attivo bottone edit SelFeature.RefreshFCMBtnVisibility() ' resetto tutte le variabili correnti @@ -537,7 +541,8 @@ Public Class FreeContourManagerVM nSelFeatureId = GDB_ID.NULL nProcessingLayerId = GDB_ID.NULL ' riattivo Part Manager - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) ' disattivo modifiche su scena Map.refSceneHostVM.MainScene.SetStatusNull() If m_bPrevShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) @@ -557,7 +562,8 @@ Public Class FreeContourManagerVM Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) EgtZoom(ZM.ALL) ' rimetto PartManager - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) End Sub ' funzione lanciata su fine creazione percorso diff --git a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml index 2d9d56e2..84a981bd 100644 --- a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml @@ -39,9 +39,24 @@ - + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb new file mode 100644 index 00000000..8e1b5347 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb @@ -0,0 +1,1919 @@ +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_OnlyProdManager_IsEnabled As Boolean = True + Public ReadOnly Property OnlyProdManager_IsEnabled As Boolean + Get + Return m_OnlyProdManager_IsEnabled + End Get + End Property + Friend Sub SetOnlyProdManagerIsEnabled(bIsEnabled As Boolean) + m_OnlyProdManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(OnlyProdManager_IsEnabled)) + End Sub + + Friend Property CurrProj As ProjFileVM + Get + Return ProjectManagerVM.CurrProj + End Get + Set(value As ProjFileVM) + ProjectManagerVM.CurrProj = value + End Set + End Property + + Friend Property CurrProd As ProdFileVM + Get + Return ProjectManagerVM.CurrProd + End Get + Set(value As ProdFileVM) + ProjectManagerVM.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 PdId As Integer = 0 + Dim sPdId As String = Path.GetFileNameWithoutExtension(DirectCast(FileName, String).Replace("__", "_")) + Integer.TryParse(sPdId, PdId) + Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(PdId) + If IsNothing(PdFileM) Then + m_MruFiles.Remove(FileName) + Else + Dim PdFileVM = New ProdFileVM(PdFileM) + IdAndBTLFileNames.Add(sPdId & " | " & PdFileVM.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 + + Public ReadOnly Property nProjType As BWType + Get + Return If(Not IsNothing(CurrProj), CurrProj.nType, BWType.NULL) + End Get + End Property + + Public ReadOnly Property nProdType As BWType + Get + Return If(Not IsNothing(CurrProd), CurrProd.nType, BWType.NULL) + End Get + End Property + + ' Definizione comandi + Private m_cmdNew As ICommand + Private m_cmdOpen As ICommand + Private m_cmdOpenMruFile 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_cmdAddProj 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 ExportProject_ToolTip As String + Get + Return EgtMsg(61838) + 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 + + ' Leggo ultimo indice di progetto + m_nLastProdId = GetMainPrivateProfileInt(S_GENERAL, K_PRODSINDEX, 1) + ' Impostazioni MruLists + m_MruFiles.Init(S_MRUPRODFILES, 8) + + ' 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 + Return ProjectManagerVM.SetCurrProj(nProjId) + End Function + + Public Function UpdateCurrProj() As Boolean + Return SetCurrProj(CurrProj.nProjId) + End Function + + Private Function InitNewProj(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 + + Friend Function InitNewProd(ByRef nProjId As Integer, ByRef nProdId As Integer, ByRef sProjectDir As String) As Boolean + ' richiedo indice nuovo progetto + nProdId = DbControllers.m_ProdController.GetNextIndex(nProjId, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + If nProdId <= 0 Then Return False + sProjectDir = refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.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(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 + Return ProjectManagerVM.SetCurrProd(nProdId) + End Function + + Public Sub OpenProject_Tick() + If Not m_bOpenProj Then Return + m_bOpenProj = False + + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' 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(ProjectManagerVM.CurrProj, ProjectType.PROJ) Then Return + OpenProject(ProjectVM) + End If + m_nProjIdToOpen = GDB_ID.NULL + End Sub + + Private Sub NewProdFromProj() + ' inizializzo nuovo progetto PROD + Dim nProdId As Integer = 0 + Dim sProdDir As String = "" + InitNewProd(CurrProj.nProjId, nProdId, sProdDir) + ' setto il PType del Prod + DbControllers.m_ProdController.UpdatePType(nProdId, CurrProj.nType) + ' setto la Macchina associata al Prod + DbControllers.m_ProdController.UpdateMachine(nProdId, CurrProj.sMachine) + ' copio file progetto + Dim sProjPath As String = String.Empty + Dim bOk = False + Dim sProdPath As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" + If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then + Try + File.Copy(sProjPath, sProdPath) + 'Map.refSceneHostVM.MainController.OpenProject(sProdPath) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + End If + If bOk Then + ' aggiorno path proj + UpdateCurrProj() + ' imposto currprod + SetCurrProd(nProdId) + ' imposto TempCurrProd + TempCurrProd = CurrProd + ' setto flag nuovo progetto in prod + CurrProd.bIsNew = True + Else + ' elimino da DB + DbControllers.m_ProdController.DeleteProd(nProdId, True) + 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 + ' riapro progetto prod + OpenProject(TempCurrProd) + 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 + + Public Sub OpenOnlyProjectFromSupervisor(ProjIdToOpen As Integer) + If Not IsNothing(ProjectManagerVM.CurrProd) Then + m_nProjIdToOpen = ProjIdToOpen + m_bOpenProj = True + End If + 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 PROJ + Dim nProjId As Integer = 0 + Dim sProjDir As String = "" + InitNewProj(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)) + ' inizializzo nuovo progetto PROD + NewProdFromProj() + 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 = TempCurrProd.sMachine)) Then + ' rimuovo il file in apertura dalla lista degli MRU + m_MruFiles.Remove(sFilePath) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + 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) + If Not IsNothing(Map.refTopPanelVM) Then 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.refRawPartManagerVM.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 "OpenMruFileCommand" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property OpenMruFileCommand As ICommand + Get + If m_cmdOpenMruFile Is Nothing Then + m_cmdOpenMruFile = New Command(AddressOf OpenMruFile) + End If + Return m_cmdOpenMruFile + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Public Sub OpenMruFile(ByVal param As Object) + ' verifico se progetto modificato, e chiedo se salvare + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return + ' ricavo l'Id e il progetto associato per l'apertura di quest'ultimo + Dim PdId As Integer = 0 + Dim arrStrPdId As String() = DirectCast(param, String).Split("|") + Integer.TryParse(arrStrPdId(0), PdId) + Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(PdId) + Dim PdFileVM = New ProdFileVM(PdFileM) + OpenProject(PdFileVM) + End Sub + +#End Region ' OpenMruFileCommand + +#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(CurrProd.nProdId, Map.refCALCPanelVM.SelectedMachine.Name) + CurrProd.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + ' ciclo sulla lista di ProjId associati + For Each ProjId In 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 = CurrProj.nProjId Then CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + Next + Map.refCALCPanelVM.ResetMachineModified() + End If + ' se nuovo progetto + If CurrProd.bIsNew Then + ' resetto stato new + ' DbControllers.m_ProdController.Reset(CurrProd.nProjId) + 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 ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel 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 + InitNewProj(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 + If bOk Then + ' inizializzo nuovo progetto PROD + NewProdFromProj() + 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 + +#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(CurrProd) Then Return + ' verifico se progetto modificato, e chiedo se salvare + If CurrProd.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 + Configuration.ShowAllPieces(bShowBuilding, bShowSolid, nSelPartId, True, True) + '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 + ' If Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then 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 nProdType = 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 + Configuration.DeletePieces(UpdateBTLWndVM.BTLPartList) + '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 = CurrProd.nProdId 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 = ProjectManagerVM.CurrProj.nProjId Then Exit While + If SameAsseBaseProjId = CurrProd.nProdId 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 = ProjectManagerVM.CurrProj.sProjDirPath & "\" & Path.GetFileNameWithoutExtension(sFile) + Dim sDestPath As String = CurrProd.sProdDirPath & "\" & Path.GetFileNameWithoutExtension(sFile) + While File.Exists(sDestPath & ".btl") + 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(CurrProd) = MessageBoxResult.Cancel Then Return Nothing + If IsNothing(CurrProd) Then Return Nothing + Case Pages.ONLYPRODPAGE + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return Nothing + If IsNothing(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 = CurrProd.nProdId.ToString("0000") & " - " & CurrProd.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 OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Configuration.ShowAllPieces(bShowBuilding) + '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, CurrProd.sMachine) + EgtSetInfo(nImpExpPartId, BTL_GEN_PROJTYPE, CurrProd.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(CurrProd.nProdId > 0, CurrProd.sProdDirPath, CurrProd.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 TempCurrProd As ProjectFileVM = CurrProd + ' lista di tutti gli errori riscontrati + Dim ErrorList As New List(Of String) + 'If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + If ProdFileVM.VerifyProjectModification(TempCurrProd) 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 = "" + InitNewProj(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 + 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 = "" + InitNewProd(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(TempCurrProd) ' Da controllare + End If + ' ripristino eventuale CurrProd precedente + CurrProd = TempCurrProd + WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEXPDIR, Path.GetDirectoryName(ImportDlg.FileName)) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + End Sub + +#End Region ' ImportProject + +#Region "AddProj" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property AddProj_Command As ICommand + Get + If m_cmdAddProj Is Nothing Then + m_cmdAddProj = New Command(AddressOf AddProj) + End If + Return m_cmdAddProj + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub AddProj() + ' verifico se progetto modificato, e chiedo se salvare + If IsNothing(CurrProd) Then Return + Dim bNewProject As Boolean = False + Dim sProjectDirPath As String = "" + sProjectDirPath = CurrProd.sProdDirPath + Dim VerifyResult As MessageBoxResult = MessageBoxResult.None + ' verifico se progetto modificato, e chiedo se salvare + If EgtGetModified() OrElse CurrProd.bIsNew OrElse Map.refCALCPanelVM.IsMachineModified() Then + VerifyResult = MessageBox.Show(EgtMsg(61875), "", If(CurrProd.bIsNew, MessageBoxButton.OKCancel, MessageBoxButton.YesNoCancel), MessageBoxImage.Question) + Select Case VerifyResult + Case MessageBoxResult.Yes, MessageBoxResult.OK + ' salvo proj + Save() + Case MessageBoxResult.Cancel + Return + Case Else ' No + EgtResetModified() + OpenProject(CurrProd) + End Select + Else + EgtResetModified() + End If + ' faccio scegliere proj da aggiungere + Dim OpenProjectFileDialogVM As New OpenProjectFileDialogVM + Dim ChooseProdFileDialog As New OpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = ChooseProdFileDialog.EgtShowDialog(ProjectType.PROJ, True) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + If IsNothing(OpenProjectFileDialogVM.SelProject.nProjId) OrElse OpenProjectFileDialogVM.SelProject.nProjId <= 0 Then Return + ' verifico che il proj selezionato non abbia prod + If Not IsNothing(OpenProjectFileDialogVM.SelProject.nProdId) AndAlso OpenProjectFileDialogVM.SelProject.nProdId > 0 Then + ' verifico che non sia uno di quelli gia' collegati a questo Prod + Dim bFound As Boolean = False + For Each nProjId As Integer In CurrProd.nProjIdList + If nProjId = OpenProjectFileDialogVM.SelProject.nProjId Then + bFound = True + Exit For + End If + Next + If bFound Then + MessageBox.Show("Selezionato progetto che fa gia' parte di questa produzione!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + Else + MessageBox.Show("Progetto gia' collegato ad una produzione!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + End If + Return + End If + ' verifico che sia associato alla stessa macchina + If OpenProjectFileDialogVM.SelProject.sMachine <> CurrProd.sMachine Then + MessageBox.Show("Progetto per una macchina diversa da quella del progetto corrente!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' inserisco proj nel prod corrente + Dim bOk As Boolean = EgtInsertFile(OpenProjectFileDialogVM.SelProject.sProjPath) + ' lo salvo + bOk = bOk AndAlso Save(False) + If bOk Then + ' riporto aggiunta proj a prod su Db + DbControllers.m_ProdController.AddProj(CurrProd.nProdId, OpenProjectFileDialogVM.SelProject.nProjId) + 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 + ' aggiorno CurrProd + Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(CurrProd.nProdId) + CurrProd.ProdFileM.SetProjIdList(PdFileM.nProjIdList) + ' ricarico BTLPartList + OpenProject(CurrProd) + End Sub + +#End Region ' AddProj + +#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(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, CurrProd.nProdId, 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..6bb0d011 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdProject/OnlyProdProjectV.xaml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/OpenProjectFileDialog/OpenProjectFileDialogVM.vb b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb index 3a94b47e..1b917c1a 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb @@ -71,9 +71,9 @@ Public Class OpenProjectFileDialogVM For Each Project In DbProjectList ' recupero path per verificare esista If IsNothing(Project.nProdId) OrElse Project.nProdId = 0 Then Continue For - Dim sPath As String = Map.refMainWindowVM.MainWindowM.sProjsDir & "\" & Project.nProjId.ToString("0000") & "\" & Project.nProjId.ToString("0000") & ".nge" - If Project.sMachine = Map.refProjManagerVM.CurrProj.sMachine AndAlso - Project.nType = Map.refProjManagerVM.CurrProj.nType Then + Dim sPath As String = Map.refMainWindowVM.MainWindowM.sProdsDir & "\" & Project.nProdId.ToString("0000") & "\" & Project.nProdId.ToString("0000") & ".nge" + If Project.sMachine = ProjectManagerVM.CurrProj.sMachine AndAlso + Project.nType = ProjectManagerVM.CurrProj.nType Then If File.Exists(sPath) Then m_ProjectList.Add(New ProjFileVM(Project)) Else @@ -119,7 +119,7 @@ Public Class OpenProjectFileDialogVM Dim ProjListIndex As Integer = m_ProjectList.IndexOf(SelProject) If m_ProjectType = ProjectType.PROJ Then ' verifico se proj selezionato e' il corrente - If Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso SelProject.nProjId = Map.refProjManagerVM.CurrProj.nProjId Then + If Not IsNothing(ProjectManagerVM.CurrProj) AndAlso SelProject.nProjId = ProjectManagerVM.CurrProj.nProjId Then MessageBox.Show(EgtMsg(61872), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning) Return End If @@ -148,7 +148,7 @@ Public Class OpenProjectFileDialogVM Next ElseIf m_ProjectType = ProjectType.PROD Then ' verifico se prod selezionato e' il corrente - If Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso SelProject.nProdId = Map.refProdManagerVM.CurrProd.nProdId Then + If Not IsNothing(ProjectManagerVM.CurrProd) AndAlso SelProject.nProdId = ProjectManagerVM.CurrProd.nProdId Then MessageBox.Show(EgtMsg(61872), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning) Return End If @@ -208,7 +208,7 @@ Public Class OpenProjectFileDialogVM EgtDeleteContext(nTempCtx) End If ' se proj corrente era il prod cancellato, aggiorno proj corrente - If Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso Map.refProjManagerVM.CurrProj.nProdId = SelProject.nProdId Then + If Not IsNothing(ProjectManagerVM.CurrProj) AndAlso ProjectManagerVM.CurrProj.nProdId = SelProject.nProdId Then Map.refProjManagerVM.UpdateCurrProj() End If ' cancello cartella del Prod diff --git a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml new file mode 100644 index 00000000..a0c7a695 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml.vb new file mode 100644 index 00000000..6127d0fd --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml.vb @@ -0,0 +1,11 @@ +Public Class OnlyProdOptimizePanelV + + Private Sub OptimizeBtn_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) + Dim OptimizeBtn = TryCast(sender, FrameworkElement) + + If OptimizeBtn IsNot Nothing Then + OptimizeBtn.ContextMenu.IsOpen = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb index de3a9c17..447ae49e 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb @@ -116,6 +116,15 @@ Public Class OptimizePanelVM 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 @@ -248,11 +257,12 @@ Public Class OptimizePanelVM m_bNestingRunning = True ' se vista tutti i pezzi Dim bShowBuilding As Boolean = False - 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 + Configuration.ShowAllPieces(bShowBuilding) + '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 Dim NestingRunningWndVM As New NestingRunningWndVM(m_SelPartType.Id, BTLPart) Dim NestingRunningWnd As New NestingRunningWndV(Application.Current.MainWindow, NestingRunningWndVM) NestingRunningWnd.ShowDialog() @@ -484,7 +494,7 @@ Public Class OptimizePanelVM ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub Warehouse() - If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then 'If Not IsNothing(Map.refProdManagerVM.CurrProd) Then + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then 'If Not IsNothing(ProjectManagerVM.CurrProd) Then Dim WarehouseWnd As New WarehouseWndV(Application.Current.MainWindow, New WarehouseWndVM()) WarehouseWnd.ShowDialog() End If diff --git a/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerV.xaml b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerV.xaml new file mode 100644 index 00000000..4cf757de --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerV.xaml @@ -0,0 +1,35 @@ + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerV.xaml.vb new file mode 100644 index 00000000..e9a8122c --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class PartInRawPartManagerV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerVM.vb new file mode 100644 index 00000000..dd1562d4 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerVM.vb @@ -0,0 +1,222 @@ +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.Core.ConstBeam +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class PartInRawPartManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Public ReadOnly Property MovePart_Visibility As Visibility + Get + If Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + Return If(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM, Visibility.Visible, Visibility.Collapsed) + End If + Return Visibility.Visible + End Get + End Property + + Private m_PartInRawPartManager_IsEnabled As Boolean = True + Public ReadOnly Property PartInRawPartManager_IsEnabled As Boolean + Get + Return m_PartInRawPartManager_IsEnabled + End Get + End Property + Friend Sub SetPartInRawPartManagerIsEnabled(bIsEnabled As Boolean) + m_PartInRawPartManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(PartInRawPartManager_IsEnabled)) + End Sub + + ' Definizione comandi + Private m_cmdRemovePart As ICommand + Private m_cmdMoveUpPart As ICommand + Private m_cmdMoveDownPart As ICommand + Private m_cmdReOrderPart As ICommand + +#End Region ' Fields & Properties + +#Region "CONSTRUCTORS" + + Sub New() + Map.SetRefPartInRawPartManagerVM(Me) + End Sub + +#End Region ' Constructor + +#Region "Messages" + + 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 + +#End Region ' Messages + +#Region "COMMANDS" + +#Region "RemovePart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemovePart_Command As ICommand + Get + If m_cmdRemovePart Is Nothing Then + m_cmdRemovePart = New Command(AddressOf RemovePart) + End If + Return m_cmdRemovePart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemovePart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + SelPart.DeletePart() + SelMachGroup.UpdateUsage() + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' RemovePart + +#Region "MoveUpPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MoveUpPart_Command As ICommand + Get + If m_cmdMoveUpPart Is Nothing Then + m_cmdMoveUpPart = New Command(AddressOf MoveUpPart) + End If + Return m_cmdMoveUpPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MoveUpPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + If SelMachGroup.nType = MachineType.BEAM Then + SelMachGroup.MoveBeam(SelPart, MoveDirections.UP) + EgtDraw() + ' riseleziono trave + SelMachGroup.SelPart = SelPart + End If + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' MoveUpPart + +#Region "MoveDownPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MoveDownPart_Command As ICommand + Get + If m_cmdMoveDownPart Is Nothing Then + m_cmdMoveDownPart = New Command(AddressOf MoveDownPart) + End If + Return m_cmdMoveDownPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MoveDownPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + If SelMachGroup.nType = MachineType.BEAM Then + SelMachGroup.MoveBeam(SelPart, MoveDirections.DOWN) + EgtDraw() + ' riseleziono trave + SelMachGroup.SelPart = SelPart + End If + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' MoveDownPart + +#Region "ReOrderPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ReOrderPart_Command As ICommand + Get + If m_cmdReOrderPart Is Nothing Then + m_cmdReOrderPart = New Command(AddressOf ReOrderPart) + End If + Return m_cmdReOrderPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ReOrderPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + If SelMachGroup.nType = MachineType.BEAM Then + SelMachGroup.ReorderBeam() + EgtDraw() + ' riseleziono trave + If Not IsNothing(SelPart) Then + SelMachGroup.SelPart = SelPart + End If + End If + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' ReOrderPart + + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml new file mode 100644 index 00000000..dfb4b5ad --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml.vb new file mode 100644 index 00000000..04aa079e --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml.vb @@ -0,0 +1,3 @@ +Public Class PartInRawPartManagerWndV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/PartParametersWnd/PartParametersWndV.xaml b/EgtBEAMWALL.ViewerOptimizer/PartParametersWnd/PartParametersWndV.xaml new file mode 100644 index 00000000..da339fe0 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/PartParametersWnd/PartParametersWndV.xaml @@ -0,0 +1,468 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb index 0ab55fd2..07c2dc45 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb @@ -23,13 +23,12 @@ Public Class ProdManagerVM End Get End Property - Private m_CurrProd As ProdFileVM Friend Property CurrProd As ProdFileVM Get - Return m_CurrProd + Return ProjectManagerVM.CurrProd End Get Set(value As ProdFileVM) - m_CurrProd = value + ProjectManagerVM.CurrProd = value End Set End Property @@ -84,6 +83,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 +148,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 @@ -184,10 +190,7 @@ Public Class ProdManagerVM End Function Public Function SetCurrProd(nProdId As Integer) As Boolean - Dim CurrProdM As ProdFileM = DbControllers.m_ProdController.FindCoreByProdId(nProdId) - If IsNothing(CurrProdM) Then Return False - Map.refProdManagerVM.CurrProd = New ProdFileVM(CurrProdM) - Return True + Return ProjectManagerVM.SetCurrProd(nProdId) End Function Public Sub ResetCurrProd() @@ -200,7 +203,7 @@ Public Class ProdManagerVM End Sub Public Sub OpenProjectFromSupervisor(ProjIdToOpen As Integer) - If (Not IsNothing(Map.refProdManagerVM.m_CurrProd) AndAlso ProjIdToOpen <> Map.refProdManagerVM.m_CurrProd.nProdId) OrElse Map.refMainMenuVM.SelPage <> Pages.MACHINING Then + If (Not IsNothing(ProjectManagerVM.CurrProd) AndAlso ProjIdToOpen <> ProjectManagerVM.CurrProd.nProdId) OrElse Map.refMainMenuVM.SelPage <> Pages.MACHINING Then m_nProjIdToOpen = ProjIdToOpen m_bOpenProj = True End If @@ -216,17 +219,17 @@ Public Class ProdManagerVM 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 + If Not ProjFileVM.VerifyProjectModification(ProjectManagerVM.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 + If Not ProjFileVM.VerifyProjectModification(ProjectManagerVM.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 + If Not IsNothing(ProjectManagerVM.CurrProj) AndAlso (m_nProjIdToOpen <> ProjectManagerVM.CurrProj.nProdId OrElse IsNothing(ProjectManagerVM.CurrProd)) Then Map.refProdManagerVM.SetCurrProd(m_nProjIdToOpen) - Map.refProdManagerVM.CurrProd.SetReloadProject(True) + ProjectManagerVM.CurrProd.SetReloadProject(True) Else - Map.refProdManagerVM.CurrProd.SetReloadProject(False) + ProjectManagerVM.CurrProd.SetReloadProject(False) End If ' Ricavo il tipo di Warehouse settato nell'INI Dim nDefault As Integer = 2 @@ -334,7 +337,7 @@ Public Class ProdManagerVM ' aggiorno lista possibili nesting Map.refOptimizePanelVM.UpdateOriginTypeList(EgtGetFirstNameInGroup(GDB_ID.ROOT, "RawParts") <> GDB_ID.NULL) ' aggiorno visibilità bottone Muovi pezzi - Map.refTopPanelVM.UpdateMovePartInRawPartVisibility() + Map.refRawPartManagerVM.UpdateMovePartInRawPartVisibility() ' resetto eventuale visualizzazione statistiche Map.refInstrumentPanelVM.ResetStatisticsIsChecked() ' aggiorno titolo @@ -398,7 +401,7 @@ Public Class ProdManagerVM End Sub Public Function Save(Optional bShowLoading As Boolean = False) As Boolean - If IsNothing(m_CurrProd) Then Return False + 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 @@ -415,23 +418,23 @@ Public Class ProdManagerVM End If ' verifico se Reset Macchina modificato e nel caso aggiorno DB e CurrProj If Map.refCALCPanelVM.IsMachineModified() Then - DbControllers.m_ProdController.UpdateMachine(Map.refProdManagerVM.CurrProd.nProdId, Map.refCALCPanelVM.SelectedMachine.Name) - Map.refProdManagerVM.CurrProd.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + DbControllers.m_ProdController.UpdateMachine(ProjectManagerVM.CurrProd.nProdId, Map.refCALCPanelVM.SelectedMachine.Name) + ProjectManagerVM.CurrProd.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) ' ciclo sulla lista di ProjId associati - For Each ProjId In Map.refProdManagerVM.CurrProd.nProjIdList + For Each ProjId In ProjectManagerVM.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) + If ProjId = ProjectManagerVM.CurrProj.nProjId Then ProjectManagerVM.CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) Next Map.refCALCPanelVM.ResetMachineModified() End If ' se nuovo progetto - If m_CurrProd.bIsNew Then + If CurrProd.bIsNew Then ' resetto stato new ' DbControllers.m_ProdController.Reset(CurrProd.nProjId) - m_CurrProd.bIsNew = False + CurrProd.bIsNew = False End If Map.refMainWindowVM.UpdateTitle() NotifyPropertyChanged(NameOf(MruFileNames)) @@ -551,12 +554,12 @@ Public Class ProdManagerVM ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub GoToProj() - If IsNothing(m_CurrProd) Then Return + If IsNothing(CurrProd) Then Return ' recupero Proj associati da Db - Dim ProjFileMList As List(Of ProjFileM) = DbControllers.m_ProjController.GetByProdAsc(m_CurrProd.nProdId) + Dim ProjFileMList As List(Of ProjFileM) = DbControllers.m_ProjController.GetByProdAsc(CurrProd.nProdId) Dim nProjId As Integer = 0 ' verifico se salvare progetto corrente - Dim VerifyResult As MessageBoxResult = ProdFileVM.VerifyProjectModification(Map.refProdManagerVM.CurrProd) + Dim VerifyResult As MessageBoxResult = ProdFileVM.VerifyProjectModification(ProjectManagerVM.CurrProd) If VerifyResult = MessageBoxResult.Cancel Then Return ' se piu' di uno If IsNothing(ProjFileMList) Then @@ -584,7 +587,7 @@ Public Class ProdManagerVM ' apro progetto proj Map.refProjManagerVM.SetCurrProj(nProjId) ' ricarico progetto se il prod e' nullo (quindi e' stato cancellato) - Map.refProjManagerVM.CurrProj.SetReloadProject(IsNothing(CurrProd) OrElse VerifyResult = MessageBoxResult.No) + ProjectManagerVM.CurrProj.SetReloadProject(IsNothing(CurrProd) OrElse VerifyResult = MessageBoxResult.No) ' vado in pagina proj Map.refMainMenuVM.SetSelPage(Pages.VIEW, False) LoadingWndHelper.CloseLoadingWnd(ActiveIds.GOTOPROJ) @@ -610,7 +613,7 @@ Public Class ProdManagerVM ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub GoToSupervisor() - If IsNothing(m_CurrProd) Then Return + If IsNothing(CurrProd) Then Return ' apro supervisore Dim sSupervisorName As String = "EgtBEAMWALL.SupervisorR32" ' recupero processo del supervisore @@ -631,7 +634,7 @@ Public Class ProdManagerVM End If ' mando richiesta di apertura progetto in supervisore 'Dim x = DbControllers.m_StatusMapController.GetProd - DbControllers.m_StatusMapController.UpdateAction(DbControllers.m_SupervisorId, Map.refProdManagerVM.CurrProd.nProdId, Map.refProdManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ChangeProdInSupervisorRequest, "") + DbControllers.m_StatusMapController.UpdateAction(DbControllers.m_SupervisorId, ProjectManagerVM.CurrProd.nProdId, ProjectManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ChangeProdInSupervisorRequest, "") End Sub #End Region ' GoToSupervisor diff --git a/EgtBEAMWALL.ViewerOptimizer/ProdProjManager/ProdProjManagerV.xaml b/EgtBEAMWALL.ViewerOptimizer/ProdProjManager/ProdProjManagerV.xaml new file mode 100644 index 00000000..bdfa52bf --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ProdProjManager/ProdProjManagerV.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ProdProjManager/ProdProjManagerV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/ProdProjManager/ProdProjManagerV.xaml.vb new file mode 100644 index 00000000..816dd5c5 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ProdProjManager/ProdProjManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ProdProjManagerV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/ProdProjManager/ProdProjManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProdProjManager/ProdProjManagerVM.vb new file mode 100644 index 00000000..d9302a9a --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ProdProjManager/ProdProjManagerVM.vb @@ -0,0 +1,43 @@ +Imports EgtBEAMWALL.Core.ConstGen +Imports EgtWPFLib5 + +Public Class ProdProjManagerVM + Inherits VMBase + +#Region "FIELD & PROPERTIES" + + ' Selezione Tab Prod / Proj + Private m_SelProdProj As ProdProj + Public Property SelProdProj As Integer + Get + Return m_SelProdProj + End Get + Set(value As Integer) + m_SelProdProj = value + NotifyPropertyChanged(NameOf(SelProdProj)) + End Set + End Property + + Public ReadOnly Property PartManager_Visibility As Visibility + Get + Return If((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso Not Map.refFreeContourManagerVM.bIsActive, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property FreeContourManager_Visibility As Visibility + Get + Return Map.refProjectVM.FreeContourManager_Visibility + End Get + End Property + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + Map.SetRefProdProjManagerVM(Me) + End Sub + +#End Region ' Constructor + +End Class 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..33447800 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb @@ -20,13 +20,12 @@ Public Class ProjManagerVM End Get End Property - Private m_CurrProj As ProjFileVM Friend Property CurrProj As ProjFileVM Get - Return m_CurrProj + Return ProjectManagerVM.CurrProj End Get Set(value As ProjFileVM) - m_CurrProj = value + ProjectManagerVM.CurrProj = value End Set End Property @@ -104,6 +103,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 @@ -200,7 +205,7 @@ Public Class ProjManagerVM ' inizializzo nuovo progetto Dim nProdId As Integer = 0 Dim sProdDir As String = "" - Map.refProdManagerVM.InitNewProject(m_CurrProj.nProjId, nProdId, sProdDir) + Map.refProdManagerVM.InitNewProject(CurrProj.nProjId, nProdId, sProdDir) ' setto il PType del Prod DbControllers.m_ProdController.UpdatePType(nProdId, CurrProj.nType) ' setto la Macchina associata al Prod @@ -225,9 +230,9 @@ Public Class ProjManagerVM ' imposto currprod Map.refProdManagerVM.SetCurrProd(nProdId) ' imposto TempCurrProd - Map.refProdManagerVM.TempCurrProd = Map.refProdManagerVM.CurrProd + Map.refProdManagerVM.TempCurrProd = ProjectManagerVM.CurrProd ' setto flag nuovo progetto in prod - Map.refProdManagerVM.CurrProd.bIsNew = True + ProjectManagerVM.CurrProd.bIsNew = True Else ' elimino da DB DbControllers.m_ProdController.DeleteProd(nProdId, True) @@ -285,10 +290,7 @@ Public Class ProjManagerVM End Function 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 + Return ProjectManagerVM.SetCurrProj(nProjId) End Function Public Function UpdateCurrProj() As Boolean @@ -305,7 +307,7 @@ Public Class ProjManagerVM End Sub Private Sub ReloadBTLStructure() - Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(Map.refProjManagerVM.CurrProj.nProjId)) + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(ProjectManagerVM.CurrProj.nProjId)) ' verifico se volume pezzi calcolato Dim bIsCalculated As Boolean = False For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList @@ -560,15 +562,16 @@ Public Class ProjManagerVM Dim bShowSolid As Boolean = False If bShowLoading Then LoadingWndHelper.OpenLoadingWnd(ActiveIds.SAVEPROJ, 1, EgtMsg(63007), "", 100) ' Project saving ' se vista tutti i pezzi - 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) - End If + Configuration.ShowAllPieces(bShowBuilding, bShowSolid, True, False) + '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) + 'End If ' imposto ProjId di caricamento m_nLoadingProjId = CurrProj.nProjId Map.refSceneHostVM.SaveProject() @@ -576,20 +579,20 @@ Public Class ProjManagerVM ' aggiorno BTLParts su DB DbControllers.m_ProjController.UpdateBtlParts(CurrProj.nProjId, Map.refProjectVM.BTLStructureVM.BTLStructureM.BTLPartMList) ' se nuovo progetto - If m_CurrProj.bIsNew Then + If CurrProj.bIsNew Then ' resetto stato new DbControllers.m_ProjController.ResetNew(CurrProj.nProjId) - m_CurrProj.bIsNew = False + CurrProj.bIsNew = False End If ' se assemblato lo ripristino If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) ' verifico se Reset Macchina modificato e nel caso aggiorno DB e CurrProj If Map.refCALCPanelVM.IsMachineModified() Then - DbControllers.m_ProjController.UpdateMachine(Map.refProjManagerVM.CurrProj.nProjId, Map.refCALCPanelVM.SelectedMachine.Name) - Map.refProjManagerVM.CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + DbControllers.m_ProjController.UpdateMachine(ProjectManagerVM.CurrProj.nProjId, Map.refCALCPanelVM.SelectedMachine.Name) + ProjectManagerVM.CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) ' se esiste un Prod associato al Proj corrente aggiorno anche questo Prod nel DB - If Map.refProjManagerVM.CurrProj.nProdId > 0 Then DbControllers.m_ProdController.UpdateMachine(Map.refProjManagerVM.CurrProj.nProdId, + If ProjectManagerVM.CurrProj.nProdId > 0 Then DbControllers.m_ProdController.UpdateMachine(ProjectManagerVM.CurrProj.nProdId, Map.refCALCPanelVM.SelectedMachine.Name) Map.refCALCPanelVM.ResetMachineModified() End If @@ -857,18 +860,19 @@ Public Class ProjManagerVM 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 + Configuration.ShowAllPieces(bShowBuilding, bShowSolid, nSelPartId, True) + '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) @@ -889,7 +893,7 @@ Public Class ProjManagerVM 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 + ' SelPart.IsSelected = True If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) End If End If @@ -1006,7 +1010,7 @@ Public Class ProjManagerVM 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 + 'SelPart.IsSelected = True If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) End If End If @@ -1121,7 +1125,7 @@ Public Class ProjManagerVM 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 + 'SelPart.IsSelected = True If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) End If End If @@ -1177,26 +1181,27 @@ Public Class ProjManagerVM 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 + Configuration.DeletePieces(UpdateBTLWndVM.BTLPartList) + '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) @@ -1247,7 +1252,7 @@ Public Class ProjManagerVM 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 + If Not AsseBaseIdList.Contains(nAsseBaseId) AndAlso nAsseBaseProjId = ProjectManagerVM.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 @@ -1257,7 +1262,7 @@ Public Class ProjManagerVM 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 + If SameAsseBaseProjId = ProjectManagerVM.CurrProj.nProjId Then Exit While FindAsseBaseId = EgtGetNextName(FindAsseBaseId, ASSEBASE) End While ' salvo id dell'AsseBase corrente per ottenere il seguente prima di rilocarlo @@ -1316,7 +1321,7 @@ Public Class ProjManagerVM 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) + Dim sDestPath As String = ProjectManagerVM.CurrProj.sProjDirPath & "\" & Path.GetFileNameWithoutExtension(sFile) While File.Exists(sDestPath & ".btl") sDestPath = sDestPath & "_1" End While @@ -1328,7 +1333,7 @@ Public Class ProjManagerVM 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 + 'SelPart.IsSelected = True If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) End If End If @@ -1360,8 +1365,8 @@ Public Class ProjManagerVM 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 + If ProdFileVM.VerifyProjectModification(ProjectManagerVM.CurrProd) = MessageBoxResult.Cancel Then Return Nothing + If IsNothing(ProjectManagerVM.CurrProd) Then Return Nothing Case Else Return Nothing End Select @@ -1378,11 +1383,12 @@ Public Class ProjManagerVM ' 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 + Configuration.ShowAllPieces(bShowBuilding) + '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 @@ -1407,15 +1413,15 @@ Public Class ProjManagerVM EgtSetInfo(nImpExpPartId, EXP_MACHINE, CurrProj.sMachine) EgtSetInfo(nImpExpPartId, BTL_GEN_PROJTYPE, CurrProj.nType) '' se c'e' un prod collegato - 'If Map.refProjManagerVM.CurrProj.nProdId > 0 Then + 'If ProjectManagerVM.CurrProj.nProdId > 0 Then ' ' scrivo quali sono i proj e prod in questo file - ' Dim Prod As ProdFileM = DbControllers.m_ProdController.FindCoreByProdId(Map.refProjManagerVM.CurrProj.nProdId) - ' EgtSetInfo(Map.refProjectVM.BTLStructureVM.BTLStructureM.nBTLInfoId, EXP_PROD, Map.refProjManagerVM.CurrProj.nProdId) + ' Dim Prod As ProdFileM = DbControllers.m_ProdController.FindCoreByProdId(ProjectManagerVM.CurrProj.nProdId) + ' EgtSetInfo(Map.refProjectVM.BTLStructureVM.BTLStructureM.nBTLInfoId, EXP_PROD, ProjectManagerVM.CurrProj.nProdId) ' For ProjIndex = 0 To Prod.nProjIdList.Count - 1 ' EgtSetInfo(Map.refProjectVM.BTLStructureVM.BTLStructureM.nBTLInfoId, EXP_PROJ & ProjIndex + 1, Prod.nProjIdList(ProjIndex)) ' Next 'Else - ' EgtSetInfo(Map.refProjectVM.BTLStructureVM.BTLStructureM.nBTLInfoId, EXP_PROJ & 1, Map.refProjManagerVM.CurrProj.nProjId) + ' EgtSetInfo(Map.refProjectVM.BTLStructureVM.BTLStructureM.nBTLInfoId, EXP_PROJ & 1, ProjectManagerVM.CurrProj.nProjId) 'End If LoadingWndHelper.UpdateLoadingWnd(ActiveIds.EXPORTPROJECT, 2, EgtMsg(63017), 30, 100) ' Exporting... ' salvo info inserite @@ -1468,7 +1474,7 @@ Public Class ProjManagerVM ''' Execute the Export. This method is invoked by the ExportCommand. ''' Public Sub ImportProject() - Dim CurrProd As ProjectFileVM = Map.refProdManagerVM.CurrProd + Dim CurrProd As ProjectFileVM = ProjectManagerVM.CurrProd ' lista di tutti gli errori riscontrati Dim ErrorList As New List(Of String) If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return @@ -1641,7 +1647,7 @@ Public Class ProjManagerVM nDuploId = EgtGetNext(nDuploId) End While ' resetto CurrProd per evitare di leggere valori produzione dal Db di quel progetto - Map.refProdManagerVM.CurrProd = Nothing + ProjectManagerVM.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 @@ -1720,7 +1726,7 @@ Public Class ProjManagerVM OpenProject(CurrProj) End If ' ripristino eventuale CurrProd precedente - Map.refProdManagerVM.CurrProd = CurrProd + ProjectManagerVM.CurrProd = CurrProd WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEXPDIR, Path.GetDirectoryName(ImportDlg.FileName)) LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) ' imposto progetto corrente @@ -1737,7 +1743,7 @@ Public Class ProjManagerVM ' aggiorno le colonne in base al tipo progetto 'Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) 'Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) - 'DbControllers.m_ProjController.LockByProjId(Map.refProjManagerVM.CurrProj.nProjId, True) + 'DbControllers.m_ProjController.LockByProjId(ProjectManagerVM.CurrProj.nProjId, True) ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel 'Map.refCALCPanelVM.LoadMachineList() 'SectionXMaterial.SetType(nType) @@ -1782,7 +1788,7 @@ Public Class ProjManagerVM Case MessageBoxResult.Cancel Return Case Else ' No - If Map.refProjManagerVM.CurrProj.bIsNew Then + If ProjectManagerVM.CurrProj.bIsNew Then MessageBox.Show(EgtMsg(61878), "", MessageBoxButton.OK, MessageBoxImage.Exclamation) Return End If @@ -1794,10 +1800,10 @@ Public Class ProjManagerVM LoadingWndHelper.OpenLoadingWnd(ActiveIds.GOTOPROD, 3, EgtMsg(63004), EgtMsg(63011), 10) ' Optimization opening ' Loading environment - Dim nProdId As Integer = Map.refProjManagerVM.CurrProj.nProdId + Dim nProdId As Integer = ProjectManagerVM.CurrProj.nProdId If nProdId > 0 Then Map.refProdManagerVM.SetCurrProd(nProdId) - Map.refProdManagerVM.CurrProd.SetReloadProject(Not bSaved) + ProjectManagerVM.CurrProd.SetReloadProject(Not bSaved) Else 'creo nuova ottimizzazione da progetto corrente NewProdFromProj() @@ -1833,7 +1839,7 @@ Public Class ProjManagerVM ' ''' nProdPartId = EgtGetNextPart(nProdPartId) ' '''End While ' ' inserisco proj nel prod selezionato - ' bOk = bOk AndAlso EgtInsertFile(Map.refProjManagerVM.CurrProj.sProjPath) + ' bOk = bOk AndAlso EgtInsertFile(ProjectManagerVM.CurrProj.sProjPath) ' ' DA METTERE IN MERGE BTL, NON QUI!!! ' '''' deseleziono tutto ' '''EgtDeselectAll() @@ -1843,7 +1849,7 @@ Public Class ProjManagerVM ' ''' ' se arrivano dal nuovo progetto ' ''' Dim nCurrProjId As Integer ' ''' EgtGetInfo(nPartId, PROJ, nCurrProjId) - ' ''' If nCurrProjId = Map.refProjManagerVM.CurrProj.nProjId Then + ' ''' If nCurrProjId = ProjectManagerVM.CurrProj.nProjId Then ' ''' ' sposto i pezzi per non averli sovrapposti ' ''' EgtMove(nCurrProjId, New Vector3d(0, b3Parts.DimY() + 500, 0)) ' ''' End If @@ -1855,7 +1861,7 @@ Public Class ProjManagerVM ' End If ' If bOk Then ' ' riporto aggiunta proj a prod su Db - ' DbControllers.m_ProdController.AddProj(OpenProjectFileDialogVM.SelProject.nProdId, Map.refProjManagerVM.CurrProj.nProjId) + ' DbControllers.m_ProdController.AddProj(OpenProjectFileDialogVM.SelProject.nProdId, ProjectManagerVM.CurrProj.nProjId) ' ' imposto currprod ' Map.refProdManagerVM.SetCurrProd(OpenProjectFileDialogVM.SelProject.nProdId) ' End If diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml index f871c350..138aad00 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}"> @@ -81,23 +82,21 @@ + DataContext="{StaticResource FreeContourInputVM}" + Visibility="{Binding DataContext.FreeContourManager_Visibility, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:ProjectV}}}"/> - - + + diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb index 35d848ef..259c4469 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb @@ -142,6 +142,7 @@ Public Class ProjectVM End Property Friend Sub SetProjManager_Visibility(IsVisible As Boolean) m_ProjManager_Visibility = IsVisible + If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) End Sub Private m_ProdManager_Visibility As Boolean = True @@ -155,6 +156,7 @@ Public Class ProjectVM End Property Friend Sub SetProdManager_Visibility(IsVisible As Boolean) m_ProdManager_Visibility = IsVisible + If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.GoToProj_Visibility)) End Sub Private m_OptimizePanel_Visibility As Boolean = True @@ -193,7 +195,55 @@ Public Class ProjectVM End Property Friend Sub SetFreeContourManager_Visibility(IsVisible As Boolean) m_FreeContourManager_Visibility = IsVisible - NotifyPropertyChanged("FreeContourManager_Visibility") + NotifyPropertyChanged(NameOf(FreeContourManager_Visibility)) + End Sub + + ' OnlyProdProject + + Private m_OnlyProdManager_Visibility As Boolean = True + Public Property OnlyProdManager_Visibility As Visibility + Get + Return If(m_OnlyProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OnlyProdManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOnlyProdManager_Visibility(IsVisible As Boolean) + m_OnlyProdManager_Visibility = IsVisible + End Sub + + Private m_OnlyProdLeftPanel_Visibility As Boolean = True + Public Property OnlyProdLeftPanel_Visibility As Visibility + Get + Return If(m_OnlyProdLeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OnlyProdLeftPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOnlyProdLeftPanel_Visibility(IsVisible As Boolean) + m_OnlyProdLeftPanel_Visibility = IsVisible + End Sub + + Private m_OnlyProdOptimizePanel_Visibility As Boolean = True + Public Property OnlyProdOptimizePanel_Visibility As Visibility + Get + Return If(m_OnlyProdOptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OnlyProdOptimizePanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOnlyProdOptimizePanel_Visibility(IsVisible As Boolean) + m_OnlyProdOptimizePanel_Visibility = IsVisible + NotifyPropertyChanged(NameOf(OnlyProdOptimizePanel_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility)) End Sub Public ReadOnly Property SpecialPanel_Visibility As Visibility @@ -202,20 +252,33 @@ Public Class ProjectVM End Get End Property + Private m_MacroFeature_IsEnabled As Boolean = False + Public Property MacroFeature_IsEnabled As Boolean + Get + Return m_MacroFeature_IsEnabled + End Get + Set(value As Boolean) + m_MacroFeature_IsEnabled = value + NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) + End Set + End Property - 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") - NotifyCalcPanel_Visibility() + Enum GridSelTypes As Integer + PARTLIST = 1 + PART = 2 + MACHGROUP = 3 + End Enum + Private m_LastSelGridType As GridSelTypes + Public ReadOnly Property LastSelGridType As GridSelTypes + Get + Return m_LastSelGridType + End Get + End Property + Friend Sub SetLastSelGridType(value As GridSelTypes) + m_LastSelGridType = value End Sub -#End Region ' FIELDS & PROPERTIES +#End Region ' Fields & Properties #Region "CONSTRUCTOR" @@ -226,10 +289,11 @@ Public Class ProjectVM 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) + Dim ProjectGridDim As String = If(Map.refMainWindowVM.MainWindowM.bOnlyProd, ConstDims.PROJECT_ONLYPROD, ConstDims.PROJECT_VIEW) + DimensionsIniFile.ReadGridDimensions(ProjectGridDim, GridDims) End Sub -#End Region ' CONSTRUCTOR +#End Region ' Constructor #Region "METHODS" @@ -244,9 +308,13 @@ Public Class ProjectVM Map.refMainMenuVM.SetMainMenuIsEnabled(bIsEnabled) Map.refPartManagerVM.SetPartManagerIsEnabled(bIsEnabled) Map.refLeftPanelVM.SetLeftPanelIsEnabled(bIsEnabled) - Map.refProjManagerVM.SetProjManagerIsEnabled(bIsEnabled) - Map.refProdManagerVM.SetProdManagerIsEnabled(bIsEnabled) - Map.refTopPanelVM.SetTopPanelIsEnabled(bIsEnabled) + Map.refBTLPartManagerVM.SetBTLPartManagerIsEnabled(bIsEnabled) + Map.refFeatureListManagerVM.SetLeftPanelIsEnabled(bIsEnabled) + If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.SetProjManagerIsEnabled(bIsEnabled) + If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.SetProdManagerIsEnabled(bIsEnabled) + If Not IsNothing(Map.refTopPanelVM) Then Map.refTopPanelVM.SetTopPanelIsEnabled(bIsEnabled) + Map.refRawPartManagerVM.SetRawPartManagerIsEnabled(bIsEnabled) + Map.refPartInRawPartManagerVM.SetPartInRawPartManagerIsEnabled(bIsEnabled) Map.refOptimizePanelVM.SetOptimizePanelIsEnabled(bIsEnabled) Map.refFeatureManagerVM.SetFeatureManagerIsEnabled(bIsEnabled) End Sub @@ -362,7 +430,34 @@ Public Class ProjectVM End Sub -#End Region ' METHODS + Friend Sub ManageQParamsRowVisibility(bVisible As Boolean) + If bVisible Then + DimensionsIniFile.ReadGridDimensions(ConstDims.TOPPANEL_OPTIMIZER, GridDims) + Else + GridDimension.SetSoftwareMod(True) + Dim FeatureRow = m_GridDims(4) + Dim QParRow = m_GridDims(5) + m_GridDims(4).GridLen = New GridLength(1, GridUnitType.Star) + m_GridDims(4).NotifyPropertyChanged(NameOf(FeatureRow.GridLen)) + m_GridDims(5).GridLen = New GridLength(0) + m_GridDims(5).NotifyPropertyChanged(NameOf(QParRow.GridLen)) + GridDimension.SetSoftwareMod(False) + End If + End Sub + + Friend Sub NotifyAllPanelVisibility() + NotifyPropertyChanged(NameOf(LeftPanel_Visibility)) + NotifyPropertyChanged(NameOf(TopPanel_Visibility)) + NotifyPropertyChanged(NameOf(BottomPanel_Visibility)) + NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + NotifyPropertyChanged(NameOf(FeatureManager_Visibility)) + NotifyPropertyChanged(NameOf(ShowBeamPanel_Visibility)) + NotifyPropertyChanged(NameOf(ProjManager_Visibility)) + NotifyPropertyChanged(NameOf(ProdManager_Visibility)) + NotifyCalcPanel_Visibility() + End Sub + +#End Region ' Methods End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb index 9fec89cf..0f69ab3b 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProdFileVM.vb @@ -2,6 +2,7 @@ Imports EgtBEAMWALL.Core Imports EgtUILib Imports EgtWPFLib5 +Imports Org.BouncyCastle.Crypto.Engines Public Class ProdFileVM Inherits Core.ProdFileVM @@ -12,15 +13,15 @@ Public Class ProdFileVM MyBase.New(ProdFileM) ' aggiungo nome btl Dim sBTLFileName As String = "" - For Each CurrProj In nProjIdList - Dim TempProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(CurrProj) + For Each TempCurrProj In nProjIdList + Dim TempProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(TempCurrProj) If Not IsNothing(TempProj) Then sBTLFileName &= TempProj.sListName Next SetBTLFileName(sBTLFileName) ' verifico valore description If Not IsNothing(ProdFileM) AndAlso String.IsNullOrWhiteSpace(ProdFileM.sName) Then - For Each CurrProj In nProjIdList - Dim TempProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(CurrProj) + For Each TempCurrProj In nProjIdList + Dim TempProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(TempCurrProj) If Not IsNothing(TempProj) AndAlso Not String.IsNullOrWhiteSpace(TempProj.sBTLFileName) Then DbControllers.m_ProdController.UpdateDescription(ProdFileM.nProdId, TempProj.sBTLFileName) ProdFileM.sName = TempProj.sBTLFileName @@ -142,7 +143,11 @@ Public Class ProdFileVM Select Case VerifyResult Case MessageBoxResult.Yes ' salvo proj - Map.refProdManagerVM.Save() + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.Save() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.Save() + End If Case MessageBoxResult.Cancel Return MessageBoxResult.Cancel Case Else ' No @@ -154,14 +159,26 @@ Public Class ProdFileVM Directory.Delete(sProjectDirPath, True) Catch ex As Exception End Try - Map.refProdManagerVM.m_MruFiles.Remove(CurrProject.sProdPath) - Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.m_MruFiles.Remove(CurrProject.sProdPath) + Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.m_MruFiles.Remove(CurrProject.sProdPath) + Map.refOnlyProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + End If DbControllers.m_ProdController.DeleteProd(CurrProject.nProdId, False) - If CurrProject.nProdId = Map.refProjManagerVM.CurrProj.nProdId Then + If Not IsNothing(Map.refProjManagerVM) AndAlso CurrProject.nProdId = ProjectManagerVM.CurrProj.nProdId Then ' reset prod in path proj Map.refProjManagerVM.UpdateCurrProj() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso CurrProject.nProdId = Map.refOnlyProdManagerVM.CurrProj.nProdId Then + ' reset prod in path proj + Map.refOnlyProdManagerVM.UpdateCurrProj() + End If + If Not IsNothing(Map.refProdManagerVM) Then + ProjectManagerVM.CurrProd = Nothing + 'ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + ' Map.refOnlyProdManagerVM.CurrProd = Nothing End If - Map.refProdManagerVM.CurrProd = Nothing EgtResetModified() Return MessageBoxResult.No End If diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProjFileVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProjFileVM.vb index 68cc9840..7bf08f13 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProjFileVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectFileVM/ProjFileVM.vb @@ -128,7 +128,11 @@ Public Class ProjFileVM Select Case MessageBox.Show(EgtMsg(61875), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) Case MessageBoxResult.Yes ' salvo proj - Map.refProjManagerVM.Save() + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.Save() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.Save() + End If Map.refCALCPanelVM.IsMachineApplied = False Case MessageBoxResult.Cancel Return False @@ -141,12 +145,21 @@ Public Class ProjFileVM If Directory.Exists(sProjectDirPath) Then Directory.Delete(sProjectDirPath, True) End If - Map.refProjManagerVM.m_MruFiles.Remove(CurrProject.sProjPath) - Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.m_MruFiles.Remove(CurrProject.sProjPath) + Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.m_MruFiles.Remove(CurrProject.sProjPath) + Map.refOnlyProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + End If - ' CheckMe impostata come cancellazione FISICA dal DB... - DbControllers.m_ProjController.DeleteProj(CurrProject.nProjId, False) - Map.refProjManagerVM.CurrProj = Nothing + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(CurrProject.nProjId, False) + If Not IsNothing(Map.refProjManagerVM) Then + ProjectManagerVM.CurrProj = Nothing + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.CurrProj = Nothing + End If EgtResetModified() Return True End If diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectManagerVM.vb new file mode 100644 index 00000000..7cb36366 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectManagerVM.vb @@ -0,0 +1,46 @@ +Imports EgtBEAMWALL.Core +Imports EgtWPFLib5 + +Module ProjectManagerVM + + 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 + + Public Function SetCurrProj(nProjId As Integer) As Boolean + Dim CurrProjM As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nProjId) + If IsNothing(CurrProjM) Then Return False + m_CurrProj = New ProjFileVM(CurrProjM) + If Map.refMainWindowVM.MainWindowM.bOnlyProd AndAlso CurrProjM.nProdId > 0 AndAlso IsNothing(CurrProd) Then + SetCurrProd(m_CurrProj.nProdId) + End If + Return True + End Function + + 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) + If Map.refMainWindowVM.MainWindowM.bOnlyProd AndAlso CurrProdM.nProjIdList.Count > 0 AndAlso IsNothing(CurrProj) Then + SetCurrProj(m_CurrProd.nProjIdList(0)) + End If + Return True + End Function + +End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectTypeWnd/ProjectTypeWndVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectTypeWnd/ProjectTypeWndVM.vb index 63c1e102..5ac3dcde 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjectTypeWnd/ProjectTypeWndVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectTypeWnd/ProjectTypeWndVM.vb @@ -35,8 +35,10 @@ Public Class ProjectTypeWndVM End Property ' Se la Macchina selezionata è di tipo BOTH verrà mostrata anche la selezione del Tipo - Private m_IsBoth_Visibility As Visibility = If(Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso - DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + 'Private m_IsBoth_Visibility As Visibility = If (Not IsNothing(ProjectManagerVM.CurrProj) AndAlso + ' DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + Private m_IsBoth_Visibility As Visibility = If(Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProj) AndAlso + DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH OrElse Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProd), Visibility.Visible, Visibility.Collapsed) Public Property IsBoth_Visibility As Visibility Get Return m_IsBoth_Visibility @@ -57,8 +59,8 @@ Public Class ProjectTypeWndVM End Property ' Se la Macchina selezionata è di tipo BOTH verrà selezionato di default il Tipo del progetto corrente - Private m_nSelType As BWType = If(Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso - DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, Map.refProjManagerVM.CurrProj.nType, Nothing) + Private m_nSelType As BWType = If(Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProj) AndAlso Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProj) AndAlso + DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, ProjectManagerVM.CurrProj.nType, Nothing) Public Property nSelType As BWType Get Return m_nSelType diff --git a/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerV.xaml b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerV.xaml new file mode 100644 index 00000000..6ec0858d --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerV.xaml @@ -0,0 +1,47 @@ + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerV.xaml.vb new file mode 100644 index 00000000..63a2a858 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class RawPartManagerV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerVM.vb new file mode 100644 index 00000000..af09f851 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerVM.vb @@ -0,0 +1,371 @@ +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class RawPartManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_RawPartManager_IsEnabled As Boolean = True + Public ReadOnly Property RawPartManagerIsEnabled As Boolean + Get + Return m_RawPartManager_IsEnabled + End Get + End Property + Friend Sub SetRawPartManagerIsEnabled(bIsEnabled As Boolean) + m_RawPartManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(RawPartManagerIsEnabled)) + End Sub + + Private m_ProduceRawPart_Visibility As Visibility + Public ReadOnly Property ProduceRawPart_Visibility As Visibility + Get + Return m_ProduceRawPart_Visibility + End Get + End Property + + Private m_MovePartInRawPart_Visibility As Visibility + Public ReadOnly Property MovePartInRawPart_Visibility As Visibility + Get + Return m_MovePartInRawPart_Visibility + End Get + End Property + + ' Definizione comandi + Private m_cmdProduceAllRawPart As ICommand + Private m_cmdProduceRawPart As ICommand + Private m_cmdCopyRawPart As ICommand + Private m_cmdRemoveRawPart As ICommand + Private m_cmdRemoveAllRawPart As ICommand + Private m_cmdMovePartInRawPart As ICommand + +#End Region ' Fields & Properties + +#Region "Messages" + + Public ReadOnly Property ProduceRawPart_ToolTip As String + Get + Return EgtMsg(61912) + 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 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 "CONSTRUCTORS" + + Sub New() + Map.SetRefRawPartManagerVM(Me) + ' mostro bottoni produci solo se supervisore attivo + m_ProduceRawPart_Visibility = If(Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.SUPERVISOR), Visibility.Visible, Visibility.Collapsed) + End Sub + +#End Region ' Constructors + +#Region "METHODS" + + Friend Sub UpdateMovePartInRawPartVisibility() + m_MovePartInRawPart_Visibility = If(Map.refMainWindowVM.MainWindowM.nUserLevel > 5 AndAlso Not IsNothing(ProjectManagerVM.CurrProd) AndAlso + ProjectManagerVM.CurrProd.nType = BWType.WALL, Visibility.Visible, Visibility.Collapsed) + NotifyPropertyChanged(NameOf(MovePartInRawPart_Visibility)) + End Sub + +#End Region ' Methods + +#Region "COMMANDS" + +#Region "ProduceRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ProduceRawPart_Command As ICommand + Get + If m_cmdProduceRawPart Is Nothing Then + m_cmdProduceRawPart = New Command(AddressOf ProduceRawPart) + End If + Return m_cmdProduceRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ProduceRawPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim ErrorMsg As String = "" + ' se attiva opzione e non ancora calcolato + If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.NOTCALCULATED Then + Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCE) + Map.refCALCPanelVM.Verify() + Return + End If + If Not Produce(Map.refMachGroupPanelVM.SelectedMachGroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then + MessageBox.Show(ErrorMsg) + End If + End Sub + + Private Function Produce(MachGroup As MyMachGroupVM, ByRef ErrorMsg As String) As Boolean + If IsNothing(MachGroup) Then Return False + ' se barra gia' assegnata a supervisore, esco + If MachGroup.nProduction_State >= ItemState.Assigned Then Return False + If MachGroup.nGlobalState = CalcStates.OK Or MachGroup.nGlobalState = CalcStates.INFO Then + ' se ci sono modifiche, salvo il pogetto + If EgtGetModified() AndAlso Map.refMainMenuVM.SelPage = Pages.MACHINING Then + Map.refProdManagerVM.Save() + ElseIf EgtGetModified() AndAlso Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Map.refOnlyProdManagerVM.Save() + End If + ' mando al supervisore + DbControllers.m_MachGroupController.UpdateOrder(ProjectManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_MachGroupController.GetMinIndex(ProjectManagerVM.CurrProd.nProdId) + 1) + DbControllers.m_MachGroupController.UpdateSupervisor(ProjectManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_SupervisorId) + MachGroup.SentToSupervisor() + For Each Part As PartVM In MachGroup.PartVMList + DbControllers.m_PartController.UpdateStatus(ProjectManagerVM.CurrProd.nProdId, MachGroup.Id, Part.nPartId, ItemState.Assigned) + Part.nProduction_State = ItemState.Assigned + Part.NotifyPropertyChanged(NameOf(Part.Background)) + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + ' blocco modifica del pezzo + EgtDuploSetLocked(Part.nPartId) + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + Next + Return True + Else + ErrorMsg = String.Format("Impossible sending {0} to supervisor because not machinable!", MachGroup.Name) + 'MessageBox.Show(String.Format("Impossible sending {0} to supervisor because it is not machinable!", MachGroup.Name)) + Return False + End If + End Function + +#End Region ' ProduceRawPart + +#Region "ProduceAllRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ProduceAllRawPart_Command As ICommand + Get + If m_cmdProduceAllRawPart Is Nothing Then + m_cmdProduceAllRawPart = New Command(AddressOf ProduceAllRawPart) + End If + Return m_cmdProduceAllRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ProduceAllRawPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + ' se attiva opzione e non ancora calcolato + If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) x.nProduction_State = ItemState.ND AndAlso x.nGlobalState = CalcStates.NOTCALCULATED) Then + Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCEALL) + Map.refCALCPanelVM.VerifyAll() + Return + End If + If Map.refMachGroupPanelVM.MachGroupVMList.Count > 0 Then + Dim MachgroupErrorList As New List(Of MachGroupVM) + For Each Machgroup In Map.refMachGroupPanelVM.MachGroupVMList + Dim ErrorMsg As String = "" + If Not Produce(Machgroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then + MachgroupErrorList.Add(Machgroup) + End If + Next + If MachgroupErrorList.Count > 0 Then + Dim sMachGroups As String = "" + For Each MachGroup In MachgroupErrorList + sMachGroups &= " " & MachGroup.Name & "," + Next + sMachGroups = sMachGroups.Trim({" "c, ","c}) + MessageBox.Show(String.Format("Impossible sending {0} to supervisor because not machinable!", sMachGroups)) + End If + End If + End Sub + +#End Region ' ProduceAllRawPart + +#Region "CopyRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property CopyRawPart_Command As ICommand + Get + If m_cmdCopyRawPart Is Nothing Then + m_cmdCopyRawPart = New Command(AddressOf CopyRawPart) + End If + Return m_cmdCopyRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub CopyRawPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim nQty As Integer = 1 + ' se premuto shift + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + Dim MultiCopyRawPartWndVM As New MultiCopyRawPartWndVM() + Dim MultiCopyRawPartWnd As New MultiCopyRawPartWndV(Application.Current.MainWindow, MultiCopyRawPartWndVM) + If Not MultiCopyRawPartWnd.ShowDialog() Then Return + nQty = MultiCopyRawPartWndVM.nQuantity + End If + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' creo copia + Dim NewMachGroup As MyMachGroupVM = SelMachGroup.Copy(nQty) + If Not IsNothing(NewMachGroup) Then + ' lo seleziono + Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = NewMachGroup + End If + End Sub + +#End Region ' CopyRawPart + +#Region "RemoveRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemoveRawPart_Command As ICommand + Get + If m_cmdRemoveRawPart Is Nothing Then + m_cmdRemoveRawPart = New Command(AddressOf RemoveRawPartCmd) + End If + Return m_cmdRemoveRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemoveRawPartCmd() + RemoveRawPart() + End Sub + + Public Sub RemoveRawPart(Optional bAll As Boolean = False) + If IsNothing(ProjectManagerVM.CurrProd) Then Return + ' se tutti + If bAll Then + ' cancello tutti + For Index = Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 To 0 Step -1 + Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(Index) + ' se barra gia' assegnata a supervisore, esco + If CurrMachGroup.nProduction_State >= ItemState.Assigned Then Continue For + CurrMachGroup.DeleteMachGroup(True) + Next + Else + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + SelMachGroup.DeleteMachGroup() + End If + EgtDraw() + ' se nessun grezzo, rimetto tutti i pezzi invisibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.HideAll(True) + End If + End Sub + +#End Region ' RemoveRawPart + +#Region "RemoveAllRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemoveAllRawPart_Command As ICommand + Get + If m_cmdRemoveAllRawPart Is Nothing Then + m_cmdRemoveAllRawPart = New Command(AddressOf RemoveAllRawPart) + End If + Return m_cmdRemoveAllRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemoveAllRawPart() + RemoveRawPart(True) + End Sub + +#End Region ' RemoveAllRawPart + +#Region "MovePartInRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MovePartInRawPart_Command As ICommand + Get + If m_cmdMovePartInRawPart Is Nothing Then + m_cmdMovePartInRawPart = New Command(AddressOf MovePartInRawPart) + End If + Return m_cmdMovePartInRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MovePartInRawPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim MovePartInRawPartWndVM As New MovePartInRawPartWndVM() + Dim MovePartInRawPartWnd As New MovePartInRawPartWndV(Application.Current.MainWindow, MovePartInRawPartWndVM) + If Not MovePartInRawPartWnd.ShowDialog() Then Return + End Sub + +#End Region ' MovePartInRawPart + + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerWndV.xaml b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerWndV.xaml new file mode 100644 index 00000000..1d0e9418 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerWndV.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerWndV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerWndV.xaml.vb new file mode 100644 index 00000000..f35aa6e4 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/RawPartManager/RawPartManagerWndV.xaml.vb @@ -0,0 +1,3 @@ +Public Class RawPartManagerWndV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb index 23a554a6..f5348545 100644 --- a/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb @@ -1,4 +1,5 @@ -Imports System.Windows.Interop + +Imports System.Windows.Interop Imports System.IO Imports EgtUILib Imports EgtWPFLib5 @@ -270,21 +271,21 @@ Public Class MySceneHostVM Private Sub OnMouseSetObjFilterForSelect(sender As Object, bZeroDim As Boolean, bCurve As Boolean, bSurf As Boolean, bVolume As Boolean, bExtra As Boolean) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.MouseSetObjFilterForSelect(bZeroDim, bCurve, bSurf, bVolume, bExtra) End If End Sub Private Sub OnMouseSelectedAll(ByVal sender As Object, bOnlyVisble As Boolean) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.MouseSelectedAll(bOnlyVisble) End If End Sub Private Sub OnMouseDeselectedAll(ByVal sender As Object) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.MouseDeselectedAll() End If End Sub @@ -292,89 +293,86 @@ Public Class MySceneHostVM Private Sub OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs) If e.Button = Forms.MouseButtons.Middle Then Return If Map.refInstrumentPanelVM.GetDistIsChecked Then Return - Select Case Map.refMainMenuVM.SelPage - Case Pages.VIEW - If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then - If Map.refFreeContourManagerVM.bIsActive AndAlso - ( Map.refFreeContourManagerVM.SelType = FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES Or - Map.refFreeContourManagerVM.bIsOpeningCurveCompo) Then - ' passo entità selezionata - Map.refFreeContourManagerVM.OnMouseSelectedObj(EgtGetFirstSelectedObj(), True) - ElseIf Map.refShowBeamPanelVM.bShowAll Then - View_Part_OnMouseDownScene(sender, e) - Else - View_Feature_OnMouseDownScene(sender, e) - End If + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Pages.ONLYPRODPAGE And (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART OrElse Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST)) Then + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + If Map.refFreeContourManagerVM.bIsActive AndAlso + (Map.refFreeContourManagerVM.SelType = FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES Or + Map.refFreeContourManagerVM.bIsOpeningCurveCompo) Then + ' passo entità selezionata + Map.refFreeContourManagerVM.OnMouseSelectedObj(EgtGetFirstSelectedObj(), True) + ElseIf Map.refShowBeamPanelVM.bShowAll Then + View_Part_OnMouseDownScene(sender, e) + Else + View_Feature_OnMouseDownScene(sender, e) End If - Case Pages.MACHINING - If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then - Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return - If SelectedMachGroup.nType = BWType.BEAM Then - Beam_OnMouseDownScene(sender, e) - ElseIf SelectedMachGroup.nType = BWType.WALL Then - Wall_OnMouseDownScene(sender, e) - End If + End If + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse (Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) Then + If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return + If SelectedMachGroup.nType = BWType.BEAM Then + Beam_OnMouseDownScene(sender, e) + ElseIf SelectedMachGroup.nType = BWType.WALL Then + Wall_OnMouseDownScene(sender, e) End If - End Select + End If + End If End Sub Private Sub OnMouseMoveScene(sender As Object, e As Forms.MouseEventArgs) If e.Button = Forms.MouseButtons.Middle Then Return If Map.refInstrumentPanelVM.GetDistIsChecked Then Return - Select Case Map.refMainMenuVM.SelPage - Case Pages.VIEW - If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then - If Map.refFreeContourManagerVM.bIsActive Then Return - If Map.refShowBeamPanelVM.bShowAll Then - View_Part_OnMouseMoveScene(sender, e) - Else - View_Feature_OnMouseMoveScene(sender, e) - End If + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Pages.ONLYPRODPAGE And (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART OrElse Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST)) Then + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + If Map.refFreeContourManagerVM.bIsActive Then Return + If Map.refShowBeamPanelVM.bShowAll Then + View_Part_OnMouseMoveScene(sender, e) + Else + View_Feature_OnMouseMoveScene(sender, e) End If - Case Pages.MACHINING - If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then - Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return - If SelectedMachGroup.nType = BWType.BEAM Then - Beam_OnMouseMoveScene(sender, e) - ElseIf SelectedMachGroup.nType = BWType.WALL Then - Wall_OnMouseMoveScene(sender, e) - End If + End If + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse (Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) Then + If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return + If SelectedMachGroup.nType = BWType.BEAM Then + Beam_OnMouseMoveScene(sender, e) + ElseIf SelectedMachGroup.nType = BWType.WALL Then + Wall_OnMouseMoveScene(sender, e) End If - End Select + End If + End If End Sub Private Sub OnMouseUpScene(sender As Object, e As Forms.MouseEventArgs) If e.Button = Forms.MouseButtons.Middle Then Return If Map.refInstrumentPanelVM.GetDistIsChecked Then Return - Select Case Map.refMainMenuVM.SelPage - Case Pages.VIEW - If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then - If Map.refFreeContourManagerVM.bIsActive AndAlso Map.refFreeContourManagerVM.SelType = FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES Then - Return - ElseIf Map.refShowBeamPanelVM.bShowAll Then - View_Part_OnMouseUpScene(sender, e) - Else - View_Feature_OnMouseUpScene(sender, e) - End If + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Pages.ONLYPRODPAGE And (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART OrElse Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST)) Then + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + If Map.refFreeContourManagerVM.bIsActive AndAlso Map.refFreeContourManagerVM.SelType = FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES Then + Return + ElseIf Map.refShowBeamPanelVM.bShowAll Then + View_Part_OnMouseUpScene(sender, e) + Else + View_Feature_OnMouseUpScene(sender, e) End If - Case Pages.MACHINING - If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then - Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return - If SelectedMachGroup.nType = BWType.BEAM Then - Beam_OnMouseUpScene(sender, e) - ElseIf SelectedMachGroup.nType = BWType.WALL Then - Wall_OnMouseUpScene(sender, e) - End If + End If + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse (Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) Then + If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return + If SelectedMachGroup.nType = BWType.BEAM Then + Beam_OnMouseUpScene(sender, e) + ElseIf SelectedMachGroup.nType = BWType.WALL Then + Wall_OnMouseUpScene(sender, e) End If - End Select + End If + End If End Sub Private Sub OnMouseSelectingObj(ByVal sender As Object, ByVal nId As Integer, ByRef bOk As Boolean) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then bOk = Map.refFreeContourManagerVM.OnMouseSelectingObj(nId) End If End Sub @@ -385,42 +383,42 @@ Public Class MySceneHostVM Private Sub OnMouseSelectedPart(ByVal sender As Object, ByVal nId As Integer) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.MouseSelectedPart(nId) End If End Sub Private Sub OnMouseSelectedLayer(ByVal sender As Object, ByVal nId As Integer) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.MouseSelectedLayer(nId) End If End Sub Private Sub OnMouseSelectedPath(ByVal sender As Object, ByVal nId As Integer, ByVal bHaltOnFork As Boolean) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.MouseSelectedPath(nId, bHaltOnFork) End If End Sub Private Sub OnMousePointFromSelection(ByVal sender As Object, ByVal nId As Integer, ByVal PtP As Point3d, ByVal nAux As Integer) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.SetPointFromSelection(nId, PtP, nAux) End If End Sub Private Sub OnMouseDone(ByVal sender As Object) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.Done(Map.refFreeContourInputVM.Text) End If End Sub Private Sub OnMouseSelectedPoint(ByVal sender As Object, ByVal PtP As Point3d, ByVal nSep As SEP, ByVal nId As Integer) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then Dim bDone As Boolean = (Keyboard.Modifiers And ModifierKeys.Control) <> ModifierKeys.Control MainController.MouseSelectedPoint(PtP, nSep, nId, bDone) End If @@ -428,14 +426,14 @@ Public Class MySceneHostVM Private Sub OnMouseSelectedDir(ByVal sender As Object, ByVal VtDir As Vector3d) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.SetLastVector3d(VtDir) End If End Sub Private Sub OnMouseMoveSelPoint(ByVal sender As Object, ByVal PtP As Point3d) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then MainController.MouseMoveInSelectionPoint(PtP) End If End Sub @@ -446,7 +444,7 @@ Public Class MySceneHostVM Private Sub OnKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) ' Se in modalità edit L250 - If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' Con DEL eseguo cancellazione delle entità selezionate If e.KeyData = System.Windows.Forms.Keys.Delete Then MainController.SetLastInteger(GDB_ID.SEL) @@ -522,6 +520,7 @@ Public Class MySceneHostVM Private Sub OnOpenProject(sender As Object, sFile As String, bOk As Boolean) Dim ProjectType As ProjectType = If(Map.refMainMenuVM.SelPage = Pages.VIEW, ProjectType.PROJ, ProjectType.PROD) Dim ProjId As Integer = If(ProjectType = ProjectType.PROJ, Map.refProjManagerVM.nLoadingProjId, 0) + Dim CurrProd As ProdFileVM = Nothing ' Procedo a seconda del risultato If bOk Then LoadingWndHelper.UpdateLoadingWnd(ActiveIds.OPENPROJ, 2, EgtMsg(63005), 50, 70) ' Loading part list @@ -556,28 +555,50 @@ Public Class MySceneHostVM Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> BWType.BEAM) Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) - Map.refProjManagerVM.CurrProj = Map.refProjManagerVM.TempCurrProj - DbControllers.m_ProjController.LockByProjId(Map.refProjManagerVM.CurrProj.nProjId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + ProjectManagerVM.CurrProj = Map.refProjManagerVM.TempCurrProj + DbControllers.m_ProjController.LockByProjId(ProjectManagerVM.CurrProj.nProjId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel Map.refCALCPanelVM.LoadMachineList() ElseIf ProjectType = ProjectType.PROD Then ' se salvato, carico progetto in lista mru - If Not Map.refProdManagerVM.TempCurrProd.bIsNew Then + If Not IsNothing(Map.refProdManagerVM) AndAlso Not IsNothing(Map.refProdManagerVM.TempCurrProd) AndAlso Not Map.refProdManagerVM.TempCurrProd.bIsNew Then Map.refProdManagerVM.m_MruFiles.Add(sFile) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) AndAlso Not Map.refOnlyProdManagerVM.TempCurrProd.bIsNew Then + Map.refOnlyProdManagerVM.m_MruFiles.Add(sFile) End If ' imposto macchina del progetto - Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refProdManagerVM.TempCurrProd), - Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine), - Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProjManagerVM.CurrProj.sMachine)) + 'Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refProdManagerVM.TempCurrProd), + 'Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine), + 'Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = ProjectManagerVM.CurrProj.sMachine)) + If Map.refMainMenuVM.SelPage = Pages.MACHINING Then + Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refProdManagerVM.TempCurrProd), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = ProjectManagerVM.CurrProj.sMachine)) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refOnlyProdManagerVM.TempCurrProd.sMachine), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = ProjectManagerVM.CurrProd.sMachine)) + End If SectionXMaterial.SetType(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) Core.ViewPanelVM.UpdateBWType(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) ' aggiorno le colonne in base al tipo progetto Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) - Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> 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()) + If Not IsNothing(Map.refProdManagerVM) AndAlso Not IsNothing(Map.refProdManagerVM.TempCurrProd) Then + CurrProd = Map.refProdManagerVM.TempCurrProd + ProjectManagerVM.CurrProd = CurrProd + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) Then + CurrProd = Map.refOnlyProdManagerVM.TempCurrProd + ProjectManagerVM.CurrProd = CurrProd + End If + 'DbControllers.m_ProdController.LockByProdId(ProjectManagerVM.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 @@ -585,12 +606,13 @@ Public Class MySceneHostVM 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(ProjectManagerVM.CurrProd) AndAlso ActiveSession.ItemId = ProjectManagerVM.CurrProd.nProdId Then + If Not IsNothing(CurrProd) AndAlso ActiveSession.ItemId = CurrProd.nProdId Then CommIndex = ActiveSession.Index End If Next @@ -599,9 +621,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 + ' ProjectManagerVM.CurrProd.SetModificationIndex(CommIndex) + 'End If If CommIndex > -1 Then - Map.refProdManagerVM.CurrProd.SetModificationIndex(CommIndex) + If Not IsNothing(Map.refProdManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProd) Then + ProjectManagerVM.CurrProd.SetModificationIndex(CommIndex) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso 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() @@ -622,7 +652,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 @@ -663,7 +693,13 @@ Public Class MySceneHostVM If Not IsNothing(PjFileVM.ProjFileM) AndAlso Not IsNothing(PjFileVM.sProjPath) Then Map.refProjManagerVM.m_MruFiles.Add(PjFileVM.sProjPath) End If End If - If ProjectType = ProjectType.PROD Then Map.refProdManagerVM.m_MruFiles.Add(sFile) + If ProjectType = ProjectType.PROD Then + If Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.m_MruFiles.Add(sFile) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.m_MruFiles.Add(sFile) + End If + End If ' Salvo nome ultimo file WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile) End Sub @@ -671,7 +707,7 @@ Public Class MySceneHostVM Private Sub OnImportingProject(sender As Object, nType As Integer, ByRef nFlag As Integer) If nType = FT.BTL Or nType = FT.BTLX Then Dim sBTLFlag As String - If Map.refProjManagerVM.nProjType = Core.ConstBeam.BWType.BEAM Then + If Not IsNothing(Map.refProjManagerVM) AndAlso Map.refProjManagerVM.nProjType = Core.ConstBeam.BWType.BEAM OrElse Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Map.refOnlyProdManagerVM.nProjType = Core.ConstBeam.BWType.BEAM Then sBTLFlag = K_BTLFLAG Else sBTLFlag = K_WALLBTLFLAG @@ -691,7 +727,11 @@ Public Class MySceneHostVM Dim nPartId As Integer = EgtGetFirstPart() While nPartId <> GDB_ID.NULL ' scrivo in ogni pezzo ProjId - EgtSetInfo(nPartId, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) + If Not IsNothing(Map.refProjManagerVM) Then + EgtSetInfo(nPartId, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + EgtSetInfo(nPartId, BTL_PRT_PROJ, Map.refOnlyProdManagerVM.nLoadingProjId) + End If nPartId = EgtGetNextPart(nPartId) ' scrivo Id negli outline Dim nPRId As Integer = 1 @@ -710,17 +750,29 @@ Public Class MySceneHostVM End While ' scrivo info proj e type su layer BtlInfo Dim nBTLInfoLayer As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) - EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) - EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, Map.refProjManagerVM.CurrProj.nType) + If Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProj) Then + EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) + EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, ProjectManagerVM.CurrProj.nType) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProj) Then + EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, Map.refOnlyProdManagerVM.nLoadingProjId) + EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, Map.refOnlyProdManagerVM.CurrProd.nType) + End If ' scrivo info proj su layer AsseBase Dim nAsseBaseLayer As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) - EgtSetInfo(nAsseBaseLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) + If Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProj) Then + EgtSetInfo(nAsseBaseLayer, BTL_PRT_PROJ, Map.refProjManagerVM.nLoadingProjId) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProj) Then + EgtSetInfo(nAsseBaseLayer, BTL_PRT_PROJ, Map.refOnlyProdManagerVM.nLoadingProjId) + End If Else Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error - Map.refProjManagerVM.NewProject() + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.NewProject() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.NewProject() + End If End If - MainScene.SetStatusNull() End Sub @@ -1104,6 +1156,8 @@ Public Class MySceneHostVM ElseIf m_nIdToSel <> GDB_ID.NULL Then Dim CurrPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = m_nIdToSel) If e.Button = Forms.MouseButtons.Left Then + ' imposto tipo ultima Grid selezionata + Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PARTLIST) ' imposto highlight Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT) ' gestisco evidenziazione pezzo @@ -1134,6 +1188,8 @@ Public Class MySceneHostVM End If End If ElseIf e.Button = Forms.MouseButtons.Right Then + ' imposto tipo ultima Grid selezionata + Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PART) ' imposto selezione Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.SELECT_) ' seleziono il pezzo diff --git a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml index 5bdc0d27..d6a50f5f 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml @@ -8,6 +8,7 @@ diff --git a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb index c1b7a909..e41a2fbd 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb @@ -19,11 +19,13 @@ Public Class ShowBeamPanelVM m_ShowBuilding_IsEnabled = Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.BTLStructureM.nAsseBaseId <> GDB_ID.NULL Else m_ShowSolid_IsEnabled = True + 'm_ShowSolid_IsEnabled = Map.refMainMenuVM.SelPage <> Pages.ONLYPRODPAGE m_ShowBuilding_IsEnabled = False End If UpdatePartBtnIsEnabled() NotifyPropertyChanged(NameOf(ShowSolid_IsEnabled)) NotifyPropertyChanged(NameOf(ShowBuilding_IsEnabled)) + NotifyPropertyChanged(NameOf(ShowAll_Visibility)) End Set End Property @@ -97,6 +99,12 @@ Public Class ShowBeamPanelVM End Set End Property + Public ReadOnly Property ShowAll_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + #Region "ToolTip" Public ReadOnly Property ShowAll_ToolTip As String @@ -137,7 +145,10 @@ Public Class ShowBeamPanelVM Private Sub UpdatePartBtnIsEnabled() Map.refCALCPanelVM.PartShowAllChanged() - Map.refLeftPanelVM.PartShowAllChanged() + Configuration.UpdateGraphics() + 'Map.refLeftPanelVM.PartShowAllChanged() + 'If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.PartShowAllChanged() + 'If Not IsNothing(Map.refBTLPartManagerVM) Then Map.refBTLPartManagerVM.PartShowAllChanged() End Sub #End Region ' METHODS @@ -168,15 +179,16 @@ Public Class ShowBeamPanelVM End If ' nascondo barra del pezzo Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.NULL) - Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + 'Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) ' mostro in parte bassa dati BTL - Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STRUCTURE_) + If Not IsNothing(Map.refBottomPanelVM) Then Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STRUCTURE_) ' mostro tutti i pezzi Map.refProjectVM.BTLStructureVM.ShowAll(False) ' deseleziono tutto Map.refProjectVM.BTLStructureVM.SelBTLParts.Clear() ' se attivata opzione, li assemblo - Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW, ShowBuilding_IsChecked, False), False) + Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, ShowBuilding_IsChecked, False), False) If bDraw Then EgtDraw() End Sub diff --git a/EgtBEAMWALL.ViewerOptimizer/Statistics/OptimizerStatisticsV.xaml b/EgtBEAMWALL.ViewerOptimizer/Statistics/OptimizerStatisticsV.xaml index 38a3b8a0..8a314146 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Statistics/OptimizerStatisticsV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/Statistics/OptimizerStatisticsV.xaml @@ -18,17 +18,17 @@ + ItemsSource="{Binding Tag.MachGroupPanelVM.MachGroupVMList, + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}" + CanUserAddRows="False" + AutoGenerateColumns="False" + CanUserResizeRows="False" + SelectionMode="Extended" + ScrollViewer.CanContentScroll="True" + ScrollViewer.VerticalScrollBarVisibility="Auto" + ScrollViewer.HorizontalScrollBarVisibility="Auto" + Margin="0,0,0,5" + BindingColumns="{Binding OptimizerStatisticsColumns}"> @@ -106,16 +106,16 @@ + ItemsSource="{Binding RawPartList}" + CanUserAddRows="False" + AutoGenerateColumns="False" + CanUserResizeRows="False" + SelectionMode="Extended" + ScrollViewer.CanContentScroll="True" + ScrollViewer.VerticalScrollBarVisibility="Auto" + ScrollViewer.HorizontalScrollBarVisibility="Auto" + Margin="0,0,0,5" + BindingColumns="{Binding RawPartStatisticsColumns}"> @@ -178,49 +178,49 @@ + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OptimizerStatisticsV}}}"/> riempio colonne della riga degli header ' >=0 -> riempio le colonne con i valori dei pezzi Dim Itemlist As IEnumerable(Of Object) = Nothing +<<<<<<< HEAD ' Controllo se bPreview è true mostra il PDF di preview se no il PDF completo If bPreview Then Itemlist = New List(Of Object) @@ -188,6 +202,17 @@ Module PDFHelper Itemlist = Map.refStatisticsVM.RawPartList End Select End If +======= + Select Case nListType + Case ListTypes.PART + Itemlist = Map.refProjectVM.BTLStructureVM.BTLPartVMList + Case ListTypes.MACHGROUP + Itemlist = Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + Case ListTypes.RAWPART + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refStatisticsVM.LoadRawPart() + Itemlist = Map.refStatisticsVM.RawPartList + End Select +>>>>>>> feature/NewPage 'If m_ActivePage = Pages.VIEW Then ' Itemlist = Map.refProjectVM.BTLStructureVM.BTLPartVMList.ToList() 'ElseIf m_ActivePage = Pages.MACHINING Then diff --git a/EgtBEAMWALL.ViewerOptimizer/Statistics/StatisticsV.xaml b/EgtBEAMWALL.ViewerOptimizer/Statistics/StatisticsV.xaml index c2344e3c..78c792ea 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Statistics/StatisticsV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/Statistics/StatisticsV.xaml @@ -9,17 +9,17 @@ + ItemsSource="{Binding Tag.BTLPartVMList, + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:StatisticsV}}}" + CanUserAddRows="False" + AutoGenerateColumns="False" + CanUserResizeRows="False" + SelectionMode="Extended" + ScrollViewer.CanContentScroll="True" + ScrollViewer.VerticalScrollBarVisibility="Auto" + ScrollViewer.HorizontalScrollBarVisibility="Auto" + Margin="0,0,0,5" + BindingColumns="{Binding StatisticsColumns}"> @@ -148,22 +148,22 @@ + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:StatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:StatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:StatisticsV}}}"/> + RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:StatisticsV}}}"/> - - - - - - + + - - - - - - + + + 5 AndAlso Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso - Map.refProdManagerVM.CurrProd.nType = BWType.WALL, Visibility.Visible, Visibility.Collapsed) - NotifyPropertyChanged(NameOf(MovePartInRawPart_Visibility)) - End Sub - #End Region ' METHODS -#Region "COMMANDS" - -#Region "ProduceRawPart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property ProduceRawPart_Command As ICommand - Get - If m_cmdProduceRawPart Is Nothing Then - m_cmdProduceRawPart = New Command(AddressOf ProduceRawPart) - End If - Return m_cmdProduceRawPart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub ProduceRawPart() - If IsNothing(Map.refProdManagerVM.CurrProd) Then Return - Dim ErrorMsg As String = "" - ' se attiva opzione e non ancora calcolato - If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.NOTCALCULATED Then - Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCE) - Map.refCALCPanelVM.Verify() - Return - End If - If Not Produce(Map.refMachGroupPanelVM.SelectedMachGroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then - MessageBox.Show(ErrorMsg) - End If - End Sub - - Private Function Produce(MachGroup As MyMachGroupVM, ByRef ErrorMsg As String) As Boolean - If IsNothing(MachGroup) Then Return False - ' se barra gia' assegnata a supervisore, esco - If MachGroup.nProduction_State >= ItemState.Assigned Then Return False - If MachGroup.nGlobalState = CalcStates.OK Or MachGroup.nGlobalState = CalcStates.INFO Then - ' se ci sono modifiche, salvo il pogetto - If EgtGetModified() Then - Map.refProdManagerVM.Save() - End If - ' mando al supervisore - DbControllers.m_MachGroupController.UpdateOrder(Map.refProdManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_MachGroupController.GetMinIndex(Map.refProdManagerVM.CurrProd.nProdId) + 1) - DbControllers.m_MachGroupController.UpdateSupervisor(Map.refProdManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_SupervisorId) - MachGroup.SentToSupervisor() - For Each Part As PartVM In MachGroup.PartVMList - DbControllers.m_PartController.UpdateStatus(Map.refProdManagerVM.CurrProd.nProdId, MachGroup.Id, Part.nPartId, ItemState.Assigned) - Part.nProduction_State = ItemState.Assigned - Part.NotifyPropertyChanged(NameOf(Part.Background)) - ' disabilito impostazione modificato - Dim DisableMgr As New DisableModifiedMgr - ' blocco modifica del pezzo - EgtDuploSetLocked(Part.nPartId) - ' ripristino precedente impostazione modificato - DisableMgr.ReEnable() - Next - Return True - Else - ErrorMsg = String.Format("Impossible sending {0} to supervisor because not machinable!", MachGroup.Name) - 'MessageBox.Show(String.Format("Impossible sending {0} to supervisor because it is not machinable!", MachGroup.Name)) - Return False - End If - End Function - -#End Region ' ProduceRawPart - -#Region "ProduceAllRawPart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property ProduceAllRawPart_Command As ICommand - Get - If m_cmdProduceAllRawPart Is Nothing Then - m_cmdProduceAllRawPart = New Command(AddressOf ProduceAllRawPart) - End If - Return m_cmdProduceAllRawPart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub ProduceAllRawPart() - If IsNothing(Map.refProdManagerVM.CurrProd) Then Return - ' se attiva opzione e non ancora calcolato - If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) x.nProduction_State = ItemState.ND AndAlso x.nGlobalState = CalcStates.NOTCALCULATED) Then - Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCEALL) - Map.refCALCPanelVM.VerifyAll() - Return - End If - If Map.refMachGroupPanelVM.MachGroupVMList.Count > 0 Then - Dim MachgroupErrorList As New List(Of MachGroupVM) - For Each Machgroup In Map.refMachGroupPanelVM.MachGroupVMList - Dim ErrorMsg As String = "" - If Not Produce(Machgroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then - MachgroupErrorList.Add(Machgroup) - End If - Next - If MachgroupErrorList.Count > 0 Then - Dim sMachGroups As String = "" - For Each MachGroup In MachgroupErrorList - sMachGroups &= " " & MachGroup.Name & "," - Next - sMachGroups = sMachGroups.Trim({" "c, ","c}) - MessageBox.Show(String.Format("Impossible sending {0} to supervisor because not machinable!", sMachGroups)) - End If - End If - End Sub - -#End Region ' ProduceAllRawPart - -#Region "CopyRawPart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property CopyRawPart_Command As ICommand - Get - If m_cmdCopyRawPart Is Nothing Then - m_cmdCopyRawPart = New Command(AddressOf CopyRawPart) - End If - Return m_cmdCopyRawPart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub CopyRawPart() - If IsNothing(Map.refProdManagerVM.CurrProd) Then Return - Dim nQty As Integer = 1 - ' se premuto shift - If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then - Dim MultiCopyRawPartWndVM As New MultiCopyRawPartWndVM() - Dim MultiCopyRawPartWnd As New MultiCopyRawPartWndV(Application.Current.MainWindow, MultiCopyRawPartWndVM) - If Not MultiCopyRawPartWnd.ShowDialog() Then Return - nQty = MultiCopyRawPartWndVM.nQuantity - End If - Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If IsNothing(SelMachGroup) Then Return - ' creo copia - Dim NewMachGroup As MyMachGroupVM = SelMachGroup.Copy(nQty) - If Not IsNothing(NewMachGroup) Then - ' lo seleziono - Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = NewMachGroup - End If - End Sub - -#End Region ' CopyRawPart - -#Region "RemoveRawPart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property RemoveRawPart_Command As ICommand - Get - If m_cmdRemoveRawPart Is Nothing Then - m_cmdRemoveRawPart = New Command(AddressOf RemoveRawPartCmd) - End If - Return m_cmdRemoveRawPart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub RemoveRawPartCmd() - RemoveRawPart() - End Sub - - Public Sub RemoveRawPart(Optional bAll As Boolean = False) - If IsNothing(Map.refProdManagerVM.CurrProd) Then Return - ' se tutti - If bAll Then - ' cancello tutti - For Index = Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 To 0 Step -1 - Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(Index) - ' se barra gia' assegnata a supervisore, esco - If CurrMachGroup.nProduction_State >= ItemState.Assigned Then Continue For - CurrMachGroup.DeleteMachGroup(True) - Next - Else - Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If IsNothing(SelMachGroup) Then Return - ' se barra gia' assegnata a supervisore, esco - If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return - SelMachGroup.DeleteMachGroup() - End If - EgtDraw() - ' se nessun grezzo, rimetto tutti i pezzi invisibili - If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then - Map.refProjectVM.BTLStructureVM.HideAll(True) - End If - End Sub - -#End Region ' RemoveRawPart - -#Region "RemoveAllRawPart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property RemoveAllRawPart_Command As ICommand - Get - If m_cmdRemoveAllRawPart Is Nothing Then - m_cmdRemoveAllRawPart = New Command(AddressOf RemoveAllRawPart) - End If - Return m_cmdRemoveAllRawPart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub RemoveAllRawPart() - RemoveRawPart(True) - End Sub - -#End Region ' RemoveRawPart - -#Region "RemovePart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property RemovePart_Command As ICommand - Get - If m_cmdRemovePart Is Nothing Then - m_cmdRemovePart = New Command(AddressOf RemovePart) - End If - Return m_cmdRemovePart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub RemovePart() - If IsNothing(Map.refProdManagerVM.CurrProd) Then Return - Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If IsNothing(SelMachGroup) Then Return - ' se barra gia' assegnata a supervisore, esco - If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return - Dim SelPart As PartVM = SelMachGroup.SelPart - If IsNothing(SelPart) Then Return - SelPart.DeletePart() - SelMachGroup.UpdateUsage() - SelMachGroup.ResetCalcMachGroup() - End Sub - -#End Region ' RemovePart - -#Region "MoveUpPart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property MoveUpPart_Command As ICommand - Get - If m_cmdMoveUpPart Is Nothing Then - m_cmdMoveUpPart = New Command(AddressOf MoveUpPart) - End If - Return m_cmdMoveUpPart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub MoveUpPart() - If IsNothing(Map.refProdManagerVM.CurrProd) Then Return - Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If IsNothing(SelMachGroup) Then Return - ' se barra gia' assegnata a supervisore, esco - If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return - Dim SelPart As PartVM = SelMachGroup.SelPart - If IsNothing(SelPart) Then Return - If SelMachGroup.nType = MachineType.BEAM Then - SelMachGroup.MoveBeam(SelPart, MoveDirections.UP) - EgtDraw() - ' riseleziono trave - SelMachGroup.SelPart = SelPart - End If - SelMachGroup.ResetCalcMachGroup() - End Sub - -#End Region ' MoveUpPart - -#Region "MoveDownPart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property MoveDownPart_Command As ICommand - Get - If m_cmdMoveDownPart Is Nothing Then - m_cmdMoveDownPart = New Command(AddressOf MoveDownPart) - End If - Return m_cmdMoveDownPart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub MoveDownPart() - If IsNothing(Map.refProdManagerVM.CurrProd) Then Return - Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If IsNothing(SelMachGroup) Then Return - ' se barra gia' assegnata a supervisore, esco - If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return - Dim SelPart As PartVM = SelMachGroup.SelPart - If IsNothing(SelPart) Then Return - If SelMachGroup.nType = MachineType.BEAM Then - SelMachGroup.MoveBeam(SelPart, MoveDirections.DOWN) - EgtDraw() - ' riseleziono trave - SelMachGroup.SelPart = SelPart - End If - SelMachGroup.ResetCalcMachGroup() - End Sub - -#End Region ' MoveDownPart - -#Region "ReOrderPart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property ReOrderPart_Command As ICommand - Get - If m_cmdReOrderPart Is Nothing Then - m_cmdReOrderPart = New Command(AddressOf ReOrderPart) - End If - Return m_cmdReOrderPart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub ReOrderPart() - If IsNothing(Map.refProdManagerVM.CurrProd) Then Return - Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If IsNothing(SelMachGroup) Then Return - ' se barra gia' assegnata a supervisore, esco - If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return - Dim SelPart As PartVM = SelMachGroup.SelPart - If IsNothing(SelPart) Then Return - If SelMachGroup.nType = MachineType.BEAM Then - SelMachGroup.ReorderBeam() - EgtDraw() - ' riseleziono trave - If Not IsNothing(SelPart) Then - SelMachGroup.SelPart = SelPart - End If - End If - SelMachGroup.ResetCalcMachGroup() - End Sub - -#End Region ' ReOrderPart - -#Region "MovePartInRawPart" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property MovePartInRawPart_Command As ICommand - Get - If m_cmdMovePartInRawPart Is Nothing Then - m_cmdMovePartInRawPart = New Command(AddressOf MovePartInRawPart) - End If - Return m_cmdMovePartInRawPart - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub MovePartInRawPart() - If IsNothing(Map.refProdManagerVM.CurrProd) Then Return - Dim MovePartInRawPartWndVM As New MovePartInRawPartWndVM() - Dim MovePartInRawPartWnd As New MovePartInRawPartWndV(Application.Current.MainWindow, MovePartInRawPartWndVM) - If Not MovePartInRawPartWnd.ShowDialog() Then Return - End Sub - -#End Region ' MovePartInRawPart - -#End Region ' COMMANDS - End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/Configuration.vb b/EgtBEAMWALL.ViewerOptimizer/Utility/Configuration.vb new file mode 100644 index 00000000..9e116178 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/Configuration.vb @@ -0,0 +1,228 @@ +Imports System.Collections.ObjectModel +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Module Configuration + + ''' + ''' trovo ed evidenzio MachGroup e Duplo di questo pezzo + ''' + ''' Id pezzo + Friend Sub SetSearchPiece(nSelBTLPartId As Integer) + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + Dim MachGroupList As New List(Of MyMachGroupVM) + For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + Dim bFound As Boolean = False + For Each Part As PartVM In Machgroup.PartVMList + If EgtDuploGetOriginal(Part.nPartId) = nSelBTLPartId Then + Part.SetSearchFound() + bFound = True + Else + Part.ResetSearchFound() + End If + Next + If bFound Then + Machgroup.SetSearchFound() + Else + Machgroup.ResetSearchFound() + End If + Next + End If + End Sub + + ''' + ''' deevidenzio MachGroup e Duplo di questo pezzo + ''' + ''' Id pezzo + Friend Sub ResetSearchPiece(nSelBTLPartId As Integer) + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + Dim MachGroupList As New List(Of MyMachGroupVM) + For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + Dim bFound As Boolean = False + For Each Part As PartVM In Machgroup.PartVMList + If EgtDuploGetOriginal(Part.nPartId) = nSelBTLPartId Then + Part.ResetSearchFound() + bFound = True + End If + Next + If bFound Then + Machgroup.ResetSearchFound() + End If + Next + End If + End Sub + + ''' + ''' aggiornamento grafica + ''' + Friend Sub UpdateGraphics() + If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.PartShowAllChanged() + If Not IsNothing(Map.refBTLPartManagerVM) Then Map.refBTLPartManagerVM.PartShowAllChanged() + End Sub + + ''' + ''' evidenzio BTLPart di questo pezzo + ''' + ''' Id pezzo + Friend Sub SetSearch(nPartId As Integer) + For BTLPartIndex = 0 To Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count - 1 + Dim nDuploOriginalId As Integer = 0 + If EgtGetInfo(nPartId, GDB_SI_DUPSOU, nDuploOriginalId) AndAlso nDuploOriginalId > 0 AndAlso nDuploOriginalId = Map.refProjectVM.BTLStructureVM.BTLPartVMList(BTLPartIndex).nPartId Then + Map.refProjectVM.BTLStructureVM.BTLPartVMList(BTLPartIndex).SetSearchFound() + Exit For + End If + Next + End Sub + + ''' + ''' deevidenzio BTLPart di questo pezzo + ''' + ''' Id pezzo + Friend Sub ResetSearch(nPartId As Integer) + For BTLPartIndex = 0 To Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count - 1 + Dim nDuploOriginalId As Integer = 0 + If EgtGetInfo(nPartId, GDB_SI_DUPSOU, nDuploOriginalId) AndAlso nDuploOriginalId > 0 AndAlso nDuploOriginalId = Map.refProjectVM.BTLStructureVM.BTLPartVMList(BTLPartIndex).nPartId Then + Map.refProjectVM.BTLStructureVM.BTLPartVMList(BTLPartIndex).ResetSearchFound() + Exit For + End If + Next + End Sub + + ''' + ''' modalita' assemblato + ''' + ''' booleano visualizza modalita' assemblato + Friend Sub AssembledMode(bShowBuilding As Boolean) + If bShowBuilding AndAlso Map.refShowBeamPanelVM.bShowAll Then + ' devo smontarlo prima di calcolare le travi, altrimenti non trova i pezzi + Map.refProjectVM.BTLStructureVM.ShowBuilding(False, False) + End If + End Sub + + ''' + ''' vista di tutti i pezzi + ''' + ''' booleano visualizza modalita' assemblato + ''' booleano visualizza solido + ''' Id pezzo + ''' booleano controllo solido + ''' booleano controllo se pezzo selezionato + Friend Sub ShowAllPieces(bShowBuilding As Boolean, Optional bShowSolid As Boolean = False, Optional nSelPartId As Integer = 0, Optional bSolid As Boolean = False, Optional bSelPieces As Boolean = False) + 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 + ElseIf Not Map.refShowBeamPanelVM.bShowAll AndAlso bSolid Then + 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 + If bSelPieces Then + If Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then nSelPartId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId + Map.refProjectVM.BTLStructureVM.ShowAll(False) + End If + End If + End Sub + + ''' + ''' elimino i pezzi da sovrascrivere nel progetto corrente + ''' + ''' Lista BTLPart + Friend Sub DeletePieces(BTLPartList As ObservableCollection(Of BTLPartToUpdate)) + For Each BTLPartToOverwriteWith In 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 + End Sub + + ''' + ''' tolgo eventuale indicazione solido rimasta da pezzo precedente + ''' + ''' Id pezzo + ''' booleano visualizzazione solido + Friend Sub DeselectSolid(Optional nPartId As Integer = 0, Optional bShowSolid As Boolean = False) + If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then + ' tolgo eventuale indicazione solido rimasta da pezzo precedente + Map.refShowBeamPanelVM.SetShowSolid(False) + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(nPartId, False, False) + End If + End Sub + + ''' + ''' verifico se la dimensione e' maggiore del box minimo dei pezzi + ''' + ''' + ''' + Friend Sub VerifyMaxDimension(PartVMList As ObservableCollection(Of Core.PartVM), b3Parts As BBox3d) + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(PartVMList(0).nPartId, "Box") + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.EXACT, b3Parts) + For PartIndex = 1 To PartVMList.Count - 1 + Dim b3Part As New BBox3d + nBoxLayerId = EgtGetFirstNameInGroup(PartVMList(PartIndex).nPartId, "Box") + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.EXACT, b3Part) + b3Parts.Add(b3Part) + Next + End Sub + + ''' + ''' riporto il grezzo nell'angolo tavola di origine + ''' + ''' + ''' + Friend Sub SelectCorner(b3Tab As BBox3d, nRawPartId As Integer) + EgtGetTableArea(1, b3Tab) + Dim p3OrigOnTab As Point3d + Select Case CurrentMachine.OrigCorner + Case MCH_CR.BL + p3OrigOnTab = New Point3d(CurrentMachine.OrigOffsX, CurrentMachine.OrigOffsY, 0) + Case MCH_CR.BR + p3OrigOnTab = New Point3d(b3Tab.DimX() - CurrentMachine.OrigOffsX, CurrentMachine.OrigOffsY, 0) + Case MCH_CR.TL + p3OrigOnTab = New Point3d(CurrentMachine.OrigOffsX, b3Tab.DimY() - CurrentMachine.OrigOffsY, 0) + Case MCH_CR.TR + p3OrigOnTab = New Point3d(b3Tab.DimX() - CurrentMachine.OrigOffsX, b3Tab.DimY() - CurrentMachine.OrigOffsY, 0) + End Select + EgtMoveToCornerRawPart(nRawPartId, p3OrigOnTab, CurrentMachine.OrigCorner) + End Sub + + ''' + ''' + ''' + ''' + ''' + Friend Sub SelectedPieces(nPartId As Integer, BTLStructureVM As BTLStructureVM) + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) + Map.refProjectVM.MacroFeature_IsEnabled = True + ' se modalità building, la tolgo + If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + BTLStructureVM.ShowBuilding(False, False) + End If + + BTLStructureVM.SceneSelPartSelection() + ' seleziono pezzo in Db geometrico + EgtBeamSetPart(nPartId) + EgtBeamShowFacesName(True) + Dim bLoadingSideShow As Boolean = (BTLStructureVM.nPROJTYPE = BWType.BEAM) + Dim bLeftToRight As Boolean = Not (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) + EgtBeamShowLoadingSide(bLoadingSideShow, bLeftToRight) + End Sub + +End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/CurrentMachine.vb b/EgtBEAMWALL.ViewerOptimizer/Utility/CurrentMachine.vb index 1c78294f..2962d1ac 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Utility/CurrentMachine.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/CurrentMachine.vb @@ -242,9 +242,9 @@ Public Module CurrentMachine EgtLuaResetGlobVar("GWD") ' aggiorno parametro in gestore viste Core.ViewPanelVM.UpdateMachParam(m_nViewDir) - + End If ' leggo parametri macchina da WallData - ElseIf nType = MachineType.WALL Then + If nType = MachineType.WALL OrElse nType = MachineType.BOTH Then ' Assegno i dati EgtLuaCreateGlobTable("GWD") EgtLuaSetGlobStringVar("GWD.BASEDIR", Map.refMainWindowVM.MainWindowM.sWallRoot) diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/Dictionary.xaml b/EgtBEAMWALL.ViewerOptimizer/Utility/Dictionary.xaml index add491e3..35971115 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Utility/Dictionary.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/Dictionary.xaml @@ -51,9 +51,17 @@ --> + + + + + + + + - + @@ -162,8 +170,11 @@