Imports System.IO Imports EgtUILib Imports EgtWPFLib5 Public Class SpecialPanelVM Inherits VMBase Private m_ButtonList As New List(Of ButtonItem) Public ReadOnly Property ButtonList As List(Of ButtonItem) Get Return m_ButtonList End Get End Property Private m_SpecialPanelVisibility As Visibility Public ReadOnly Property SpecialPanelVisibility As Visibility Get Return m_SpecialPanelVisibility End Get End Property Friend Sub SetSpecialPanelVisibility(bValue As Boolean) m_SpecialPanelVisibility = If(bValue, Visibility.Visible, Visibility.Collapsed) NotifyPropertyChanged(NameOf(SpecialPanelVisibility)) End Sub Sub New() ' Creo riferimento a questa classe in Map Map.SetRefSpecialPanelVM(Me) ' se attivo, inizializzo i bottoni leggendoli da file ini If OptionModule.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 Public Class ButtonItem Inherits VMBase 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 Friend m_Btn_Visibility As Visibility Public ReadOnly Property Btn_Visibility As Visibility Get Return m_Btn_Visibility End Get End Property Friend m_Btn_IsEnabled As Boolean = True Public ReadOnly Property Btn_IsEnabled As Boolean Get Return m_Btn_IsEnabled End Get End Property ' Definizione comandi Private m_cmdLuaExec As ICommand Sub New(sLuaCmdPath As String, sImagePath As String, sToolTip As String) ' creo il percorso del file m_sImagePath = IniFile.m_sResourcesRoot & "\" & sImagePath If Not File.Exists(m_sImagePath) Then EgtOutLog("File '" & m_sImagePath & "' does not exist.") End If m_sLuaCmdPath = IniFile.m_sScriptsRoot & "\" & sLuaCmdPath m_sToolTip = sToolTip End Sub #Region "COMMANDS" #Region "LuaExecCommand" 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 Public Sub LuaExec(ByVal param As Object) If Not File.Exists(m_sLuaCmdPath) Then EgtOutLog("File '" & m_sLuaCmdPath & "' does not exists.") Return End If If Not Path.GetExtension(m_sLuaCmdPath).ToLower = ".lua" Then EgtOutLog("File '" & m_sLuaCmdPath & "' has not '.lua' extension.") Return End If Dim bOk As Boolean = EgtLuaExecFile(m_sLuaCmdPath) If Not bOk Then EgtOutLog("File '" & m_sLuaCmdPath & "' has not been excute.") End If End Sub #End Region ' LuaExecCommand #End Region ' Commands End Class