Imports System.Collections.ObjectModel Imports EgtUILib Imports EgtWPFLib5 Public Class MachinePanelVM Inherits VMBase #Region "FIELDS & PROPERTIES" ' Radice del direttorio delle macchine Private m_sMachinesRoot As String Friend ReadOnly Property sMachinesRoot As String Get Return m_sMachinesRoot End Get End Property ' Lista delle macchine disponibili Private m_MachineList As ObservableCollection(Of Machine) Public Property MachineList As ObservableCollection(Of Machine) Get Return m_MachineList End Get Set(value As ObservableCollection(Of Machine)) m_MachineList = value End Set End Property ' Macchina correntemente selezionata e quindi attiva Private m_SelectedMachine As Machine Public Property SelectedMachine As Machine Get Return m_SelectedMachine End Get Set(value As Machine) If value IsNot m_SelectedMachine Then 'EgtSetCurrentContext(IniFile.m_ProjectSceneContext) If EgtSetCurrMachine(value.Name) Then m_SelectedMachine = value 'IniFile.m_sMachineName = m_SelectedMachine.Name 'IniFile.m_sCurrMachIniFilePath = m_SelectedMachine.MachineDirPath & "\" & m_SelectedMachine.Name & ".ini" 'IniFile.m_sCurrMachToolsDirPath = m_SelectedMachine.MachineDirPath & "\Tools" 'IniFile.m_sCurrMachSetUpDirPath = m_SelectedMachine.MachineDirPath & "\SetUp" 'IniFile.m_sCurrMachScriptsDirPath = m_SelectedMachine.MachineDirPath & "\Scripts" 'UpdateToolAndMachDbParamVisibility() NotifyPropertyChanged("SelectedMachine") End If End If End Set End Property ' Definizione comandi Private m_cmdToolDb As ICommand Private m_cmdMachDb As ICommand Private m_cmdMachOptions As ICommand #Region "Messages" Public ReadOnly Property ToolDBMsg As String Get Return "Tool DB" End Get End Property Public ReadOnly Property MachiningDbMsg As String Get Return "Machining DB" End Get End Property #End Region ' Messages #Region "ToolTip" Public ReadOnly Property ToolDBToolTip As String Get Return "Tool DB" End Get End Property Public ReadOnly Property MachiningDbToolTip As String Get Return "Machining DB" End Get End Property #End Region ' ToolTip #End Region 'FIELDS & PROPERTIES #Region "CONSTRUCTOR" Sub New() ' Creo riferimento a questa classe in OmagOFFICEMap OmagOFFICEMap.SetRefMachinePanelVM(Me) ' recupero cartella radice delle macchine m_sMachinesRoot = OmagOFFICE.refMainWindowVM.MainWindowM.sMachinesRoot ' Carica macchine da cartella delle macchine Dim MachineList As New List(Of Machine) If Machine.MachineListInit(sMachinesRoot, MachineList) Then 'OmagOFFICEMap.refMainWindowVM.MainWindowM.sMachinesRoot, MachineList) Then m_MachineList = New ObservableCollection(Of Machine)(MachineList) End If End Sub #End Region ' CONSTRUCTOR #Region "METHODS" #End Region #Region "COMMANDS" #Region "ToolDbCommand" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property ToolDbCommand As ICommand Get If m_cmdToolDb Is Nothing Then m_cmdToolDb = New Command(AddressOf ToolDb) End If Return m_cmdToolDb End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub ToolDb(ByVal param As Object) 'If Not EgtVerifyMachinesDir() Then Return '' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) 'If Not EgtTdbReload() Then ' EgtOutLog("Impossible reloading tool Db") ' MessageBox.Show(EgtMsg(MSG_TOOLSERRORS + 30), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) ' Return 'End If 'Dim ToolDbWindow As New ToolsDbView 'ToolDbWindow.Height = 640 'ToolDbWindow.Width = 1024 'ToolDbWindow.DataContext = New ToolsDbViewModel 'ToolDbWindow.Owner = Application.Current.MainWindow 'ToolDbWindow.ShowDialog() End Sub #End Region ' ToolDbCommand #Region "MachDbCommand" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property MachDbCommand As ICommand Get If m_cmdMachDb Is Nothing Then m_cmdMachDb = New Command(AddressOf MachDb) End If Return m_cmdMachDb End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub MachDb(ByVal param As Object) 'If Not EgtVerifyMachinesDir() Then Return '' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) 'If Not EgtMdbReload() Then ' EgtOutLog("Impossible reloading machining Db") ' MessageBox.Show(EgtMsg(MSG_MACHININGSERRORS + 7), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) ' Return 'End If 'Dim MachDbWindow As New MachiningsDbView 'MachDbWindow.Height = 614 'MachDbWindow.Width = 1024 'MachDbWindow.DataContext = New MachiningsDbViewModel 'MachDbWindow.Owner = Application.Current.MainWindow 'MachDbWindow.ShowDialog() End Sub #End Region ' MachDbCommand #Region "MachOptionsCommand" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property MachOptionsCommand As ICommand Get If m_cmdMachOptions Is Nothing Then m_cmdMachOptions = New Command(AddressOf MachOptions) End If Return m_cmdMachOptions End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub MachOptions(ByVal param As Object) 'Dim MachOptionWindow As New MachOptionsView ''MachOptionWindow.Height = 614 ''MachOptionWindow.Width = 256 'MachOptionWindow.DataContext = New MachOptionsViewModel 'MachOptionWindow.Owner = Application.Current.MainWindow 'MachOptionWindow.ShowDialog() End Sub #End Region ' MachOptionsCommand #End Region ' COMMANDS End Class