Imports System.IO Imports EgtUILib Namespace EgtCAM5 Public Class SpecialPanelViewModel Private m_ButtonList As New List(Of ButtonItem) Public ReadOnly Property ButtonList As List(Of ButtonItem) Get Return m_ButtonList End Get End Property Sub New() ' se attivo, inizializzo i bottoni leggendoli da file ini If IniFile.IsActiveSpecialPanel Then Dim BtnIndex As Integer = 1 Dim CurrBtn As ButtonItem = Nothing While GetPrivateProfileButton(S_SPECIAL, K_BUTTON & BtnIndex, CurrBtn) m_ButtonList.Add(CurrBtn) BtnIndex += 1 End While End If End Sub End Class End Namespace Public Class ButtonItem Private m_sImagePath As String Public ReadOnly Property ImagePath As String Get Return m_sImagePath End Get End Property Private m_sLuaCmdPath As String Private m_sToolTip As String Public ReadOnly Property ToolTip As String Get Return m_sToolTip End Get End Property ' Definizione comandi Private m_cmdLuaExec As ICommand Sub New(sLuaCmdPath As String, sImagePath As String, sToolTip As String) m_sImagePath = IniFile.m_sResourcesRoot & "\" & sImagePath m_sLuaCmdPath = sLuaCmdPath m_sToolTip = sToolTip End Sub #Region "COMMANDS" #Region "LuaExecCommand" ''' ''' Returns a command that do New. ''' Public ReadOnly Property LuaExecCommand As ICommand Get If m_cmdLuaExec Is Nothing Then m_cmdLuaExec = New Command(AddressOf LuaExec) End If Return m_cmdLuaExec End Get End Property ''' ''' Execute the New. This method is invoked by the NewCommand. ''' Public Sub LuaExec(ByVal param As Object) If String.IsNullOrWhiteSpace(m_sLuaCmdPath) Then Return If Not File.Exists(m_sLuaCmdPath) Then Return If Not Path.GetExtension(m_sLuaCmdPath).ToLower = ".lua" Then Return ' eseguo file Lua Application.Msn.NotifyColleagues(Application.EXECSCRIPT, m_sLuaCmdPath) End Sub #End Region ' LuaExecCommand #End Region ' Commands End Class