EgtDOORCreator 1.8d1 :

- modifiche e migliorie varie.
This commit is contained in:
Nicola Pievani
2017-04-21 15:47:51 +00:00
parent f365dee1c7
commit 1158fa4d9f
37 changed files with 1250 additions and 299 deletions
+144 -32
View File
@@ -2,6 +2,7 @@
Imports System.ComponentModel
Imports System.IO
Imports EgtUILib
Imports Ionic.zip
Public Class ProjectManagerViewModel
Implements INotifyPropertyChanged
@@ -30,10 +31,7 @@ Public Class ProjectManagerViewModel
Private m_cmdExport As ICommand
Private m_cmdOptions As ICommand
Private m_CmdLastProject As ICommand
#Region "Messages"
#End Region ' Messages
Private m_cmdSendFeedback As ICommand
#Region "ToolTip"
@@ -68,14 +66,14 @@ Public Class ProjectManagerViewModel
Return EgtMsg(MSG_TOPCOMMANDBAR + 6)
End Get
End Property
Public ReadOnly Property ExportToolTip As String
Public ReadOnly Property SendFeedbackToolTip As String
Get
Return EgtMsg(MSG_TOPCOMMANDBAR + 7)
Return "Send Feedback"
End Get
End Property
Public ReadOnly Property OptionsToolTip As String
Get
Return EgtMsg(MSG_TOPCOMMANDBAR + 4)
Return EgtMsg(MSG_MAINWINDOW + 209)
End Get
End Property
@@ -142,10 +140,10 @@ Public Class ProjectManagerViewModel
''' </summary>
Public Sub NewCmd()
Dim SaveFileDialog As New EgtWPFLib5.EgtSaveFileDialog
SaveFileDialog.Title = EgtMsg(50304)
SaveFileDialog.FileName = "c:\EgtData\EgtDOORCreator\MyProjects\"
If Not SaveFileDialog.ShowDialog Then
SaveFileDialog.Directory = IniFile.m_MyProjectDir & "\"
SaveFileDialog.Extension = "\"
If Not SaveFileDialog.EgtShowDialog Then
Return
End If
Directory.CreateDirectory(SaveFileDialog.FileName)
@@ -168,7 +166,9 @@ Public Class ProjectManagerViewModel
' Notifico aggiornamento DoorList e Name per aggiornare la grafica
CurrProject.NotifyPropertyChanged("Name")
CurrProject.NotifyPropertyChanged("DoorList")
m_rfMainWindowViewModel.ProjectNameMsg = m_CurrProject.Name
m_rfMainWindowViewModel.ProjectNameMsg = m_rfMainWindowViewModel.SetTitle(m_CurrProject.Name)
m_rfMainWindowViewModel.ModifyTitle(True)
'm_rfMainWindowViewModel.ProjectNameMsg = m_CurrProject.Name
End Sub
#End Region ' NewCommand
@@ -192,7 +192,7 @@ Public Class ProjectManagerViewModel
''' </summary>
Public Sub Open()
Dim FolderBrowserDialog As New System.Windows.Forms.FolderBrowserDialog
FolderBrowserDialog.SelectedPath = "c:\EgtData\EgtDOORCreator\MyProjects"
FolderBrowserDialog.SelectedPath = IniFile.m_MyProjectDir
' mostriamo la finestra di dialogo aperta fino alla directory MyProjects
If FolderBrowserDialog.ShowDialog <> Forms.DialogResult.OK Then
' se la risposta è diversa da OK esce
@@ -272,7 +272,7 @@ Public Class ProjectManagerViewModel
''' <summary>
''' Execute the Save. This method is invoked by the SaveCommand.
''' </summary>
Public Sub Save(ByVal param As Object)
Public Sub Save()
Dim SetTitle As String
Dim CurrDoor As Door = DirectCast(m_rfMainWindowViewModel.DoorParameters.DataContext, DoorParametersViewModel).CurrDoor
Dim DoorManagerViewModel As DoorManagerViewModel = DirectCast(m_rfMainWindowViewModel.DoorManager.DataContext, DoorManagerViewModel)
@@ -337,8 +337,8 @@ Public Class ProjectManagerViewModel
''' </summary>
Public Sub Options(ByVal param As Object)
Dim OptionsWindow As New OptionsView
OptionsWindow.Height = 614
OptionsWindow.Width = 1024
OptionsWindow.Height = 550
OptionsWindow.Width = 550
OptionsWindow.DataContext = New OptionsViewModel
OptionsWindow.Owner = Application.Current.MainWindow
OptionsWindow.ShowDialog()
@@ -365,29 +365,141 @@ Public Class ProjectManagerViewModel
CurrProject.Name = OptionModule.m_sLastProject
' ripulisco la lista di porte
CurrProject.DoorList.Clear()
' Aggiungo porte trovate nella cartella ad un vettore
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
CurrProject.DoorList.Add(DDFFileArray(DDFIndex))
' verifico che esista la cartella
If Directory.Exists(CurrProject.Name) Then
' Aggiungo porte trovate nella cartella ad un vettore
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
CurrProject.DoorList.Add(DDFFileArray(DDFIndex))
End If
Next
' Notifico aggiornamento DoorList e Name per aggiornare la grafica
CurrProject.NotifyPropertyChanged("Name")
CurrProject.NotifyPropertyChanged("DoorList")
' Se c'è almeno una porta la visualizzo
If CurrProject.DoorList.Count > 0 Then
DoorManagerViewModel.SelectedDoor = CurrProject.DoorList(0)
End If
Next
' Notifico aggiornamento DoorList e Name per aggiornare la grafica
CurrProject.NotifyPropertyChanged("Name")
CurrProject.NotifyPropertyChanged("DoorList")
' Se c'è almeno una porta la visualizzo
If CurrProject.DoorList.Count > 0 Then
DoorManagerViewModel.SelectedDoor = CurrProject.DoorList(0)
m_rfMainWindowViewModel.ProjectNameMsg = CurrProject.Name
End If
m_rfMainWindowViewModel.ProjectNameMsg = CurrProject.Name
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
GetPrivateProfileString(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 & "\CurrDoor.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)
' aggiungo progetto corrente .nge
If Not String.IsNullOrWhiteSpace(sCurrProject) Then
zip.AddItem(sCurrProject, "")
End If
' aggiungo progetto corrente .ddf
If Not String.IsNullOrWhiteSpace(sCurrProjectDDF) Then
zip.AddItem(sCurrProjectDDF, "")
End If
' aggiungo file log
If Not String.IsNullOrWhiteSpace(sFileLog) Then
zip.AddItem(sFileLog, "")
End If
' aggiungo la cartella Doors
If Directory.Exists(IniFile.m_sDoorsDirPath) Then
zip.AddItem(IniFile.m_sDoorsDirPath, "Doors")
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("EgtCAM5 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)
Dim rfStatusBarView As StatusBarView = DirectCast(m_rfMainWindowViewModel.SceneManager.DataContext, SceneManagerViewModel).StatusBar
Dim rfStatusBarViewModel As StatusBarViewModel = DirectCast(rfStatusBarView.DataContext, StatusBarViewModel)
' stampo il messaggio nella StatusBar
rfStatusBarViewModel.StatusOutput = EgtMsg(MSG_TOPCOMMANDBAR + 14)
Else
Dim rfStatusBarView As StatusBarView = DirectCast(m_rfMainWindowViewModel.SceneManager.DataContext, SceneManagerViewModel).StatusBar
Dim rfStatusBarViewModel As StatusBarViewModel = DirectCast(rfStatusBarView.DataContext, StatusBarViewModel)
' stampo il messaggio nella StatusBar
rfStatusBarViewModel.StatusOutput = EgtMsg(MSG_TOPCOMMANDBAR + 14)
End If
End Sub
#End Region ' SendFeedbackCommand
#End Region ' Commands
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged