- aggiunto splashscreen

- aggiunta gestione chiave di protezione con limite macchine utilizzabili
- impostata cartella dati da programma per script lua
This commit is contained in:
Emmanuele Sassi
2024-11-08 13:14:07 +01:00
parent f47809379d
commit 71a280e41d
16 changed files with 263 additions and 44 deletions
+8 -2
View File
@@ -5,10 +5,16 @@
Protected Overrides Sub OnStartup(e As StartupEventArgs)
MyBase.OnStartup(e)
ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose
If e.Args.Count = 0 Then
' creo finestra SplashScreen
Dim SplashScreen As New SplashScreen
Me.MainWindow = SplashScreen
Me.MainWindow.Show()
Map.SetRefSplashScreen(SplashScreen)
End If
' Creo la View principale
Dim MainWindowVM As New MainWindowVM
Me.MainWindow = New MainWindowV
Me.MainWindow.DataContext = MainWindowVM
' Mostro la View principale
Me.MainWindow.Show()
End Sub
+24 -16
View File
@@ -16,29 +16,37 @@ Public Class MachineManager
Sub Init()
If GetMainPrivateProfileInt(S_NC, K_NC_SIMULATE, 0) = 1 Then
Dim nMachineIndex As Integer = 0
Dim nMachineIndex As Integer = 1
Dim sMachine As String = ""
While GetMainPrivateProfileString(S_NC, K_MACHINE & (nMachineIndex + 1).ToString(), "", sMachine) > 0
Dim NewSimulatedMachine As New NC.Simulated
NewSimulatedMachine.Connect("")
m_MachineList(nMachineIndex) = NewSimulatedMachine
While GetMainPrivateProfileString(S_NC, K_MACHINE & nMachineIndex.ToString(), "", sMachine) > 0
If Map.refMainWindowVM.MainWindowM.GetKeyOption1(nMachineIndex) Then
Dim NewSimulatedMachine As New NC.Simulated
NewSimulatedMachine.Connect("")
m_MachineList(nMachineIndex - 1) = NewSimulatedMachine
Else
EgtOutLog("Tentativo di caricare macchine oltre il limite imposto dalla chiave!")
End If
nMachineIndex += 1
End While
Else
Dim nMachineIndex As Integer = 1
Dim sMachine As String = ""
While GetMainPrivateProfileString(S_NC, K_MACHINE & nMachineIndex.ToString(), "", sMachine) > 0
Dim sMachineSplit() As String = sMachine.Split(","c)
Dim nType As Integer = 0
If sMachineSplit.Count >= 1 AndAlso Not String.IsNullOrWhiteSpace(sMachineSplit(0)) AndAlso Integer.TryParse(sMachineSplit(0), nType) Then
Select Case nType
Case 1 ' OsaiOpen
If sMachineSplit.Count >= 2 AndAlso Not String.IsNullOrWhiteSpace(sMachineSplit(1)) Then
Dim NewOsaiOpen As New NC.OsaiOpen
NewOsaiOpen.Connect(sMachineSplit(1))
m_MachineList(nMachineIndex - 1) = NewOsaiOpen
End If
End Select
If Map.refMainWindowVM.MainWindowM.GetKeyOption1(nMachineIndex) Then
Dim sMachineSplit() As String = sMachine.Split(","c)
Dim nType As Integer = 0
If sMachineSplit.Count >= 1 AndAlso Not String.IsNullOrWhiteSpace(sMachineSplit(0)) AndAlso Integer.TryParse(sMachineSplit(0), nType) Then
Select Case nType
Case 1 ' OsaiOpen
If sMachineSplit.Count >= 2 AndAlso Not String.IsNullOrWhiteSpace(sMachineSplit(1)) Then
Dim NewOsaiOpen As New NC.OsaiOpen
NewOsaiOpen.Connect(sMachineSplit(1))
m_MachineList(nMachineIndex - 1) = NewOsaiOpen
End If
End Select
End If
Else
EgtOutLog("Tentativo di caricare macchine oltre il limite imposto dalla chiave!")
End If
nMachineIndex += 1
End While
+1 -1
View File
@@ -16,7 +16,7 @@ Module ConstIni
Public Const S_GENERAL As String = "General"
'Public Const K_DEBUG As String = "Debug"
'Public Const K_LICENCE As String = "Licence"
Public Const K_LICENCE As String = "Licence"
'Public Const K_USERLEVEL As String = "UserLevel"
'Public Const K_MAXINST As String = "MaxInstances"
Public Const K_INSTANCES As String = "Instances"
+11
View File
@@ -164,6 +164,9 @@
<Compile Include="LUA\LuaManager.vb" />
<Compile Include="MEFPlugin\MefPlugin.vb" />
<Compile Include="MEFPlugin\SupervisorFunctions.vb" />
<Compile Include="SplashScreen\SplashScreen.xaml.vb">
<DependentUpon>SplashScreen.xaml</DependentUpon>
</Compile>
<Compile Include="Utility\Dictionary.xaml.vb">
<DependentUpon>Dictionary.xaml</DependentUpon>
</Compile>
@@ -173,6 +176,7 @@
<Compile Include="LUA\Lua_General.vb" />
<Compile Include="Utility\Map.vb" />
<Compile Include="Utility\RedisManager.vb" />
<Compile Include="Utility\VMBase.vb" />
<Compile Include="Utility\WinPos.vb" />
<Page Include="MainWindow\MainWindowV.xaml">
<Generator>MSBuild:Compile</Generator>
@@ -187,6 +191,10 @@
<DependentUpon>MainWindowV.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="SplashScreen\SplashScreen.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Utility\Dictionary.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -268,6 +276,9 @@
<ItemGroup>
<Resource Include="Resources\Effector.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\SplashScreen.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<Import Project="..\packages\KeraLua.1.4.1\build\net46\KeraLua.targets" Condition="Exists('..\packages\KeraLua.1.4.1\build\net46\KeraLua.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
@@ -16,6 +16,7 @@ Public Class FiniteStateMachineManager
Private m_PostProcPath As String = ""
Sub New()
LuaManager.SetGlobVar("EFFECTOR.DATADIR", Map.refMainWindowVM.MainWindowM.sDataRoot)
' leggo file inizializzazione variabili lua
Dim sLuaInitPath As String = ""
If GetMainPrivateProfileString(S_GENERAL, K_INITLUA, "", sLuaInitPath) > 0 Then
+1 -1
View File
@@ -118,7 +118,7 @@ Public Module Lua_General
LuaCheckParam(state, 1, sSourcePath)
LuaCheckParam(state, 2, sDestinationPath)
LuaClearStack(state)
Dim bResult As Boolean
Dim bResult As Boolean = False
Try
' copio il file
File.Copy(sSourcePath, sDestinationPath, True)
@@ -9,6 +9,7 @@ Public Class SupervisorFunctions
Return Map.refMainWindowVM.m_PluginTestInfo
End Get
End Property
Public Function PlgOutLog(sLogMsg As String) As Boolean Implements IHost.PlgOutLog
Return EgtOutLog(sLogMsg)
End Function
+33 -19
View File
@@ -74,10 +74,17 @@ Public Class MainWindowM
End Get
End Property
Private m_nKeyOptions As UInteger = 0
Friend ReadOnly Property nKeyOptions As Integer
Private m_nKeyOpt1 As UInteger = 0
Friend ReadOnly Property nKeyOpt1 As Integer
Get
Return m_nKeyOptions
Return m_nKeyOpt1
End Get
End Property
Private m_nKeyOpt2 As UInteger = 0
Friend ReadOnly Property nKeyOpt2 As Integer
Get
Return m_nKeyOpt2
End Get
End Property
@@ -141,20 +148,6 @@ Public Class MainWindowM
m_sResourcesRoot = m_sDataRoot & "\" & RES_DIR
' Verifico indice di istanza
ManageInstance()
'' Imposto tipo di chiave
'EgtSetLockType(KEY_TYPE.HW)
'' Leggo e imposto chiave di protezione
'Dim sLicFileName As String = String.Empty
'GetMainPrivateProfileString(S_GENERAL, K_LICENCE, LIC_FILE_NAME, sLicFileName)
'Dim sLicFile As String = m_sConfigDir & "\" & sLicFileName
'Dim sKey As String = String.Empty
'EgtUILib.GetPrivateProfileString(S_LICENCE, K_KEY, "", sKey, sLicFile)
'EgtSetKey(sKey)
'' Recupero livello e opzioni della chiave
'Dim bKey As Boolean = EgtGetKeyLevel(5583, 2605, 1, m_nKeyLevel) And
' EgtGetKeyOptions(5583, 2605, 1, m_nKeyOptions)
'' Inizializzazione generale di EgtInterface
'm_nDebug = GetMainPrivateProfileInt(S_GENERAL, K_DEBUG, 0)
' inizializzo log
m_sLogFile = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", m_nInstance.ToString())
Lua_General.SetLogPath(m_sLogFile)
@@ -173,6 +166,23 @@ Public Class MainWindowM
(ChrW(97 - 1 + My.Application.Info.Version.Build)).ToString() &
My.Application.Info.Version.Revision.ToString()
EgtOutLog(sLogMsg)
' Gestione della chiave di protezione
Dim sLicFileName As String = ""
GetMainPrivateProfileString(S_GENERAL, K_LICENCE, LIC_FILE_NAME, sLicFileName)
Dim sLicFile As String = sConfigDir & "\" & sLicFileName
Dim sKey As String = ""
GenInterface.GetPrivateProfileString(S_LICENCE, K_KEY, "", sKey, sLicFile)
EgtSetKey(sKey)
' Recupero livello e opzioni della chiave
Dim bKey As Boolean = EgtGetKeyLevel(7375, 2610, 1, m_nKeyLevel) And
EgtGetKeyOptions(7375, 2610, 1, m_nKeyOpt1, m_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
'EgtInit(m_nDebug, m_sLogFile, sLogMsg)
'EgtSetTempDir(m_sTempDir)
'EgtSetIniFile(IniFile.m_sIniFile)
@@ -268,8 +278,12 @@ Public Class MainWindowM
End If
End Sub
Friend Function GetKeyOption(nKeyOpt As KEY_OPT) As Boolean
Return ((m_nKeyOptions And nKeyOpt) <> 0)
Friend Function GetKeyOption1(nKeyOpt1 As Integer) As Boolean
Return (m_nKeyOpt1 >= nKeyOpt1)
End Function
Friend Function GetKeyOption2(nKeyOpt2 As Integer) As Boolean
Return (m_nKeyOpt2 = nKeyOpt2)
End Function
Friend Function GetMaxInstances() As Integer
+6 -2
View File
@@ -2,8 +2,11 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Effector.Main"
Title="MainWindow"
Title="{Binding sTitle}"
Style="{StaticResource MainWindow}">
<Window.OpacityMask>
<SolidColorBrush Color="White" Opacity="{Binding Window_Opacity}"/>
</Window.OpacityMask>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
@@ -28,8 +31,9 @@
<TextBlock Grid.Column="2"
Margin="4 0 0 0"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontSize="14"
Text="{Binding WindowTitle}">
Text="{Binding sTitle}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
+8 -2
View File
@@ -7,11 +7,13 @@ Class MainWindowV
#Region "CONSTRUCTOR"
Sub New()
m_MainWindowVM = New MainWindowVM
' Funzione che interpreta l'xaml
InitializeComponent()
' Assegno al riferimento locale al VM il VM preso dal DataContext
m_MainWindowVM = DirectCast(Me.DataContext, MainWindowVM)
' Assegno al DataContext il VM appena creato
Me.DataContext = m_MainWindowVM
AddHandler Me.Loaded, AddressOf MainWindowV_Loaded
AddHandler Me.ContentRendered, AddressOf MainWindowV_ContentRendered
AddHandler Me.StateChanged, AddressOf Window_StateChanged
AddHandler Me.Closing, AddressOf MainWindowV_Closing
AddHandler Me.Closed, AddressOf MainWindowV_Closed
@@ -57,6 +59,10 @@ Class MainWindowV
WinPosFromIniToWindow(S_GENERAL, K_WINPLACE, Me)
End Sub
Private Sub MainWindowV_ContentRendered(sender As Object, e As EventArgs)
m_MainWindowVM.ContentRendered()
End Sub
Private Sub MainWindowV_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs)
If (Keyboard.Modifiers And ModifierKeys.Alt) = ModifierKeys.Alt OrElse Keyboard.IsKeyDown(Key.F4) Then
e.Cancel = True
+106 -1
View File
@@ -1,8 +1,46 @@
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
@@ -22,7 +60,6 @@ Public Class MainWindowVM
End Get
End Property
' Riferimento al gestore del della comunicazione macchine
Private m_MachineManager As MachineManager
Friend ReadOnly Property MachineManager As MachineManager
@@ -53,12 +90,58 @@ Public Class MainWindowVM
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()
@@ -80,6 +163,10 @@ Public Class MainWindowVM
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
@@ -88,6 +175,24 @@ Public Class MainWindowVM
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()
Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

@@ -0,0 +1,28 @@
<Window x:Class="SplashScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
AllowsTransparency="True"
Background="White"
Topmost="False"
ShowInTaskbar="False"
Height="600"
Width="1000">
<Grid>
<Image Source="/Resources/SplashScreen.png"
Stretch="UniformToFill"/>
<TextBlock x:Name="VersionTxBl"
FontSize="14"
FontFamily="/Resources/Fonts/#Roboto"
Foreground="White"
HorizontalAlignment="Center"
Margin="591,140,0,0"/>
<!--<TextBlock Text="2022-2023"
FontSize="6"
FontFamily="/Resources/Fonts/#Roboto"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Margin="0,0,254,60"/>-->
</Grid>
</Window>
@@ -0,0 +1,10 @@
Public Class SplashScreen
Private Sub SplashScreen_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
VersionTxBl.Text = "Version " & My.Application.Info.Version.Major.ToString() &
"." & My.Application.Info.Version.Minor.ToString() &
(ChrW(97 - 1 + My.Application.Info.Version.Build)).ToString() &
My.Application.Info.Version.Revision.ToString()
End Sub
End Class
+13
View File
@@ -2,6 +2,8 @@
Module Map
Private m_refMainWindowVM As MainWindowVM
Private m_refSplashScreen As SplashScreen
'Private m_refProjectVM As ProjectVM
'Private m_refSecondaryWindowVM As SecondaryWindowVM
'Private m_refSecondaryWindowV As SecondaryWindowV
@@ -14,6 +16,12 @@ Module Map
End Get
End Property
Public ReadOnly Property refSplashScreen As SplashScreen
Get
Return m_refSplashScreen
End Get
End Property
'Public ReadOnly Property refMyStatusBarVM As MyStatusBarVM
' Get
' Return LibMap.refStatusBarVM
@@ -47,6 +55,11 @@ Module Map
#Region "Set"
Friend Function SetRefSplashScreen(SplashScreen As SplashScreen) As Boolean
m_refSplashScreen = SplashScreen
Return Not IsNothing(m_refSplashScreen)
End Function
'Friend Function SetRefMyStatusBarVM(MyStatusBarVM As MyStatusBarVM) As Boolean
' LibMap.SetRefStatusBarVM(MyStatusBarVM)
' Return Not IsNothing(LibMap.refStatusBarVM)
+12
View File
@@ -0,0 +1,12 @@
Imports System.ComponentModel
Public Class VMBase
Implements INotifyPropertyChanged
Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class