From abefc05966c96bddeb3da944433f6dcb6f03a32f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 27 Nov 2017 05:43:24 +0000 Subject: [PATCH] =?UTF-8?q?EgtCAM5=20:=20-=20migliorata=20differenziazione?= =?UTF-8?q?=20tra=20mancanza=20chiave=20e=20problemi=20con=20licenza=20-?= =?UTF-8?q?=20in=20caso=20di=20problemi=20con=20licenza=20possibilit=C3=A0?= =?UTF-8?q?=20di=20sceglierne=20una=20nuova=20con=20dialogo=20ApriFile.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IniFile.vb | 1 + MainWindow/MainWindowViewModel.vb | 9 +++-- ProjectPage/ProjectViewModel.vb | 60 +++++++++++++++++++++---------- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/IniFile.vb b/IniFile.vb index 54002b1..62efb5a 100644 --- a/IniFile.vb +++ b/IniFile.vb @@ -47,6 +47,7 @@ Public Module IniFile GUNSTOCK = 4 End Enum Friend m_sDataRoot As String + Friend m_sConfigDir As String Friend m_sIniFile As String Friend m_sTempDir As String Friend m_sMachinesRoot As String diff --git a/MainWindow/MainWindowViewModel.vb b/MainWindow/MainWindowViewModel.vb index 50e54af..e77da80 100644 --- a/MainWindow/MainWindowViewModel.vb +++ b/MainWindow/MainWindowViewModel.vb @@ -13,13 +13,11 @@ Namespace EgtCAM5 #Region "FIELDS" ' EGALTECH ENVIRONMENT FIELDS - Private m_objMutex As Mutex Private m_sDataRoot As String = String.Empty Private m_sConfigDir As String = String.Empty Private m_nDebug As Integer = 0 - ' EGALTECH ENVIRONMENT FIELDS WITH PROPERTY ' GRAPHICAL FIELDS @@ -293,13 +291,14 @@ Namespace EgtCAM5 IniFile.m_sDataRoot = m_sDataRoot ' Impostazione direttorio di configurazione m_sConfigDir = m_sDataRoot & "\" & CONF_DIR + IniFile.m_sConfigDir = m_sConfigDir ' Impostazione direttorio per file temporanei - m_sTempDir = m_sDataRoot & "\" & TEMP_DIR + IniFile.m_sTempDir = m_sDataRoot & "\" & TEMP_DIR ' Impostazione path Ini file - m_sIniFile = m_sConfigDir & "\" & INI_FILE_NAME + IniFile.m_sIniFile = m_sConfigDir & "\" & INI_FILE_NAME EgtWPFLib5.IniFile.m_sIniFile = m_sIniFile ' Impostazione path resources dir - m_sResourcesRoot = m_sDataRoot & "\" & RES_DIR + IniFile.m_sResourcesRoot = m_sDataRoot & "\" & RES_DIR ' Impostazione direttorio per le macchine If GetPrivateProfileString(S_MACH, K_MACHINESDIR, "", m_sMachinesRoot) = 0 Then m_sMachinesRoot = m_sDataRoot & "\" & MACHINES_DFL_DIR diff --git a/ProjectPage/ProjectViewModel.vb b/ProjectPage/ProjectViewModel.vb index be33eaf..a1eca6a 100644 --- a/ProjectPage/ProjectViewModel.vb +++ b/ProjectPage/ProjectViewModel.vb @@ -142,25 +142,13 @@ Namespace EgtCAM5 ''' Execute the Point. This method is invoked by the PointCommand. ''' Public Sub Loaded(ByVal param As Object) + ' Verifico sia la prima volta If m_bLoaded Then Return m_bLoaded = True ' Creazione scena PreInitializeScene() - If Not m_ProjectScene.Init() Then - EgtOutLog("Error in Project scene creation") - SceneHost.Child = Nothing - ' Box di avviso chiave mancante - MsgBox(EgtMsg(MSG_MISSINGKEYWD + 2) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 3), MsgBoxStyle.OkOnly, EgtMsg(MSG_MISSINGKEYWD + 1)) - ' Chiudo il programma - IniFile.m_bFailedRun = True - Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND) - ' Verifico abilitazione prodotto - ElseIf (IniFile.m_nKeyOptions And KEY_OPT.BASE) = 0 Then - MsgBox(EgtMsg(MSG_MISSINGKEYWD + 5), MsgBoxStyle.OkOnly, EgtMsg(MSG_MISSINGKEYWD + 1)) - ' Chiudo il programma - IniFile.m_bFailedRun = True - Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND) - Else + ' Se tutto bene + If m_ProjectScene.Init() And (IniFile.m_nKeyOptions And KEY_OPT.BASE) <> 0 Then IniFile.m_ProjectSceneContext = m_ProjectScene.GetCtx PostInitializeScene() ' Recupero e imposto handle finestra principale @@ -170,10 +158,46 @@ Namespace EgtCAM5 EgtInitMachMgr(IniFile.m_sMachinesRoot) ' Apro progetto vuoto EgtCAM5Map.refTopCommandBarVM.NewCmd() + ' Seleziono la macchina impostata nel file ini + Application.Msn.NotifyColleagues(Application.LOADCURRENTMACHINE) + EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + Return End If - ' Seleziono la macchina impostata nel file ini - Application.Msn.NotifyColleagues(Application.LOADCURRENTMACHINE) - EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + ' Problemi + SceneHost.Child = Nothing + ' Se manca la chiave + If IniFile.m_nKeyLevel = -1 Or IniFile.m_nKeyLevel = -2 Then + EgtOutLog("Missing Dongle") + ' Box di avviso chiave mancante : "Chiave non presente. \n Inserirla e riavviare il programma." "Errore" + Dim sText As String = EgtMsg(MSG_MISSINGKEYWD + 2) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 3) + Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1) + MessageBox.Show(sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error) + ' Altrimenti manca la licenza + Else + EgtOutLog("Problems with Licence") + ' Box di avviso licenza con problemi : "Programma senza licenza. \n Caricala e riavvia il programma." "Errore" + Dim sText As String = EgtMsg(MSG_MISSINGKEYWD + 5) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 6) + Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1) + If MessageBox.Show(sText, sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.OK Then + ' Apro dialogo per richiesta file licenza + Dim LicDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".lic", + .Filter = "Licences (.lic)|*.lic", + .CheckFileExists = True, + .ValidateNames = True + } + If LicDlg.ShowDialog() = True Then + ' Copio il file nel direttorio di configurazione del programma + Dim sDestFile As String = IniFile.m_sConfigDir & "\" & LicDlg.SafeFileName + My.Computer.FileSystem.CopyFile(LicDlg.FileName, sDestFile, True) + ' Imposto il nuovo file di licenza nell'Ini + WritePrivateProfileString(S_GENERAL, K_LICENCE, LicDlg.SafeFileName) + End If + End If + End If + ' Chiudo il programma + IniFile.m_bFailedRun = True + Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND) End Sub #End Region ' LoadedCommand