30497d3ee6
- correzioni varie per decrementare sempre il conteggio di istanza all'uscita.
1790 lines
78 KiB
VB.net
1790 lines
78 KiB
VB.net
Imports combit.ListLabel25
|
|
Imports combit.ListLabel25.DataProviders
|
|
Imports System.Collections.ObjectModel
|
|
Imports System.Collections.Generic
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports Ionic.Zip
|
|
|
|
Public Class ProjectManagerVM
|
|
Implements INotifyPropertyChanged
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Friend m_CurrProject As Project
|
|
|
|
Friend m_MruFiles As New MruList
|
|
Public ReadOnly Property MruFileNames As ObservableCollection(Of String)
|
|
Get
|
|
Return m_MruFiles.FileNames
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DisableHM As Visibility
|
|
Get
|
|
If OptionModule.m_DisableHM Then
|
|
Return Visibility.Visible
|
|
Else
|
|
Return Visibility.Collapsed
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property VisibilityDeleteDDF As Visibility
|
|
Get
|
|
If OptionModule.m_SingleDoor Then
|
|
Return Visibility.Visible
|
|
Else
|
|
Return Visibility.Collapsed
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property VisibilityTemplate As Visibility
|
|
Get
|
|
If OptionModule.m_DisableTemplate Then
|
|
Return Visibility.Collapsed
|
|
Else
|
|
Return Visibility.Visible
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeleteProjectVisibility As Visibility
|
|
Get
|
|
If OptionModule.m_SingleDoor Then
|
|
Return Visibility.Visible
|
|
End If
|
|
If OptionModule.m_DeleteProject Then
|
|
Return Visibility.Visible
|
|
Else
|
|
Return Visibility.Collapsed
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property VisibilityEgtCAM As Visibility
|
|
Get
|
|
If String.IsNullOrEmpty(IniFile.m_sEgtCam5EXEPath) Then
|
|
Return Visibility.Collapsed
|
|
ElseIf Not File.Exists(IniFile.m_sEgtCam5EXEPath) Then
|
|
Return Visibility.Collapsed
|
|
ElseIf File.Exists(IniFile.m_sEgtCam5EXEPath) Then
|
|
Return Visibility.Visible
|
|
Else
|
|
Return Visibility.Collapsed
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Private m_IsModifiedImage As String = "/Resources/TopCommandBar/Save.png"
|
|
Public Property IsModifiedImage As String
|
|
Get
|
|
Return m_IsModifiedImage
|
|
End Get
|
|
Set(value As String)
|
|
m_IsModifiedImage = value
|
|
NotifyPropertyChanged("IsModifiedImage")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_DeleteProjectImg As String = "/Resources/TopCommandBar/Delete.png"
|
|
Public ReadOnly Property DeleteProjectImg As String
|
|
Get
|
|
If Not OptionModule.m_SingleDoor Then
|
|
m_DeleteProjectImg = "/Resources/TopCommandBar/DeleteDir.png"
|
|
End If
|
|
Return m_DeleteProjectImg
|
|
End Get
|
|
End Property
|
|
|
|
Private m_NewProjectImg As String = "/Resources/TopCommandBar/NewFile.png"
|
|
Public ReadOnly Property NewProjectImg As String
|
|
Get
|
|
If Not OptionModule.m_SingleDoor Then
|
|
m_NewProjectImg = "/Resources/TopCommandBar/NewDir.png"
|
|
End If
|
|
Return m_NewProjectImg
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EnableProjectManager As Boolean
|
|
Get
|
|
If Not IsNothing(Map.refInstrumentPanelVM) Then
|
|
Return Map.refInstrumentPanelVM.EnablePage
|
|
Else
|
|
Return True
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
' se in sola lettura il programma allora abilito solo i camndi Apertura e Stampa
|
|
Public ReadOnly Property EnableModifyDDF As Boolean
|
|
Get
|
|
Return Not OptionModule.ReadOnlyDDF
|
|
End Get
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdNew As ICommand
|
|
Private m_cmdDelete As ICommand
|
|
Private m_cmdOpen As ICommand
|
|
Private m_cmdOpenMruFile As ICommand
|
|
|
|
Private m_cmdReload As ICommand
|
|
|
|
Private m_cmdSave As ICommand
|
|
Private m_cmdSaveAs As ICommand
|
|
Private m_cmdInsert As ICommand
|
|
Private m_cmdImport As ICommand
|
|
Private m_cmdExport As ICommand
|
|
Private m_cmdPrint As ICommand
|
|
Private m_cmdOptions As ICommand
|
|
Private m_CmdLastProject As ICommand
|
|
Private m_cmdSendFeedback As ICommand
|
|
Private m_CmdCreateTemplate As ICommand
|
|
Private m_cmdGuide As ICommand
|
|
Private m_cmdCopy As ICommand
|
|
Private m_cmdDuplica As ICommand
|
|
Private m_cmdHardware As ICommand
|
|
Private m_cmdRefreshDir As ICommand
|
|
Private m_cmdCreateAssembly As ICommand
|
|
Private m_CmdOpenCam As ICommand
|
|
|
|
#Region "ToolTip"
|
|
|
|
'Proprietà ToolTip
|
|
Public ReadOnly Property NewToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_TOPCOMMANDBAR + 1)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property DeleteToolTip As String
|
|
Get
|
|
' Delete
|
|
Return EgtMsg(50126)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property OpenToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_TOPCOMMANDBAR + 2)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ReloadToolTip As String
|
|
Get
|
|
' 50421 = Reload Directories
|
|
Return EgtMsg(50421)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property SaveToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_TOPCOMMANDBAR + 3)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property SaveAsToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_TOPCOMMANDBAR + 4)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property InsertToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_TOPCOMMANDBAR + 5)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ImportToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_TOPCOMMANDBAR + 6)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property SendFeedbackToolTip As String
|
|
Get
|
|
Return EgtMsg(50046)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property OptionsToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 209)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property TemplateDoorToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 223)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GuideToolTip As String
|
|
Get
|
|
Return EgtMsg(50305)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Help As String
|
|
Get
|
|
Return EgtMsg(50305)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CopyToolTip As String
|
|
Get
|
|
' Export to machine
|
|
Return EgtMsg(50416)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property OpenCamToolTip As String
|
|
Get
|
|
Return "EgtCam5"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DuplicaToolTip As String
|
|
Get
|
|
' Save As
|
|
Return EgtMsg(50422)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property PrintToolTip As String
|
|
Get
|
|
' Print
|
|
Return EgtMsg(50411)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property HardwareToolTip As String
|
|
Get
|
|
' Hardware
|
|
Return EgtMsg(50413).ToUpper
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property DoorToolTip As String
|
|
Get
|
|
' Door
|
|
Return EgtMsg(50308).ToUpper
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CreateAssemblyToolTip As String
|
|
Get
|
|
' Create Assembly
|
|
Return EgtMsg(50420)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' ToolTip
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
Map.SetRefProjectManagerVM(Me)
|
|
' Impostazioni MruLists
|
|
m_MruFiles.Init(S_MRUFILES, 8)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "NewCommand"
|
|
|
|
Public ReadOnly Property NewCommand As ICommand
|
|
Get
|
|
If m_cmdNew Is Nothing Then
|
|
m_cmdNew = New Command(AddressOf NewCmd)
|
|
End If
|
|
Return m_cmdNew
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub NewCmd()
|
|
Utility.OutLog(" +++ NewProject +++")
|
|
' Gestisco porta corrente modificata
|
|
If Not Map.refAssemblyManagerVM.ManageModified() Then Return
|
|
' Modalità Progetto
|
|
If Not OptionModule.m_SingleDoor Then
|
|
Utility.UnLockDir()
|
|
' Richiedo il nome del progetto (cioè la directory da creare)
|
|
Dim SaveFileDialog As New MySaveFileDialogVM
|
|
Dim SaveFileDialogWnd As New EgtWPFLib5.SaveFileDialogV(Application.Current.MainWindow, SaveFileDialog)
|
|
SaveFileDialog.Title = EgtMsg(50304)
|
|
SaveFileDialog.Directory = IniFile.m_MyProjectDir
|
|
SaveFileDialog.Extension = "\"
|
|
' se non esite il direttorio blocco la creazione
|
|
If Not Directory.Exists(IniFile.m_MyProjectDir) Then
|
|
' 50562=Folder {0} does not exist. Check in OptionPage.
|
|
MessageBox.Show(String.Format(EgtMsg(50562), IniFile.m_MyProjectDir), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Utility.OutLog("Annullata la creazione di un nuovo progetto")
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
If Not String.IsNullOrEmpty(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
If Not Utility.IsFileLocked(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName
|
|
End If
|
|
End If
|
|
End If
|
|
Return
|
|
End If
|
|
' se annullo la creazione di un nuovo direttorio, rimango in quello attuale (verifico che l'ultimo file non sia già in lettura)
|
|
If Not SaveFileDialogWnd.ShowDialog Then
|
|
Utility.OutLog("Annullata la creazione di un nuovo progetto")
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
If Not String.IsNullOrEmpty(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
If Not Utility.IsFileLocked(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName
|
|
End If
|
|
End If
|
|
End If
|
|
Return
|
|
End If
|
|
' Se decido di continuare la creazione controllo che il direttorio non esista
|
|
Dim MsgResult As MessageBoxResult = MessageBoxResult.Yes
|
|
If Directory.Exists(SaveFileDialog.FileName) Then
|
|
' se il direttorio contiene almento un file di .lock esco
|
|
If Utility.IsFileLocked(SaveFileDialog.FileName) Then
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
If Not String.IsNullOrEmpty(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
If Not Utility.IsFileLocked(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName
|
|
End If
|
|
End If
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
' Vuoi sovrascrivere il direttorio?
|
|
String.Format(EgtMsg(50526), SaveFileDialog.FileName)
|
|
MsgResult = MessageBox.Show(String.Format(EgtMsg(50526), SaveFileDialog.FileName), EgtMsg(50144), MessageBoxButton.YesNo, MessageBoxImage.Asterisk)
|
|
' se decido di non cancellare il direttorio esco
|
|
If MsgResult = MessageBoxResult.No Then
|
|
Utility.OutLog("Annullata sovrascrittura delprogetto esistente : " & SaveFileDialog.FileName)
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
If Not String.IsNullOrEmpty(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
If Not Utility.IsFileLocked(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName
|
|
End If
|
|
End If
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
' cancello il direttorio
|
|
Try
|
|
Directory.Delete(SaveFileDialog.FileName, True)
|
|
Utility.OutLog("Sovrascrivo il progetto : " & SaveFileDialog.FileName)
|
|
Catch ex As Exception
|
|
' 50527 = Impossible to overwrite {0}
|
|
MessageBox.Show(String.Format(EgtMsg(50527), SaveFileDialog.FileName), EgtMsg(501001), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End Try
|
|
End If
|
|
' Se decido di non sovrascrivere allora rimango in quello attuale
|
|
|
|
Utility.OutLog("Creazione nuovo progetto : " & SaveFileDialog.FileName)
|
|
' Creo nuovo progetto
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
|
Directory.CreateDirectory(SaveFileDialog.FileName)
|
|
Dim CurrProject As Project = New Project
|
|
' salvo il riferimento al progetto corrente
|
|
m_CurrProject = CurrProject
|
|
' salvo path progetto
|
|
If SaveFileDialog.FileName.EndsWith("\") Then
|
|
SaveFileDialog.FileName = SaveFileDialog.FileName.Remove(SaveFileDialog.FileName.LastIndexOf("\"))
|
|
End If
|
|
CurrProject.Name = SaveFileDialog.FileName
|
|
' Ripulisco lista porte
|
|
CurrProject.AssemblyList.Clear()
|
|
EgtNewFile()
|
|
EgtZoom(ZM.ALL)
|
|
Map.refAssemblyManagerVM.CurrProject = CurrProject
|
|
Map.refMainWindowVM.ProjectNameMsg = CurrProject.Name
|
|
' Creo nuova porta
|
|
Map.refAssemblyManagerVM.AddAssembly()
|
|
' Map.refOptionsVM.MyProjectDir = CurrProject.Name
|
|
If Not IsNothing(CurrProject.SelAssemblyName) AndAlso Not String.IsNullOrEmpty(CurrProject.SelAssemblyName.GraphicName) Then
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName = CurrProject.SelAssemblyName
|
|
End If
|
|
Map.refAssemblyManagerVM.VisibilityDoorList = Visibility.Visible
|
|
Return
|
|
End If
|
|
'-------------------------------------------------------------------------------------------------------------------------
|
|
|
|
'Prima di tutto chiedo se vuole aprire un template
|
|
Dim sImportTemplate As String = Map.refAssemblyManagerVM.ShowDialogImportTemplate
|
|
|
|
' dichiaro la finestra di dialogo
|
|
Dim saveFileDialog1 As New System.Windows.Forms.SaveFileDialog()
|
|
saveFileDialog1.Filter = "(*.ddf) |*.ddf"
|
|
saveFileDialog1.FilterIndex = 2
|
|
saveFileDialog1.InitialDirectory = Map.refOptionsVM.MyProjectDir
|
|
' carico l'ultimo file, se questo procediento fallisce allora parto dal direttorio inserito di default
|
|
If File.Exists(OptionModule.m_sLastProject) Then
|
|
saveFileDialog1.InitialDirectory = Path.GetDirectoryName(OptionModule.m_sLastProject)
|
|
ElseIf Path.HasExtension(OptionModule.m_sLastProject) AndAlso Directory.Exists(Path.GetDirectoryName(OptionModule.m_sLastProject)) Then
|
|
saveFileDialog1.InitialDirectory = Path.GetDirectoryName(OptionModule.m_sLastProject)
|
|
ElseIf Not Path.HasExtension(OptionModule.m_sLastProject) AndAlso Directory.Exists(OptionModule.m_sLastProject) Then
|
|
saveFileDialog1.InitialDirectory = OptionModule.m_sLastProject
|
|
End If
|
|
' apro la finestra di dialogo
|
|
If saveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
|
|
' se decido di salvare
|
|
If Utility.IsFileLocked(Path.GetDirectoryName(saveFileDialog1.FileName), Path.GetFileNameWithoutExtension(saveFileDialog1.FileName)) Then
|
|
' apro l'ultimo progetto valido
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
If Not String.IsNullOrEmpty(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
Dim bShowMessage As Boolean = False
|
|
If Not Utility.IsFileLocked(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName, bShowMessage) Then
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName
|
|
End If
|
|
End If
|
|
End If
|
|
Return
|
|
End If
|
|
Utility.UnLockDir()
|
|
' elimino eventuali file con lo stesso nome
|
|
If File.Exists(saveFileDialog1.FileName) Then
|
|
Try
|
|
File.Delete(saveFileDialog1.FileName)
|
|
Catch ex As Exception
|
|
Utility.OutLog("Impossibilie sovrascrivere il file: " & saveFileDialog1.FileName)
|
|
Return
|
|
End Try
|
|
End If
|
|
|
|
Dim FilePath As String = Path.GetFileNameWithoutExtension(saveFileDialog1.FileName)
|
|
saveFileDialog1.FileName = saveFileDialog1.FileName.Replace(FilePath, Trim(FilePath))
|
|
Dim FilePathComplete As String = saveFileDialog1.FileName
|
|
Dim CurrProject As Project = New Project
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
CurrProject = Map.refAssemblyManagerVM.CurrProject
|
|
End If
|
|
|
|
' salvo il riferimento al progetto corrente
|
|
m_CurrProject = CurrProject
|
|
' salvo path progetto
|
|
CurrProject.Name = Path.GetDirectoryName(FilePathComplete)
|
|
' Ripulisco lista porte
|
|
CurrProject.AssemblyList.Clear()
|
|
EgtNewFile()
|
|
EgtZoom(ZM.ALL)
|
|
Map.refMainWindowVM.ProjectNameMsg = CurrProject.Name
|
|
' creo un nuovo assemblato
|
|
Dim Local_AssemblyName As New AssemblyName
|
|
Local_AssemblyName.Name = FilePathComplete
|
|
Local_AssemblyName.OrigTemplate = sImportTemplate
|
|
Local_AssemblyName.GraphicName = Path.GetFileNameWithoutExtension(FilePathComplete)
|
|
m_CurrProject.AssemblyList.Add(Local_AssemblyName)
|
|
' Seleziono AssembyName creato
|
|
m_CurrProject.SelAssemblyName = 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
|
|
' tolgo la visualizzazione della lista dei nomi
|
|
Map.refAssemblyManagerVM.CurrProject = CurrProject
|
|
Dim bImportedTemplate As Boolean = Map.refAssemblyManagerVM.ImportTemplate(sImportTemplate)
|
|
' Creo nuovo assembly
|
|
Map.refAssemblyManagerVM.NewCmd(Local_AssemblyName)
|
|
Utility.OutLog("Creazione nuovo progetto : " & saveFileDialog1.FileName)
|
|
Utility.LockDir(Path.GetDirectoryName(saveFileDialog1.FileName), Path.GetFileNameWithoutExtension(saveFileDialog1.FileName))
|
|
Map.refAssemblyManagerVM.VisibilityDoorList = Visibility.Collapsed
|
|
CurrProject.NotifyPropertyChanged("Name")
|
|
' Se l'importazione del template è andata a buon fine allora salvo
|
|
If bImportedTemplate Then
|
|
Save()
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region ' NewCommand
|
|
|
|
#Region "DeleteCommand"
|
|
|
|
Public ReadOnly Property DeleteCommand As ICommand
|
|
Get
|
|
If m_cmdDelete Is Nothing Then
|
|
m_cmdDelete = New Command(AddressOf DeleteCmd)
|
|
End If
|
|
Return m_cmdDelete
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub DeleteCmd()
|
|
Utility.OutLog(" +++ Delete +++")
|
|
Utility.UnLockDir()
|
|
If OptionModule.m_SingleDoor Then
|
|
Map.refAssemblyManagerVM.RemoveAssembly()
|
|
Else
|
|
DeleteProject()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Sub DeleteProject()
|
|
If Not OptionModule.m_DeleteProject Then Return
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse String.IsNullOrEmpty(Map.refAssemblyManagerVM.CurrProject.Name) Then
|
|
' 50535 = Impossible to delete a project if there is not a project!
|
|
MessageBox.Show(EgtMsg(50535), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
Return
|
|
End If
|
|
' 50536 = Do you want to delete entire project?
|
|
If MessageBox.Show(EgtMsg(50536), EgtMsg(50144), MessageBoxButton.YesNo, MessageBoxImage.Asterisk) <> MessageBoxResult.Yes Then
|
|
Return
|
|
End If
|
|
' svuoto il direttorio corrente dei file
|
|
If Not DeleteDDFFile(Map.refAssemblyManagerVM.CurrProject.Name) Then
|
|
Return
|
|
End If
|
|
' elimina il direttorio solo se è vuoto
|
|
Try
|
|
If Directory.GetFiles(Map.refAssemblyManagerVM.CurrProject.Name).Count = 0 Then
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
|
EgtNewFile()
|
|
EgtZoom(ZM.ALL)
|
|
Directory.Delete(Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Map.refAssemblyManagerVM.CurrProject = Nothing
|
|
Map.refAssemblyManagerVM.VisibilityDoorList = Visibility.Hidden
|
|
Map.refMainWindowVM.ProjectNameMsg = ""
|
|
Return
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) Then
|
|
Map.refAssemblyManagerVM.RefreshAssembly()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function DeleteDDFFile(sDirPath As String) As Boolean
|
|
' recupero l'elenco dei file presenti nel direttorio
|
|
Dim FileArray() As String = Directory.GetFiles(sDirPath)
|
|
' verificio che non ci siano file bloccati nel direttorio indicato
|
|
For Each sFile In FileArray
|
|
If Utility.IsFileLocked(Path.GetDirectoryName(sFile), Path.GetFileNameWithoutExtension(sFile)) Then
|
|
Return False
|
|
End If
|
|
Next
|
|
' procedo all'eliminazione dei file nel direttorio corrente
|
|
For Each sFile In FileArray
|
|
Try
|
|
File.Delete(sFile)
|
|
Catch ex As Exception
|
|
End Try
|
|
Next
|
|
' recupero l'elenco dei sottodirettori presenti nel direttorio corrente
|
|
Dim SubDirArray() As String = Directory.GetDirectories(sDirPath)
|
|
If SubDirArray.Count > 0 Then
|
|
For Each sSubDir In SubDirArray
|
|
' 50537 = Do you want to delete subdirectory {0} ?
|
|
If MessageBox.Show(String.Format(EgtMsg(50537), sSubDir), EgtMsg(50144), MessageBoxButton.YesNo, MessageBoxImage.Question) <> MessageBoxResult.Yes Then
|
|
Continue For
|
|
End If
|
|
' se decido di eliminare il sottodirettorio devo svuotarlo da tutti i file
|
|
If Not DeleteDDFFile(sSubDir) Then
|
|
Continue For
|
|
End If
|
|
Try
|
|
' se il direttorio è vuoto allora posso eliminarlo
|
|
If Directory.GetFiles(sSubDir).Count = 0 Then
|
|
Directory.Delete(sSubDir)
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
Next
|
|
End If
|
|
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' DeleteCommand
|
|
|
|
#Region "OpenCommand"
|
|
|
|
Public ReadOnly Property OpenCommand As ICommand
|
|
Get
|
|
If m_cmdOpen Is Nothing Then
|
|
m_cmdOpen = New Command(AddressOf Open)
|
|
End If
|
|
Return m_cmdOpen
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Open()
|
|
OpenProject("")
|
|
End Sub
|
|
|
|
Public Sub OpenProject(sFilePath As String)
|
|
Utility.OutLog(" +++ OpenProject +++")
|
|
'Utility.UnLockDir()
|
|
' se true carica una singola porta del progetto
|
|
Dim bIsSingleDoor As Boolean = OptionModule.m_SingleDoor
|
|
Dim sFilePathComplete As String = String.Empty
|
|
Dim bValidPath As Boolean = False
|
|
' verifico se selezionato esiste e modificato
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) AndAlso Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified Then
|
|
Dim sText As String = String.Format(EgtMsg(50109), Path.GetFileNameWithoutExtension(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name))
|
|
Select Case MessageBox.Show(sText, "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question)
|
|
Case MessageBoxResult.Yes
|
|
Map.refAssemblyManagerVM.Save(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName)
|
|
Case MessageBoxResult.No
|
|
Utility.UnLockDir()
|
|
Case MessageBoxResult.Cancel
|
|
Return
|
|
End Select
|
|
End If
|
|
|
|
' VERIFICO IL NOME PROGETTO ( DIERTTORIO/ FILE)
|
|
If Directory.Exists(sFilePath) AndAlso bIsSingleDoor Then
|
|
m_MruFiles.Remove(sFilePath)
|
|
bValidPath = False
|
|
ElseIf Directory.Exists(sFilePath) AndAlso Not bIsSingleDoor Then
|
|
sFilePathComplete = sFilePath
|
|
bValidPath = True
|
|
ElseIf File.Exists(sFilePath) Then
|
|
sFilePathComplete = sFilePath
|
|
sFilePath = Path.GetDirectoryName(sFilePath)
|
|
' se esiste un file in lettura con questo nome allora blocco tutto
|
|
If Utility.IsFileLocked(sFilePath, Path.GetFileNameWithoutExtension(sFilePathComplete)) Then
|
|
Utility.OutLog("Annullo l'apertura di : " & sFilePathComplete)
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Utility.LockDir(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName)
|
|
'Map.refAssemblyManagerVM.Open(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName)
|
|
End If
|
|
Return
|
|
End If
|
|
bValidPath = True
|
|
Else
|
|
' elimino eventual FilePath inesistente dalla lista dei recenti
|
|
m_MruFiles.Remove(sFilePath)
|
|
bValidPath = False
|
|
End If
|
|
|
|
' CARCIO IL NOME DIRETTORIO
|
|
' Se FilePath non valida
|
|
If Not bValidPath Then
|
|
'If OptionModule.m_SingleDoor OrElse Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) Then
|
|
' se in modalità porta singola
|
|
If OptionModule.m_SingleDoor Then
|
|
bIsSingleDoor = True
|
|
' definisco la finestra di dialogo per la scelta dei file
|
|
Dim fd As System.Windows.Forms.OpenFileDialog = New System.Windows.Forms.OpenFileDialog()
|
|
' 50559=Open File Dialog
|
|
fd.Title = EgtMsg(50559)
|
|
' indirizzo la scelta verso una cartella
|
|
fd.InitialDirectory = Map.refOptionsVM.MyProjectDir
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not String.IsNullOrWhiteSpace(Map.refAssemblyManagerVM.CurrProject.Name) Then
|
|
fd.InitialDirectory = Map.refAssemblyManagerVM.CurrProject.Name
|
|
ElseIf Not String.IsNullOrEmpty(OptionModule.m_sLastProject) Then
|
|
fd.InitialDirectory = Path.GetDirectoryName(OptionModule.m_sLastProject)
|
|
Else
|
|
fd.InitialDirectory = IniFile.m_MyProjectDir
|
|
End If
|
|
' seleziono il filtro di apertura
|
|
fd.Filter = "(*.ddf) |*.ddf|(*.ddt) |*.ddt"
|
|
fd.FilterIndex = GetCurrentFilter()
|
|
fd.RestoreDirectory = True
|
|
' apro la finestra di dialogo
|
|
If fd.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Utility.LockDir(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName)
|
|
End If
|
|
Return
|
|
End If
|
|
Utility.UnLockDir()
|
|
' salvo il nome del direttorio
|
|
sFilePath = Path.GetDirectoryName(fd.FileName)
|
|
' salvo il nome completo del file
|
|
sFilePathComplete = fd.FileName
|
|
' salvo l'estensione dell'ultimo progetto aperto
|
|
WriteMainPrivateProfileString("General", "LastExtensionOpened", Path.GetExtension(fd.FileName).ToLower)
|
|
' se esiste un file in lettura con questo nome allora blocco tutto
|
|
If Utility.IsFileLocked(sFilePath, Path.GetFileNameWithoutExtension(sFilePathComplete)) Then
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Utility.LockDir(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName)
|
|
End If
|
|
Return
|
|
End If
|
|
Else
|
|
' dichiaro la finestra di scelta cartella di progetto
|
|
Dim FolderBrowserDialog As New System.Windows.Forms.FolderBrowserDialog
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not String.IsNullOrWhiteSpace(Map.refAssemblyManagerVM.CurrProject.Name) Then
|
|
FolderBrowserDialog.SelectedPath = Map.refAssemblyManagerVM.CurrProject.Name
|
|
ElseIf Not String.IsNullOrEmpty(OptionModule.m_sLastProject) Then
|
|
FolderBrowserDialog.SelectedPath = Path.GetDirectoryName(OptionModule.m_sLastProject)
|
|
Else
|
|
FolderBrowserDialog.SelectedPath = IniFile.m_MyProjectDir
|
|
End If
|
|
' mostriamo la finestra di dialogo aperta nel direttorio selzionato sopra
|
|
If FolderBrowserDialog.ShowDialog <> Forms.DialogResult.OK Then
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Utility.LockDir(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName)
|
|
End If
|
|
' se la risposta è diversa da OK esce
|
|
Return
|
|
End If
|
|
' salvo il nome del direttorio
|
|
sFilePath = FolderBrowserDialog.SelectedPath
|
|
' se sto eseguendo la selezione dello stesso direttorio allora interrompo
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) Then
|
|
If Map.refAssemblyManagerVM.CurrProject.Name = sFilePath Then
|
|
Return
|
|
End If
|
|
End If
|
|
' se esiste un file in lettura con questo nome allora blocco tutto
|
|
'If Utility.VerifyFileLocked(sFilePath) Then
|
|
' Return
|
|
'End If
|
|
End If
|
|
End If
|
|
|
|
' CARICO ELENCO FILE
|
|
Dim CurrProject As Project = New Project
|
|
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) Then
|
|
CurrProject = Map.refAssemblyManagerVM.CurrProject
|
|
Else
|
|
Map.refAssemblyManagerVM.CurrProject = CurrProject
|
|
End If
|
|
' salvo il riferimento al progetto corrente
|
|
m_CurrProject = CurrProject
|
|
' salvo path progetto
|
|
CurrProject.Name = sFilePath
|
|
' Ripulisco lista porte
|
|
CurrProject.AssemblyList.Clear()
|
|
|
|
' caricamento elenco porte
|
|
If Not bIsSingleDoor Then
|
|
' Aggiungo porte trovate nella cartella ad un vettore
|
|
Dim DDFFileArray() As String = Directory.GetFiles(sFilePath)
|
|
' ripulisco il nome della porta (cancello tutto il percorso del file lasciando solo il nome del file)
|
|
For DDFIndex = 0 To DDFFileArray.Count - 1
|
|
If Path.GetExtension(DDFFileArray(DDFIndex)).ToLower = ".ddf" Then
|
|
' lo aggiungo alla lista delle porte
|
|
Dim Local_Assembly As New AssemblyName
|
|
Local_Assembly.Name = DDFFileArray(DDFIndex)
|
|
Local_Assembly.IsModified = False
|
|
CurrProject.AssemblyList.Add(Local_Assembly)
|
|
End If
|
|
Next
|
|
Else
|
|
' carcio la singola porta
|
|
Dim Local_Assembly As New AssemblyName
|
|
Local_Assembly.Name = sFilePathComplete
|
|
Local_Assembly.IsModified = False
|
|
CurrProject.AssemblyList.Add(Local_Assembly)
|
|
End If
|
|
|
|
' SELEZIONE FILE DA ELENCO
|
|
' Notifico aggiornamento DoorList per aggiornare la grafica
|
|
CurrProject.NotifyPropertyChanged("AssemblyList")
|
|
Utility.UnLockDir()
|
|
' Se c'è almeno una porta la visualizzo
|
|
If CurrProject.AssemblyList.Count > 0 Then
|
|
Dim bAssemblyIsSelected As Boolean = False
|
|
If Not String.IsNullOrWhiteSpace(sFilePathComplete) Then
|
|
For Each ItemFile In CurrProject.AssemblyList
|
|
If sFilePathComplete = ItemFile.Name Then
|
|
If Not Utility.IsFileLocked(Path.GetDirectoryName(ItemFile.Name), ItemFile.GraphicName, False) Then
|
|
CurrProject.SelAssemblyName = ItemFile
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Utility.LockDir(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName)
|
|
bAssemblyIsSelected = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
If Not bAssemblyIsSelected Then
|
|
For IndexFile As Integer = 0 To CurrProject.AssemblyList.Count - 1
|
|
If Not Utility.IsFileLocked(Path.GetDirectoryName(CurrProject.AssemblyList(IndexFile).Name), CurrProject.AssemblyList(IndexFile).GraphicName, False) Then
|
|
CurrProject.SelAssemblyName = CurrProject.AssemblyList(IndexFile)
|
|
Utility.OutLog("Apertura progetto : " & Map.refAssemblyManagerVM.CurrProject.Name)
|
|
Utility.LockDir(Map.refAssemblyManagerVM.CurrProject.Name, Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName)
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
Else
|
|
Map.refPartPageVM.CurrPart = Nothing
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
|
EgtNewFile()
|
|
EgtZoom(ZM.ALL)
|
|
End If
|
|
|
|
' carico il nome del direttorio e la visbilità della lista delle porte
|
|
If bIsSingleDoor Then
|
|
If Not IsNothing(CurrProject.SelAssemblyName.Name) Then
|
|
Map.refMainWindowVM.ProjectNameMsg = CurrProject.SelAssemblyName.Name
|
|
End If
|
|
Map.refAssemblyManagerVM.VisibilityDoorList = Visibility.Collapsed
|
|
Else
|
|
Map.refMainWindowVM.ProjectNameMsg = CurrProject.Name
|
|
Map.refAssemblyManagerVM.VisibilityDoorList = Visibility.Visible
|
|
End If
|
|
' aggiorno la grafica
|
|
CurrProject.NotifyPropertyChanged("Name")
|
|
' salvo il nome del file corrente in lettura
|
|
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
|
|
|
|
' Aggiungo alla lista dei recenti/ verifico se esite anche se posso salvare un indirizzo comlpeto
|
|
If bIsSingleDoor Then
|
|
m_MruFiles.Add(CurrProject.SelAssemblyName.Name)
|
|
Else
|
|
m_MruFiles.Add(sFilePath)
|
|
End If
|
|
End Sub
|
|
|
|
Private Function GetCurrentFilter() As Integer
|
|
Dim nFilter As Integer = 1
|
|
Dim sExt As String = String.Empty
|
|
GetMainPrivateProfileString("General", "LastExtensionOpened", "ddf", sExt)
|
|
sExt = sExt.Replace("."c, "")
|
|
sExt = sExt.Trim
|
|
Select Case sExt
|
|
Case = "ddf"
|
|
nFilter = 1
|
|
Case = "ddt"
|
|
nFilter = 2
|
|
End Select
|
|
Return nFilter
|
|
End Function
|
|
|
|
#End Region ' OpenCommand
|
|
|
|
#Region "OpenMruFileCommand"
|
|
|
|
Public ReadOnly Property OpenMruFileCommand As ICommand
|
|
Get
|
|
If m_cmdOpenMruFile Is Nothing Then
|
|
m_cmdOpenMruFile = New Command(AddressOf OpenMruFile)
|
|
End If
|
|
Return m_cmdOpenMruFile
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub OpenMruFile(ByVal param As Object)
|
|
Dim sLastProject As String = DirectCast(param, String).Replace("__", "_")
|
|
Utility.UnLockDir()
|
|
OpenProject(sLastProject)
|
|
End Sub
|
|
|
|
#End Region ' OpenMruFileCommand
|
|
|
|
#Region "ReloadCommand"
|
|
|
|
Public ReadOnly Property ReloadCommand As ICommand
|
|
Get
|
|
If m_cmdReload Is Nothing Then
|
|
m_cmdReload = New Command(AddressOf ReloadCmd)
|
|
End If
|
|
Return m_cmdReload
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ReloadCmd()
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then Map.SetRefCompoPanelVM(New CompoPanelVM("PartPage"))
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
Return
|
|
End If
|
|
' Map.refAssemblyManagerVM.LoadTempFile()
|
|
' Map.refMainWindowVM.selectedWatcher = MainWindowVM.WatcherCalling.OnLoadTempFile
|
|
Map.refAssemblyManagerVM.RefreshAssembly()
|
|
Map.refSceneManagerVM.RefreshBtn()
|
|
End Sub
|
|
|
|
#End Region ' ReloadCommand
|
|
|
|
#Region "SaveCommand"
|
|
|
|
Public ReadOnly Property SaveCommand As ICommand
|
|
Get
|
|
If m_cmdSave Is Nothing Then
|
|
m_cmdSave = New Command(AddressOf Save)
|
|
End If
|
|
Return m_cmdSave
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Save()
|
|
' Verifico esista elemento selezionato
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) OrElse IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name) Then
|
|
' Impossibile savare un file se non esiste una porta! Errore
|
|
MessageBox.Show(EgtMsg(50128), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
Return
|
|
End If
|
|
' Eseguo salvataggio
|
|
Map.refAssemblyManagerVM.Save(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName)
|
|
If DdfFile.DDFIsCorrect Then Map.refSceneManagerVM.RefreshBtn() ' aggiorno l'immagine solo se il salvataggio è andato a buon fine
|
|
' Aggiungo alla lista dei recenti/ verifico se esite anche se posso salvare un indirizzo comlpeto
|
|
' Map.refOptionsVM.MyProjectDir = Map.refAssemblyManagerVM.CurrProject.Name
|
|
If OptionModule.m_SingleDoor Then
|
|
m_MruFiles.Add(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name)
|
|
Else
|
|
m_MruFiles.Add(Map.refAssemblyManagerVM.CurrProject.Name)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' SaveCommand
|
|
|
|
#Region "OptionsCommand"
|
|
|
|
Public ReadOnly Property OptionsCommand As ICommand
|
|
Get
|
|
If m_cmdOptions Is Nothing Then
|
|
m_cmdOptions = New Command(AddressOf Options)
|
|
End If
|
|
Return m_cmdOptions
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Options(ByVal param As Object)
|
|
Dim OptionsWindow As New OptionsV
|
|
OptionsWindow.Height = 800
|
|
OptionsWindow.Width = 650
|
|
OptionsWindow.DataContext = New OptionsVM()
|
|
OptionsWindow.Owner = Application.Current.MainWindow
|
|
OptionsWindow.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' OptionsCommand
|
|
|
|
#Region "LastProject"
|
|
|
|
Public ReadOnly Property LastProjectCommand As ICommand
|
|
Get
|
|
If m_CmdLastProject Is Nothing Then
|
|
m_CmdLastProject = New Command(AddressOf OpenLastProject)
|
|
End If
|
|
Return m_CmdLastProject
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub OpenLastProject()
|
|
Utility.OutLog(" +++ OpenLastProject +++")
|
|
Dim CurrProject As Project = Map.refAssemblyManagerVM.CurrProject
|
|
' carico il percorso dell'ultimo progetto salvato (sul file Config.ini)
|
|
If IsNothing(CurrProject.Name) Then
|
|
If File.Exists(OptionModule.m_sLastProject) Then
|
|
CurrProject.Name = Path.GetDirectoryName(OptionModule.m_sLastProject)
|
|
ElseIf Path.HasExtension(OptionModule.m_sLastProject) AndAlso Directory.Exists(Path.GetDirectoryName(OptionModule.m_sLastProject)) Then
|
|
CurrProject.Name = Path.GetDirectoryName(OptionModule.m_sLastProject)
|
|
ElseIf Not Path.HasExtension(OptionModule.m_sLastProject) AndAlso Directory.Exists(OptionModule.m_sLastProject) Then
|
|
CurrProject.Name = OptionModule.m_sLastProject
|
|
End If
|
|
End If
|
|
|
|
' CARICAMENTO LISTA
|
|
' ripulisco la lista di porte
|
|
CurrProject.AssemblyList.Clear()
|
|
' verifico che esista la cartella
|
|
If Directory.Exists(CurrProject.Name) Then
|
|
' se sono in modalità porta singola
|
|
If OptionModule.m_SingleDoor Then
|
|
Dim Local_Assembly As New AssemblyName
|
|
' nascondo l'elenco delle porte
|
|
Map.refAssemblyManagerVM.VisibilityDoorList = Visibility.Collapsed
|
|
' verifico che il file selezionato esista e non sia in lettura
|
|
If File.Exists(OptionModule.m_sLastProject) And
|
|
Not Utility.IsFileLocked(Path.GetDirectoryName(OptionModule.m_sLastProject), Path.GetFileNameWithoutExtension(OptionModule.m_sLastProject)) Then
|
|
Local_Assembly.Name = OptionModule.m_sLastProject
|
|
Local_Assembly.IsModified = False
|
|
CurrProject.AssemblyList.Add(Local_Assembly)
|
|
Else
|
|
EgtOutLog("LastProject '" & OptionModule.m_sLastProject & "' is not a file or does not exist!")
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
|
If OptionModule.AdjustDDT Then
|
|
EgtExit()
|
|
Map.refMainWindowVM.MainWindowModel.ReleaseInstance()
|
|
Application.Current.Shutdown(3)
|
|
End If
|
|
Return
|
|
End If
|
|
Else
|
|
' carico un vettore con i file della cartella
|
|
Dim DDFFileArray() As String = Directory.GetFiles(CurrProject.Name)
|
|
' ripulisco il nome della porta (cancello tutto il percorso del file lasciando solo il nome del file)
|
|
For DDFIndex = 0 To DDFFileArray.Count - 1
|
|
If Path.GetExtension(DDFFileArray(DDFIndex)).ToLower = ".ddf" Then
|
|
' lo aggiungo alla lista delle porte
|
|
Dim Local_Assembly As New AssemblyName
|
|
Local_Assembly.Name = DDFFileArray(DDFIndex)
|
|
Local_Assembly.IsModified = False
|
|
CurrProject.AssemblyList.Add(Local_Assembly)
|
|
End If
|
|
Next
|
|
Map.refAssemblyManagerVM.VisibilityDoorList = Visibility.Visible
|
|
End If
|
|
' Notifico aggiornamento DoorList e Name per aggiornare la grafica
|
|
CurrProject.NotifyPropertyChanged("Name")
|
|
CurrProject.NotifyPropertyChanged("AssemblyList")
|
|
Map.refMainWindowVM.ProjectNameMsg = CurrProject.Name
|
|
|
|
' CARICAMENTO ELEMENTO LISTA
|
|
' Se c'è almeno una porta la visualizzo
|
|
If CurrProject.AssemblyList.Count > 0 Then
|
|
' provo a caricare l'ultimo file aperto cercando nell'elenco dei file del progetto
|
|
If File.Exists(OptionModule.m_sLastProject) Then
|
|
For Each ItemFile In CurrProject.AssemblyList
|
|
Dim Index As Integer = 1
|
|
If ItemFile.Name = OptionModule.m_sLastProject Then
|
|
If Utility.IsFileLocked(Path.GetDirectoryName(OptionModule.m_sLastProject), Path.GetFileNameWithoutExtension(OptionModule.m_sLastProject)) Then
|
|
Utility.OutLog("Annullata apertura ultimo progetto : " & OptionModule.m_sLastProject)
|
|
Exit For
|
|
End If
|
|
CurrProject.SelAssemblyName = ItemFile
|
|
'If OptionModule.m_SingleDoor Then
|
|
'Map.refMainWindowVM.ProjectNameMsg = OptionModule.m_sLastProject
|
|
Dim sFileName As String = Path.GetFileNameWithoutExtension(CurrProject.SelAssemblyName.Name)
|
|
Utility.OutLog("Blocco progetto : " & sFileName)
|
|
Utility.LockDir(CurrProject.Name, sFileName)
|
|
'End If
|
|
Return
|
|
End If
|
|
Index = Index + 1
|
|
Next
|
|
End If
|
|
' se non esiste il file allora provo a caricare il primo della lista
|
|
Dim bFileExist As Boolean = False
|
|
For IndexFile As Integer = 0 To CurrProject.AssemblyList.Count - 1
|
|
If File.Exists(CurrProject.AssemblyList(IndexFile).Name) And
|
|
Not Utility.IsFileLocked(Path.GetDirectoryName(CurrProject.AssemblyList(IndexFile).Name),
|
|
Path.GetFileNameWithoutExtension(CurrProject.AssemblyList(IndexFile).Name), False) Then
|
|
'CurrProject.VerifySelAssemblyName(CurrProject.AssemblyList(IndexFile))
|
|
CurrProject.SelAssemblyName = CurrProject.AssemblyList(IndexFile)
|
|
'If OptionModule.m_SingleDoor Then
|
|
Utility.LockDir(CurrProject.Name, CurrProject.SelAssemblyName.GraphicName)
|
|
Map.refMainWindowVM.ProjectNameMsg = CurrProject.AssemblyList(IndexFile).Name
|
|
'End If
|
|
bFileExist = True
|
|
Exit For
|
|
'Else
|
|
' Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
|
End If
|
|
Next
|
|
If Not bFileExist Then
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
|
End If
|
|
Else
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
|
End If
|
|
Else
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
|
Map.refAssemblyManagerVM.VisibilityDoorList = Visibility.Collapsed
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' LastProject
|
|
|
|
#Region "SendFeedbackCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do SendFeedback.
|
|
''' </summary>
|
|
Public ReadOnly Property SendFeedbackCommand As ICommand
|
|
Get
|
|
If m_cmdSendFeedback Is Nothing Then
|
|
m_cmdSendFeedback = New Command(AddressOf SendFeedback)
|
|
End If
|
|
Return m_cmdSendFeedback
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the SendFeedback. This method is invoked by the SendFeedbackCommand.
|
|
''' </summary>
|
|
Public Sub SendFeedback()
|
|
' Recupero indirizzo a cui spedire la mail
|
|
Dim sSupportAddress As String = String.Empty
|
|
GetMainPrivateProfileString(S_GENERAL, K_SUPPORT, "support@egaltech.com", sSupportAddress)
|
|
' se vuoto do messaggio di errore ed esco
|
|
If String.IsNullOrWhiteSpace(sSupportAddress) Then
|
|
MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 10), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
' Recupero numero chiave
|
|
Dim sKey As String = String.Empty
|
|
EgtGetKeyInfo(sKey)
|
|
' Recupero file del progetto corrente (tipo file .nge)
|
|
Dim sCurrProject As String = String.Empty
|
|
EgtGetCurrFilePath(sCurrProject)
|
|
' se nome file vuoto, chiedo se si vuole salvare (file .nge)
|
|
If String.IsNullOrWhiteSpace(sCurrProject) Then
|
|
If MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 11), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then
|
|
Save()
|
|
End If
|
|
EgtGetCurrFilePath(sCurrProject)
|
|
' se modificato, chiedo se si vuole salvare
|
|
Else
|
|
If EgtGetModified() Then
|
|
If MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 11), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then
|
|
Save()
|
|
End If
|
|
End If
|
|
End If
|
|
' recuro il file DDF associato al file .nge
|
|
Dim sCurrProjectDDF As String = String.Empty
|
|
sCurrProjectDDF = IniFile.m_sTempDir & "\CurrPart.ddf"
|
|
' recupero il file di log
|
|
Dim sFileLog As String = String.Empty
|
|
sFileLog = IniFile.m_sTempDir & "\EgtDOORCreatorLog1.txt"
|
|
|
|
' Creo zip file da allegare
|
|
Dim sZipToCreate As String = IniFile.m_sTempDir & "\Feedback.zip"
|
|
If File.Exists(sZipToCreate) Then
|
|
File.Delete(sZipToCreate)
|
|
End If
|
|
Try
|
|
Using zip As New Ionic.Zip.ZipFile(sZipToCreate, Console.Out)
|
|
zip.AlternateEncodingUsage = Ionic.Zip.ZipOption.Always
|
|
zip.AlternateEncoding = Text.Encoding.UTF8
|
|
' aggiungo progetto corrente .nge
|
|
If File.Exists(sCurrProject) Then
|
|
zip.AddItem(sCurrProject, "")
|
|
End If
|
|
' aggiungo progetto corrente .ddf
|
|
If File.Exists(sCurrProjectDDF) Then
|
|
zip.AddItem(sCurrProjectDDF, "")
|
|
End If
|
|
' aggiungo file log
|
|
If File.Exists(sFileLog) Then
|
|
zip.AddItem(sFileLog, "")
|
|
End If
|
|
' aggiungo la cartella Doors
|
|
If Directory.Exists(IniFile.m_sDoorsDirPath) Then
|
|
zip.AddItem(IniFile.m_sDoorsDirPath, Path.GetFileName(IniFile.m_sDoorsDirPath))
|
|
End If
|
|
zip.Save()
|
|
End Using
|
|
Catch ex1 As Exception
|
|
EgtOutLog("Exception in zip: " & ex1.ToString())
|
|
End Try
|
|
|
|
' preparo la mail per il supporto
|
|
Dim bEx As Boolean = False
|
|
Try
|
|
Dim SendFeedbackWindow As New EgtWPFLib5.MapiMailMessage("EgtDOORCreator Feedback - " & sKey)
|
|
SendFeedbackWindow.Recipients.Add(sSupportAddress)
|
|
If Not String.IsNullOrWhiteSpace(sZipToCreate) AndAlso File.Exists(sZipToCreate) Then
|
|
SendFeedbackWindow.Files.Add(IniFile.m_sTempDir & "\Feedback.zip")
|
|
End If
|
|
SendFeedbackWindow.ShowDialog()
|
|
Catch ex As Exception
|
|
EgtOutLog("Feedback exception: " & ex.ToString)
|
|
bEx = True
|
|
End Try
|
|
If bEx OrElse EgtWPFLib5.MapiMailMessage.m_ErrorCode <> 0 Then
|
|
MessageBox.Show(String.Format(EgtMsg(MSG_TOPCOMMANDBAR + 12), sSupportAddress, sZipToCreate), EgtMsg(MSG_EGTDOORCREATOR + 118), MessageBoxButton.OK, MessageBoxImage.Information)
|
|
' stampo il messaggio nella StatusBar
|
|
Map.refStatusBarVM.StatusOutput = EgtMsg(MSG_TOPCOMMANDBAR + 14)
|
|
Else
|
|
' stampo il messaggio nella StatusBar
|
|
Map.refStatusBarVM.StatusOutput = EgtMsg(MSG_TOPCOMMANDBAR + 14)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' SendFeedbackCommand
|
|
|
|
#Region "CreateTemplate"
|
|
Public ReadOnly Property CreateTemplateCommand As ICommand
|
|
Get
|
|
If m_CmdCreateTemplate Is Nothing Then
|
|
m_CmdCreateTemplate = New Command(AddressOf CreateTemplate)
|
|
End If
|
|
Return m_CmdCreateTemplate
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub CreateTemplate()
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) OrElse IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name) Then
|
|
' 50538 = Impossibile savare un file se non esiste una porta! Errore
|
|
MessageBox.Show(EgtMsg(50538), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
Return
|
|
End If
|
|
' se esite una porta, allora rendo possibile la creazione di un template della porta corrente
|
|
If Not IsNothing(Map.refPartPageVM.CurrPart) Then
|
|
|
|
' ' Stampo il file correte nella cartella Template
|
|
' Dim SaveFileDialog As New MySaveFileDialogVM
|
|
' Dim SaveFileDialogWnd As New EgtWPFLib5.SaveFileDialogV(Application.Current.MainWindow, SaveFileDialog)
|
|
' SaveFileDialog.Title = EgtMsg(50417)
|
|
' SaveFileDialog.Directory = IniFile.m_TemplateDir
|
|
' SaveFileDialog.Extension = DDT_EXTENSION
|
|
' 'SaveFileDialog.FileName = m_CurrProject.Name & "\"
|
|
' ' se decido di chiuedere la finestra
|
|
' If Not SaveFileDialogWnd.ShowDialog Then
|
|
' Return
|
|
' End If
|
|
|
|
' Apro la finestra di salvataggio generica
|
|
Dim SaveFileDialog As New System.Windows.Forms.SaveFileDialog()
|
|
' controllo se esiste il file DDF
|
|
Dim sFilePath As String = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name
|
|
If File.Exists(sFilePath) Then
|
|
' recupero il nome del template che ha generato il DDF corrente
|
|
Dim DDTOrig As String = String.Empty
|
|
Dim fStream As String() = File.ReadAllLines(sFilePath)
|
|
DDTOrig = ReadOrigTemplate(fStream)
|
|
SaveFileDialog.Filter = "(*.ddt) |*.ddt"
|
|
SaveFileDialog.FilterIndex = 2
|
|
If String.IsNullOrEmpty(DDTOrig) Then
|
|
If OptionModule.m_SingleDoor Then
|
|
SaveFileDialog.FileName = Path.GetFileNameWithoutExtension(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name)
|
|
Else
|
|
SaveFileDialog.FileName = Path.GetFileNameWithoutExtension(Map.refAssemblyManagerVM.CurrProject.Name)
|
|
End If
|
|
Else
|
|
SaveFileDialog.FileName = Path.GetFileNameWithoutExtension(DDTOrig)
|
|
End If
|
|
End If
|
|
|
|
' avvio la ricerca nell'ultimo direttorio aperto
|
|
SaveFileDialog.InitialDirectory = IniFile.m_TemplateDir
|
|
If SaveFileDialog.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then
|
|
' Interrompo la creazione del template
|
|
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 = DDT_EXTENSION Then
|
|
SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, DDT_EXTENSION)
|
|
End If
|
|
Else
|
|
SaveFileDialog.FileName &= DDT_EXTENSION
|
|
End If
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then
|
|
DdfFile.WriteDDFPart(Map.refPartPageVM.CurrPart, SaveFileDialog.FileName, False, False)
|
|
Else
|
|
DdfFile.WriteDDFAssembly(Map.refAssemblyPageVM.CurrAssembly, SaveFileDialog.FileName, False)
|
|
End If
|
|
Else
|
|
MessageBox.Show(EgtMsg(50155), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' CreateTemplate
|
|
|
|
#Region "Guide"
|
|
Public ReadOnly Property GuideCommand As ICommand
|
|
Get
|
|
If m_cmdGuide Is Nothing Then
|
|
m_cmdGuide = New Command(AddressOf Guide)
|
|
End If
|
|
Return m_cmdGuide
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Guide()
|
|
Dim GuideWindow As New GuideV(Application.Current.MainWindow, New GuideVM)
|
|
If Not OptionModule.m_SmartHelp = HelpPage.WebBrowserPC Then GuideWindow.Show()
|
|
End Sub
|
|
|
|
#End Region ' Guide
|
|
|
|
#Region "Copy"
|
|
|
|
Public ReadOnly Property CopyCommand As ICommand
|
|
Get
|
|
If m_cmdCopy Is Nothing Then
|
|
m_cmdCopy = New Command(AddressOf CopyDDF)
|
|
End If
|
|
Return m_cmdCopy
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub CopyDDF()
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
' 50192 = Impossible to export to machine a door if there is not a door!
|
|
MessageBox.Show(EgtMsg(50192), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
Return
|
|
End If
|
|
'Verifico che tutto sia salvato, altrimenti esco con messaggio
|
|
If Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified() Then
|
|
' Project must be saved before copying
|
|
MessageBox.Show(EgtMsg(50186), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
Return
|
|
End If
|
|
' Do you want to copy all files ? {0} (No to copy only the current file)
|
|
Dim sMsg As String = String.Format(EgtMsg(50187), vbCrLf & vbCrLf)
|
|
' Export to machine
|
|
Dim Result = MessageBox.Show(sMsg, EgtMsg(50188), MessageBoxButton.YesNoCancel, MessageBoxImage.Question)
|
|
Dim CurrProjetc As String = Map.refAssemblyManagerVM.CurrProject.Name
|
|
Dim MachinProject As String = IniFile.m_MachinProject
|
|
If String.IsNullOrEmpty(MachinProject) Then
|
|
' Machine Directory not found
|
|
MessageBox.Show(EgtMsg(50189), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
Select Case Result
|
|
Case MessageBoxResult.Yes
|
|
For IndexFile As Integer = 0 To Map.refAssemblyManagerVM.CurrProject.AssemblyList.Count - 1
|
|
' controllo che abbia estensione ddf
|
|
If Path.GetExtension(Map.refAssemblyManagerVM.CurrProject.AssemblyList(IndexFile).Name).ToLower = ".ddf" Then
|
|
Dim SouFile As String = Map.refAssemblyManagerVM.CurrProject.AssemblyList(IndexFile).Name
|
|
Dim DestFile As String = Path.Combine(MachinProject, Path.GetFileName(SouFile))
|
|
Try
|
|
File.Copy(SouFile, DestFile, True)
|
|
Catch ex As System.IO.IOException
|
|
' Error in copying: {0}
|
|
MessageBox.Show(String.Format(EgtMsg(50189), ex.Message))
|
|
Exit For
|
|
End Try
|
|
End If
|
|
Next
|
|
Case MessageBoxResult.No
|
|
Dim SouFile As String = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name
|
|
Dim DestFile As String = Path.Combine(MachinProject, Path.GetFileName(SouFile))
|
|
Try
|
|
File.Copy(SouFile, DestFile, True)
|
|
Catch ex As System.IO.IOException
|
|
' Error in copying: {0}
|
|
MessageBox.Show(String.Format(EgtMsg(50189), ex.Message))
|
|
End Try
|
|
Case Else
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region ' Copy
|
|
|
|
#Region "OpenCam5"
|
|
|
|
Public ReadOnly Property OpenCamCommand As ICommand
|
|
Get
|
|
If m_CmdOpenCam Is Nothing Then
|
|
m_CmdOpenCam = New Command(AddressOf OpenCam)
|
|
End If
|
|
Return m_CmdOpenCam
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub OpenCam()
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
' 50192 = Impossible to export to machine a door if there is not a door!
|
|
MessageBox.Show(EgtMsg(50192), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
Return
|
|
End If
|
|
'Verifico che tutto sia salvato, altrimenti esco con messaggio
|
|
If Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified Then
|
|
' 50177=Do you want to save the current changes?
|
|
Dim ResultMsg As MessageBoxResult = MessageBox.Show(EgtMsg(50177), EgtMsg(50144), MessageBoxButton.OKCancel, MessageBoxImage.Warning)
|
|
If ResultMsg = MessageBoxResult.OK Then
|
|
' salvo e continuo
|
|
Save()
|
|
Else
|
|
' esco
|
|
Return
|
|
End If
|
|
End If
|
|
' Lancio esecuzione CAM5
|
|
Dim Proc As New Process
|
|
Dim sCurrFile As String = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name
|
|
' Flag : 0 = solo disegno, 1 = anche calcolo lavorazioni
|
|
Dim nFlag As Integer = If((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift, 1, 0)
|
|
Try
|
|
Proc.StartInfo.FileName = IniFile.m_sEgtCam5EXEPath
|
|
Proc.StartInfo.Arguments = """" & sCurrFile & """ """ & nFlag & """"
|
|
If Not Proc.Start() Then
|
|
' Error in starting EgtCam5.exe
|
|
MessageBox.Show(EgtMsg(50567), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
Catch ex As Exception
|
|
' Error in starting EgtCam5.exe
|
|
MessageBox.Show(EgtMsg(50567), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End Try
|
|
End Sub
|
|
|
|
#End Region ' Copy
|
|
|
|
#Region "Duplica"
|
|
|
|
Public ReadOnly Property DuplicaCommand As ICommand
|
|
Get
|
|
If m_cmdDuplica Is Nothing Then
|
|
m_cmdDuplica = New Command(AddressOf Duplica)
|
|
End If
|
|
Return m_cmdDuplica
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Duplica()
|
|
Utility.OutLog(" +++ SaveAs +++")
|
|
' questo test potrebbe essere sostituito con il controllo : If IsNothing(Map.refPartPageVM.CurrPart) Then Return
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
' 50191 = Impossible to copy a door if there is not a door!
|
|
MessageBox.Show(EgtMsg(50191), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
Return
|
|
End If
|
|
|
|
'' anche se il file è modificato procedo con il salvataggio
|
|
'If Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified() Then
|
|
' ' Project must be saved before copying
|
|
' MessageBox.Show(EgtMsg(50186), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
' Return
|
|
'End If
|
|
|
|
Dim LocalCurrProject As New Project
|
|
'LocalCurrProject = Map.refAssemblyManagerVM.CurrProject
|
|
' Creo nuovo assembly
|
|
Dim SaveFileDialog As New System.Windows.Forms.SaveFileDialog()
|
|
SaveFileDialog.Filter = "(*.ddf) |*.ddf"
|
|
SaveFileDialog.FilterIndex = 2
|
|
' avvio la ricerca nell'ultimo direttorio aperto
|
|
SaveFileDialog.InitialDirectory = Map.refAssemblyManagerVM.CurrProject.Name
|
|
' apro la finestra di dialogo
|
|
Dim bChangeProject As Boolean = True
|
|
If SaveFileDialog.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then
|
|
Utility.OutLog("Annullata creazione di una copia di : " & Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name)
|
|
Return
|
|
ElseIf Trim(SaveFileDialog.InitialDirectory.ToLower) <> Trim(Path.GetDirectoryName(SaveFileDialog.FileName).ToLower) And Not OptionModule.m_SingleDoor Then
|
|
' 50539 = Do you want to change project? Question
|
|
Dim ResultMsg As MessageBoxResult = MessageBox.Show(EgtMsg(50539), EgtMsg(50110), MessageBoxButton.YesNoCancel, MessageBoxImage.Warning)
|
|
If ResultMsg = MessageBoxResult.Cancel Then
|
|
Return
|
|
ElseIf ResultMsg = MessageBoxResult.No Then
|
|
bChangeProject = False
|
|
End If
|
|
End If
|
|
|
|
' aggiorno 'elenco dei file presenti nel direttorio selezionato
|
|
LocalCurrProject.Name = Path.GetDirectoryName(SaveFileDialog.FileName)
|
|
LocalCurrProject.AssemblyList = New ObservableCollection(Of AssemblyName)
|
|
Dim DDFFileArray() As String = Directory.GetFiles(LocalCurrProject.Name)
|
|
' ripulisco il nome della porta (cancello tutto il percorso del file lasciando solo il nome del file)
|
|
For DDFIndex = 0 To DDFFileArray.Count - 1
|
|
If Path.GetExtension(DDFFileArray(DDFIndex)).ToLower = ".ddf" Then
|
|
' lo aggiungo alla lista delle porte
|
|
Dim Local_Assembly As New AssemblyName
|
|
Local_Assembly.Name = DDFFileArray(DDFIndex)
|
|
Local_Assembly.IsModified = False
|
|
LocalCurrProject.AssemblyList.Add(Local_Assembly)
|
|
End If
|
|
Next
|
|
|
|
Dim FilePath As String = Path.GetFileNameWithoutExtension(SaveFileDialog.FileName)
|
|
SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(FilePath, Trim(FilePath))
|
|
' 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
|
|
|
|
If Utility.IsFileLocked(Path.GetDirectoryName(SaveFileDialog.FileName), Path.GetFileNameWithoutExtension(SaveFileDialog.FileName)) Then
|
|
Utility.OutLog("Annullata creazione di una copia di : " & Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name & " -> " & SaveFileDialog.FileName)
|
|
Return
|
|
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 LocalCurrProject.AssemblyList.Count - 1
|
|
If LocalCurrProject.AssemblyList(IndexDoorList).Name = SaveFileDialog.FileName Then
|
|
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
|
|
Utility.OutLog("Sovrascrivo file : " & SaveFileDialog.FileName)
|
|
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
|
|
LocalCurrProject.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
|
|
Local_AssemblyName.GraphicName = Path.GetFileNameWithoutExtension(SaveFileDialog.FileName)
|
|
LocalCurrProject.AssemblyList.Add(Local_AssemblyName)
|
|
|
|
' devo creare tutto l'assemblato (comando GoBack nel CompoPanel)
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage
|
|
Map.refSceneManagerVM.RefreshBtn()
|
|
End If
|
|
|
|
' Seleziono AssembyName creato
|
|
Try
|
|
Utility.OutLog("Creazione copia : " & Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name & " -> " & Local_AssemblyName.Name)
|
|
File.Copy(IniFile.m_sTempDir & "\" & TEMP_FILE, Local_AssemblyName.Name, True)
|
|
'File.Copy(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name, Local_AssemblyName.Name, True)
|
|
Catch ex As System.IO.IOException
|
|
' Error in copying: {0}
|
|
MessageBox.Show(String.Format(EgtMsg(50190), ex.Message))
|
|
' interrompo la copia e la creazione del nuovo file
|
|
File.Delete(Local_AssemblyName.Name)
|
|
Return
|
|
End Try
|
|
|
|
If bChangeProject Then
|
|
Try
|
|
Map.refAssemblyManagerVM.CurrProject = LocalCurrProject
|
|
LocalCurrProject.SelAssemblyName = LocalCurrProject.AssemblyList.First(Function(x) x.Name = Local_AssemblyName.Name)
|
|
Catch ex As Exception
|
|
EgtOutLog("Impossibile trovare" & Local_AssemblyName.Name & " nel direttorio " & LocalCurrProject.Name)
|
|
Return
|
|
End Try
|
|
End If
|
|
|
|
Map.refAssemblyManagerVM.Save(LocalCurrProject.SelAssemblyName)
|
|
|
|
'Map.refAssemblyManagerVM.Open(LocalCurrProject.AssemblyList(LocalCurrProject.AssemblyList.Count - 1))
|
|
If OptionModule.m_SingleDoor Then
|
|
m_MruFiles.Add(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name)
|
|
Utility.LockDir(Path.GetDirectoryName(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name),
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName)
|
|
Else
|
|
m_MruFiles.Add(Map.refAssemblyManagerVM.CurrProject.Name)
|
|
If Not String.IsNullOrEmpty(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName) Then
|
|
Utility.LockDir(Path.GetDirectoryName(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name),
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#End Region ' Duplica
|
|
|
|
#Region "Hardware"
|
|
|
|
Public ReadOnly Property HardwareCommand As ICommand
|
|
Get
|
|
If m_cmdHardware Is Nothing Then
|
|
m_cmdHardware = New Command(AddressOf GoToHardwarePage)
|
|
End If
|
|
Return m_cmdHardware
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub GoToHardwarePage()
|
|
' se decido di annullare l'operazione di salvataggio
|
|
If Not Map.refAssemblyManagerVM.ManageModified() Then Return
|
|
Utility.OutLog(" +++ HardwarePage +++")
|
|
Utility.UnLockDir()
|
|
' prima di continuare salvo il riferimento all'ultima cartella aperta
|
|
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nHardwarePage
|
|
' nascondo la visibilità del bottone goback dalla lista dei bottoni
|
|
Map.refCompoPanelHardwareVM.GoBackVisibility = Visibility.Collapsed
|
|
Map.refHardwarePageVM.VisibilityGeneral = Visibility.Collapsed
|
|
' disabilito DimensioningPanel
|
|
Map.refDimensioningPanelVM.SetDimensioningPanel_Visibility(False)
|
|
' creo una porta per il disegno dell'Hardware
|
|
Map.refHardwarePageVM.CreateDoor()
|
|
' creo un pezzo di telaio per il disegno dell'hardware
|
|
Map.refHardwarePageVM.CreateJamb()
|
|
|
|
Map.refSceneManagerVM.RefreshBtn()
|
|
' carico la lista dei nomi delle geometrie
|
|
CompoMatch.LoadTableGeometry()
|
|
Map.refHardwareHelpSceneHostV.CleanHelpProject()
|
|
Map.refRefreshPanelVM.ButtonVisibility = Visibility.Collapsed
|
|
Map.refRefreshPanelVM.DimensionVisibility = Visibility.Visible
|
|
Map.refInstrumentPanelVM.DimensionVisibility = OptionModule.m_DimensionHardware
|
|
Map.refInstrumentPanelVM.SaveImgHardware = OptionModule.m_DimensionHardware
|
|
Map.refProjectManagerHardwareVM.HardwareIsChecked = True
|
|
End Sub
|
|
|
|
Private m_DoorIsChecked As Boolean = True
|
|
Public Property DoorIsChecked As Boolean
|
|
Get
|
|
Return m_DoorIsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_DoorIsChecked = value
|
|
NotifyPropertyChanged("DoorIsChecked")
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Hardware
|
|
|
|
#Region "PrintCommand"
|
|
|
|
Public ReadOnly Property PrintCommand As ICommand
|
|
Get
|
|
If m_cmdPrint Is Nothing Then
|
|
m_cmdPrint = New Command(AddressOf Print)
|
|
End If
|
|
Return m_cmdPrint
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Print(ByVal param As Object)
|
|
Utility.OutLog(" +++ PrintDoor +++")
|
|
' questo test potrebbe essere sostituito con il controllo : If IsNothing(Map.refPartPageVM.CurrPart) Then Return
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
' 50193 = Impossible to print a door if there is not a door!
|
|
MessageBox.Show(EgtMsg(50193), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
Return
|
|
End If
|
|
If Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified() Then
|
|
' Project must be saved before printing
|
|
MessageBox.Show(EgtMsg(50186), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
Return
|
|
End If
|
|
|
|
Dim PrintWindow As New PrintWndV(Application.Current.MainWindow, New PrintWndVM)
|
|
PrintWindow.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' PrintCommand
|
|
|
|
#Region "CreateAssemblyCommand"
|
|
|
|
Private m_VisibilityCreateAssembly As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property VisibilityCreateAssembly As Visibility
|
|
Get
|
|
If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then Return Visibility.Collapsed
|
|
' verifco di essere nelle condizioni di poter mostrare il bottone
|
|
If Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nDDFPage AndAlso
|
|
Not IsNothing(Map.refAssemblyManagerVM) AndAlso
|
|
Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso
|
|
Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) AndAlso
|
|
Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.SelAssembly) AndAlso
|
|
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.SelAssembly.JambExists AndAlso
|
|
Not IsNothing(Map.refPartPageVM) AndAlso Not IsNothing(Map.refPartPageVM.CurrPart) AndAlso
|
|
Not IsNothing(Map.refPartPageVM.CurrPart.refPartDoor) AndAlso
|
|
Not IsNothing(Map.refPartPageVM.CurrPart.refPartDoor.Door) AndAlso
|
|
Map.refPartPageVM.CurrPart.refPartDoor.Door.TypePart.Contains("DO_") Then
|
|
' se sono sono nella schermata principale oppure su un'anta
|
|
'If (Not IsNothing(Map.refPartPageVM) AndAlso Not IsNothing(Map.refPartPageVM.CurrPart) AndAlso
|
|
' Not IsNothing(Map.refPartPageVM.CurrPart.refPartDoor) AndAlso
|
|
' Not IsNothing(Map.refPartPageVM.CurrPart.refPartDoor.Door) AndAlso
|
|
' Map.refPartPageVM.CurrPart.refPartDoor.Door.TypePart.Contains("DO_")) OrElse
|
|
' Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage Then
|
|
' m_VisibilityCreateAssembly = Visibility.Visible
|
|
'Else
|
|
' m_VisibilityCreateAssembly = Visibility.Collapsed
|
|
'End If
|
|
m_VisibilityCreateAssembly = Visibility.Visible
|
|
Else
|
|
m_VisibilityCreateAssembly = Visibility.Collapsed
|
|
End If
|
|
Return m_VisibilityCreateAssembly
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CreateAssemblyCommand As ICommand
|
|
Get
|
|
If m_cmdCreateAssembly Is Nothing Then
|
|
m_cmdCreateAssembly = New Command(AddressOf CreateAssembly)
|
|
End If
|
|
Return m_cmdCreateAssembly
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub CreateAssembly()
|
|
If Not IsNothing(Map.refAssemblyPageVM) AndAlso Not IsNothing(Map.refAssemblyPageVM.CurrAssembly) Then
|
|
Map.refAssemblyPageVM.CurrAssembly.CreateAssembly()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' CreateAssemblyCommand
|
|
|
|
#Region "METHODS"
|
|
|
|
#End Region ' Methos
|
|
'questo metodo restituisce l'errore letto nel file CurrDoor.txt
|
|
Public Sub ShowGraphicError(ByRef ErrorMessages As String, ByRef Type As Integer)
|
|
' se non c'è nessuna porta aperta allora esco
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse
|
|
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
|
|
Return
|
|
End If
|
|
Dim FileLog As String = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name
|
|
FileLog = FileLog.Replace(DDF_EXTENSION, ".txt")
|
|
Dim FileContent() As String
|
|
' controllo se esite il file CurrDoor.txt
|
|
If Not File.Exists(FileLog) Then Return
|
|
FileContent = File.ReadAllLines(FileLog)
|
|
' se il file esiste ma è vuoto
|
|
If FileContent.Count = 0 Then
|
|
MessageBox.Show(EgtMsg(50107), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
Dim IndexLine As Integer = 0
|
|
Dim nMsgErr As Integer = 0
|
|
' leggo il valore numerico (se il valore non è numerico è passato di default il valore 0)
|
|
nMsgErr = RegexFunction.ErrDraw(FileContent(IndexLine))
|
|
Type = nMsgErr
|
|
' passo alla riga succesiva
|
|
IndexLine += 1
|
|
' se il valore è maggiore di zero allora è un errore
|
|
If nMsgErr > 0 Then
|
|
' salto tutte le righe vuote
|
|
While String.IsNullOrEmpty(FileContent(IndexLine)) AndAlso IndexLine < FileContent.Count
|
|
IndexLine += 1
|
|
End While
|
|
ErrorMessages = FileContent(IndexLine)
|
|
IndexLine += 1
|
|
While IndexLine < FileContent.Count
|
|
ErrorMessages &= vbNewLine & FileContent(IndexLine)
|
|
IndexLine += 1
|
|
End While
|
|
' altrimenti un avvertimento
|
|
ElseIf nMsgErr < 0 Then
|
|
While String.IsNullOrEmpty(FileContent(IndexLine)) AndAlso IndexLine < FileContent.Count
|
|
IndexLine += 1
|
|
End While
|
|
ErrorMessages = FileContent(IndexLine)
|
|
IndexLine += 1
|
|
While IndexLine < FileContent.Count
|
|
ErrorMessages &= vbNewLine & FileContent(IndexLine)
|
|
IndexLine += 1
|
|
End While
|
|
Else
|
|
ErrorMessages = String.Empty
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Commands
|
|
|
|
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
|
|
|
|
Public NotInheritable Class ObjectDataProvider
|
|
'Implements ICanHandleUsedIdentifiers, IDataProvider, ISupportsLogger
|
|
End Class
|
|
|
|
Public Sub NotifyPropertyChanged(propName As String)
|
|
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public NotInheritable Class ObjectDataProvider
|
|
Private order As ReportOrder
|
|
Public Sub New(order As ReportOrder)
|
|
Me.order = order
|
|
End Sub
|
|
End Class |