EgtCAM5 :
- Migliorie varie.
This commit is contained in:
@@ -47,6 +47,7 @@ Namespace EgtCAM5
|
||||
Private m_cmdMainWindow_Deactivated As ICommand
|
||||
' MainWindow Closing Event
|
||||
Private m_cmdMainWindow_Closing As ICommand
|
||||
Private m_cmdCloseApplication As ICommand
|
||||
|
||||
' GRAPHICAL ELEMENTS
|
||||
Private m_TopCommandBar As TopCommandBarView
|
||||
@@ -132,7 +133,7 @@ Namespace EgtCAM5
|
||||
#Region "CONSTRUCTOR"
|
||||
|
||||
Sub New()
|
||||
'Application.Current.MainWindow.Icon = New System.Windows.Media.Imaging.BitmapImage(New Uri("/Resources/EgtCAM5.ico", UriKind.Relative))
|
||||
|
||||
RegisterMyMessages()
|
||||
' INITIALIZE EGALTECH ENVIRONMENT
|
||||
InitializeEgtEnvironment()
|
||||
@@ -170,9 +171,9 @@ Namespace EgtCAM5
|
||||
Public Sub MainWindow_Closing(ByVal param As Object)
|
||||
Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATION)
|
||||
'' Gestisco eventuale file corrente modificato
|
||||
'If Not m_Controller.ManageModified() Then
|
||||
' E.Cancel = True
|
||||
' Return
|
||||
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
|
||||
@@ -208,6 +209,63 @@ Namespace EgtCAM5
|
||||
|
||||
#End Region ' Closing Command
|
||||
|
||||
#Region "CloseApplicationCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that manage the MainWindow_Unloaded command
|
||||
''' </summary>
|
||||
Public ReadOnly Property CloseApplicationCommand() As ICommand
|
||||
Get
|
||||
If m_cmdCloseApplication Is Nothing Then
|
||||
m_cmdCloseApplication = New RelayCommand(AddressOf CloseApplication, AddressOf CanCloseApplication)
|
||||
End If
|
||||
Return m_cmdCloseApplication
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
||||
''' </summary>
|
||||
Public Sub CloseApplication(ByVal param As Object)
|
||||
'' Gestisco eventuale file corrente modificato
|
||||
Application.Msn.NotifyColleagues(Application.MANAGEMODIFIED)
|
||||
If m_allowWindowToClose Then
|
||||
Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATION)
|
||||
' 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
|
||||
Application.Current.MainWindow.Close()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Returns true if the application can be closed
|
||||
''' </summary>
|
||||
Private Function CanCloseApplication(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 ' CloseApplicationCommand
|
||||
|
||||
#Region "cmdMainWindow_ContentRendered"
|
||||
|
||||
''' <summary>
|
||||
@@ -288,6 +346,9 @@ Namespace EgtCAM5
|
||||
Application.Msn.Register(Application.CLOSEAPPLICATIONCOMMAND, Sub()
|
||||
Application.Current.MainWindow.Close()
|
||||
End Sub)
|
||||
Application.Msn.Register(Application.ALLOWWINDOWTOCLOSE, Sub(bBoolean As Boolean)
|
||||
m_allowWindowToClose = bBoolean
|
||||
End Sub)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
@@ -470,6 +531,16 @@ Namespace EgtCAM5
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Verify closing"
|
||||
|
||||
''' <summary>
|
||||
''' Should we let our window close?
|
||||
''' </summary>
|
||||
Private m_allowWindowToClose As Boolean = False
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user