Files
effector.main/Supervisor/MainWindow/MainWindowVM.vb
T
2024-07-31 16:52:52 +02:00

94 lines
2.9 KiB
VB.net

Imports System.IO
Imports System.Windows.Threading
Imports Supervisor.Plugin.Interface
Public Class MainWindowVM
Friend m_PluginTestInfo As Integer = 764
' Riferimento al Model della MainWindow
Private m_MainWindowM As MainWindowM
Friend ReadOnly Property MainWindowM As MainWindowM
Get
Return m_MainWindowM
End Get
End Property
' Riferimento al gestore delle macchine a stati
Private m_FiniteStateMachineManager As FiniteStateMachineManager
Friend ReadOnly Property FiniteStateMachineManager As FiniteStateMachineManager
Get
Return m_FiniteStateMachineManager
End Get
End Property
' Riferimento al gestore del della comunicazione macchine
Private m_MachineManager As MachineManager
Friend ReadOnly Property MachineManager As MachineManager
Get
Return m_MachineManager
End Get
End Property
' Riferimento al gestore del server Redis
Private m_RedisManager As RedisManager
Friend ReadOnly Property RedisManager As RedisManager
Get
Return m_RedisManager
End Get
End Property
Private m_ContentPanel As Panel
Public Property ContentPanel As Panel
Get
Return m_ContentPanel
End Get
Set(value As Panel)
m_ContentPanel = value
End Set
End Property
Sub New()
' Avvio l'inizializzazione della mappa passandogli il riferimento al MainWindowVM
Map.BeginInit(Me)
' Creo Model della MainWindow
m_MainWindowM = New MainWindowM
' creo gestore delle macchine a stati
m_FiniteStateMachineManager = New FiniteStateMachineManager
m_MachineManager = New MachineManager
m_MachineManager.Init()
m_RedisManager = New RedisManager
Dim PluginUI As IPluginControl = GetControlByName(Of IPluginControl)("Supervisor.Plugin.FiveLakes")
ContentPanel = PluginUI
End Sub
#Region "Plugin"
Private m_Loader As MEFLoader = New MEFLoader()
Private Function GetPathByName(ByVal name As String) As String
'Dim PluginNameSplit() As String = name.Split("."c)
'Dim res = MainWindowM.sDataRoot & "\Plugin\" & PluginNameSplit(0)
Dim res = MainWindowM.sDataRoot & "\Plugin\" & name
Return res
End Function
Friend Function GetControlByName(Of T)(sName As String) As Panel
Dim PlugInControl As Object = m_Loader.LoadByTag(Of T)(GetPathByName(sName), sName).FirstOrDefault()
Dim PluginPanel As Panel = Nothing
If PlugInControl.GetType().BaseType.FullName = GetType(Panel).FullName OrElse PlugInControl.GetType().BaseType.FullName = GetType(Grid).FullName Then
PluginPanel = TryCast(PlugInControl, Panel)
End If
Return PluginPanel
End Function
#End Region ' Plugin
End Class