02ada8a38d
- nuova gestione degli errori; - nuovo pulsante Reload.
1213 lines
58 KiB
VB.net
1213 lines
58 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class AssemblyManagerVM
|
|
Inherits VMBase
|
|
|
|
' creiamo un nuovo progetto: un nome e una lista di porte
|
|
Private m_CurrProject As New Project
|
|
Public Property CurrProject As Project
|
|
Get
|
|
Return m_CurrProject
|
|
End Get
|
|
Set(value As Project)
|
|
m_CurrProject = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_VisibilityDoorList As Visibility = Visibility.Visible
|
|
Public Property VisibilityDoorList As Visibility
|
|
Get
|
|
Return m_VisibilityDoorList
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_VisibilityDoorList = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "MESSAGES"
|
|
|
|
Public ReadOnly Property AddNewDoorToolTip As String
|
|
Get
|
|
Return EgtMsg(50302)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RemoveDoorToolTip As String
|
|
Get
|
|
Return EgtMsg(50303)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region 'MESSAGES
|
|
|
|
' Definizione comandi
|
|
Private m_cmdAddAssembly As ICommand
|
|
Private m_cmdRemoveAssembly As ICommand
|
|
|
|
Sub New()
|
|
Map.SetRefDoorManagerVM(Me)
|
|
End Sub
|
|
|
|
#Region "METHODS"
|
|
|
|
#Region "Apertura e salvataggio"
|
|
|
|
Public Sub NewCmd(NewAssName As AssemblyName)
|
|
' segno come modificato il nome dell'assemblato
|
|
CurrProject.SelAssemblyName.IsModified = True
|
|
' definisco e rimuovo file temporaneo di assemblato
|
|
Dim sTempFile As String = IniFile.m_sTempDir & "\" & TEMP_FILE
|
|
Try
|
|
File.Delete(sTempFile)
|
|
Catch ex As Exception
|
|
End Try
|
|
' creo nuovo assemblato
|
|
m_CurrProject.SelAssemblyName.SelAssembly = CreateNewAssembly(CurrProject.SelAssemblyName.Name)
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then
|
|
' ricarico la lista completa degli swing
|
|
NewAssName.SelAssembly.ListPartDoor(0).Door.SwingTypeList = OptionModule.m_SwingTypeList
|
|
NewAssName.SelAssembly.ListPartDoor(0).Door.SetSwing(OptionModule.m_Swing)
|
|
DdfFile.WriteDDFPart(NewAssName.SelAssembly.ListPartDoor(0).Door, sTempFile, False, False)
|
|
' assegno la porte salvata nel CurrPart.ddf come porta corrente del progetto
|
|
Map.refPartPageVM.CurrPart = NewAssName.SelAssembly.ListPartDoor(0).Door
|
|
' aggiorno elenco quotature
|
|
Map.refDimensioningPanelVM.LoadHardwareDimList()
|
|
ExecDoors(Map.refSceneManagerVM.ProjectScene, sTempFile, False)
|
|
EgtZoom(ZM.ALL)
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nDDFPage
|
|
Else
|
|
DdfFile.WriteDDFAssembly(NewAssName.SelAssembly, sTempFile, False)
|
|
ExecDoors(Map.refSceneManagerVM.ProjectScene, sTempFile, False)
|
|
' aggiorno elenco quotature
|
|
Map.refDimensioningPanelVM.LoadHardwareDimList()
|
|
EgtZoom(ZM.ALL)
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage
|
|
End If
|
|
Return
|
|
End Sub
|
|
|
|
Public Function Save(SavedAssName As AssemblyName) As Boolean
|
|
If IsNothing(SavedAssName) OrElse IsNothing(SavedAssName.SelAssembly) Then Return False
|
|
' Salvo
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then
|
|
' questa condizione non DOVREBBE mai accadere, perchè viene interrotto prima il caricamento
|
|
If SavedAssName.SelAssembly.ListPartDoorOfDoor.Count < 1 Then
|
|
If MessageBox.Show("The current ddf is a part of a frame, do you want to save?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) = MessageBoxResult.Yes Then
|
|
DdfFile.SaveErrorCompo = True
|
|
DdfFile.WriteDDFPart(SavedAssName.SelAssembly.ListPartDoor(0).Door, SavedAssName.Name, True, False)
|
|
DdfFile.SaveErrorCompo = False
|
|
Else
|
|
Return False
|
|
End If
|
|
Else
|
|
DdfFile.SaveErrorCompo = True
|
|
DdfFile.WriteDDFPart(SavedAssName.SelAssembly.ListPartDoorOfDoor(0).Door, SavedAssName.Name, True, False)
|
|
DdfFile.SaveErrorCompo = False
|
|
End If
|
|
Else
|
|
DdfFile.SaveErrorCompo = True
|
|
DdfFile.WriteDDFAssembly(SavedAssName.SelAssembly, SavedAssName.Name, True)
|
|
DdfFile.SaveErrorCompo = False
|
|
End If
|
|
' controllo che il salvataggio sia andato a buon fine
|
|
If Not String.IsNullOrEmpty(DdfFile.ErrorInWriting) Then
|
|
DdfFile.ErrorInWriting &= "Do you want to procede?"
|
|
If MessageBox.Show(DdfFile.ErrorInWriting, EgtMsg(50101), MessageBoxButton.YesNo, MessageBoxImage.Error) = MessageBoxResult.Yes Then
|
|
DdfFile.DDFIsCorrect = True
|
|
Else
|
|
Return False
|
|
End If
|
|
End If
|
|
If DdfFile.DDFIsCorrect Then
|
|
SavedAssName.IsModified = False
|
|
' ogni progetto salvato è l'ultimo da aprire, anche se il programma è chiuso dall'HardwareManager
|
|
WriteMainPrivateProfileString(S_LAUNCHERWINDOW, K_LASTPROJECT, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name)
|
|
SavedAssName.NotifyPropertyChanged("IsModify")
|
|
Else
|
|
Return False
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
' rileggo le componenti caricate di default e se possibile le correggo
|
|
Public Function RefreshAssembly(Optional ErCompo As Compo = Nothing) As Boolean
|
|
' se ricevo una componente specifica non controllo solo qella
|
|
If IsNothing(Map.refAssemblyManagerVM) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.SelAssembly) Then
|
|
Return False
|
|
End If
|
|
' creo una copia dell'assemblato
|
|
Dim CurrAssembly As Assembly = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.SelAssembly
|
|
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then
|
|
Dim CurrPart As Part = CurrAssembly.ListPartDoor(0).Door
|
|
Select Case Map.refMainWindowVM.selectedWatcher
|
|
|
|
Case MainWindowVM.WatcherCalling.OnCreated
|
|
' in fase di creazione devo scorrere tutte le componenti che sono CompoDDFName e che hanno il LoadDefault = True
|
|
If IsNothing(ErCompo) Then
|
|
Dim IndexCompo As Integer = 0
|
|
For IndexCompo = 0 To CurrAssembly.ListPartDoor(0).Door.m_CompoList.Count - 1
|
|
' se non ricevo il nome del direttorio allora scorro su tutte le componeti che hanno il LoadDefault = True
|
|
If Not String.IsNullOrEmpty(Map.refMainWindowVM.CompoDDFName) Then
|
|
If Map.refMainWindowVM.CompoDDFName = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).CompoType.DDFName AndAlso
|
|
CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then
|
|
Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo)
|
|
ReCreateCompo(ErrCompo, CurrPart)
|
|
'RecreateCompoParm(ErrCompo, CurrPart)
|
|
End If
|
|
Else
|
|
If CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then
|
|
Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo)
|
|
ReCreateCompo(ErrCompo, CurrPart)
|
|
'RecreateCompoParm(ErrCompo, CurrPart)
|
|
End If
|
|
End If
|
|
Next
|
|
Else
|
|
' se ricevo una componente specifica
|
|
If ErCompo.LoadByDefault Then ReCreateCompo(ErCompo, CurrPart)
|
|
'RecreateCompoParm(ErCompo, CurrPart)
|
|
End If
|
|
|
|
Case MainWindowVM.WatcherCalling.OnDeleted
|
|
' in fase di eliminazione devo scorrere tutte le componenti che sono CompoDDFName e che hanno il LoadDefault = false
|
|
If IsNothing(ErCompo) Then
|
|
Dim IndexCompo As Integer = 0
|
|
For IndexCompo = 0 To CurrAssembly.ListPartDoor(0).Door.m_CompoList.Count - 1
|
|
' se non ricevo il nome del direttorio allora scorro su tutte le componeti che hanno il LoadDefault = False
|
|
If Not String.IsNullOrEmpty(Map.refMainWindowVM.CompoDDFName) Then
|
|
If Map.refMainWindowVM.CompoDDFName = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).CompoType.DDFName AndAlso
|
|
Not CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then
|
|
Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo)
|
|
ReCreateCompo(ErrCompo, CurrPart)
|
|
'RecreateCompoParm(ErrCompo, CurrPart)
|
|
End If
|
|
Else
|
|
If Not CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then
|
|
Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo)
|
|
ReCreateCompo(ErrCompo, CurrPart)
|
|
'RecreateCompoParm(ErrCompo, CurrPart)
|
|
End If
|
|
End If
|
|
Next
|
|
Else
|
|
' se ricevo una componente specifica
|
|
If Not ErCompo.LoadByDefault Then ReCreateCompo(ErCompo, CurrPart)
|
|
'RecreateCompoParm(ErCompo, CurrPart)
|
|
End If
|
|
|
|
Case MainWindowVM.WatcherCalling.OnRenamed
|
|
' in fase di eliminazione devo scorrere tutte le componenti che sono CompoDDFName
|
|
If IsNothing(ErCompo) Then
|
|
Dim IndexCompo As Integer = 0
|
|
For IndexCompo = 0 To CurrAssembly.ListPartDoor(0).Door.m_CompoList.Count - 1
|
|
' se non ricevo il nome del direttorio allora scorro su tutte le componeti che hanno il LoadDefault = False
|
|
If Not String.IsNullOrEmpty(Map.refMainWindowVM.CompoDDFName) Then
|
|
If Map.refMainWindowVM.CompoDDFName = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).CompoType.DDFName Then
|
|
Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo)
|
|
ReCreateCompo(ErrCompo, CurrPart)
|
|
'RecreateCompoParm(ErrCompo, CurrPart)
|
|
End If
|
|
Else
|
|
Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo)
|
|
ReCreateCompo(ErrCompo, CurrPart)
|
|
'RecreateCompoParm(ErrCompo, CurrPart)
|
|
End If
|
|
Next
|
|
Else
|
|
' se ricevo una componente specifica
|
|
ReCreateCompo(ErCompo, CurrPart)
|
|
'RecreateCompoParm(ErCompo, CurrPart)
|
|
End If
|
|
|
|
Case MainWindowVM.WatcherCalling.OnChanged
|
|
|
|
Case MainWindowVM.WatcherCalling.OnLoadTempFile
|
|
LoadTempFile()
|
|
|
|
Case Else
|
|
If Not IsNothing(ErCompo) Then
|
|
' ReCreateCompo(ErCompo, CurrPart)
|
|
RecreateCompoParm(ErCompo, CurrPart)
|
|
Else
|
|
Dim IndexCompo As Integer = 0
|
|
For IndexCompo = 0 To CurrAssembly.ListPartDoor(0).Door.m_CompoList.Count - 1
|
|
Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo)
|
|
ReCreateCompo(ErrCompo, CurrPart)
|
|
Next
|
|
End If
|
|
' se sto forzando un ricalcolo completo di tutto faccio passare tutte le componenti senza pietà?
|
|
|
|
End Select
|
|
' comunico che nessun evento particolare è stato selezionato
|
|
Map.refMainWindowVM.selectedWatcher = MainWindowVM.WatcherCalling.NoEvents
|
|
|
|
Else
|
|
Dim IndexPart As Integer = 0
|
|
For IndexPart = 0 To CurrAssembly.ListPartDoor.Count - 1
|
|
Dim IndexCompo As Integer = 0
|
|
For IndexCompo = 0 To CurrAssembly.ListPartDoor(IndexPart).Door.m_CompoList.Count - 1
|
|
If CurrAssembly.ListPartDoor(IndexPart).Door.m_CompoList(IndexCompo).LoadByDefault Then
|
|
Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(IndexPart).Door.m_CompoList(IndexCompo)
|
|
Dim CurrPart As Part = CurrAssembly.ListPartDoor(IndexPart).Door
|
|
ReCreateCompo(ErrCompo, CurrPart)
|
|
ElseIf CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).ErrorValue Then
|
|
|
|
End If
|
|
Next
|
|
Next
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
' ricerca il tipo di compoente chiamato
|
|
Private Function SearchCompotypeIndex(sDDFName As String) As Integer
|
|
Dim CompoListIndex As Integer = -1
|
|
For CmpInd = 0 To Map.refCompoPanelVM.CompoTypeList.Count() - 1
|
|
' eseguo il confronto con il nome dei componenti che è stato caricato dal file Default.ini
|
|
If Map.refCompoPanelVM.CompoTypeList(CmpInd).DDFName = sDDFName Then
|
|
CompoListIndex = CmpInd
|
|
Exit For
|
|
End If
|
|
Next
|
|
Return CompoListIndex
|
|
End Function
|
|
|
|
' ricarica l'elenco dei file per la componnete selezionata
|
|
Private Function ReCreateCompo(ByRef ErrCompo As Compo, CurrPart As Part) As Boolean
|
|
' Controllo esistenza del componente
|
|
Dim CompoListIndex As Integer = -1
|
|
CompoListIndex = SearchCompotypeIndex(ErrCompo.CompoType.DDFName)
|
|
' verifico che la componente non esiste
|
|
If CompoListIndex = -1 Then Return False
|
|
|
|
Dim m_CurrCompo = New Compo(Map.refCompoPanelVM.CompoTypeList(CompoListIndex))
|
|
' Se previsto template o shape da configurazione
|
|
Dim CurrCompoTypePath As String = Map.refCompoPanelVM.CompoTypeList(CompoListIndex).Path
|
|
Dim nIsActive As Integer = EgtUILib.GetPrivateProfileInt(S_TEMPLATE, K_ISACTIVE, 1, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME)
|
|
|
|
' leggo se template o shape
|
|
Dim Name As String = String.Empty
|
|
Dim DDFName As String = String.Empty
|
|
IniFile.GetPrivateProfileCompoName(S_TEMPLATE, K_NAME, DDFName, Name, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME)
|
|
|
|
' inizializzazione della componente
|
|
m_CurrCompo.TemplateDDFName = DDFName
|
|
m_CurrCompo.TemplateName = Name
|
|
If ErrCompo.SelBrandPart.Contains(".frame") Then
|
|
CurrPart.LoadBrandFileList(m_CurrCompo, True)
|
|
Else
|
|
CurrPart.LoadBrandFileList(m_CurrCompo)
|
|
End If
|
|
If IsNothing(m_CurrCompo) Then Return False
|
|
|
|
' verifico che i nomi che sono caricati esistano
|
|
Dim bBrandExists As Boolean = False
|
|
Dim bFileExists As Boolean = False
|
|
|
|
Dim sBrand As String = ErrCompo.SelBrandPart
|
|
For IndexBrand As Integer = 0 To m_CurrCompo.BrandListPart.Count - 1
|
|
If sBrand.ToLower = m_CurrCompo.BrandListPart(IndexBrand).ToLower Then
|
|
m_CurrCompo.SelBrandPart = m_CurrCompo.BrandListPart(IndexBrand)
|
|
bBrandExists = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If bBrandExists Then
|
|
For IndexFile As Integer = 0 To m_CurrCompo.FileList.Count - 1
|
|
If ErrCompo.SelFile.ToLower = m_CurrCompo.FileList(IndexFile).ToLower Then
|
|
m_CurrCompo.SelFile = m_CurrCompo.FileList(IndexFile)
|
|
bFileExists = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
' in caso sia fallita la ricera dei direttori o dei file
|
|
If Not bBrandExists OrElse Not bFileExists Then
|
|
ErrCompo.LoadByDefault = True
|
|
Return False
|
|
End If
|
|
|
|
' termmino la creazione della nuova componente
|
|
m_CurrCompo.CompoParamList = ErrCompo.CompoParamList
|
|
ErrCompo.LoadByDefault = False
|
|
ErrCompo = m_CurrCompo
|
|
Return True
|
|
End Function
|
|
|
|
' verifica che la componente non riceva un errore in fase di inserimento di un parametro
|
|
Public Function RecreateCompoParm(ByRef ErrCompo As Compo, CurrPart As Part) As Boolean
|
|
Dim CompoListIndex As Integer = SearchCompotypeIndex(ErrCompo.CompoType.DDFName)
|
|
If CompoListIndex = -1 Then Return False
|
|
|
|
Dim IndexParam As Integer = 0
|
|
For IndexParam = 0 To ErrCompo.CompoParamList.Count - 1
|
|
If ErrCompo.CompoParamList(IndexParam).ErrorInReading Then
|
|
If TypeOf ErrCompo.CompoParamList(IndexParam) Is TextBoxParam Then
|
|
Dim Param As TextBoxParam = DirectCast(ErrCompo.CompoParamList(IndexParam), TextBoxParam)
|
|
Dim dVal As Double
|
|
If StringToDouble(Param.Value, dVal) Then
|
|
ErrCompo.CompoParamList(IndexParam).ErrorInReading = False
|
|
End If
|
|
ElseIf TypeOf ErrCompo.CompoParamList(IndexParam) Is ComboBoxParam Then
|
|
Dim Param As ComboBoxParam = DirectCast(ErrCompo.CompoParamList(IndexParam), ComboBoxParam)
|
|
Dim IndexItem As Integer = -1
|
|
For IndexItem = 0 To Param.ItemListDDF.Count - 1
|
|
If Param.SelItem = Param.ItemList(IndexItem) Then
|
|
If Param.ItemList.Count > Param.ItemListDDF.Count Then
|
|
Param.ItemList.RemoveAt(Param.ItemList.Count - 1)
|
|
End If
|
|
Param.ErrorInReading = False
|
|
Exit For
|
|
End If
|
|
Next
|
|
ElseIf TypeOf ErrCompo.CompoParamList(IndexParam) Is TextBoxOnOffParam Then
|
|
Dim Param As TextBoxOnOffParam = DirectCast(ErrCompo.CompoParamList(IndexParam), TextBoxOnOffParam)
|
|
Dim dVal As Double
|
|
If StringToDouble(Param.Value, dVal) Then
|
|
ErrCompo.CompoParamList(IndexParam).ErrorInReading = False
|
|
End If
|
|
ElseIf TypeOf ErrCompo.CompoParamList(IndexParam) Is ComboBoxOnOffParam Then
|
|
Dim Param As ComboBoxOnOffParam = DirectCast(ErrCompo.CompoParamList(IndexParam), ComboBoxOnOffParam)
|
|
For Each Item In Param.ItemListDDF
|
|
If Param.SelItem = Item Then
|
|
If Param.ItemList.Count > Param.ItemListDDF.Count Then
|
|
Param.ItemList.RemoveAt(Param.ItemList.Count - 1)
|
|
End If
|
|
Param.ErrorInReading = False
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
ErrCompo.ErrorValue = False
|
|
For Each Param In ErrCompo.CompoParamList
|
|
If Param.ErrorInReading Then
|
|
ErrCompo.ErrorValue = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
' rielegge il file temporaneo e qundi permette di stampare gli errori attuali
|
|
Public Function LoadTempFile() As Boolean
|
|
Dim sTempFile As String = IniFile.m_sTempDir & "\" & TEMP_FILE
|
|
If Not File.Exists(sTempFile) Then Return False
|
|
' verifico che un progetto esiste
|
|
If IsNothing(Map.refAssemblyManagerVM) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.SelAssembly) Then
|
|
Return False
|
|
End If
|
|
Dim TempAssembly As New Assembly
|
|
Assembly.ReadDDFAssembly(sTempFile, TempAssembly)
|
|
Try
|
|
File.Delete(sTempFile)
|
|
Catch
|
|
End Try
|
|
' If IsNothing(TempAssembly) Then Return False
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.SelAssembly = TempAssembly
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then
|
|
DdfFile.WriteDDFPart(TempAssembly.ListPartDoor(0).Door, sTempFile, False, False)
|
|
' aggiorno elenco quotature
|
|
Map.refDimensioningPanelVM.LoadHardwareDimList()
|
|
ExecDoors(Map.refSceneManagerVM.ProjectScene, sTempFile, False)
|
|
Map.refSceneManagerVM.ShowGraphicError()
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nDDFPage
|
|
' rendo visibili quotature
|
|
For Each HardwareDimension In Map.refDimensioningPanelVM.HardwareDimensionList
|
|
PrintWndVM.TurnDimensioningLayer(HardwareDimension.NameLayer, HardwareDimension.SelectedLayer)
|
|
Next
|
|
EgtZoom(ZM.ALL)
|
|
Else
|
|
' ! questa parte non funziona !
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage
|
|
DdfFile.WriteDDFAssembly(TempAssembly, sTempFile, False)
|
|
' aggiorno elenco quotature
|
|
Map.refDimensioningPanelVM.LoadHardwareDimList()
|
|
ExecDoors(Map.refSceneManagerVM.ProjectScene, sTempFile, False)
|
|
Map.refSceneManagerVM.ShowGraphicError()
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage
|
|
' rendo visibili quotature
|
|
For Each HardwareDimension In Map.refDimensioningPanelVM.HardwareDimensionList
|
|
PrintWndVM.TurnDimensioningLayer(HardwareDimension.NameLayer, HardwareDimension.SelectedLayer)
|
|
Next
|
|
EgtZoom(ZM.ALL)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Public Function Open(OpenedAssName As AssemblyName) As Boolean
|
|
If IsNothing(OpenedAssName) Then Return False
|
|
If Not File.Exists(OpenedAssName.Name) Then Return False
|
|
' resetto errori sui bevel edge
|
|
Part.FirstReadingEdge = False
|
|
' leggo il ddf e creo relativo assemblato
|
|
OpenedAssName.SelAssembly = New Assembly
|
|
Assembly.ReadDDFAssembly(OpenedAssName.Name, OpenedAssName.SelAssembly)
|
|
' definisco e rimuovo file temporaneo di assemblato
|
|
Dim sTempFile As String = IniFile.m_sTempDir & "\" & TEMP_FILE
|
|
Try
|
|
File.Delete(sTempFile)
|
|
Catch ex As Exception
|
|
End Try
|
|
' se l'apertura di un assemblato genera un errore esco
|
|
If IsNothing(OpenedAssName.SelAssembly) Then Return False
|
|
OpenedAssName.IsModified = Part.FirstReadingEdge
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then
|
|
DdfFile.WriteDDFPart(OpenedAssName.SelAssembly.ListPartDoor(0).Door, sTempFile, True, False)
|
|
' aggiorno elenco quotature
|
|
Map.refDimensioningPanelVM.LoadHardwareDimList()
|
|
ExecDoors(Map.refSceneManagerVM.ProjectScene, sTempFile, False)
|
|
Map.refSceneManagerVM.ShowGraphicError()
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nDDFPage
|
|
' rendo visibili quotature
|
|
For Each HardwareDimension In Map.refDimensioningPanelVM.HardwareDimensionList
|
|
PrintWndVM.TurnDimensioningLayer(HardwareDimension.NameLayer, HardwareDimension.SelectedLayer)
|
|
Next
|
|
EgtZoom(ZM.ALL)
|
|
Else
|
|
DdfFile.WriteDDFAssembly(OpenedAssName.SelAssembly, sTempFile, True)
|
|
' aggiorno elenco quotature
|
|
Map.refDimensioningPanelVM.LoadHardwareDimList()
|
|
ExecDoors(Map.refSceneManagerVM.ProjectScene, sTempFile, False)
|
|
Map.refSceneManagerVM.ShowGraphicError()
|
|
EgtZoom(ZM.ALL)
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage
|
|
End If
|
|
' ogni progetto salvato è l'ultimo da aprire, anche se il programma è chiuso dall'HardwareManager
|
|
' controllo che esiste almeno un file aperto
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) AndAlso
|
|
Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name) Then
|
|
WriteMainPrivateProfileString(S_LAUNCHERWINDOW, K_LASTPROJECT, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name)
|
|
Else
|
|
WriteMainPrivateProfileString(S_LAUNCHERWINDOW, K_LASTPROJECT, Map.refAssemblyManagerVM.CurrProject.Name)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Public Sub Delete(DeleteAssName As AssemblyName)
|
|
' Se il file esiste eliminalo
|
|
If File.Exists(DeleteAssName.Name) Then
|
|
Try
|
|
File.Delete(DeleteAssName.Name)
|
|
Catch ex As Exception
|
|
' non è un problema
|
|
End Try
|
|
End If
|
|
' Elimino anche il temporaneo
|
|
Dim sTempFile As String = IniFile.m_sTempDir & "\" & TEMP_FILE
|
|
Try
|
|
File.Delete(sTempFile)
|
|
Catch ex As Exception
|
|
End Try
|
|
' elimino dall'elenco dei file MruFiles
|
|
Map.refProjectManagerVM.m_MruFiles.Remove(DeleteAssName.Name)
|
|
' Salvo indice posizione elemento da eliminare
|
|
Dim SelIndex As Integer = m_CurrProject.AssemblyList.IndexOf(DeleteAssName)
|
|
m_CurrProject.AssemblyList.Remove(DeleteAssName)
|
|
If m_CurrProject.AssemblyList.Count > 0 Then
|
|
' aggiorno la porta da visualizzare
|
|
If SelIndex > m_CurrProject.AssemblyList.Count - 1 Then
|
|
m_CurrProject.SelAssemblyName = m_CurrProject.AssemblyList(m_CurrProject.AssemblyList.Count - 1)
|
|
Open(m_CurrProject.SelAssemblyName)
|
|
Else
|
|
m_CurrProject.SelAssemblyName = m_CurrProject.AssemblyList(SelIndex)
|
|
Open(m_CurrProject.SelAssemblyName)
|
|
End If
|
|
' se non ci sono altre porte nella lista allora
|
|
Else
|
|
' elimino qualsiasi resto di porta
|
|
m_CurrProject.SelAssemblyName = Nothing
|
|
' pulisco entry page
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
|
' elimino i nomi scritti nell'interstazione della pagina
|
|
Map.refMainWindowVM.ProjectNameMsg = ""
|
|
' aggiorno l'immagine a nulla
|
|
EgtNewFile()
|
|
EgtZoom(ZM.ALL)
|
|
End If
|
|
End Sub
|
|
|
|
Public Function ManageModified() As Boolean
|
|
' verifico se selezionato esiste e modificato
|
|
If Not IsNothing(m_CurrProject.SelAssemblyName) AndAlso m_CurrProject.SelAssemblyName.IsModified Then
|
|
Dim sText As String = String.Format(EgtMsg(50109), Path.GetFileNameWithoutExtension(m_CurrProject.SelAssemblyName.Name))
|
|
Select Case MessageBox.Show(sText, "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question)
|
|
Case MessageBoxResult.Yes
|
|
If Save(m_CurrProject.SelAssemblyName) Then
|
|
m_CurrProject.SelAssemblyName.IsModified = False
|
|
Else
|
|
Return False
|
|
End If
|
|
Case MessageBoxResult.No
|
|
If Not File.Exists(m_CurrProject.SelAssemblyName.Name) Then
|
|
Delete(m_CurrProject.SelAssemblyName)
|
|
Return False
|
|
Else
|
|
m_CurrProject.SelAssemblyName.IsModified = False
|
|
End If
|
|
Case MessageBoxResult.Cancel
|
|
Return False
|
|
End Select
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' Apertura e salvataggio
|
|
|
|
#Region "Creazione e caricamento degli oggetti dell'assemblato"
|
|
|
|
' creazione e di un nuovo assemblato
|
|
Friend Function CreateNewAssembly(value As String) As Assembly
|
|
' costruisco un nuvo assemblato e lo carico con i valori
|
|
Dim Local_SelAssembly As New Assembly
|
|
' carico i valori di default dell'assemblato
|
|
LoadAssemblyInformation(Local_SelAssembly)
|
|
' costruisco e carico le parti (Jamb)
|
|
CreateJamb(Local_SelAssembly)
|
|
' carico le info comuni a tutti i jamb
|
|
LoadOM_M_ET(Local_SelAssembly)
|
|
' carico il numero massimo di porte ammesse (e intanto dimesiono i jamb)
|
|
CreateDoor(Local_SelAssembly)
|
|
' carico come progetto corrente l'assemblato che sto creando in locale (così da poter gestire i Jamb), l'array delle porte è ancora vuoto!
|
|
m_CurrProject.SelAssemblyName.SelAssembly = Local_SelAssembly
|
|
' costruisco le associazioni tra i pezzi
|
|
CreateAssociation(Local_SelAssembly)
|
|
' carico le dimensioni dell'assemblato
|
|
Local_SelAssembly.SetNewDimensionAssembly()
|
|
Return Local_SelAssembly
|
|
End Function
|
|
|
|
' Caricamento dei dati della pagina generale degli assemblati
|
|
Public Sub LoadAssemblyInformation(CurrAssembly As Assembly)
|
|
' carico tutti le proprietà della classe Assembly
|
|
CurrAssembly.SetExterior(OptionModule.m_Exterior)
|
|
CurrAssembly.DoorListNumber = OptionModule.m_DoorsListNumber
|
|
CurrAssembly.SetThickness(OptionModule.m_ThicknessJamb)
|
|
CurrAssembly.SetWidth(OptionModule.m_WidthJamb)
|
|
CurrAssembly.SetLightUp(OptionModule.m_LightUp)
|
|
CurrAssembly.SetLightLock(OptionModule.m_LightLock)
|
|
CurrAssembly.SetLightBottom(OptionModule.m_LightBottom)
|
|
CurrAssembly.SetLightHinge(OptionModule.m_LightHinge)
|
|
CurrAssembly.SetThicknessHead(OptionModule.m_ThicknessHead)
|
|
CurrAssembly.SetOverlapHinge(OptionModule.m_OverlapHinge)
|
|
CurrAssembly.SetOverlapLock(OptionModule.m_OverlapLock)
|
|
CurrAssembly.SetOverlapTop(OptionModule.m_OverlapTop)
|
|
CurrAssembly.SetDeltaThickness(OptionModule.m_DeltaThickness)
|
|
CurrAssembly.SetLockEdgeType(OptionModule.m_LockEdgeTypeAssembly)
|
|
CurrAssembly.SetHingeEdgeType(OptionModule.m_HingeEdgeTypeAssembly)
|
|
CurrAssembly.SetTopType(OptionModule.m_TopTypeAssembly)
|
|
CurrAssembly.SetBottomType(OptionModule.m_BottomTypeAssembly)
|
|
CurrAssembly.SetLockEdgeMachining(OptionModule.m_LockEdgeMachiningAssembly)
|
|
CurrAssembly.SetHingeEdgeMachining(OptionModule.m_HingeEdgeMachiningAssembly)
|
|
CurrAssembly.SetTopMachining(OptionModule.m_TopMachiningAssembly)
|
|
CurrAssembly.SetBottomMachining(OptionModule.m_BottomMachiningAssembly)
|
|
CurrAssembly.SetLockEdgeOverMaterial(OptionModule.m_LockEdgeOverMaterialAssembly)
|
|
CurrAssembly.SetHingeEdgeOverMaterial(OptionModule.m_HingeEdgeOverMaterialAssembly)
|
|
CurrAssembly.SetTopOverMaterial(OptionModule.m_TopOverMaterialAssembly)
|
|
CurrAssembly.SetBottomOverMaterial(OptionModule.m_BottomOverMaterialAssembly)
|
|
CurrAssembly.SetDoorNumber(OptionModule.m_DoorsNumber)
|
|
CurrAssembly.SetDispositionItem(OptionModule.m_Disposition)
|
|
CurrAssembly.SetDimension(OptionModule.m_TotalDimension)
|
|
CurrAssembly.SetAssemblyHeight(OptionModule.m_TotalHeight)
|
|
CurrAssembly.SetAssemblyWidth(OptionModule.m_TotalWidth)
|
|
End Sub
|
|
|
|
' creazione dei jamb
|
|
Public Sub CreateJamb(ByRef CurrAssembly As Assembly, Optional bNewAssembly As Boolean = True)
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then Return
|
|
' in questa fase carico separatamete i valori di ogni jamb
|
|
' in particolare le differenze tra i jamb sono -> Type, -> le dimensioni (ThicknessHead = Door.Height)
|
|
' carico i valori del JambLeft ( solo se è selezionato nella pagina delle impostazioni)
|
|
If IsNothing(ReserchPartDoor("FL_")) Then
|
|
Dim LeftJamb As New PartDoor
|
|
LeftJamb.Door = New Part(LeftJamb)
|
|
LeftJamb.Door.TypePart = ConstGen.PART_FRAME_LEFT
|
|
LeftJamb.Door.SetThickness(CurrAssembly.Thickness)
|
|
LeftJamb.Door.SetWidth(CurrAssembly.Width)
|
|
' assegno la lista completa degli swing perchè la selezione dello swing corretto avviene nel programma
|
|
LeftJamb.Door.SwingTypeList = OptionModule.m_SwingTypeList
|
|
' definisce la disposizione (da selezionare in una sola anta)
|
|
LeftJamb.Door.SetDispositionItem(OptionModule.m_Disposition)
|
|
If bNewAssembly Then
|
|
LeftJamb.IsChecked = OptionModule.m_LeftJambChk
|
|
LeftJamb.Door.IsActive = OptionModule.m_LeftJambChk
|
|
Else
|
|
LeftJamb.IsChecked = False
|
|
LeftJamb.Door.IsActive = False
|
|
End If
|
|
CreateNewPropertiesListJamb(LeftJamb.Door.PropertiesList)
|
|
' aggiungo alla lista dei PartDoor
|
|
CurrAssembly.ListPartDoor.Add(LeftJamb)
|
|
End If
|
|
|
|
If IsNothing(ReserchPartDoor("FR_")) Then
|
|
' carico i valori del JambRight
|
|
Dim RightJamb As New PartDoor
|
|
RightJamb.Door = New Part(RightJamb)
|
|
RightJamb.Door.TypePart = ConstGen.PART_FRAME_RIGHT
|
|
RightJamb.Door.SetThickness(CurrAssembly.Thickness)
|
|
RightJamb.Door.SetWidth(CurrAssembly.Width)
|
|
' assegno la lista completa degli swing perchè la selezione dello swing corretto avviene nel programma
|
|
RightJamb.Door.SwingTypeList = OptionModule.m_SwingTypeList
|
|
' definisce la disposizione (da selezionare in una sola anta)
|
|
RightJamb.Door.SetDispositionItem(OptionModule.m_Disposition)
|
|
If bNewAssembly Then
|
|
RightJamb.IsChecked = OptionModule.m_RightJambChk
|
|
RightJamb.Door.IsActive = OptionModule.m_RightJambChk
|
|
Else
|
|
RightJamb.IsChecked = False
|
|
RightJamb.Door.IsActive = False
|
|
End If
|
|
CreateNewPropertiesListJamb(RightJamb.Door.PropertiesList)
|
|
' aggiungo alla lista dei PartDoor
|
|
CurrAssembly.ListPartDoor.Add(RightJamb)
|
|
End If
|
|
|
|
If IsNothing(ReserchPartDoor("FT_")) Then
|
|
' carico i valori del JambTop
|
|
Dim TopJamb As New PartDoor
|
|
TopJamb.Door = New Part(TopJamb)
|
|
TopJamb.Door.TypePart = ConstGen.PART_FRAME_TOP
|
|
TopJamb.Door.SetThickness(CurrAssembly.Thickness)
|
|
TopJamb.Door.SetHeight(CurrAssembly.ThicknessHead)
|
|
' assegno la lista completa degli swing perchè la selezione dello swing corretto avviene nel programma
|
|
TopJamb.Door.SwingTypeList = OptionModule.m_SwingTypeList
|
|
' definisce la disposizione (da selezionare in una sola anta)
|
|
TopJamb.Door.SetDispositionItem(OptionModule.m_Disposition)
|
|
If bNewAssembly Then
|
|
TopJamb.IsChecked = OptionModule.m_TopJambChk
|
|
TopJamb.Door.IsActive = OptionModule.m_TopJambChk
|
|
Else
|
|
TopJamb.IsChecked = False
|
|
TopJamb.Door.IsActive = False
|
|
End If
|
|
CreateNewPropertiesListJamb(TopJamb.Door.PropertiesList)
|
|
CurrAssembly.ListPartDoor.Add(TopJamb)
|
|
End If
|
|
|
|
If IsNothing(ReserchPartDoor("FB_")) AndAlso CurrAssembly.Exterior Then
|
|
Dim BottomJamb As New PartDoor
|
|
BottomJamb.Door = New Part(BottomJamb)
|
|
' carico i valori del JambBottom
|
|
BottomJamb.Door.TypePart = ConstGen.PART_FRAME_BOTTOM
|
|
BottomJamb.Door.SetThickness(CurrAssembly.Thickness)
|
|
BottomJamb.Door.SetHeight(CurrAssembly.Width)
|
|
' assegno la lista completa degli swing perchè la selezione dello swing corretto avviene nel programma
|
|
BottomJamb.Door.SwingTypeList = OptionModule.m_SwingTypeList
|
|
BottomJamb.Door.IsActive = OptionModule.m_BottomJambChk
|
|
' definisce la disposizione (da selezionare in una sola anta)
|
|
BottomJamb.Door.SetDispositionItem(OptionModule.m_Disposition)
|
|
CreateNewPropertiesListJamb(BottomJamb.Door.PropertiesList)
|
|
If bNewAssembly Then
|
|
BottomJamb.IsChecked = True
|
|
BottomJamb.IsChecked = OptionModule.m_TopJambChk
|
|
Else
|
|
BottomJamb.IsChecked = False
|
|
BottomJamb.IsChecked = False
|
|
End If
|
|
' aggiungo alla lista dei PartDoor
|
|
CurrAssembly.ListPartDoor.Add(BottomJamb)
|
|
ElseIf Not IsNothing(ReserchPartDoor("FB_")) AndAlso Not CurrAssembly.Exterior Then
|
|
Dim LocalJamb As PartDoor = ReserchPartDoor("FB_")
|
|
CurrAssembly.ListPartDoor.RemoveAt(CurrAssembly.ListPartDoor.IndexOf(ReserchPartDoor("FB_")))
|
|
LocalJamb = Nothing
|
|
End If
|
|
|
|
' i parametri che non sono ancora stati caricati sono:
|
|
' Swing -> dalla porta
|
|
' Size -> dalla porta
|
|
' OverMaterial -> LoadOM_M_ET
|
|
' Machining -> LoadOM_M_ET
|
|
' EdgeType -> LoadOM_M_ET
|
|
|
|
End Sub
|
|
|
|
' carica i valori di Overmaterial, Machining e EdgeType settati di Default
|
|
Public Sub LoadOM_M_ET(CurrAssembly As Assembly)
|
|
For IndexPartDoor As Integer = 0 To CurrAssembly.ListPartDoor.Count - 1
|
|
Dim Local_Part As Part = CurrAssembly.ListPartDoor(IndexPartDoor).Door
|
|
' se gli oggetti esistono gia vengono sempicemente ricaricati
|
|
If Local_Part.TypePart.Contains("F") Then
|
|
' OverMaterial
|
|
Local_Part.TopOverMaterial = CurrAssembly.TopOverMaterial
|
|
Local_Part.BottomOverMaterial = CurrAssembly.BottomOverMaterial
|
|
Local_Part.HingeEdgeOverMaterial = CurrAssembly.HingeEdgeOverMaterial
|
|
Local_Part.LockEdgeOverMaterial = CurrAssembly.LockEdgeOverMaterial
|
|
' Machining
|
|
Local_Part.TopMachining = CurrAssembly.TopMachining
|
|
Local_Part.BottomMachining = CurrAssembly.BottomMachining
|
|
Local_Part.HingeEdgeMachining = CurrAssembly.HingeEdgeMachining
|
|
Local_Part.LockEdgeMachining = CurrAssembly.LockEdgeMachining
|
|
' EdgeType
|
|
Local_Part.SetTopType(CurrAssembly.TopType)
|
|
Local_Part.SetBottomType(CurrAssembly.BottomType)
|
|
Local_Part.SetHingeEdgeType(CurrAssembly.HingeEdgeType)
|
|
Local_Part.SetLockEdgeType(CurrAssembly.LockEdgeType)
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
' creazione ante/eliminazione ante
|
|
Public Sub CreateDoor(ByRef CurrAssembly As Assembly)
|
|
Dim nDoorNumber As Integer
|
|
Dim sDN As String = "0"
|
|
Int32.TryParse(CurrAssembly.DoorNumber, nDoorNumber)
|
|
If nDoorNumber < 1 OrElse nDoorNumber > MAX_DOORNUMBER Then
|
|
nDoorNumber = 1
|
|
End If
|
|
If nDoorNumber > 0 Then sDN = "1"
|
|
' creo le Ante
|
|
For IndexDoor As Integer = 0 To nDoorNumber - 1
|
|
Dim Type As String = ConstGen.PART_DO_ & IndexDoor + 1
|
|
If IsNothing(ReserchPartDoor(Type)) Then
|
|
Dim Local_PartDoor As New PartDoor
|
|
Local_PartDoor.Door = New Part(Local_PartDoor)
|
|
Local_PartDoor.Door.TypePart = Type
|
|
' non viene caricato lo swing, che è carciato al termine del ciclo for
|
|
LoadDefaultSingleDoor(Local_PartDoor.Door, CStr(nDoorNumber))
|
|
Local_PartDoor.IsChecked = True
|
|
CreateNewPropertiesList(Local_PartDoor.Door.PropertiesList)
|
|
CurrAssembly.ListPartDoor.Add(Local_PartDoor)
|
|
End If
|
|
Next
|
|
|
|
' eliminazione porta
|
|
If nDoorNumber < CurrAssembly.ListPartDoorOfDoor.Count Then
|
|
If Not IsNothing(ReserchPartDoor("DO_2")) Then
|
|
Dim LocalPartDoor2 As PartDoor = ReserchPartDoor("DO_2")
|
|
Dim Type As String = "DO_2"
|
|
For IndexPartDoor As Integer = 0 To CurrAssembly.ListPartDoor.Count - 1
|
|
If CurrAssembly.ListPartDoor(IndexPartDoor).Type = Type Then
|
|
CurrAssembly.ListPartDoor.RemoveAt(IndexPartDoor)
|
|
Exit For
|
|
End If
|
|
Next
|
|
LocalPartDoor2.Door = Nothing
|
|
LocalPartDoor2 = Nothing
|
|
' aggiorno la lista delle ante
|
|
CurrAssembly.NotifyPropertyChanged("ListPartDoorOfDoor")
|
|
' devo eliminare tutti riferiemnti che possono esistere
|
|
CreateAssociation(CurrAssembly)
|
|
End If
|
|
End If
|
|
|
|
' prima di cambiare lo swing
|
|
Dim IndexSwing As Integer = 0
|
|
If Not IsNothing(ReserchPartDoor("DO_1")) Then
|
|
Dim LocalPartDorr As PartDoor = ReserchPartDoor("DO_1")
|
|
If LocalPartDorr.Door.TypePart.Contains("DO_1") Then
|
|
For Each Item In LocalPartDorr.Door.SwingTypeList
|
|
If Item = LocalPartDorr.Door.SwingAlias.AliasName Then
|
|
Exit For
|
|
End If
|
|
IndexSwing += 1
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
' carica la lista degli swing
|
|
For Each ItemPartDoor In CurrAssembly.ListPartDoorOfDoor
|
|
SetSwingOnDoor(CurrAssembly.DoorNumber, ItemPartDoor.Door, IndexSwing)
|
|
Next
|
|
CurrAssembly.NotifyPropertyChanged("ListPartDoorOfDoor")
|
|
End Sub
|
|
|
|
' carica i valori di default (dell'option page) nella prima porta
|
|
Public Sub LoadDefaultSingleDoor(ByRef ref_Part As Part, Optional ByVal sDN As String = "0")
|
|
ref_Part.SetWidth(OptionModule.m_Width)
|
|
ref_Part.SetHeight(OptionModule.m_Height)
|
|
ref_Part.SetThickness(OptionModule.m_Thickness)
|
|
ref_Part.IsActive = False
|
|
ref_Part.Measure = ConvertMmUnitsToString(OptionModule.m_bIsMmUnit)
|
|
ref_Part.Weight = OptionModule.m_Weight
|
|
ref_Part.SetLockEdgeType(OptionModule.m_LockEdgeType)
|
|
ref_Part.SetHingeEdgeType(OptionModule.m_HingeEdgeType)
|
|
ref_Part.SetTopType(OptionModule.m_TopType)
|
|
ref_Part.SetBottomType(OptionModule.m_BottomType)
|
|
ref_Part.LockEdgeMachining = OptionModule.m_LockEdgeMachining
|
|
ref_Part.HingeEdgeMachining = OptionModule.m_HingeEdgeMachining
|
|
ref_Part.TopMachining = OptionModule.m_TopMachining
|
|
ref_Part.BottomMachining = OptionModule.m_BottomMachining
|
|
ref_Part.LockEdgeOverMaterial = OptionModule.m_LockEdgeOverMaterial
|
|
ref_Part.HingeEdgeOverMaterial = OptionModule.m_HingeEdgeOverMaterial
|
|
ref_Part.TopOverMaterial = OptionModule.m_TopOverMaterial
|
|
ref_Part.BottomOverMaterial = OptionModule.m_BottomOverMaterial
|
|
ref_Part.SetDispositionItem(OptionModule.m_Disposition)
|
|
End Sub
|
|
|
|
' carica la lista degli swing a seconda del numero di porte selezionato
|
|
Public Sub SetSwingOnDoor(sDN As String, ByRef CurrPart As Part, nIndexSwing As Integer)
|
|
Select Case sDN
|
|
Case "1"
|
|
CurrPart.SwingTypeList = OptionModule.m_SwingTypeListSinlgeDoor
|
|
CurrPart.SetSwing(CurrPart.SwingTypeList(nIndexSwing))
|
|
Case "2"
|
|
If CurrPart.TypePart.Contains("DO_1") Then
|
|
CurrPart.SwingTypeList = OptionModule.m_SwingTypeListLeftDoor
|
|
CurrPart.SetSwing(CurrPart.SwingTypeList(nIndexSwing))
|
|
End If
|
|
If CurrPart.TypePart.Contains("DO_2") Then
|
|
CurrPart.SwingTypeList = OptionModule.m_SwingTypeListRightDoor
|
|
CurrPart.SetSwing(CurrPart.SwingTypeList(nIndexSwing))
|
|
End If
|
|
Case Else
|
|
CurrPart.SwingTypeList = OptionModule.m_SwingTypeList
|
|
CurrPart.SetSwing(OptionModule.m_Swing)
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region ' Creazione e caricamento degli oggetti dell'assemblato
|
|
|
|
#Region "Association"
|
|
|
|
' questa è la funzione principale che esegue l'aggiunta/aggiornamento dei riferimenti
|
|
' per tutti gli oggetti presenti nell'assemblato viene costruito il riferimento
|
|
Public Function CreateAssociation(ByRef CurrAssembly As Assembly) As Boolean
|
|
Dim TypePart As String = String.Empty
|
|
Dim LocalPd As PartDoor = Nothing
|
|
Dim nDN As Integer
|
|
Int32.TryParse(CurrAssembly.DoorNumber, nDN)
|
|
' ripulisco elimino le assiciazioni che non esisto più ( se elimino un'anta ricostruisco le giuste associazioni)
|
|
CleanAssociation()
|
|
For Each ItemPartDoor In CurrAssembly.ListPartDoor
|
|
' se l'oggetto che ricevo è di tipo Frame ripulisco il nome del tipo per ottenre le forma "FL", "FR", "FB", FT
|
|
If ItemPartDoor.Type.Contains("F") Then
|
|
TypePart = ItemPartDoor.Type.Remove(ItemPartDoor.Type.LastIndexOf("_"c))
|
|
Else
|
|
TypePart = ItemPartDoor.Type
|
|
End If
|
|
Select Case TypePart
|
|
Case "FL"
|
|
LocalPd = ReserchPartDoor("DO_1")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 100)
|
|
LocalPd = ReserchPartDoor("FT_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 200)
|
|
LocalPd = ReserchPartDoor("FB_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 400)
|
|
Case "FR"
|
|
If nDN = 1 Then
|
|
LocalPd = ReserchPartDoor("DO_1")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 300)
|
|
Else
|
|
' se esiste elimino la precedente associazione
|
|
DeleteAssociation(ReserchPartDoor("DO_1"), ItemPartDoor)
|
|
LocalPd = ReserchPartDoor("DO_2")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 300)
|
|
End If
|
|
LocalPd = ReserchPartDoor("FT_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 200)
|
|
LocalPd = ReserchPartDoor("FB_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 400)
|
|
Case "FT"
|
|
LocalPd = ReserchPartDoor("DO_1")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 400)
|
|
LocalPd = ReserchPartDoor("DO_2")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 400)
|
|
LocalPd = ReserchPartDoor("FL_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 400)
|
|
LocalPd = ReserchPartDoor("FR_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 400)
|
|
Case "FB"
|
|
LocalPd = ReserchPartDoor("DO_1")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 200)
|
|
LocalPd = ReserchPartDoor("DO_2")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 200)
|
|
LocalPd = ReserchPartDoor("FL_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 200)
|
|
LocalPd = ReserchPartDoor("FR_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 200)
|
|
Case "DO_1"
|
|
If nDN = 1 Then
|
|
LocalPd = ReserchPartDoor("FR_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 100)
|
|
Else
|
|
' se esiste elimino la precedente associazione
|
|
DeleteAssociation(ReserchPartDoor("FR_"), ItemPartDoor)
|
|
LocalPd = ReserchPartDoor("DO_2")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 100)
|
|
End If
|
|
LocalPd = ReserchPartDoor("FL_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 300)
|
|
LocalPd = ReserchPartDoor("FT_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 200)
|
|
LocalPd = ReserchPartDoor("FB_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 400)
|
|
Case "DO_2"
|
|
LocalPd = ReserchPartDoor("DO_1")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 300)
|
|
LocalPd = ReserchPartDoor("FL_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 300)
|
|
LocalPd = ReserchPartDoor("FR_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 100)
|
|
LocalPd = ReserchPartDoor("FT_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 200)
|
|
LocalPd = ReserchPartDoor("FB_")
|
|
BuildAssociation(ItemPartDoor, LocalPd, 400)
|
|
End Select
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
' in base al tipo (Type) di Part restistuisce il PartDoor associato
|
|
Public Function ReserchPartDoor(TypePart As String) As PartDoor
|
|
Dim PD As PartDoor = Nothing
|
|
If Not IsNothing(Map.refAssemblyPageVM.CurrAssembly) Then
|
|
For Each ItemPartDoor In Map.refAssemblyPageVM.CurrAssembly.ListPartDoor
|
|
If ItemPartDoor.Type.Contains(TypePart) Then
|
|
PD = ItemPartDoor
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
Return PD
|
|
End Function
|
|
|
|
' costruisce (sull'oeggto ItemPD) il riferimento all'ogetto passato (ReserchPD)
|
|
Public Function BuildAssociation(ByRef ItemPD As PartDoor, ByRef ReserchPd As PartDoor, nSide As Integer) As Boolean
|
|
If IsNothing(ReserchPd) Then Return False
|
|
' conto il numero di associazioni presenti sullo stesso lato
|
|
Dim CountAssociation As Integer = 0
|
|
For Each ItemAssociation In ItemPD.ListAssociation
|
|
If ItemAssociation.Side > nSide AndAlso ItemAssociation.Side < nSide + 100 Then
|
|
' se l'associazione esiste già allora esco
|
|
If ItemAssociation.refPartDoor.Type = ReserchPd.Type Then Return True
|
|
CountAssociation = 1 + CountAssociation
|
|
End If
|
|
Next
|
|
' quindi sommo uno (perchè è la nuova associazione)
|
|
CountAssociation = 1 + CountAssociation
|
|
Dim NewAssociation1 As New Association(ReserchPd, nSide + CountAssociation)
|
|
ItemPD.ListAssociation.Add(NewAssociation1)
|
|
Return True
|
|
End Function
|
|
|
|
' elimina le associazioni che hanno riferimenti nulli
|
|
Public Sub CleanAssociation()
|
|
If IsNothing(Map.refAssemblyPageVM) AndAlso IsNothing(Map.refAssemblyPageVM.CurrAssembly) Then Return
|
|
For Each ItemPartDoor In Map.refAssemblyPageVM.CurrAssembly.ListPartDoor
|
|
Dim ListIndexToRemove As New List(Of Integer)
|
|
' raccolgo l'elenco degli indici da eliminare
|
|
For IndexAssociation As Integer = 0 To ItemPartDoor.ListAssociation.Count - 1
|
|
If IsNothing(ItemPartDoor.ListAssociation(IndexAssociation).refPartDoor.Door) Then
|
|
ListIndexToRemove.Add(IndexAssociation)
|
|
End If
|
|
Next
|
|
' rimuovo dalla lista precedentemente analizzata
|
|
For Each ItemIndex In ListIndexToRemove
|
|
ItemPartDoor.ListAssociation.RemoveAt(ItemIndex)
|
|
Next
|
|
Next
|
|
End Sub
|
|
|
|
' elimina il PartDoor (DeletingAssication) dalla lista delle associazioni di un altro PartDoor (CurrPartDoor)
|
|
Public Sub DeleteAssociation(DeletingAssication As PartDoor, CurrPartDoor As PartDoor)
|
|
If Not IsNothing(DeletingAssication) Then
|
|
For Each ItemAssociated In CurrPartDoor.ListAssociation
|
|
If DeletingAssication.Type = ItemAssociated.refPartDoor.Type Then
|
|
CurrPartDoor.ListAssociation.RemoveAt(CurrPartDoor.ListAssociation.IndexOf(ItemAssociated))
|
|
Return
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region ' Association
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "AddDoor"
|
|
|
|
Public ReadOnly Property AddAssembly_Command As ICommand
|
|
Get
|
|
If m_cmdAddAssembly Is Nothing Then
|
|
m_cmdAddAssembly = New Command(AddressOf AddAssembly)
|
|
End If
|
|
Return m_cmdAddAssembly
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub AddAssembly()
|
|
' Gestisco porta corrente modificata
|
|
If Not ManageModified() Then Return
|
|
'---------------------------------------------------------------------------------------------------------------------------------------------------
|
|
' CHIEDO SE SI VUOLE IMPORTARE UN TEMPLATE
|
|
'Prima di tutto chiedo se vuole aprire un template
|
|
Dim sImportTemplate As String = ShowDialogImportTemplate()
|
|
'----------------------------------------------------------------------------------------------------------------------------------------------------
|
|
' Creo nuovo assembly
|
|
' Lancio la finestra per chiedere il nome dell'assemblato
|
|
Dim SaveFileDialog As New MySaveFileDialogVM
|
|
Dim SaveFileDialogWnd As New EgtWPFLib5.SaveFileDialogV(Application.Current.MainWindow, SaveFileDialog)
|
|
' New Door
|
|
SaveFileDialog.Title = EgtMsg(50113)
|
|
SaveFileDialog.Directory = m_CurrProject.Name
|
|
SaveFileDialog.Extension = DDF_EXTENSION
|
|
' Se annullo esco
|
|
If Not SaveFileDialogWnd.ShowDialog Then Return
|
|
' Controllo se il nome della porta ha estensione
|
|
If Path.HasExtension(SaveFileDialog.FileName) Then
|
|
Dim sExtension As String = Path.GetExtension(SaveFileDialog.FileName)
|
|
If Not sExtension.ToLower = DDF_EXTENSION Then
|
|
SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, DDF_EXTENSION)
|
|
End If
|
|
Else
|
|
SaveFileDialog.FileName &= DDF_EXTENSION
|
|
End If
|
|
' controllo che il nome non sia presente nella lista degli assemblati
|
|
Dim bNameExist As Boolean = False
|
|
Dim IndexDoorList As Integer
|
|
For IndexDoorList = 0 To m_CurrProject.AssemblyList.Count - 1
|
|
If m_CurrProject.AssemblyList(IndexDoorList).Name = SaveFileDialog.FileName Then
|
|
' se il nome è nella lista allora esco dal ciclo e rendo falsa la variabile bNameExist
|
|
bNameExist = True
|
|
Exit For
|
|
End If
|
|
bNameExist = False
|
|
Next
|
|
' se il nome è nella lista allora sovrascrivo la porta esistente
|
|
If bNameExist Then
|
|
' elimino la porta esistente
|
|
If File.Exists(SaveFileDialog.FileName) Then
|
|
Try
|
|
File.Delete(SaveFileDialog.FileName)
|
|
Catch ex As FileNotFoundException
|
|
' non è un problema
|
|
Catch ex As Exception
|
|
' non è un problema
|
|
End Try
|
|
End If
|
|
' elimino dalla lista
|
|
m_CurrProject.AssemblyList.RemoveAt(IndexDoorList)
|
|
End If
|
|
' aggiungo il nome del file alla lista degli assemblati
|
|
Dim Local_AssemblyName As New AssemblyName
|
|
Local_AssemblyName.Name = SaveFileDialog.FileName
|
|
m_CurrProject.AssemblyList.Add(Local_AssemblyName)
|
|
' Seleziono AssembyName creato
|
|
m_CurrProject.SelAssemblyName = Local_AssemblyName
|
|
' aggiorno la lista
|
|
'------------------------------------------------------------------------------------------------------------------------------------------------
|
|
' LETTURA DI UN FILE DI TIPO TEMPLATE
|
|
If ImportTemplate(sImportTemplate) Then Return
|
|
'------------------------------------------------------------------------------------------------------------------------------------------------
|
|
' Creo nuovo assembly (Solo se non ho importato un template!)
|
|
NewCmd(Local_AssemblyName)
|
|
' carico il nome come Assemblato selezionato
|
|
If Not OptionModule.m_DisableWindowOrder Then
|
|
Dim OrderWindow As New OrderV(Application.Current.MainWindow, New OrderVM())
|
|
OrderWindow.ShowDialog()
|
|
End If
|
|
End Sub
|
|
|
|
' carico il template nel ddf corrente
|
|
Public Function ImportTemplate(sTemplateFile As String) As Boolean
|
|
If Not String.IsNullOrEmpty(sTemplateFile) Then
|
|
' creo il file ddf associato al template
|
|
'm_CurrProject.SelAssemblyName.SelAssembly = CreateNewAssembly(ImportTemplate)
|
|
m_CurrProject.SelAssemblyName.SelAssembly = New Assembly
|
|
Assembly.ReadDDFAssembly(sTemplateFile, m_CurrProject.SelAssemblyName.SelAssembly)
|
|
Dim sTempFile As String = IniFile.m_sTempDir & "\" & TEMP_FILE
|
|
Try
|
|
File.Delete(sTempFile)
|
|
Catch ex As Exception
|
|
End Try
|
|
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then
|
|
DdfFile.WriteDDFPart(m_CurrProject.SelAssemblyName.SelAssembly.ListPartDoorOfDoor(0).Door, m_CurrProject.SelAssemblyName.Name, False, False)
|
|
DdfFile.WriteDDFPart(m_CurrProject.SelAssemblyName.SelAssembly.ListPartDoorOfDoor(0).Door, m_CurrProject.SelAssemblyName.Name, True, False)
|
|
' Va salvato ancora con i parametri perchè sotto viene riletto e ci devono ancora essere i parametri
|
|
DdfFile.WriteDDFPart(m_CurrProject.SelAssemblyName.SelAssembly.ListPartDoorOfDoor(0).Door, m_CurrProject.SelAssemblyName.Name, False, False)
|
|
' aggiorno elenco quotature
|
|
Map.refDimensioningPanelVM.LoadHardwareDimList()
|
|
ExecDoors(Map.refSceneManagerVM.ProjectScene, m_CurrProject.SelAssemblyName.Name, False)
|
|
Map.refSceneManagerVM.ShowGraphicError()
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nDDFPage
|
|
' rendo visibili quotature
|
|
For Each HardwareDimension In Map.refDimensioningPanelVM.HardwareDimensionList
|
|
PrintWndVM.TurnDimensioningLayer(HardwareDimension.NameLayer, HardwareDimension.SelectedLayer)
|
|
Next
|
|
EgtZoom(ZM.ALL)
|
|
Else
|
|
DdfFile.WriteDDFAssembly(m_CurrProject.SelAssemblyName.SelAssembly, m_CurrProject.SelAssemblyName.Name, False)
|
|
ExecDoors(Map.refSceneManagerVM.ProjectScene, sTempFile, False)
|
|
Map.refSceneManagerVM.ShowGraphicError()
|
|
EgtZoom(ZM.ALL)
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage
|
|
End If
|
|
|
|
If Open(m_CurrProject.SelAssemblyName) Then
|
|
m_CurrProject.SelAssemblyName.IsModified = True
|
|
' Cancello il file ancora con i parametri
|
|
File.Delete(m_CurrProject.SelAssemblyName.Name)
|
|
End If
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
' mostro chiedo di caricare un template e mostro a video browse per la ricerca dei file .ddt
|
|
Public Function ShowDialogImportTemplate() As String
|
|
If Not OptionModule.m_DisableTemplate Then
|
|
If Directory.GetFiles(IniFile.m_TemplateDir).Count < 1 Then Return String.Empty
|
|
If MessageBox.Show(EgtMsg(50146), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then
|
|
' Apro la finestra di dialogo aperta direttamente sulla cartella cercata
|
|
Dim OpenFileDialog As New Microsoft.Win32.OpenFileDialog() With {
|
|
.InitialDirectory = IniFile.m_TemplateDir
|
|
}
|
|
If OpenFileDialog.ShowDialog() <> True Then
|
|
' se la risposta è diversa da OK esce
|
|
Return String.Empty
|
|
End If
|
|
' carico l'indirizzo del template che voglio aprire
|
|
Return OpenFileDialog.FileName
|
|
End If
|
|
End If
|
|
Return String.Empty
|
|
End Function
|
|
|
|
#End Region ' AddDoor
|
|
|
|
#Region "RemoveAssembly"
|
|
|
|
Public ReadOnly Property RemoveAssembly_Command As ICommand
|
|
Get
|
|
If m_cmdRemoveAssembly Is Nothing Then
|
|
m_cmdRemoveAssembly = New Command(AddressOf RemoveAssembly)
|
|
End If
|
|
Return m_cmdRemoveAssembly
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub RemoveAssembly()
|
|
If IsNothing(CurrProject.SelAssemblyName) Then Return
|
|
Select Case MessageBox.Show(String.Format(EgtMsg(50116), Path.GetFileNameWithoutExtension(CurrProject.SelAssemblyName.Name)),
|
|
EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No)
|
|
Case MessageBoxResult.Yes
|
|
Delete(CurrProject.SelAssemblyName)
|
|
Case MessageBoxResult.No
|
|
' non faccio alcunchè
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region ' RemoveAssembly
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|