71a280e41d
- aggiunta gestione chiave di protezione con limite macchine utilizzabili - impostata cartella dati da programma per script lua
228 lines
8.3 KiB
VB.net
228 lines
8.3 KiB
VB.net
Imports System.IO
|
|
Imports System.Runtime.InteropServices
|
|
Imports System.Security
|
|
Imports System.Windows.Threading
|
|
Imports Effector.Plugin.Interface
|
|
|
|
Public Module EgtInterface
|
|
|
|
#If DEBUG Then
|
|
Const EgtIntDll32 As String = "EgtBasisD32.dll"
|
|
#Else
|
|
Const EgtIntDll32 As String = "EgtBasisR32.dll"
|
|
#End If
|
|
|
|
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtSetKey"), SuppressUnmanagedCodeSecurity()>
|
|
Public Function EgtSetKey(sKey As String) As Boolean
|
|
End Function
|
|
|
|
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyLevel"), SuppressUnmanagedCodeSecurity()>
|
|
Public Function EgtGetKeyLevel(nProd As Integer, nVer As Integer, nLev As Integer, ByRef nKLev As Integer) As Boolean
|
|
End Function
|
|
|
|
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyOptions"), SuppressUnmanagedCodeSecurity()>
|
|
Public Function EgtGetKeyOptions(nProd As Integer, nVer As Integer, nLev As Integer,
|
|
ByRef nOpt1 As UInteger, ByRef nOpt2 As UInteger) As Boolean
|
|
End Function
|
|
|
|
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyLeftDays"), SuppressUnmanagedCodeSecurity()>
|
|
Public Function EgtGetKeyLeftDays(ByRef nLeftDays As Integer) As Boolean
|
|
End Function
|
|
|
|
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyAssLeftDays"), SuppressUnmanagedCodeSecurity()>
|
|
Public Function EgtGetKeyAssLeftDays(ByRef nAssLeftDays As Integer) As Boolean
|
|
End Function
|
|
|
|
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyOptLeftDays"), SuppressUnmanagedCodeSecurity()>
|
|
Public Function EgtGetKeyOptLeftDays(ByRef nOptLeftDays As Integer) As Boolean
|
|
End Function
|
|
|
|
End Module
|
|
|
|
Public Class MainWindowVM
|
|
Inherits vmbase
|
|
|
|
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 ReadOnly Property ContentPanel As Panel
|
|
Get
|
|
Return m_ContentPanel
|
|
End Get
|
|
End Property
|
|
|
|
Private m_ContentMenu As Panel
|
|
Public ReadOnly Property ContentMenu As Panel
|
|
Get
|
|
Return m_ContentMenu
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SplashScreen_Timer As New DispatcherTimer
|
|
Private m_WaitAfterRender As Integer = 0
|
|
|
|
Private m_Window_Opacity As Double = 0.2
|
|
Public ReadOnly Property Window_Opacity As Double
|
|
Get
|
|
Return m_Window_Opacity
|
|
End Get
|
|
End Property
|
|
|
|
' Titolo
|
|
Public ReadOnly Property sTitle As String
|
|
Get
|
|
Return "Effector"
|
|
End Get
|
|
End Property
|
|
|
|
Sub New()
|
|
' Avvio l'inizializzazione della mappa passandogli il riferimento al MainWindowVM
|
|
Map.BeginInit(Me)
|
|
|
|
' imposto e avvio contatore SplashScreen
|
|
m_SplashScreen_Timer.Interval = New TimeSpan(0, 0, 0, 0, 500)
|
|
AddHandler m_SplashScreen_Timer.Tick, AddressOf SplashScreenTimer_Tick
|
|
If Not IsNothing(Map.refSplashScreen) Then
|
|
m_SplashScreen_Timer.Start()
|
|
End If
|
|
|
|
' Creo Model della MainWindow
|
|
m_MainWindowM = New MainWindowM
|
|
|
|
'' Gestione della chiave di protezione
|
|
'Dim sLicFileName As String = ""
|
|
'GetMainPrivateProfileString(S_GENERAL, K_LICENCE, LIC_FILE_NAME, sLicFileName)
|
|
'Dim sLicFile As String = m_MainWindowM.sConfigDir & "\" & sLicFileName
|
|
'Dim sKey As String = ""
|
|
'GenInterface.GetPrivateProfileString(S_LICENCE, K_KEY, "", sKey, sLicFile)
|
|
'EgtSetKey( sKey)
|
|
'' Recupero livello e opzioni della chiave
|
|
'Dim nKeyLevel As Integer = 0
|
|
'Dim nKeyOpt1 As Integer = 0
|
|
'Dim nKeyOpt2 As Integer = 0
|
|
'Dim bKey As Boolean = EgtGetKeyLevel(7375, 2610, 1, nKeyLevel) And
|
|
' EgtGetKeyOptions(7375, 2610, 1, nKeyOpt1, nKeyOpt2)
|
|
|
|
'If Not bKey Then
|
|
' EgtOutLog("Key or Licence Problem (" & (-nKeyLevel).ToString() & ")")
|
|
' MessageBox.Show("Key or Licence Problem (" & (-nKeyLevel).ToString() & ")", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
' EgtOutLog("Exit")
|
|
' End
|
|
'End If
|
|
|
|
' creo gestore della comunicazione
|
|
m_MachineManager = New MachineManager
|
|
m_MachineManager.Init()
|
|
|
|
' recupero nome del plugin
|
|
Dim sPluginName As String = ""
|
|
If GetMainPrivateProfileString(S_GENERAL, K_PLUGINNAME, "", sPluginName) > 0 AndAlso Not String.IsNullOrWhiteSpace(sPluginName) Then
|
|
' aggiungo Dictionary del plugin
|
|
Dim PluginDictionary As IPluginControl = GetDictionary(Of IPluginControl)(sPluginName)
|
|
Application.Current.Resources.MergedDictionaries.Add(PluginDictionary)
|
|
'' aggiungo MainMenu dal plugin
|
|
Dim PluginMainMenu As IPluginControl = GetControlByName(Of IPluginControl)(sPluginName, "MainMenu")
|
|
m_ContentMenu = PluginMainMenu
|
|
'' aggiungo manager delle funzioni Lua del Plugin
|
|
Dim PluginLuaManager As IPluginLuaManager = Map.refMainWindowVM.GetLuaManager(Of IPluginLuaManager)(sPluginName)
|
|
PluginLuaManager.PlgInit(LuaManager.state)
|
|
' aggiungo Project dal plugin
|
|
Dim ProjectPlugin As IPluginControl = GetControlByName(Of IPluginControl)(sPluginName, "Project")
|
|
m_ContentPanel = ProjectPlugin
|
|
End If
|
|
|
|
' creo variabile globale Effector per dati programma
|
|
LuaManager.CreateGlobTable("EFFECTOR")
|
|
LuaManager.SetGlobVar("EFFECTOR.INIPATH", Map.refMainWindowVM.MainWindowM.sConfigDir & "\" & INI_FILE_NAME)
|
|
|
|
' creo gestore delle macchine a stati
|
|
m_FiniteStateMachineManager = New FiniteStateMachineManager
|
|
If GetMainPrivateProfileInt(S_REDIS, K_ENABLED, 0) = 1 Then
|
|
m_RedisManager = New RedisManager
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Friend Sub ContentRendered()
|
|
' segno su contatore splashscreen render finito
|
|
m_WaitAfterRender = 1
|
|
End Sub
|
|
|
|
Private Sub SplashScreenTimer_Tick()
|
|
If m_WaitAfterRender > 1 Then
|
|
m_Window_Opacity = 1
|
|
NotifyPropertyChanged(NameOf(Window_Opacity))
|
|
' chiudo SplashScreen
|
|
Map.refSplashScreen.Close()
|
|
Map.SetRefSplashScreen(Nothing)
|
|
m_SplashScreen_Timer.Stop()
|
|
ElseIf m_WaitAfterRender > 0 Then
|
|
m_WaitAfterRender += 1
|
|
End If
|
|
End Sub
|
|
|
|
#Region "Plugin"
|
|
|
|
Private m_Loader As MEFLoader = New MEFLoader()
|
|
|
|
Private Function GetPathByName(sPluginFileName As String) As String
|
|
Return MainWindowM.sDataRoot & "\Plugin\" & sPluginFileName
|
|
End Function
|
|
|
|
Friend Function GetControlByName(Of T)(sPluginFileName As String, sPluginTagName As String) As Panel
|
|
Dim PlugInControl As Object = m_Loader.LoadByTag(Of T)(GetPathByName(sPluginFileName), sPluginTagName).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
|
|
|
|
Friend Function GetDictionary(Of T)(sPluginFileName As String) As ResourceDictionary
|
|
Dim DictionaryControl As Object = m_Loader.LoadByTag(Of T)(GetPathByName(sPluginFileName), "Dictionary").FirstOrDefault()
|
|
Dim Dictionary As ResourceDictionary = Nothing
|
|
Dictionary = TryCast(DictionaryControl, ResourceDictionary)
|
|
Return DictionaryControl
|
|
End Function
|
|
|
|
Friend Function GetLuaManager(Of T)(sPluginFileName As String) As IPluginLuaManager
|
|
Dim LuaManager As Object = m_Loader.LoadByTag(Of T)(GetPathByName(sPluginFileName), "LuaManager").FirstOrDefault()
|
|
Return LuaManager
|
|
End Function
|
|
|
|
#End Region ' Plugin
|
|
|
|
End Class
|