From 67143be354a906f101b07155fbdb4cf9769e3247 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 5 Sep 2017 14:08:35 +0000 Subject: [PATCH] EgtCAM5 1.8i1 : - piccole migliorie. --- AboutBoxWindow/AboutBoxView.xaml.vb | 2 ++ MainWindow/MainWindowViewModel.vb | 38 ++++++++++++++--------------- My Project/AssemblyInfo.vb | 20 +++++++-------- ProjectPage/ProjectViewModel.vb | 10 ++++---- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/AboutBoxWindow/AboutBoxView.xaml.vb b/AboutBoxWindow/AboutBoxView.xaml.vb index f52dfe7..430972b 100644 --- a/AboutBoxWindow/AboutBoxView.xaml.vb +++ b/AboutBoxWindow/AboutBoxView.xaml.vb @@ -35,6 +35,8 @@ Public Class AboutBoxView Dim sKlev As String = IniFile.m_nKeyLevel.ToString() Dim sOpts As String = IniFile.m_nKeyOptions.ToString() sInfo = sKey & " - " & sKlev & " - " & sOpts & Environment.NewLine + sInfo &= "User " & Environment.MachineName & "\" & Environment.UserName & + " (" & IniFile.m_nInstance.ToString() & ")" & Environment.NewLine sInfo &= "DataRoot " & IniFile.m_sDataRoot & Environment.NewLine sInfo &= "MachinesRoot " & IniFile.m_sMachinesRoot & Environment.NewLine Dim sScene As String = String.Empty diff --git a/MainWindow/MainWindowViewModel.vb b/MainWindow/MainWindowViewModel.vb index 2047649..50e54af 100644 --- a/MainWindow/MainWindowViewModel.vb +++ b/MainWindow/MainWindowViewModel.vb @@ -14,8 +14,7 @@ Namespace EgtCAM5 ' EGALTECH ENVIRONMENT FIELDS - Private m_objMutex As New Mutex - '' '' '' '' '' ''Private m_nInstance As Integer = 0 + 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 @@ -162,10 +161,10 @@ Namespace EgtCAM5 ' Terminazione generale di EgtInterface EgtExit() ' Rilascio mutex - m_objMutex.Close() + If Not IsNothing(m_objMutex) Then m_objMutex.Close() ' Aggiorno istanze usate Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0) - nTmp -= (1 << (m_nInstance - 1)) + nTmp -= (1 << (IniFile.m_nInstance - 1)) WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString()) ' Salvo impostazione macchina corrente Application.Msn.NotifyColleagues(Application.SAVECURRENTMACHINE) @@ -263,10 +262,10 @@ Namespace EgtCAM5 ' Terminazione generale di EgtInterface EgtExit() ' Rilascio mutex - m_objMutex.Close() + If Not IsNothing(m_objMutex) Then m_objMutex.Close() ' Aggiorno istanze usate Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0) - nTmp -= (1 << (m_nInstance - 1)) + nTmp -= (1 << (IniFile.m_nInstance - 1)) WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString()) Application.Current.Shutdown() End Sub) @@ -307,7 +306,7 @@ Namespace EgtCAM5 End If IniFile.m_sMachinesRoot = m_sMachinesRoot ' Verifico indice di istanza - ManageIstance() + ManageInstance() ' Imposto tipo di chiave EgtSetLockType(KEY_TYPE.HW) ' Leggo e imposto chiave di protezione @@ -322,9 +321,9 @@ Namespace EgtCAM5 EgtGetKeyOptions(3279, 18, 1, IniFile.m_nKeyOptions) ' Inizializzazione generale di EgtInterface m_nDebug = GetPrivateProfileInt(S_GENERAL, K_DEBUG, 0) - IniFile.m_sLogFile = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", m_nInstance.ToString()) - Dim sLogMsg As String = "User " & Environment.UserName & "\" & Environment.MachineName & " (" & m_nInstance.ToString() & ")" & vbLf & - My.Application.Info.Description.ToString() & " ver. " & + IniFile.m_sLogFile = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", IniFile.m_nInstance.ToString()) + Dim sLogMsg As String = "User " & Environment.MachineName & "\" & Environment.UserName & " (" & IniFile.m_nInstance.ToString() & ")" & vbLf & + My.Application.Info.Title.ToString() & " ver. " & My.Application.Info.Version.Major.ToString() & "." & My.Application.Info.Version.Minor.ToString() & (ChrW(97 - 1 + My.Application.Info.Version.Build)).ToString() & @@ -395,7 +394,7 @@ Namespace EgtCAM5 ''' ''' Funzione che permette di gestire il numero di istanze del programma attive contemporaneamente ''' - Private Sub ManageIstance() + Private Sub ManageInstance() Dim bCreated As Boolean Try m_objMutex = New Mutex(False, "Global\EgtCAM5", bCreated) @@ -404,23 +403,24 @@ Namespace EgtCAM5 End Try If bCreated Then ' Prima istanza - m_nInstance = 1 + IniFile.m_nInstance = 1 ' Aggiorno stato istanze attive - WritePrivateProfileString(S_GENERAL, K_INSTANCES, m_nInstance.ToString) + WritePrivateProfileString(S_GENERAL, K_INSTANCES, IniFile.m_nInstance.ToString) Else ' Leggo il massimo numero di istanze ammesse + Const MAX_INST As Integer = 32 Dim nMaxInst As Integer = GetPrivateProfileInt(S_GENERAL, K_MAXINST, 1) - nMaxInst = Max(1, Min(nMaxInst, 32)) + nMaxInst = Max(1, Min(nMaxInst, MAX_INST)) ' Cerco il primo indice di istanza libero (max 32) Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0) - m_nInstance = 1 + IniFile.m_nInstance = 1 Dim nMask As Integer = 1 - While (nTmp And nMask) <> 0 And m_nInstance <= m_nInstance - m_nInstance += 1 + While (nTmp And nMask) <> 0 And IniFile.m_nInstance < MAX_INST + IniFile.m_nInstance += 1 nMask *= 2 End While ' Se l'indice supera il massimo - If m_nInstance > nMaxInst Then + If IniFile.m_nInstance > nMaxInst Then ' porto in primo piano la prima istanza Dim bFound As Boolean = False ' processi del programma a 32 bit @@ -447,7 +447,7 @@ Namespace EgtCAM5 End End If ' Aggiorno stato istanze attive - nTmp += (1 << (m_nInstance - 1)) + nTmp += (1 << (IniFile.m_nInstance - 1)) WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString()) End If End Sub diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 0b9bb93..2a3db6c 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -13,19 +13,19 @@ Imports System.Windows #If PLATFORM = "x64" Then #If DEBUG Then - - + + #Else - - + + #End if #Else #If DEBUG Then - - + + #Else - - + + #End If #End If @@ -70,5 +70,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/ProjectPage/ProjectViewModel.vb b/ProjectPage/ProjectViewModel.vb index e5494ff..3938822 100644 --- a/ProjectPage/ProjectViewModel.vb +++ b/ProjectPage/ProjectViewModel.vb @@ -151,7 +151,7 @@ Namespace EgtCAM5 ' Chiudo il programma IniFile.m_bFailedRun = True Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND) - ' Verifico abilitazione prodotto + ' 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 @@ -219,7 +219,7 @@ Namespace EgtCAM5 ' Impostazioni Controller m_Controller.SetScene(m_ProjectScene) Dim bLuaReg As Boolean = (GetPrivateProfileInt(S_GENERAL, K_COMMANDLOG, 0) <> 0) - Dim sCmdLogFile As String = CMDLOG_FILE_NAME.Replace("#", m_nInstance.ToString()) + Dim sCmdLogFile As String = CMDLOG_FILE_NAME.Replace("#", IniFile.m_nInstance.ToString()) If Not m_Controller.SetCommandLog(bLuaReg, m_sTempDir, sCmdLogFile) Then EgtOutLog("Command log not started") If Environment.GetCommandLineArgs.Count() <= 1 Then @@ -321,7 +321,7 @@ Namespace EgtCAM5 ' nome file Dim sTitle As String = m_Controller.GetCurrFile() If String.IsNullOrEmpty(sTitle) Then - sTitle = EgtMsg(MSG_TOPCOMMANDBAR + 1) & m_nInstance.ToString() + sTitle = EgtMsg(MSG_TOPCOMMANDBAR + 1) & IniFile.m_nInstance.ToString() End If ' indicazione di modificato If m_Controller.GetModified() Then @@ -440,7 +440,7 @@ Namespace EgtCAM5 Dim sFile As String = String.Empty GetPrivateProfileString(S_GENERAL, K_LASTNGEDIR, "", sFile) sFile.TrimEnd("\"c) - sFile += "\New" & m_nInstance.ToString() & ".nge" + sFile += "\New" & IniFile.m_nInstance.ToString() & ".nge" m_Controller.SaveAsProject(sFile, nType) End If @@ -451,7 +451,7 @@ Namespace EgtCAM5 If String.IsNullOrWhiteSpace(sFile) Then GetPrivateProfileString(S_GENERAL, K_LASTNGEDIR, "", sFile) sFile.TrimEnd("\"c) - sFile += "\New" & m_nInstance.ToString() & ".nge" + sFile += "\New" & IniFile.m_nInstance.ToString() & ".nge" End If m_Controller.SaveAsProject(sFile, nType) End Sub)