Files
EgtDOORCreator/AssemblyManager/AssemblyManagerVM.vb
T
Dario Sassi 7e7d78eec4 EgtDOORCreator :
- correzioni varie.
2017-11-27 05:40:53 +00:00

571 lines
26 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.IO
Imports EgtUILib
Public Class AssemblyManagerVM
Implements INotifyPropertyChanged
' percorso della porta corrente (creata o già esistente nella cartella)
Friend NewAssembly As Boolean = False
Friend DeleteNewPart As Integer = 1
Private SelAssembly As New Assembly
Friend MsgResult As MessageBoxResult
' 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_SelectedAssembly As New AssemblyName
Public Property SelectedAssembly As AssemblyName
Get
Return m_SelectedAssembly
End Get
Set(value As AssemblyName)
m_SelectedAssembly = value
NotifyPropertyChanged("SelectedAssembly")
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_cmdRemoveDoor As ICommand
Sub New()
Map.SetRefDoorManagerVM(Me)
End Sub
#Region "METHODS"
Private CreateRabbet As Boolean = False
#Region "Apertura e salvataggio"
Public Sub RemoveFromAssemblyList()
NewAssembly = False
Dim SelIndex As Integer = m_CurrProject.AssemblyList.IndexOf(m_SelectedAssembly)
m_CurrProject.AssemblyList.Remove(m_SelectedAssembly)
CurrProject.NotifyPropertyChanged("AssemblyList")
If m_CurrProject.AssemblyList.Count > 0 Then
' aggiorno la porta da visualizzare
If SelIndex > m_CurrProject.AssemblyList.Count - 1 Then
m_SelectedAssembly = m_CurrProject.AssemblyList(SelIndex - 1)
OpenSelectedAssembly(SelectedAssembly)
Else
m_SelectedAssembly = m_CurrProject.AssemblyList(SelIndex)
OpenSelectedAssembly(SelectedAssembly)
End If
CurrProject.NotifyPropertyChanged("AssemblyList")
' se non ci sono altre porte nella lista allora
Else
' elimino qualsiasi resto di porta
Map.refAssemblyPageVM.CurrAssembly = Nothing
' aggiorni l'immagine a nulla
EgtNewFile()
EgtZoom(ZM.ALL)
End If
End Sub
' salva il file corrente o se è stato appena creato lo elimina dalla lista
Friend Function SaveCurrentAssembly() As Boolean
' Se nessun elemento è selezionato allora continua
If IsNothing(m_SelectedAssembly) Then Return True
' Se l'elemento non è modificato allora continua
If Not m_SelectedAssembly.IsModify Then Return True
' Gestisco salvataggio dell'elemento
Dim sText As String = String.Format(EgtMsg(50109), Path.GetFileNameWithoutExtension(m_SelectedAssembly.Name))
MsgResult = MessageBox.Show(sText, EgtMsg(50110), MessageBoxButton.YesNoCancel, MessageBoxImage.Warning)
' Salvo
If MsgResult = MessageBoxResult.Yes Then
m_SelectedAssembly.IsModify = False
Part.FirstReadingEdge = False
SelectedAssembly.NotifyPropertyChanged("IsModify")
If Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.IsNotAssembly Then
DdfFile.WriteDDFPart(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door, m_SelectedAssembly.Name, True, False)
Else
DdfFile.WriteDDFAssembly(Map.refAssemblyPageVM.CurrAssembly, m_SelectedAssembly.Name, True)
End If
Return True
' Non salvo
ElseIf MsgResult = MessageBoxResult.No Then
' devo eliminare dall'elenco degli assemblati o non salvare nulla
Part.FirstReadingEdge = False
If Not File.Exists(m_SelectedAssembly.Name) Then
CurrProject.AssemblyList.Remove(m_SelectedAssembly)
Else
m_SelectedAssembly.IsModify = False
End If
Return True
' Interrompo operazione
Else
Return False
End If
End Function
' Apre il File in selezionato o crea un nuovo oggetto
Friend bSaveCurrent As Boolean = True
Public Function OpenSelectedAssembly(value As AssemblyName) As Boolean
If Not IsNothing(SelectedAssembly) Then
If Not IsNothing(m_SelectedAssembly.Name) AndAlso m_SelectedAssembly.Name = value.Name Then
Dim OrderWindow As New OrderV(Application.Current.MainWindow, Map.refOrderVM)
bSaveCurrent = True
If NewAssembly Then
OrderWindow.ShowDialog()
NewAssembly = False
End If
Else
bSaveCurrent = SaveCurrentAssembly()
SelectedAssembly = value
End If
Else
bSaveCurrent = SaveCurrentAssembly()
SelectedAssembly = value
End If
If bSaveCurrent Then
If File.Exists(m_SelectedAssembly.Name) Then
Map.refAssemblyPageVM.CurrAssembly = CreateNewAssembly(m_SelectedAssembly.Name)
Assembly.ReadDDFAssembly(m_SelectedAssembly.Name, Map.refAssemblyPageVM.CurrAssembly)
' se l'apertura di un assemblato genera un errore interrompi tutto
If IsNothing(Map.refAssemblyPageVM.CurrAssembly) Then
Return False
End If
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then
DdfFile.WriteDDFPart(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door, m_SelectedAssembly.Name, True, False)
Else
DdfFile.WriteDDFAssembly(Map.refAssemblyPageVM.CurrAssembly, IniFile.m_sTempDir & "\" & TEMP_ASSEMBLY, True)
End If
NotifyPropertyChanged("SelectedAssembly")
' se è avvenuta la modifica dei valori dei bevel devo avvisare che vi è stata una modifica
' dopo aver caricato tutti i valori all'apertura del progetto devo riportare la modifica a false
m_SelectedAssembly.IsModify = Part.FirstReadingEdge
If Not Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.IsNotAssembly Then
ExecDoors(Map.refSceneManagerVM.ProjectScene, IniFile.m_sTempDir & "\" & TEMP_ASSEMBLY, False)
Map.refSceneManagerVM.ComposeAssembly(SceneManagerVM.nComposeAssembly)
End If
Return True
Else
' modifico il nome dell'assemblato
m_SelectedAssembly.IsModify = True
CreateRabbet = True
Map.refAssemblyPageVM.CurrAssembly = CreateNewAssembly(m_SelectedAssembly.Name)
DdfFile.WriteDDFAssembly(Map.refAssemblyPageVM.CurrAssembly, IniFile.m_sTempDir & "\" & TEMP_ASSEMBLY, True)
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then
Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.IsNotAssembly = True
End If
If Not Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.IsNotAssembly Then
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage
ExecDoors(Map.refSceneManagerVM.ProjectScene, IniFile.m_sTempDir & "\" & TEMP_ASSEMBLY, False)
Map.refSceneManagerVM.ComposeAssembly(SceneManagerVM.nComposeAssembly)
CreateRabbet = False
Else
Assembly.ReadDDFAssembly(IniFile.m_sTempDir & "\" & TEMP_ASSEMBLY, Map.refAssemblyPageVM.CurrAssembly)
End If
NotifyPropertyChanged("SelectedAssembly")
Return True
End If
NewAssembly = False
'NotifyPropertyChanged("SelectedAssembly")
Else
Return False
End If
End Function
#End Region ' Apertura e salvataggio
#Region "Creazione e caricamento degli oggetti dell'assemblato"
' Caricamento dei dati della pagina generale degli assemblati
Friend Function CreateNewAssembly(value As String) As Assembly
'' se non esisteva nessuna porta allora posso procedere
'm_SelectedAssembly.Name = value
'NotifyPropertyChanged("SelectedAssembly")
' costruisco un nuvo assemblato e lo carico con i valori
Dim Local_SelAssembly As New Assembly
Local_SelAssembly.NewAssembly = NewAssembly
Local_SelAssembly.SetExterior(OptionModule.m_Exterior)
Local_SelAssembly.DoorListNumber = OptionModule.m_DoorsListNumber
' Carico tutti i vettori in sola lettura (i metodi set non contengono nessuna operazione)
Local_SelAssembly.SetThickness(OptionModule.m_ThicknessJamb)
Local_SelAssembly.SetWidth(OptionModule.m_WidthJamb)
Local_SelAssembly.SetLightUp(OptionModule.m_LightUp)
Local_SelAssembly.SetLightLock(OptionModule.m_LightLock)
Local_SelAssembly.SetLightBottom(OptionModule.m_LightBottom)
Local_SelAssembly.SetLightHinge(OptionModule.m_LightHinge)
Local_SelAssembly.SetThicknessHead(OptionModule.m_ThicknessHead)
Local_SelAssembly.SetOverlapHinge(OptionModule.m_OverlapHinge)
Local_SelAssembly.SetOverlapLock(OptionModule.m_OverlapLock)
Local_SelAssembly.SetOverlapTop(OptionModule.m_OverlapTop)
Local_SelAssembly.SetDeltaThickness(OptionModule.m_DeltaThickness)
Local_SelAssembly.SetLockEdgeType(OptionModule.m_LockEdgeTypeAssembly)
Local_SelAssembly.SetHingeEdgeType(OptionModule.m_HingeEdgeTypeAssembly)
Local_SelAssembly.SetTopType(OptionModule.m_TopTypeAssembly)
Local_SelAssembly.SetBottomType(OptionModule.m_BottomTypeAssembly)
Local_SelAssembly.SetLockEdgeMachining(OptionModule.m_LockEdgeMachiningAssembly)
Local_SelAssembly.SetHingeEdgeMachining(OptionModule.m_HingeEdgeMachiningAssembly)
Local_SelAssembly.SetTopMachining(OptionModule.m_TopMachiningAssembly)
Local_SelAssembly.SetBottomMachining(OptionModule.m_BottomMachiningAssembly)
Local_SelAssembly.SetLockEdgeOverMaterial(OptionModule.m_LockEdgeOverMaterialAssembly)
Local_SelAssembly.SetHingeEdgeOverMaterial(OptionModule.m_HingeEdgeOverMaterialAssembly)
Local_SelAssembly.SetTopOverMaterial(OptionModule.m_TopOverMaterialAssembly)
Local_SelAssembly.SetBottomOverMaterial(OptionModule.m_BottomOverMaterialAssembly)
Local_SelAssembly.SetDoorNumber(OptionModule.m_DoorsNumber)
' costruisco e carico le parti
CreatePart(Local_SelAssembly)
' carico l'assemblato che sto creando in locale (così da poter gestire i Jamb)
Map.refAssemblyPageVM.CurrAssembly = Local_SelAssembly
CreateDoor(Local_SelAssembly)
' calcolo la dimensione dei Jambs in funzione del numero di porte visibili
Local_SelAssembly.DoorVisibilityNew()
Local_SelAssembly.TopRabbetJamb()
'Local_SelAssembly.HingeRabbetJamb()
Return Local_SelAssembly
End Function
' creazione dei jamb
Private Sub CreatePart(ByRef CurrAssembly As Assembly)
CurrAssembly.LeftJamb = New Part
CurrAssembly.LeftJamb.TypePart = "FL_"
CurrAssembly.LeftJamb.SetThickness(CurrAssembly.Thickness)
CurrAssembly.LeftJamb.SetWidth(CurrAssembly.Width)
CurrAssembly.LeftJamb.SwingTypeList = OptionModule.m_SwingTypeList
CurrAssembly.LeftJamb.IsActive = OptionModule.m_LeftJambChk
CurrAssembly.RightJamb = New Part
CurrAssembly.RightJamb.TypePart = "FR_"
CurrAssembly.RightJamb.SetThickness(CurrAssembly.Thickness)
CurrAssembly.RightJamb.SetWidth(CurrAssembly.Width)
CurrAssembly.RightJamb.SwingTypeList = OptionModule.m_SwingTypeList
CurrAssembly.RightJamb.IsActive = OptionModule.m_RightJambChk
CurrAssembly.TopJamb = New Part
CurrAssembly.TopJamb.TypePart = "FT_"
CurrAssembly.TopJamb.SetThickness(CurrAssembly.Thickness)
CurrAssembly.TopJamb.SetHeight(CurrAssembly.ThicknessHead)
CurrAssembly.TopJamb.SwingTypeList = OptionModule.m_SwingTypeList
CurrAssembly.TopJamb.IsActive = OptionModule.m_TopJambChk
CurrAssembly.BottomJamb = New Part
CurrAssembly.BottomJamb.TypePart = "FB_"
CurrAssembly.BottomJamb.SetThickness(CurrAssembly.Thickness)
CurrAssembly.BottomJamb.SetHeight(CurrAssembly.Width)
CurrAssembly.BottomJamb.SwingTypeList = OptionModule.m_SwingTypeList
CurrAssembly.BottomJamb.IsActive = OptionModule.m_BottomJambChk
End Sub
' Caricamento del vettore delle porte, se già ne esiste uno esso viene sovrascritto con nuovi oggetti
Private Sub CreateDoor(ByRef CurrAssembly As Assembly)
CurrAssembly.LockEdgeType = CurrAssembly.LockEdgeType
CurrAssembly.HingeEdgeType = CurrAssembly.HingeEdgeType
CurrAssembly.TopType = CurrAssembly.TopType
CurrAssembly.BottomType = CurrAssembly.BottomType
CurrAssembly.LockEdgeMachining = CurrAssembly.LockEdgeMachining
CurrAssembly.HingeEdgeMachining = CurrAssembly.HingeEdgeMachining
CurrAssembly.TopMachining = CurrAssembly.TopMachining
CurrAssembly.BottomMachining = CurrAssembly.BottomMachining
CurrAssembly.LockEdgeOverMaterial = CurrAssembly.LockEdgeOverMaterial
CurrAssembly.HingeEdgeOverMaterial = CurrAssembly.HingeEdgeOverMaterial
CurrAssembly.TopOverMaterial = CurrAssembly.TopOverMaterial
CurrAssembly.BottomOverMaterial = CurrAssembly.BottomOverMaterial
' qui carico il vettore delle porte (se il vettore è vuoto)
Dim ref_PartDoor As PartDoor
Dim ref_Door As Part
For IndexDoor As Integer = 0 To K_DOORNUMBER
ref_PartDoor = New PartDoor
ref_Door = New Part
ref_Door.TypePart = "DO_" & IndexDoor + 1
LoadDefaultPartOne(ref_Door)
ref_PartDoor.Door = ref_Door
ref_PartDoor.IsChecked = True
CurrAssembly.ArrayPartDoor.Add(ref_PartDoor)
Next
End Sub
' carica i valori di default negli oggetti appena creati
Public Sub LoadDefaultPartOne(ByRef ref_Part As Part)
'OptionModule.GeneralDoor.CompoList.Clear()
'---------------------------------------------------------------------------------------------------------------
' Date le dimensioni della porta calcoliamo la dimensione dei Jamb
ref_Part.Width = OptionModule.m_Width
ref_Part.Height = OptionModule.m_Height
ref_Part.Thickness = OptionModule.m_Thickness
'---------------------------------------------------------------------------------------------------------------
' i parametri che seguono non influenzano in alcun modo i jamb
ref_Part.SetSwing(OptionModule.m_Swing)
ref_Part.IsActive = False
ref_Part.Measure = OptionModule.m_SelectedMeasureUnit
ref_Part.Weight = OptionModule.m_Weight
ref_Part.LockEdgeType = OptionModule.m_LockEdgeType
ref_Part.HingeEdgeType = OptionModule.m_HingeEdgeType
ref_Part.TopType = OptionModule.m_TopType
ref_Part.BottomType = 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
End Sub
#End Region ' Creazione e caricamento degli oggetti dell'assemblato
' controllo che tutti gli oggetti siano stati creati
Private Function CurrAssembyIsNotEmpty(ref_CurrAssembly As Assembly) As Boolean
Dim bJambExist As Boolean = False
Dim bDoorExist As Boolean = False
If Not IsNothing(ref_CurrAssembly.BottomJamb) Or Not IsNothing(ref_CurrAssembly.LeftJamb) Or Not IsNothing(ref_CurrAssembly.RightJamb) Or Not IsNothing(ref_CurrAssembly.TopJamb) Then
bJambExist = True
End If
If CInt(ref_CurrAssembly.DoorNumber) > 0 Then
bDoorExist = True
End If
If bJambExist And bDoorExist Then
Return True
Else
Return False
End If
Return False
End Function
Private Sub DeleteDoorFromList()
Dim SelIndex As Integer = m_CurrProject.AssemblyList.IndexOf(m_SelectedAssembly)
Dim ExtensionFile As String = Path.GetExtension(m_SelectedAssembly.Name)
Dim FileName As String = Path.GetFileName(m_SelectedAssembly.Name)
' modifico l'estensione del file
FileName = FileName.Replace(ExtensionFile, ".err")
' qui modifico il nome del file, ma ancora non è sostituito nel sistema
m_SelectedAssembly.Name = m_SelectedAssembly.Name.Replace(Path.GetFileName(m_SelectedAssembly.Name), FileName)
m_CurrProject.AssemblyList.RemoveAt(SelIndex)
CurrProject.NotifyPropertyChanged("AssemblyList")
' se la lista non è rimasta vuota
If m_CurrProject.AssemblyList.Count > 0 Then
' aggiorno la porta da visualizzare
If SelIndex > m_CurrProject.AssemblyList.Count - 1 Then
SelectedAssembly = m_CurrProject.AssemblyList(SelIndex - 1)
Else
SelectedAssembly = m_CurrProject.AssemblyList(SelIndex)
End If
' se non ci sono altre porte nella lista allora
Else
' elimino qualsiasi resto di porta
Map.refPartPageVM.CurrPart = Nothing
' aggiorni l'immagine a nulla
EgtNewFile()
EgtZoom(ZM.ALL)
End If
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "AddDoorCommand"
''' <summary>
''' Returns a command that do New.
''' </summary>
Public ReadOnly Property AddAssemblyCommand As ICommand
Get
If m_cmdAddAssembly Is Nothing Then
m_cmdAddAssembly = New Command(AddressOf AddAssembly)
End If
Return m_cmdAddAssembly
End Get
End Property
''' <summary>
''' Execute the New. This method is invoked by the NewCommand.
''' </summary>
Public Sub AddAssembly()
If Not SaveCurrentAssembly() Then
Exit Sub
End If
Dim NameExist As Boolean = True
Dim ImportTemplate As String = String.Empty
'---------------------------------------------------------------------------------------------------------------------------------------------------
' CHIEDO SE SI VUOLE IMPORTARE UN TEMPLATE
'Prima di tutto chiedo se vuole aprire un template
'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
' End If
' ' carico l'indirizzo del template che voglio aprire
' ImportTemplate = OpenFileDialog.FileName
'End If
'----------------------------------------------------------------------------------------------------------------------------------------------------
' lancio la finestra per la creazione di una nuova porta
Dim SaveFileDialog As New EgtWPFLib5.EgtSaveFileDialog
SaveFileDialog.Title = K_NEWDOOR
SaveFileDialog.Directory = m_CurrProject.Name
SaveFileDialog.Extension = K_DDFEXTENSION
' se decido di chiuedere la finestra
If Not SaveFileDialog.EgtShowDialog Then
Return
End If
' Controllo se ha estensione il nome della porta
If Path.HasExtension(SaveFileDialog.FileName) Then
Dim sExtension As String = Path.GetExtension(SaveFileDialog.FileName)
If Not sExtension.ToLower = K_DDFEXTENSION Then
SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, K_DDFEXTENSION)
End If
Else
SaveFileDialog.FileName &= K_DDFEXTENSION
End If
' controllo che il nome non sia presente nella lista
Dim bNameExist As Boolean = False
Dim IndexDoorList As Integer
For IndexDoorList = 0 To CurrProject.AssemblyList.Count - 1
If 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 sovrascirvo sulla porta esistente
If bNameExist Then
' elimino la porta esistente
File.Delete(SaveFileDialog.FileName)
' elimino dalla lista
m_CurrProject.AssemblyList.RemoveAt(IndexDoorList)
CurrProject.NotifyPropertyChanged("AssemblyList")
End If
' aggiungo il nome del file alla lista degli assemblati
Dim Local_AssemblyName As New AssemblyName
Local_AssemblyName.Name = SaveFileDialog.FileName
Local_AssemblyName.IsModify = False
CurrProject.AssemblyList.Add(Local_AssemblyName)
' aggiorno la lista
CurrProject.NotifyPropertyChanged("AssemblyList")
'------------------------------------------------------------------------------------------------------------------------------------------------
' LETTURA DI UN FILE DI TIPO TEMPLATE
'If String.IsNullOrEmpty(ImportTemplate) Then
' NewAssembly = True
'Else
' ' !!!!se sto aprendo un template significa che devo leggere un file già esistente!!!!
' NewAssembly = False
' ' creo il file ddf associato al template
' Map.refAssemblyPageVM.CurrAssembly = CreateNewAssembly(ImportTemplate)
' Assembly.ReadDDFAssembly(ImportTemplate, Map.refAssemblyPageVM.CurrAssembly)
' DdfFile.WriteDDFPart(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door, Local_AssemblyName.Name, True, False)
'End If
'------------------------------------------------------------------------------------------------------------------------------------------------
' carico il nome come Assemblato selezionato
Dim OrderWindow As New OrderV(Application.Current.MainWindow, New OrderVM())
OrderWindow.ShowDialog()
NewAssembly = True
OpenSelectedAssembly(Local_AssemblyName)
End Sub
#End Region ' AddDoorCommand
#Region "RemoveDoorCommand"
''' <summary>
''' Returns a command that do New.
''' </summary>
Public ReadOnly Property RemoveDoorCommand As ICommand
Get
If m_cmdRemoveDoor Is Nothing Then
m_cmdRemoveDoor = New Command(AddressOf RemoveAssembly)
End If
Return m_cmdRemoveDoor
End Get
End Property
''' <summary>
''' Execute the New. This method is invoked by the NewCommand.
''' </summary>
Public Sub RemoveAssembly()
Dim DeletingQuestion As Integer = 0
Dim DeletingResult As MessageBoxResult = MessageBoxResult.No
If IsNothing(m_SelectedAssembly) Then Return
''DeleteNewPart = -1
'' salvo il nome del file che sta per essere eliminato
'Dim RemoveDoorName As String = Path.GetFileNameWithoutExtension(m_SelectedAssembly)
''If Map.refPartPageVM.CurrPart.NewPart Then
'' ' se sono arrivato qui signifoca che sto chiudendo il programma con una porta nuova aperta ma non salvata
'' ' se ho dichiarato che non voglio salvare significa che devo eliminare
'' DeletingResult = MessageBoxResult.Yes
'Else
' ' stamp a video il messaggio per chiedere se eliminare
' DeletingResult = MessageBox.Show(String.Format(EgtMsg(50116), Path.GetFileNameWithoutExtension(m_SelectedAssembly)), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No)
'End if
DeletingResult = MessageBox.Show(String.Format(EgtMsg(50116), Path.GetFileNameWithoutExtension(m_SelectedAssembly.Name)), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No)
' chiedo se devo eliminere il file: se si
If DeletingResult = MessageBoxResult.Yes Then
' ricerco l'indice del file all'interno della lista delle porte
'SetNameCurrAssemblyAsSaved(m_SelectedAssembly)
'Dim SelIndex As Integer = m_CurrProject.AssemblyList.IndexOf(m_SelectedAssembly)
' elimino dall'elenco dei file
If File.Exists(m_SelectedAssembly.Name) Then
File.Delete(m_SelectedAssembly.Name)
End If
RemoveFromAssemblyList()
' elimino dalla lista
' m_CurrProject.AssemblyList.Remove(m_SelectedAssembly)
' CurrProject.NotifyPropertyChanged("AssemblyList")
' '' per quando torno nel m_SelectedDoor...per non chiedere di salvare o eliminare
' 'DeleteNewPart = -1
' '' se la lista non è rimasta vuota
' If m_CurrProject.AssemblyList.Count > 0 Then
' ' aggiorno la porta da visualizzare
' If SelIndex > m_CurrProject.AssemblyList.Count - 1 Then
' SelectedAssembly = m_CurrProject.AssemblyList(SelIndex - 1)
' OpenSelectedAssembly(SelectedAssembly)
' Else
' SelectedAssembly = m_CurrProject.AssemblyList(SelIndex)
' OpenSelectedAssembly(SelectedAssembly)
' End If
' ' se non ci sono altre porte nella lista allora
' Else
' ' elimino qualsiasi resto di porta
' Map.refJambPageVM.CurrAssembly = Nothing
' ' aggiorni l'immagine a nulla
' EgtNewFile()
' EgtZoom(ZM.ALL)
' End If
Else
'altrimenti salvo il file
DdfFile.WriteDDFAssembly(Map.refAssemblyPageVM.CurrAssembly, m_SelectedAssembly.Name, True)
End If
End Sub
#End Region ' RemoveDoorCommand
#End Region ' Commands
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class