From 79b9e49ae0b06ab44bce5be174dece687d335e9d Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Wed, 15 Feb 2017 19:14:28 +0000 Subject: [PATCH] EgtCAM5 : - Aggiunto bottoni per mandare mail all'assistenza in TopCommandBar. - Corretta visualizzazione tooltip in setup quando caricato da archivio. --- Constants/ConstIni.vb | 2 + Constants/ConstMsg.vb | 1 + EgtCAM5.vbproj | 6 + IniFile.vb | 8 +- ProjectPage/DoorsPanel/DoorsPanelViewModel.vb | 4 +- Resources/TopCommandBar/Send.png | Bin 0 -> 1036 bytes SetUpWindow/SetUpViewModel.vb | 78 +++++++++++-- Special/Doors.vb | 8 +- TopCommandBar/TopCommandBarView.xaml | 3 + TopCommandBar/TopCommandBarViewModel.vb | 106 ++++++++++++++++++ 10 files changed, 202 insertions(+), 14 deletions(-) create mode 100644 Resources/TopCommandBar/Send.png diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index 266dafd..4c7a077 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -35,6 +35,7 @@ Module ConstIni Public Const K_MODIFY As String = "Modify" Public Const K_TRANSFORM As String = "Transform" Public Const K_ONLYDRAW As String = "OnlyDraw" + Public Const K_SUPPORT As String = "Support" Public Const S_LANGUAGES As String = "Languages" Public Const K_LANGUAGE As String = "Language" @@ -90,6 +91,7 @@ Module ConstIni Public Const S_DOORS As String = "Doors" Public Const K_DDFENABLE As String = "DdfEnable" + Public Const K_DIRECTORYPATH As String = "DirectoryPath" Public Const K_DDFEXEC As String = "DdfExec" Public Const K_DDFFUNCTION As String = "DdfFun" Public Const K_DDFDIR As String = "DdfDir" diff --git a/Constants/ConstMsg.vb b/Constants/ConstMsg.vb index eaaf100..6add164 100644 --- a/Constants/ConstMsg.vb +++ b/Constants/ConstMsg.vb @@ -23,6 +23,7 @@ Public Const MSG_DOORSERRORS As Integer = MSG_EGTCAM5 + 3100 Public Const MSG_GUNSTOCK As Integer = MSG_EGTCAM5 + 3200 Public Const MSG_GUNSTOCKERRORS As Integer = MSG_EGTCAM5 + 3250 + Public Const MSG_MESSAGEBOX As Integer = 15000 Public Const MSG_MISSINGKEYWD As Integer = 10100 Public Const MSG_EGTWPFLIB5 As Integer = 30000 diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj index e70eef4..86da606 100644 --- a/EgtCAM5.vbproj +++ b/EgtCAM5.vbproj @@ -100,6 +100,9 @@ ..\..\EgtProg\DllD32\EgtWPFLib5.dll + + ..\..\EgtProg\EgtCAM5\Ionic.Zip.dll + False ..\..\EgtProg\EgtCAM5\Microsoft.Expression.Interactions.dll @@ -662,6 +665,9 @@ true + + + IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\EgtCAM5\EgtCAM5R32.exe diff --git a/IniFile.vb b/IniFile.vb index ac8941d..1d5b65a 100644 --- a/IniFile.vb +++ b/IniFile.vb @@ -49,6 +49,8 @@ Public Module IniFile Friend m_sTempDir As String Friend m_sMachinesRoot As String Friend m_sTablesRoot As String + ' path della cartella DOORS + Friend m_sDoorsDirPath As String Friend m_ProjectMode As ProjectModeOpt Friend m_bMmUnits As Boolean @@ -184,7 +186,11 @@ Public Module IniFile End Function Friend Function IsActiveDoors() As Boolean - Return (IniFile.m_nKeyOptions And KEY_OPT.DOORS) <> 0 And (GetPrivateProfileInt(S_DOORS, K_DDFENABLE, 0) <> 0) + Dim bIsActive As Boolean = (IniFile.m_nKeyOptions And KEY_OPT.DOORS) <> 0 And (GetPrivateProfileInt(S_DOORS, K_DDFENABLE, 0) <> 0) + If bIsActive Then + GetPrivateProfileString(S_DOORS, K_DIRECTORYPATH, "", m_sDoorsDirPath) + End If + Return bIsActive End Function Friend Function IsActiveGunStock() As Boolean diff --git a/ProjectPage/DoorsPanel/DoorsPanelViewModel.vb b/ProjectPage/DoorsPanel/DoorsPanelViewModel.vb index b91cc10..d102d05 100644 --- a/ProjectPage/DoorsPanel/DoorsPanelViewModel.vb +++ b/ProjectPage/DoorsPanel/DoorsPanelViewModel.vb @@ -108,11 +108,13 @@ Namespace EgtCAM5 ''' Public Sub MTableDb(ByVal param As Object) ' Leggo dal file ini il direttorio delle MTable - If GetPrivateProfileString(S_DOORS, K_TABLESDIR, "", IniFile.m_sTablesRoot) = 0 Then + Dim sTablesDir As String = String.Empty + If GetPrivateProfileString(S_DOORS, K_TABLESDIR, "", sTablesDir) = 0 Then ' Se non lo trovo mando messaggio di errore e chiudo la finestra MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 4), EgtMsg(MSG_DOORSERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) Return End If + IniFile.m_sTablesRoot = IniFile.m_sDoorsDirPath & "\" & sTablesDir ' Verifico che la cartella indicata esista If Not My.Computer.FileSystem.DirectoryExists(IniFile.m_sTablesRoot) Then ' Se non la trovo mando messaggio di errore e chiudo la finestra diff --git a/Resources/TopCommandBar/Send.png b/Resources/TopCommandBar/Send.png new file mode 100644 index 0000000000000000000000000000000000000000..a9bcbe4cd51b66bd5c3b882382f499af988adabe GIT binary patch literal 1036 zcmV+n1oQieP)cz0tUU zY>^R+I<7Dw@xp+K8pVva3^EXP!(c??DszG%+0BTg!@;`3Szp#ZZI2gdrP;xjY^~b7bq3rgDs{45v3Covj8DK(VGRZ2o$pw1p}v4 zsd)WIV?qT`O%!9|ybN<$MuKj+!z>E! ziAYKO{zu6Fp^M4izGGth3%D}wAdev7RTpVkubjvG?PrV(buszaUN)X}6A}uMMEd~d zW(e_=fKQp!KC0zCmx8_mtxoVcY z{60m6rP75?fI#vLt5@A1MvRN-&%VP`<*(tb*&&Xd`bthMJGD$SzlWLrj~N;25T32O z<(-L#^r2sO^1yMFO~YC&r6_EA3E zjpxYo^pAbR?_^`gjQN_a%Emr6$auAjmWfg3UTmPKd0bX$PV58--YDs%ZJq&w+B%#~ z-?KL}8}a24er-QYzu$|F4Qo=Xyy)$R>HoBWk(}G+kKO0uo>bbtG?YLDrEcyo8QGtPV;bf|tY=e;l$JO#0&xe0000 0 Then + ' disattivo tutte le uscite tranne quelle attrezzate + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + ExitToolAssociationList(ExitIndex).IsValidPos = False + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + Dim sToolName As String = String.Empty + EgtTdbGetToolFromUUID(TUuid, sToolName) + EgtOutLog("Error in setup! Tool:" & sToolName & " TcPos: " & m_TcPos) + Return + End If + If bIsValid Then + ' se l'uscita restituita è libera la attivo e disattivo tutte le altre non occupate + If Not ExitToolAssociationList(nExit - 1).IsOccupied Then + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitIndex = nExit - 1 Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + ExitToolAssociationList(ExitIndex).IsValidPos = True + ElseIf ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsValidPos = False + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + ' altrimenti le disattivo tutte tranne quelle occupate + Else + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + If ExitIndex = nExit - 1 Then + ExitToolAssociationList(ExitIndex).IsValidPos = True + Else + ExitToolAssociationList(ExitIndex).IsValidPos = False + End If + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + End If + Else + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + Next + End If End If End Sub @@ -1201,9 +1255,13 @@ Public Class ExitToolAssociation If IsNothing(m_IsValidPos) Then Return New SolidColorBrush(Color.FromArgb(255, 221, 221, 221)) ElseIf m_IsValidPos Then - Return EgaltechGreen + If m_IsOccupied Then + Return EgaltechYellow + Else + Return EgaltechGreen + End If Else - Return EgaltechYellow + Return New SolidColorBrush(Color.FromArgb(255, 221, 221, 221)) End If End Get End Property diff --git a/Special/Doors.vb b/Special/Doors.vb index b4ae58c..ff11d1c 100644 --- a/Special/Doors.vb +++ b/Special/Doors.vb @@ -57,7 +57,9 @@ Public Module Doors Function CreateDoors(ByRef sDdfFile As String, bNcGen As Boolean, bBatch As Boolean) As Boolean ' Carico il file Dim sExecPath As String = String.Empty - GetPrivateProfileString(S_DOORS, K_DDFEXEC, "", sExecPath) + Dim sExecName As String = String.Empty + GetPrivateProfileString(S_DOORS, K_DDFEXEC, "", sExecName) + sExecPath = IniFile.m_sDoorsDirPath & "\" & sExecName If Not EgtLuaExecFile(sExecPath) Then Return False ' Lancio la creazione EgtLuaSetGlobStringVar("DGD.FILE", sDdfFile) @@ -79,7 +81,9 @@ Public Module Doors scene.Cursor = System.Windows.Forms.Cursors.WaitCursor ' Carico ed eseguo il file Dim sExecPath As String = String.Empty - GetPrivateProfileString(S_DOORS, K_DDFMACHEXEC, "", sExecPath) + Dim sExecName As String = String.Empty + GetPrivateProfileString(S_DOORS, K_DDFMACHEXEC, "", sExecName) + sExecPath = IniFile.m_sDoorsDirPath & "\" & sExecName Dim bOk As Boolean = EgtLuaExecFile(sExecPath) ' Cursore standard scene.Cursor = System.Windows.Forms.Cursors.Default diff --git a/TopCommandBar/TopCommandBarView.xaml b/TopCommandBar/TopCommandBarView.xaml index e60d00e..37ea0db 100644 --- a/TopCommandBar/TopCommandBarView.xaml +++ b/TopCommandBar/TopCommandBarView.xaml @@ -37,6 +37,9 @@ + diff --git a/TopCommandBar/TopCommandBarViewModel.vb b/TopCommandBar/TopCommandBarViewModel.vb index 6a5d5e2..adbb35f 100644 --- a/TopCommandBar/TopCommandBarViewModel.vb +++ b/TopCommandBar/TopCommandBarViewModel.vb @@ -1,4 +1,5 @@ Imports System.Collections.ObjectModel +Imports System.IO Imports EgtUILib Namespace EgtCAM5 @@ -24,6 +25,7 @@ Namespace EgtCAM5 Private m_cmdImport As ICommand Private m_cmdExport As ICommand Private m_cmdOptions As ICommand + Private m_cmdSendFeedback As ICommand #Region "Messages" @@ -369,6 +371,110 @@ Namespace EgtCAM5 #End Region ' OptionsCommand +#Region "SendFeedbackCommand" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property SendFeedbackCommand As ICommand + Get + If m_cmdSendFeedback Is Nothing Then + m_cmdSendFeedback = New RelayCommand(AddressOf SendFeedback) + End If + Return m_cmdSendFeedback + End Get + End Property + + ''' + ''' Execute the Export. This method is invoked by the ExportCommand. + ''' + Public Sub SendFeedback(ByVal param As Object) + ' recupero indirizzo supporto + Dim sSupportAddress As String = String.Empty + GetPrivateProfileString(S_GENERAL, K_SUPPORT, "", sSupportAddress) + ' se vuoto do messaggio di errore ed esco + If String.IsNullOrWhiteSpace(sSupportAddress) Then + MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 10), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' recupero numero chiave + Dim sKey As String = String.Empty + EgtGetKeyInfo(sKey) + ' recupero file del progetto corrente + Dim sCurrProject As String = String.Empty + EgtGetCurrFilePath(sCurrProject) + If String.IsNullOrWhiteSpace(sCurrProject) Then + If MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 11), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + Application.Msn.NotifyColleagues(Application.SAVEPROJECT) + End If + EgtGetCurrFilePath(sCurrProject) + Else + If EgtGetModified() Then + If MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 11), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + Application.Msn.NotifyColleagues(Application.SAVEPROJECT) + End If + End If + End If + Dim DoorOtherFiles As New List(Of String) + ' se door attivo + If IniFile.IsActiveDoors Then + ' recupero file con lo stesso nome del progetto + If Not String.IsNullOrWhiteSpace(sCurrProject) Then + Dim sCurrProjectDir As String = Path.GetDirectoryName(sCurrProject) + If Not String.IsNullOrWhiteSpace(sCurrProjectDir) Then + Dim TempFiles() As String = Directory.GetFiles(sCurrProjectDir) + For FileIndex = 0 To TempFiles.Count - 1 + If Path.GetFileNameWithoutExtension(TempFiles(FileIndex)).Contains(Path.GetFileNameWithoutExtension(sCurrProject)) AndAlso TempFiles(FileIndex) <> sCurrProject Then + DoorOtherFiles.Add(TempFiles(FileIndex)) + End If + Next + End If + End If + End If + ' 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 file macchina + zip.AddItem(IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName, IniFile.m_sMachineName) + ' aggiungo progetto corrente + If Not String.IsNullOrWhiteSpace(sCurrProject) Then + zip.AddItem(sCurrProject, "") + End If + ' se door attivo + If IniFile.IsActiveDoors Then + zip.AddItem(IniFile.m_sDoorsDirPath, "Doors") + If DoorOtherFiles.Count > 0 Then + For FileIndex = 0 To DoorOtherFiles.Count - 1 + zip.AddItem(DoorOtherFiles(FileIndex), "") + Next + End If + End If + ' salvo lo zip + zip.Save() + End Using + Catch ex1 As Exception + EgtOutLog("Exception in zip: " & ex1.ToString()) + End Try + ' preparo la mail per il supporto + 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) + MessageBox.Show(String.Format(EgtMsg(MSG_TOPCOMMANDBAR + 12), sSupportAddress, sZipToCreate), EgtMsg(MSG_MESSAGEBOX + 3), MessageBoxButton.OK, MessageBoxImage.Information) + End Try + End Sub + +#End Region ' SendFeedbackCommand + #End Region ' Commands End Class