Files
EgtDOORCreator/CompoPanel/CompoPanelViewModel.vb
T
Nicola Pievani cb84da03cd EgtDOORCreator 1.8e7 :
- Inserimento della guida
2017-05-25 17:09:28 +00:00

120 lines
4.2 KiB
VB.net

Imports System.ComponentModel
Imports System.Collections.ObjectModel
Imports EgtUILib
Imports System.IO
Public Class CompoPanelViewModel
Implements INotifyPropertyChanged
Private m_rfMainWindowViewModel As MainWindowViewModel
Private m_rfDoorParametersViewModel As DoorParametersViewModel
Dim m_Chapter As String
Private Shared m_CompoTypeList As New ObservableCollection(Of CompoType)
Public Shared ReadOnly Property CompoTypeList As ObservableCollection(Of CompoType)
Get
Return m_CompoTypeList
End Get
End Property
' Definizione comando
Private m_CmdCompoBtn As ICommand
' definizione comando
Private m_EnterRefreshCmd As ICommand
Sub New(MainWindowViewModel As MainWindowViewModel)
m_rfMainWindowViewModel = MainWindowViewModel
m_rfDoorParametersViewModel = DirectCast(m_rfMainWindowViewModel.DoorParameters.DataContext, DoorParametersViewModel)
Dim IndexCompoOrder = 0
Dim CompoPanelList As List(Of String) = OptionModule.m_CompoPaneOrder
' Lettura file ini per generare bottoni
Dim Index As Integer = 1
Dim CompoName As String = String.Empty
Dim CompoNameDDF As String = String.Empty
' Carico un vettore con il nome delle Path delle componenti
Dim CompoDirectory As String = String.Empty
If GetPrivateProfileString(S_DOORS, K_COMPODIR, "", CompoDirectory) <> 0 Then
IniFile.m_CompoDir = CompoDirectory
End If
Dim CompoArray() As String = Directory.GetDirectories(CompoDirectory)
' carico i valori dei bottoni con un preciso ordine
For IndexCompoOrder = 0 To DdfFile.CompoListOrder.Count - 1
For Index = 0 To CompoArray.Count - 1
' apro ogni directory e cerco un file di testo di nome Config.ini
Dim CurrCompoPath As String = CompoArray(Index) & "\" & ConstCompo.CONFIGINI_FILE_NAME
If File.Exists(CurrCompoPath) Then
GetPrivateProfileCompoName(ConstCompo.S_COMPO, ConstCompo.K_NAME, CompoNameDDF, CompoName, CurrCompoPath)
If CompoPanelList(IndexCompoOrder) = CompoNameDDF Then
m_CompoTypeList.Add(New CompoType(CompoName, CompoNameDDF, CompoArray(Index)))
Exit For
End If
End If
Next
Next
End Sub
#Region "COMMANDS"
#Region "CompoBtnCommand"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property CompoBtnCommand As ICommand
Get
If m_CmdCompoBtn Is Nothing Then
m_CmdCompoBtn = New Command(AddressOf CompoBtn)
End If
Return m_CmdCompoBtn
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
'''
Public Sub CompoBtn(param As Object)
Dim m_CurrCompoType As CompoType = DirectCast(param, CompoType)
If Not IsNothing(m_rfDoorParametersViewModel.CurrDoor) Then
m_rfDoorParametersViewModel.CurrDoor.AddNewCompo(m_CurrCompoType)
'richiamo la pagina della guida ssociata alla componente selezionata
GuideViewModel.m_AddressGuide = m_CurrCompoType.DDFName & ".html"
Else
MessageBox.Show(EgtMsg(50108), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Exclamation)
End If
End Sub
#End Region ' CompoBtnCommand
#Region "ENTERREFRESH"
''' <summary>
''' Returns a command that do Refresh.
''' </summary>
Public ReadOnly Property RefreshCmd As ICommand
Get
If m_EnterRefreshCmd Is Nothing Then
m_EnterRefreshCmd = New Command(AddressOf EnterRefresh)
End If
Return m_EnterRefreshCmd
End Get
End Property
Public Sub EnterRefresh()
DirectCast(m_rfMainWindowViewModel.SceneManager.DataContext, SceneManagerViewModel).RefreshBtn()
End Sub
#End Region ' EnterRefresh
#End Region 'Commands
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class