diff --git a/Application.xaml.vb b/Application.xaml.vb
index b3564f8..9ec6000 100644
--- a/Application.xaml.vb
+++ b/Application.xaml.vb
@@ -7,6 +7,7 @@ Class Application
' can be handled in this file.
Protected Overrides Sub OnStartUp(e As System.Windows.StartupEventArgs)
MyBase.OnStartup(e)
+ ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose
' Creo la View principale
Dim MainWndView As New MainWindow
' Creo il ViewModel principale
diff --git a/Constants/ConstGen.vb b/Constants/ConstGen.vb
index b35c097..b472826 100644
--- a/Constants/ConstGen.vb
+++ b/Constants/ConstGen.vb
@@ -25,9 +25,9 @@ Module ConstGen
Public Const K_KEY As String = "Key"
' File di log generale
- Public Const GENLOG_FILE_NAME As String = "EgtCAM5Log.txt"
+ Public Const GENLOG_FILE_NAME As String = "EgtCAM5Log#.txt"
' File di log dei comandi
- Public Const CMDLOG_FILE_NAME As String = "EgtCAM5Log.tua"
+ Public Const CMDLOG_FILE_NAME As String = "EgtCAM5Log#.tua"
' Sottodirettorio di configurazione
Public Const CONF_DIR As String = "Config"
diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj
index 92bcb94..f2ffffa 100644
--- a/EgtCAM5.vbproj
+++ b/EgtCAM5.vbproj
@@ -74,6 +74,9 @@
OnBuildSuccess
+
+ Resources\EgtCAM5.ico
+
..\..\EgtProg\DllD32\EgtUILib.dll
diff --git a/IniFile.vb b/IniFile.vb
index 4337d13..08f5856 100644
--- a/IniFile.vb
+++ b/IniFile.vb
@@ -14,7 +14,8 @@ Module IniFile
Return m_nUserLevel
End Get
End Property
- Friend m_sIniFilePath As String
+ Friend m_sIniFile As String
+ Friend m_sTempDir As String
Friend m_sMachinesRoot As String
' Project Page
Friend m_ProjectSceneContext As Integer = 0
@@ -27,35 +28,35 @@ Module IniFile
Friend m_ToolsDbSceneContext As Integer = 0
Public Function GetPrivateProfileInt(IpAppName As String, IpKeyName As String, nDefault As Integer) As Integer
- Return EgtUILib.GetPrivateProfileInt(IpAppName, IpKeyName, nDefault, m_sIniFilePath)
+ Return EgtUILib.GetPrivateProfileInt(IpAppName, IpKeyName, nDefault, m_sIniFile)
End Function
Public Function GetPrivateProfileDouble(IpAppName As String, IpKeyName As String, nDefault As Integer) As Double
- Return EgtUILib.GetPrivateProfileDouble(IpAppName, IpKeyName, nDefault, m_sIniFilePath)
+ Return EgtUILib.GetPrivateProfileDouble(IpAppName, IpKeyName, nDefault, m_sIniFile)
End Function
Public Function GetPrivateProfileString(IpAppName As String, IpKeyName As String, IpDefault As String, ByRef IpString As String) As Integer
- Return EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_sIniFilePath)
+ Return EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_sIniFile)
End Function
Public Function GetPrivateProfileColor(IpAppName As String, IpKeyName As String, ByRef Col As EgtUILib.EgtInterface.Color3d) As Boolean
- Return EgtUILib.GetPrivateProfileColor(IpAppName, IpKeyName, Col, m_sIniFilePath)
+ Return EgtUILib.GetPrivateProfileColor(IpAppName, IpKeyName, Col, m_sIniFile)
End Function
Public Function GetPrivateProfileWinPos(IpAppName As String, IpKeyName As String, ByRef nFlag As Integer, ByRef nLeft As Integer, ByRef nTop As Integer, ByRef nWidth As Integer, ByRef nHeight As Integer) As Boolean
- Return EgtUILib.GetPrivateProfileWinPos(IpAppName, IpKeyName, nFlag, nLeft, nTop, nWidth, nHeight, m_sIniFilePath)
+ Return EgtUILib.GetPrivateProfileWinPos(IpAppName, IpKeyName, nFlag, nLeft, nTop, nWidth, nHeight, m_sIniFile)
End Function
Public Function GetPrivateProfileZoomWin(IpAppName As String, IpKeyName As String, ByRef bOutline As Boolean, ByRef Col As EgtUILib.EgtInterface.Color3d) As Boolean
- Return EgtUILib.GetPrivateProfileZoomWin(IpAppName, IpKeyName, bOutline, Col, m_sIniFilePath)
+ Return EgtUILib.GetPrivateProfileZoomWin(IpAppName, IpKeyName, bOutline, Col, m_sIniFile)
End Function
Public Function WritePrivateProfileString(IpAppName As String, IpKeyName As String, ByRef IpString As String) As Boolean
- Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, IpString, m_sIniFilePath)
+ Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, IpString, m_sIniFile)
End Function
Public Function WritePrivateProfileWinPos(IpAppName As String, IpKeyName As String, ByRef nFlag As Integer, ByRef nLeft As Integer, ByRef nTop As Integer, ByRef nWidth As Integer, ByRef nHeight As Integer) As Boolean
- Return EgtUILib.WritePrivateProfileWinPos(IpAppName, IpKeyName, nFlag, nLeft, nTop, nWidth, nHeight, m_sIniFilePath)
+ Return EgtUILib.WritePrivateProfileWinPos(IpAppName, IpKeyName, nFlag, nLeft, nTop, nWidth, nHeight, m_sIniFile)
End Function
End Module
diff --git a/MainWindow/MainWindow.xaml b/MainWindow/MainWindow.xaml
index c3515a9..106d000 100644
--- a/MainWindow/MainWindow.xaml
+++ b/MainWindow/MainWindow.xaml
@@ -19,9 +19,6 @@
-
-
-
diff --git a/MainWindow/MainWindowViewModel.vb b/MainWindow/MainWindowViewModel.vb
index b01cff6..7488a67 100644
--- a/MainWindow/MainWindowViewModel.vb
+++ b/MainWindow/MainWindowViewModel.vb
@@ -16,9 +16,6 @@ Namespace EgtCAM5
'' '' '' '' '' ''Private m_nInstance As Integer = 0
Private m_sDataRoot As String = String.Empty
Private m_sConfigDir As String = String.Empty
- Private m_sTempDir As String = String.Empty
- Private m_sMachinesRoot As String = String.Empty
- Private m_sIniFile As String = String.Empty
Private m_nDebug As Integer = 0
' Opzioni abilitate dalla licenza attiva associata alla chiave
'Private m_nKeyOptions As UInteger
@@ -151,64 +148,6 @@ Namespace EgtCAM5
#Region "COMMANDS"
-#Region "cmdMainWindow_Closing"
-
- '''
- ''' Returns a command that manage the MainWindow_Unloaded command
- '''
- Public ReadOnly Property cmdMainWindow_Closing() As ICommand
- Get
- If m_cmdMainWindow_Closing Is Nothing Then
- m_cmdMainWindow_Closing = New RelayCommand(AddressOf MainWindow_Closing, AddressOf CanMainWindow_Closing)
- End If
- Return m_cmdMainWindow_Closing
- End Get
- End Property
-
- '''
- ''' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
- '''
- Public Sub MainWindow_Closing(ByVal param As Object)
- 'Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATION)
- ' '' Gestisco eventuale file corrente modificato
- 'Application.Msn.NotifyColleagues(Application.MANAGEMODIFIED)
- ''If m_allowWindowToClose Then
- '' CloseCommand = New RelayCommand(Nothing, Function() True)
- ''End If
- '' Salvo posizione Form (se non minimizzato)
- 'If Application.Current.MainWindow.WindowState <> WindowState.Minimized Then
- ' Dim WinPos As New WinPos
- ' WindowToWinPos(Application.Current.MainWindow, WinPos)
- ' WritePrivateProfileWinPos(S_GENERAL, K_WINPLACE, WinPos.nFlag, WinPos.nLeft, WinPos.nTop, WinPos.nWidth, WinPos.nHeight)
- 'End If
- '' Terminazione generale di EgtInterface
- 'EgtExit()
- '' Rilascio mutex
- 'm_objMutex.Close()
- '' Aggiorno istanze usate
- 'Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0)
- 'nTmp -= (1 << (m_nInstance - 1))
- 'WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
- ' '' Disabilito gestore Idle
- ''RemoveHandler Application.Idle, AddressOf Application_Idle
-
- End Sub
-
- '''
- ''' Returns true if the application can be closed
- '''
- Private Function CanMainWindow_Closing(ByVal param As Object) As Boolean
- '' Impedisco uscita se script in esecuzione
- 'If m_bScriptRunning Then
- ' m_bStopScript = True
- ' E.Cancel = True
- ' Return
- 'End If
- Return True
- End Function
-
-#End Region ' Closing Command
-
#Region "CloseApplicationCommand"
'''
@@ -346,6 +285,14 @@ Namespace EgtCAM5
Private Sub RegisterMyMessages()
Application.Msn.Register(Application.CLOSEAPPLICATIONCOMMAND, Sub()
+ ' Terminazione generale di EgtInterface
+ EgtExit()
+ ' Rilascio mutex
+ m_objMutex.Close()
+ ' Aggiorno istanze usate
+ Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0)
+ nTmp -= (1 << (m_nInstance - 1))
+ WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
Application.Current.MainWindow.Close()
End Sub)
Application.Msn.Register(Application.ALLOWWINDOWTOCLOSE, Sub(bBoolean As Boolean)
@@ -374,8 +321,6 @@ Namespace EgtCAM5
m_sTempDir = m_sDataRoot & "\" & TEMP_DIR
' Impostazione path Ini file
m_sIniFile = m_sConfigDir & "\" & INI_FILE_NAME
- ' Lo riporto nel modulo IniFile
- IniFile.m_sIniFilePath = m_sIniFile
' Impostazione direttorio per le macchine
If GetPrivateProfileString(S_MACH, K_MACHINESDIR, "", m_sMachinesRoot) = 0 Then
m_sMachinesRoot = m_sDataRoot & "\" & MACHINES_DFL_DIR
@@ -383,8 +328,6 @@ Namespace EgtCAM5
IniFile.m_sMachinesRoot = m_sMachinesRoot
' Verifico indice di istanza
ManageIstance()
- 'Imposto nome file log
- Dim sCmdLogFile As String = CMDLOG_FILE_NAME.Replace("#", m_nInstance.ToString())
' Leggo e imposto chiave di protezione
Dim sLicFileName As String = String.Empty
GetPrivateProfileString(S_GENERAL, K_LICENCE, LIC_FILE_NAME, sLicFileName)
@@ -392,12 +335,14 @@ Namespace EgtCAM5
Dim sKey As String = String.Empty
EgtUILib.GetPrivateProfileString(S_LICENCE, K_KEY, "", sKey, sLicFile)
EgtSetKey(sKey)
- ' Recupero opzioni della chiave
- Dim bKey As Boolean = EgtGetKeyOptions(3279, 16, 1, m_nKeyOptions)
+ ' Recupero livello e opzioni della chiave
+ Dim bKey As Boolean = EgtGetKeyLevel(3279, 16, 1, m_nUserLevel) And
+ EgtGetKeyOptions(3279, 16, 1, m_nKeyOptions)
' Inizializzazione generale di EgtInterface
m_nDebug = GetPrivateProfileInt(S_GENERAL, K_DEBUG, 0)
- Dim sLogFile As String = m_sTempDir & "\" & GENLOG_FILE_NAME
- Dim sLogMsg As String = My.Application.Info.Description.ToString() & " ver. " & My.Application.Info.Version.ToString()
+ Dim sLogFile As String = 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. " & My.Application.Info.Version.ToString()
EgtInit(m_nDebug, sLogFile, sLogMsg)
' Leggo direttorio dei messaggi (se manca uso direttorio di configurazione)
Dim sMsgDir As String = String.Empty
@@ -412,7 +357,8 @@ Namespace EgtCAM5
EgtOutLog("Error in EgtLoadMessages")
End If
' Leggo e imposto livello utilizzatore
- IniFile.m_nUserLevel = GetPrivateProfileInt(S_GENERAL, K_USERLEVEL, 1)
+ Dim nIniLev = GetPrivateProfileInt(S_GENERAL, K_USERLEVEL, 1)
+ m_nUserLevel = Math.Min(m_nUserLevel, nIniLev)
' imposto dir font Nfe e font default
Dim sNfeDir As String = String.Empty
GetPrivateProfileString(S_GEOMDB, K_NFEFONTDIR, "", sNfeDir)
@@ -426,21 +372,10 @@ Namespace EgtCAM5
Dim sLuaBaseLib As String = String.Empty
GetPrivateProfileString(S_LUA, K_BASELIB, "EgtBase", sLuaBaseLib)
EgtLuaRequire(sLuaBaseLib)
- '' aggiungo voce per about box nel menù di sistema
- 'Dim hSysMenu As IntPtr = GetSystemMenu(Handle, False)
- 'If hSysMenu <> IntPtr.Zero Then
- ' AppendMenu(hSysMenu, MF_SEPARATOR, 0, "")
- ' AppendMenu(hSysMenu, MF_STRING, IDM_ABOUTBOX, "About TestEIn...")
- 'End If
' Posizione e dimensioni del Form
Dim WinPos As New WinPos
GetPrivateProfileWinPos(S_GENERAL, K_WINPLACE, WinPos.nFlag, WinPos.nLeft, WinPos.nTop, WinPos.nWidth, WinPos.nHeight)
WinPosToWindow(Application.Current.MainWindow, WinPos)
- 'If m_Controller.GetCommandLog() Then
- ' tsStatusReg.BackColor = Color.Lime
- 'ElseIf bLuaReg Then
- ' tsStatusReg.BackColor = Color.Red
- 'End If
'' Impostazioni MruLists
'm_MruFiles.Init(m_sIniFile, S_MRUFILES, 8)
'm_MruScripts.Init(m_sIniFile, S_MRUSCRIPTS, 8)
diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb
index 37941d3..6e9c840 100644
--- a/My Project/AssemblyInfo.vb
+++ b/My Project/AssemblyInfo.vb
@@ -70,5 +70,5 @@ Imports System.Windows
' by using the '*' as shown below:
'
-
-
+
+
diff --git a/ProjectPage/ProjectViewModel.vb b/ProjectPage/ProjectViewModel.vb
index 39850a8..dcb2288 100644
--- a/ProjectPage/ProjectViewModel.vb
+++ b/ProjectPage/ProjectViewModel.vb
@@ -12,6 +12,8 @@ Namespace EgtCAM5
Private m_CloseProgram As Boolean = False
+ Private m_bLoaded As Boolean = False
+
'PROJECT PAGE'S PANELS
Private m_GridViewPanel As BaseWindowView
Private m_DrawPanel As BaseWindowView
@@ -121,6 +123,8 @@ Namespace EgtCAM5
''' Execute the Point. This method is invoked by the PointCommand.
'''
Public Sub Loaded(ByVal param As Object)
+ If m_bLoaded Then Return
+ m_bLoaded = True
' Creazione scena
PreInitializeScene()
If Not m_ProjectScene.Init() Then
@@ -197,16 +201,17 @@ Namespace EgtCAM5
End Sub
Private Sub PostInitializeScene()
- 'Impostazioni Controller
+ ' Impostazioni Controller
m_Controller.SetScene(m_ProjectScene)
Dim bLuaReg As Boolean = (GetPrivateProfileInt(S_GENERAL, K_COMMANDLOG, 0) <> 0)
- 'If Not m_Controller.SetCommandLog(bLuaReg, m_sTempDir, sCmdLogFile) Then
- EgtOutLog("Command log not started")
- If Environment.GetCommandLineArgs.Count() = 0 Then
- MessageBox.Show("Command log not started", "TestEIn Warning",
- MessageBoxButton.OK, MessageBoxImage.Warning)
+ Dim sCmdLogFile As String = CMDLOG_FILE_NAME.Replace("#", m_nInstance.ToString())
+ If Not m_Controller.SetCommandLog(bLuaReg, m_sTempDir, sCmdLogFile) Then
+ EgtOutLog("Command log not started")
+ If Environment.GetCommandLineArgs.Count() = 0 Then
+ MessageBox.Show("Command log not started", "TestEIn Warning",
+ MessageBoxButton.OK, MessageBoxImage.Warning)
+ End If
End If
- 'End If
' imposto unità di misura per interfaccia utente
m_bMmUnits = (GetPrivateProfileInt(S_SCENE, K_MMUNITS, 1) <> 0)
Application.Msn.NotifyColleagues(Application.UPDATESTATUSUNITS, m_bMmUnits)