- Aggiunta finestra di selezione per UpdateBTL per aggiornare il progetto corrrente con i pezzi del progetto importato o accodare quest'ultimi

- Aggiunta finestra per checkare i pezzi che si desidera aggiungere nel caso "Aggiorna" di UpdateBTL
This commit is contained in:
RenzoL
2022-02-21 16:41:40 +01:00
parent cd940ccf7e
commit 76bdc0bb19
10 changed files with 883 additions and 67 deletions
+2
View File
@@ -126,6 +126,8 @@
' layer per assemblato
Public Const ASSEBASE As String = "AsseBase"
' info parametri assemblato
Public Const BTL_ASSEBASE_N As String = "N"
' info parametri BTL
Public Const BTL_PRT_PROJ As String = "PROJ"
@@ -27,6 +27,7 @@
Public Const S_SECTXMATLIST_WALL As String = "DG_SectXMatList_WALL"
Public Const S_VARIABLESLIST As String = "DG_VariablesList"
Public Const S_MDICOMMANDS As String = "DG_MDICommands"
Public Const S_UPDATEBTLPARTLIST As String = "DG_UpdateBTLPartList"
Public Const K_LOCKTABLE As String = "LockTable"
@@ -252,6 +252,14 @@
<Compile Include="SupervisorCommThread\SupervisorCommThread.vb" />
<Compile Include="ToolsDbWindow\MyToolDbWindowVM.vb" />
<Compile Include="ToolsDbWindow\ToolsUpdate.vb" />
<Compile Include="UpdateBTLWnd\UpdateOrAppendWndVM.vb" />
<Compile Include="UpdateBTLWnd\UpdateBTLWndV.xaml.vb">
<DependentUpon>UpdateBTLWndV.xaml</DependentUpon>
</Compile>
<Compile Include="UpdateBTLWnd\UpdateBTLWndVM.vb" />
<Compile Include="UpdateBTLWnd\UpdateOrAppendWndV.xaml.vb">
<DependentUpon>UpdateOrAppendWndV.xaml</DependentUpon>
</Compile>
<Compile Include="Utility\DbControllers.vb" />
<Compile Include="Utility\DisableModifiedMgr.vb" />
<Compile Include="Utility\LuaExec.vb" />
@@ -437,6 +445,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UpdateBTLWnd\UpdateBTLWndV.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UpdateBTLWnd\UpdateOrAppendWndV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WarehouseWnd\WarehouseWndV.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -10,6 +10,9 @@ Public Class ProjManagerVM
#Region "FIELDS & PROPERTIES"
' Nome file NGE con i pezzi selezionati per effettuare UpdateBTL
Friend Const UPDATEBTL_NGE As String = "UpdateBTL.nge"
Private m_ProjManager_IsEnabled As Boolean = True
Public ReadOnly Property ProjManager_IsEnabled As Boolean
Get
@@ -274,6 +277,22 @@ Public Class ProjManagerVM
NotifyPropertyChanged(NameOf(ProjManager_IsEnabled))
End Sub
Private Sub ReloadBTLStructure()
Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(Map.refProjManagerVM.CurrProj.nProjId))
' verifico se volume pezzi calcolato
Dim bIsCalculated As Boolean = False
For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList
If BTLPart.BTLPartM.dVolume > 0 Then Continue For
bIsCalculated = True
BTLPart.CalcBTLPartVolume()
Next
If bIsCalculated Then
Dim CurrProject As String = ""
EgtGetCurrFilePath(CurrProject)
EgtSaveFile(CurrProject, NGE.CMPTEXT)
End If
End Sub
#End Region ' METHODS
#Region "COMMANDS"
@@ -791,81 +810,394 @@ Public Class ProjManagerVM
' creo un nuovo contesto su cui aprire il file BTL
Dim nCurrCtx As Integer = EgtGetCurrentContext()
Dim nTempCtx As Integer = EgtInitContext()
' setto il flag per inizializzazione gestore travi e pareti per importare progetto
Dim nFlag As Integer
Dim sBTLFlag As String
If Map.refProjManagerVM.nProjType = Core.ConstBeam.BWType.BEAM Then
sBTLFlag = K_BTLFLAG
Else
sBTLFlag = K_WALLBTLFLAG
End If
nFlag = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR)
' inizializzo gestore travi e pareti
EgtInitBeamMgr(nFlag)
Dim bOk As Boolean = nTempCtx <> 0
If bOk Then
' importo il file BTL
bOk = bOk AndAlso EgtImportBtl(sFile)
' rimuovo i parametri generali e salvo come file NGE
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)
EgtErase(AsseBaseId)
EgtErase(BtlInfoId)
EgtSaveFile("C:\EgtData\EgtBEAMWALL\Temp\Prova.nge", NGE.CMPTEXT)
' torno sul contesto corrente
EgtSetCurrentContext(nCurrCtx)
EgtDeleteContext(nTempCtx)
' 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)
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))
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))
End If
nPartId = EgtGetNextPart(nPartId)
End While
EgtErase(BtlInfoId)
BtlInfoId = EgtGetNextName(BtlInfoId, BTLINFO)
End While
' inserisco il file importato nel progetto corrente
bOk = bOk AndAlso EgtInsertFile("C:\EgtData\EgtBEAMWALL\Temp\Prova.nge")
' deseleziono tutto
EgtDeselectAll()
' ciclo sui pezzi aggiunti
Dim nAddedPartId As Integer = EgtGetNextPart(nLastProjPartId)
Dim bFirstLoop As Boolean = True
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)
' eseguo rotazione del pezzo
Dim ptRot = b3Box.Min() + New Vector3d(0, b3Box.DimZ() / 2, b3Box.DimZ() / 2)
bOk = bOk AndAlso EgtRotate(nAddedPartId, ptRot, -Vector3d.X_AX, -90)
' ricaviamo il box globale del part appena aggiunto e ruotato
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.DimY(), 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)
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) 'Map.refProjectVM.BTLStructureVM.SelBTLPart = 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)
' 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
nNewPartId = EgtGetNextPart(nNewPartId)
nAsseBaseSubNodeId = EgtGetNext(nAsseBaseSubNodeId)
End While
WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile))
' 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()
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.DimY(), 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()
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
EgtSetCurrentContext(nCurrCtx)
EgtDeleteContext(nTempCtx)
' rileggo la struttura BTL del progetto corrente per non avere quella del contesto temporaneo ancora presente
ReloadBTLStructure()
' elimino i pezzi da sovrascrivere nel progetto corrente
For Each BTLPartToOverwriteWith In UpdateBTLWndVM.BTLPartList
If BTLPartToOverwriteWith.bInsert Then
Dim BTLPartToUpdate As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPDN = BTLPartToOverwriteWith.nPDN)
' se BTLPartToUpdate è Nothing significa che il pezzo è nuovo e quindi basta accodarlo senza eliminare nulla
If Not IsNothing(BTLPartToUpdate) Then
Dim nPartToDeleteId As Integer = BTLPartToUpdate.nPartId
Dim nCurrPartId = EgtGetCurrPart()
EgtErase(nPartToDeleteId)
nCurrPartId = EgtGetCurrPart()
' verifico se rimuovere sezione dalla lista
If Not Map.refProjectVM.BTLStructureVM.BTLPartVMList.Any(Function(x) x IsNot BTLPartToUpdate AndAlso x.Section = BTLPartToUpdate.Section) Then
Map.refProjectVM.BTLStructureVM.SectionList.Remove(BTLPartToUpdate.Section)
End If
' rimuovo dalla lista pezzi
Dim Index As Integer = Map.refProjectVM.BTLStructureVM.BTLPartVMList.IndexOf(BTLPartToUpdate)
Map.refProjectVM.BTLStructureVM.SelBTLPart = 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 = 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 NGE (ricavato dal BTL importato) nel progetto corrente
bOk = bOk AndAlso EgtInsertFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE)
' ciclo su tutti gli AsseBase del progetto corrente
Dim nAsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE)
While nAsseBaseId <> GDB_ID.NULL
Dim nAsseBaseProjId As Integer
Dim nAsseBaseToEraseId As Integer = 0
EgtGetInfo(nAsseBaseId, BTL_PRT_PROJ, nAsseBaseProjId)
' se AsseBase di questo step del ciclo è nuovo e suo ProjId uguale a quello del progetto corrente
If Not AsseBaseIdList.Contains(nAsseBaseId) AndAlso nAsseBaseProjId = Map.refProjManagerVM.CurrProj.nProjId Then
' riloco i sottonodi del nuovo AsseBase nell'AsseBase del progetto aperto col medesimo ProjId
Dim AsseBaseSubNodeId As Integer = EgtGetFirstInGroup(nAsseBaseId)
While AsseBaseSubNodeId <> GDB_ID.NULL
' ciclo su tutti gli AsseBase per trovare l'id di quello con ProjId uguale al progetto corrente
Dim FindAsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE)
While FindAsseBaseId <> GDB_ID.NULL
Dim SameAsseBaseProjId As Integer
EgtGetInfo(FindAsseBaseId, BTL_PRT_PROJ, SameAsseBaseProjId)
' se l'ho trovato esco dal While (FindAsseBaseId è l'id dell'AsseBase in cui vogliamo rilocare i sottonodi)
If SameAsseBaseProjId = Map.refProjManagerVM.CurrProj.nProjId Then Exit While
FindAsseBaseId = EgtGetNextName(FindAsseBaseId, ASSEBASE)
End While
' salvo id dell'AsseBase corrente per ottenere il seguente prima di rilocarlo
Dim CurrAsseBaseSubNodeId = AsseBaseSubNodeId
AsseBaseSubNodeId = EgtGetNext(CurrAsseBaseSubNodeId)
bOk = bOk AndAlso EgtRelocate(CurrAsseBaseSubNodeId, FindAsseBaseId, GDB_POS.LAST_SON)
End While
' salvo id dell'AsseBase per cancellarlo
nAsseBaseToEraseId = nAsseBaseId
End If
' ricavo id del prossimo AsseBase
nAsseBaseId = EgtGetNextName(nAsseBaseId, ASSEBASE)
' se salvato id dell'AsseBase per cancellarlo lo cancello
If nAsseBaseToEraseId <> 0 Then bOk = bOk AndAlso EgtErase(nAsseBaseToEraseId)
End While
' deseleziono tutto
EgtDeselectAll()
' ciclo sui pezzi aggiunti
Dim nAddedPartId As Integer = EgtGetNextPart(nLastProjPartId)
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)
nAddedPartId = EgtGetNextPart(nAddedPartId)
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
WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile))
End If
End If
End If
'If bOk Then
' ' riporto aggiunta proj a prod su Db
' DbControllers.m_ProdController.AddProj(OpenProjectFileDialogVM.SelProject.nProdId, Map.refProjManagerVM.CurrProj.nProjId)
' ' imposto currprod
' Map.refProdManagerVM.SetCurrProd(OpenProjectFileDialogVM.SelProject.nProdId)
'End If
EgtZoom(ZM.ALL)
End Sub
@@ -1172,7 +1504,7 @@ Public Class ProjManagerVM
EgtSetInfo(nDuploId, BTL_PRT_PROJ, NewProjIdList(nOldProjIndex))
nDuploId = EgtGetNext(nDuploId)
End While
' resetto CurrProd per evitare di leggero valori produzione dal Db di quel progetto
' resetto CurrProd per evitare di leggere valori produzione dal Db di quel progetto
Map.refProdManagerVM.CurrProd = Nothing
' carico Machgroup che non verrebbero altrimenti importati
Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList()))
@@ -0,0 +1,88 @@
<EgtWPFLib5:EgtCustomWindow x:Class="UpdateBTLWndV"
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"
Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}"
WindowStyle="None" ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner"
IsClosable="False"
IsMinimizable="False"
IsResizable="False"
Title="UpdateBTLWnd">
<StackPanel Margin="5,5,5,0">
<TextBlock Grid.Row="0"
Text="{Binding UpdateBTLWnd_Msg}"
TextWrapping="Wrap"
Width="400"
Margin="5"/>
<EgtBEAMWALLCORE:EgtDataGrid Grid.Row="1" Width="400" MaxHeight="600"
ItemsSource="{Binding BTLPartList}"
SelectedItem="{Binding SelBTLPart}"
CanUserAddRows="False"
AutoGenerateColumns="False"
CanUserResizeRows="False"
SelectionMode="Single"
ScrollViewer.CanContentScroll="False"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
Margin="5"
BindingColumns="{Binding UpdateBTLColumns}">
<DataGrid.Resources>
<!-- PDN -->
<DataGridTextColumn x:Key="colPDN" Binding="{Binding nPDN}">
<DataGridTextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=DataContext.PDN_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:UpdateBTLWndV}}}"/>
</DataTemplate>
</DataGridTextColumn.HeaderTemplate>
</DataGridTextColumn>
<!-- Descrizione -->
<DataGridTextColumn x:Key="colNAM" Binding="{Binding sNAM}">
<DataGridTextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=DataContext.NAM_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:UpdateBTLWndV}}}"/>
</DataTemplate>
</DataGridTextColumn.HeaderTemplate>
</DataGridTextColumn>
<!-- Insert -->
<DataGridTemplateColumn x:Key="colINSERT">
<DataGridTemplateColumn.Header>
<TextBlock Text="{Binding Path=DataContext.Insert_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:UpdateBTLWndV}}}"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=bInsert, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Center"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Resources>
</EgtBEAMWALLCORE:EgtDataGrid>
<Grid Grid.Row="2" Margin="0,0,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Content="{Binding Ok_Msg}"
Command="{Binding Ok_Command}"
IsDefault="True"
Grid.Column="1"
Style="{StaticResource EgtWPFLib5_InputButton}"/>
<Button Content="{Binding Cancel_Msg}"
Command="{Binding Cancel_Command}"
IsCancel="True"
Grid.Column="3"
Style="{StaticResource EgtWPFLib5_InputButton}"/>
</Grid>
</StackPanel>
</EgtWPFLib5:EgtCustomWindow>
@@ -0,0 +1,18 @@
Public Class UpdateBTLWndV
Private WithEvents m_UpdateBTLWndVM As UpdateBTLWndVM
Sub New(Owner As Window, UpdateBTLWndVM As UpdateBTLWndVM)
MyBase.New(Owner)
' This call is required by the designer.
InitializeComponent()
Me.DataContext = UpdateBTLWndVM
' Assegno al riferimento locale al VM il VM preso dal DataContext
m_UpdateBTLWndVM = UpdateBTLWndVM
End Sub
Private Sub CloseWindow(bDialogResult As Boolean) Handles m_UpdateBTLWndVM.m_CloseWindow
Me.DialogResult = bDialogResult
End Sub
End Class
@@ -0,0 +1,177 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Imports EgtBEAMWALL.Core
Public Class UpdateBTLWndVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Friend Event m_CloseWindow(bDialogResult As Boolean)
Protected m_UpdateBTLColumns As New ObservableCollection(Of EgtDataGridColumn)
Public Property UpdateBTLColumns As ObservableCollection(Of EgtDataGridColumn)
Get
Return m_UpdateBTLColumns
End Get
Set(value As ObservableCollection(Of EgtDataGridColumn))
m_UpdateBTLColumns = value
End Set
End Property
Private m_BTLPartList As New ObservableCollection(Of BTLPartToUpdate)
Public Property BTLPartList As ObservableCollection(Of BTLPartToUpdate)
Get
Return m_BTLPartList
End Get
Set(value As ObservableCollection(Of BTLPartToUpdate))
m_BTLPartList = value
End Set
End Property
Private m_SelBTLPart As BTLPartToUpdate
Public Property SelBTLPart As BTLPartToUpdate
Get
Return m_SelBTLPart
End Get
Set(value As BTLPartToUpdate)
m_SelBTLPart = value
End Set
End Property
' Definizione comandi
Private m_cmdOk As ICommand
Private m_cmdCancel As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "MESSAGES"
Public ReadOnly Property Name_Msg As String
Get
Return EgtMsg(61808)
End Get
End Property
Public ReadOnly Property NAM_Msg As String
Get
Return EgtMsg(61603)
End Get
End Property
Public ReadOnly Property PDN_Msg As String
Get
Return EgtMsg(61809)
End Get
End Property
Public ReadOnly Property Insert_Msg As String
Get
Return EgtMsg(30505)
End Get
End Property
Public ReadOnly Property Ok_Msg As String
Get
Return EgtMsg(61761)
End Get
End Property
Public ReadOnly Property Cancel_Msg As String
Get
Return EgtMsg(61763)
End Get
End Property
Public ReadOnly Property UpdateBTLWnd_Msg As String
Get
Return EgtMsg(61960)
End Get
End Property
#End Region ' MESSAGES
#Region "CONSTRUCTOR"
Sub New(InputBTLPartList As List(Of BTLPartToUpdate))
' carico le colonne della datagrid
GetPrivateProfileColumns(S_UPDATEBTLPARTLIST, UpdateBTLColumns)
' carica la lista dei Part importati
BTLPartList = New ObservableCollection(Of BTLPartToUpdate)(InputBTLPartList)
End Sub
#End Region ' CONSTRUCTOR
#Region "COMMANDS"
#Region "Ok"
Public ReadOnly Property Ok_Command As ICommand
Get
If m_cmdOk Is Nothing Then
m_cmdOk = New Command(AddressOf Ok)
End If
Return m_cmdOk
End Get
End Property
Public Sub Ok()
RaiseEvent m_CloseWindow(True)
End Sub
#End Region ' Ok
#End Region ' COMMANDS
End Class
Public Class BTLPartToUpdate
Private m_nPartId As Integer
Public ReadOnly Property nPartId As Integer
Get
Return m_nPartId
End Get
End Property
Private m_nPDN As Integer
Public ReadOnly Property nPDN As Integer
Get
Return m_nPDN
End Get
End Property
Private m_sNAM As String
Public ReadOnly Property sNAM As String
Get
Return m_sNAM
End Get
End Property
Private m_UIDList As List(Of Integer)
Public ReadOnly Property UIDList As List(Of Integer)
Get
Return m_UIDList
End Get
End Property
Private m_bInsert As Boolean = False
Public Property bInsert As Boolean
Get
Return m_bInsert
End Get
Set(value As Boolean)
m_bInsert = value
End Set
End Property
Sub New(PartId As Integer, PDN As Integer, NAM As String, UIDList As List(Of Integer))
m_nPartId = PartId
m_nPDN = PDN
m_sNAM = NAM
m_UIDList = UIDList
End Sub
End Class
@@ -0,0 +1,66 @@
<EgtWPFLib5:EgtCustomWindow x:Class="UpdateOrAppendWndV"
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"
Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}"
WindowStyle="None" ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner"
IsClosable="False"
IsMinimizable="False"
IsResizable="False"
Title="UpdateOrAppendWndV">
<Grid Margin="5,5,5,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid HorizontalAlignment="Center"
Margin="0,0,0,5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<RadioButton Content="{Binding Update_Msg}"
IsChecked="{Binding UpdateIsChecked}"
Style="{StaticResource ToolBar_TextToggleButton}"
Grid.Row="1" Grid.Column="0">
</RadioButton>
<RadioButton Content="{Binding Append_Msg}"
IsChecked="{Binding AppendIsChecked}"
Style="{StaticResource ToolBar_TextToggleButton}"
Grid.Row="1" Grid.Column="1">
</RadioButton>
</Grid>
<Grid Grid.Row="3"
Margin="0,0,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Content="Ok"
Command="{Binding Ok_Command}"
IsDefault="True"
Grid.Column="1"
Style="{StaticResource EgtWPFLib5_InputButton}"/>
<Button Content="{Binding Cancel_Msg}"
IsCancel="True"
Grid.Column="3"
Style="{StaticResource EgtWPFLib5_InputButton}"/>
</Grid>
</Grid>
</EgtWPFLib5:EgtCustomWindow>
@@ -0,0 +1,18 @@
Public Class UpdateOrAppendWndV
Private WithEvents m_UpdateOrAppendWndVM As UpdateOrAppendWndVM
Sub New(Owner As Window, UpdateOrAppendWndVM As UpdateOrAppendWndVM)
MyBase.New(Owner)
' This call is required by the designer.
InitializeComponent()
Me.DataContext = UpdateOrAppendWndVM
' Assegno al riferimento locale al VM il VM preso dal DataContext
m_UpdateOrAppendWndVM = UpdateOrAppendWndVM
End Sub
Private Sub CloseWindow(bDialogResult As Boolean) Handles m_UpdateOrAppendWndVM.m_CloseWindow
Me.DialogResult = bDialogResult
End Sub
End Class
@@ -0,0 +1,98 @@
Imports EgtWPFLib5
Imports EgtUILib
Public Class UpdateOrAppendWndVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Friend Event m_CloseWindow(bDialogResult As Boolean)
Private m_UpdateIsChecked As Boolean
Public Property UpdateIsChecked As Boolean
Get
Return m_UpdateIsChecked
End Get
Set(value As Boolean)
If value <> m_UpdateIsChecked Then
m_UpdateIsChecked = value
End If
End Set
End Property
Private m_AppendIsChecked As Boolean
Public Property AppendIsChecked As Boolean
Get
Return m_AppendIsChecked
End Get
Set(value As Boolean)
If value <> m_AppendIsChecked Then
m_AppendIsChecked = value
End If
End Set
End Property
' Definizione comandi
Private m_cmdOk As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "MESSAGES"
Public ReadOnly Property Update_Msg As String
Get
Return EgtMsg(61958)
End Get
End Property
Public ReadOnly Property Append_Msg As String
Get
Return EgtMsg(61959)
End Get
End Property
Public ReadOnly Property Ok_Msg As String
Get
Return EgtMsg(61761)
End Get
End Property
Public ReadOnly Property Cancel_Msg As String
Get
Return EgtMsg(61763)
End Get
End Property
#End Region ' MESSAGES
#Region "CONSTRUCTOR"
Sub New()
' setto il bottone Update a premuto
UpdateIsChecked = True
End Sub
#End Region ' CONSTRUCTOR
#Region "COMMANDS"
#Region "Ok"
Public ReadOnly Property Ok_Command As ICommand
Get
If m_cmdOk Is Nothing Then
m_cmdOk = New Command(AddressOf Ok)
End If
Return m_cmdOk
End Get
End Property
Public Sub Ok()
RaiseEvent m_CloseWindow(True)
End Sub
#End Region ' Ok
#End Region ' COMMANDS
End Class