Files
EgtCAM5/ProjectPage/MachGroupPanel/MachGroupPanelViewModel.vb
T
Dario Sassi 79654b89a5 EgtCAM5 :
- piccola correzione per lancio script lua di init Disp.
2016-10-04 10:19:04 +00:00

105 lines
3.5 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtUILib
Namespace EgtCAM5
Public Class MachGroupPanelViewModel
Inherits ViewModelBase
#Region "FIELDS & PROPERTIES"
Private m_MachGroupList As New ObservableCollection(Of String)
Public Property MachGroupList As ObservableCollection(Of String)
Get
Return m_MachGroupList
End Get
Set(value As ObservableCollection(Of String))
If value IsNot m_MachGroupList Then
m_MachGroupList = value
End If
End Set
End Property
' Definizione comandi
Private m_cmdSetCurrMachGroup As ICommand
'Private m_cmdAddMachGroup As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New()
Application.Msn.Register(Application.INITIALIZEMACHGROUPS, Sub()
InitializeMachGroups()
End Sub)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Private Sub InitializeMachGroups()
Dim bOk As Boolean
Dim nId = EgtGetFirstMachGroup()
If nId <> GDB_ID.NULL Then
bOk = EgtSetCurrMachGroup(nId)
Else
bOk = (EgtAddMachGroup("Mach01") <> GDB_ID.NULL)
Dim sInitScriptPath As String = String.Empty
EgtUILib.GetPrivateProfileString(S_DISPOSITION, K_INITSCRIPT, "", sInitScriptPath, IniFile.m_sCurrMachIniFilePath)
If bOk And Not String.IsNullOrEmpty(sInitScriptPath) Then
sInitScriptPath = IniFile.m_sCurrMachScriptsDirPath & "\" & sInitScriptPath
If Not EgtLuaExecFile(sInitScriptPath) Then
EgtOutLog("Error executing disposition init script " & sInitScriptPath)
MessageBox.Show(EgtMsg(MSG_DISPOSITIONERRORS + 1), EgtMsg(MSG_DISPOSITIONERRORS + 2) & " " & sInitScriptPath, MessageBoxButton.OK, MessageBoxImage.Exclamation)
End If
End If
End If
LoadMachGroups()
Application.Msn.NotifyColleagues(Application.MACHGROUPSRESULT, bOk)
End Sub
Private Sub LoadMachGroups()
' Pulisco la lista
MachGroupList.Clear()
' Carico i gruppi di lavorazione nella lista
Dim nId = EgtGetFirstMachGroup()
While nId <> GDB_ID.NULL
Dim sName As String = String.Empty
EgtGetMachGroupName(nId, sName)
MachGroupList.Add(sName)
nId = EgtGetNextMachGroup(nId)
End While
End Sub
#End Region
#Region "COMMANDS"
#Region "SetCurrMachGroupCommand"
''' <summary>
''' Returns a command that set the selected MachGroup as the Current one.
''' </summary>
Public ReadOnly Property SetCurrMachGroupCommand As ICommand
Get
If m_cmdSetCurrMachGroup Is Nothing Then
m_cmdSetCurrMachGroup = New RelayCommand(AddressOf SetCurrMachGroup)
End If
Return m_cmdSetCurrMachGroup
End Get
End Property
Public Sub SetCurrMachGroup(ByVal param As Object)
EgtSetCurrMachGroup(EgtGetMachGroupId(DirectCast(param, String)))
EgtDraw()
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, -1)
End Sub
#End Region ' SetCurrMachGroupCommand
#End Region ' COMMANDS
End Class
End Namespace