Imports System.Collections.ObjectModel Imports EgtUILib Namespace EgtCAM5 Public Class DoorsPanelViewModel Inherits ViewModelBase Public ReadOnly Property MruDoorNames As ObservableCollection(Of String) Get Return IniFile.m_MruDoors.m_FileNames End Get End Property ' Definizione comandi Private m_cmdDoors As ICommand Private m_cmdDMach As ICommand Private Shared m_cmdOpenMruDoor As ICommand Private m_cmdMTableDb As ICommand #Region "COMMANDS" #Region "DoorsCommand" ''' ''' Returns a command that do Import. ''' Public ReadOnly Property DoorsCommand As ICommand Get If m_cmdDoors Is Nothing Then m_cmdDoors = New RelayCommand(AddressOf Doors) End If Return m_cmdDoors End Get End Property ''' ''' Execute the Door. This method is invoked by the DoorsCommand. ''' Public Sub Doors(ByVal param As Object) Application.Msn.NotifyColleagues(Application.DOORSSCRIPT, String.Empty) End Sub #End Region ' DoorsCommand #Region "OpenMruDoorCommand" ''' ''' Returns a command that do Open. ''' Public Shared ReadOnly Property OpenMruDoorCommand As ICommand Get If m_cmdOpenMruDoor Is Nothing Then m_cmdOpenMruDoor = New RelayCommand(AddressOf OpenMruDoor) End If Return m_cmdOpenMruDoor End Get End Property ''' ''' Execute the Open. This method is invoked by the OpenCommand. ''' Public Shared Sub OpenMruDoor(ByVal param As Object) Application.Msn.NotifyColleagues(Application.DOORSSCRIPT, DirectCast(param, String).Replace("__", "_")) End Sub #End Region ' OpenMruFileCommand #Region "DMachCommand" ''' ''' Returns a command that do Import. ''' Public ReadOnly Property DMachCommand As ICommand Get If m_cmdDMach Is Nothing Then m_cmdDMach = New RelayCommand(AddressOf DMach) End If Return m_cmdDMach End Get End Property ''' ''' Execute the Dmach. This method is invoked by the DMachCommand. ''' Public Sub DMach(ByVal param As Object) Application.Msn.NotifyColleagues(Application.DMACHSCRIPT) End Sub #End Region ' DMachCommand #Region "MTableDbCommand" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property MTableDbCommand As ICommand Get If m_cmdMTableDb Is Nothing Then m_cmdMTableDb = New RelayCommand(AddressOf MTableDb) End If Return m_cmdMTableDb End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub MTableDb(ByVal param As Object) ' Leggo dal file ini il direttorio delle MTable 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 MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 5), EgtMsg(MSG_DOORSERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) Return End If ' Verifico che ci sia il file ini per scrivere le tabelle If Not My.Computer.FileSystem.FileExists(IniFile.m_sTablesRoot & "\" & MTABLETEMPLATE_FILE) OrElse Not My.Computer.FileSystem.FileExists(IniFile.m_sTablesRoot & "\" & GEONAMELIST_FILE) _ OrElse Not My.Computer.FileSystem.FileExists(IniFile.m_sTablesRoot & "\" & OPERATIONLIST_FILE) Then ' Se non la trovo mando messaggio di errore e chiudo la finestra MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 6), EgtMsg(MSG_DOORSERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) Return End If ' verifico If Not EgtVerifyMachinesDir() Then Return Dim MTableDb As New MTableDbV(Application.Current.MainWindow, New MTableDbVM) MTableDb.ShowDialog() 'Dim MTableDbWindow As New MTableDbView 'MTableDbWindow.Height = 614 'MTableDbWindow.Width = 1024 'MTableDbWindow.DataContext = New MTableDbViewModel 'MTableDbWindow.Owner = Application.Current.MainWindow 'MTableDbWindow.ShowDialog() End Sub #End Region ' MTableDbCommand #End Region End Class End Namespace