diff --git a/Supervisor.Plugin.FiveLakes/LUA/Lua_General.vb b/Supervisor.Plugin.FiveLakes/LUA/Lua_General.vb index cb47bfd..b4a0dad 100644 --- a/Supervisor.Plugin.FiveLakes/LUA/Lua_General.vb +++ b/Supervisor.Plugin.FiveLakes/LUA/Lua_General.vb @@ -2,10 +2,69 @@ Imports KeraLua Public Module Lua_General + Friend func_PlgGetNumberFromIni As LuaFunction = AddressOf Lua_PlgGetNumberFromIni + Friend func_PlgGetStringFromIni As LuaFunction = AddressOf Lua_PlgGetStringFromIni + Friend func_PlgWriteStringToIni As LuaFunction = AddressOf Lua_PlgWriteStringToIni Friend func_PlgExecProcess As LuaFunction = AddressOf Lua_PlgExecProcess Friend func_PlgExecProcessAsync As LuaFunction = AddressOf Lua_PlgExecProcessAsync Friend func_PlgCheckExecProcessAsync As LuaFunction = AddressOf Lua_PlgCheckExecProcessAsync Friend func_PlgGetNextDoor As LuaFunction = AddressOf Lua_PlgGetNextDoor + Friend func_PlgOpenRestartWnd As LuaFunction = AddressOf Lua_PlgOpenRestartWnd + + Private Function Lua_PlgGetNumberFromIni(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + ' 4 parametri: sSec, sKey, dDef, sIniFile + Dim sSec As String = "" + Dim sKey As String = "" + Dim dDef As Integer = 0 + Dim sIniFile As String = "" + LuaCheckParam(state, 1, sSec) + LuaCheckParam(state, 2, sKey) + LuaCheckParam(state, 3, dDef) + LuaCheckParam(state, 4, sIniFile) + LuaClearStack(state) + Dim dResult As Double = GetPluginPrivateProfileDouble(sSec, sKey, dDef) + ' restituisco il risultato + LuaSetParam(state, dResult) + Return 1 + End Function + + Private Function Lua_PlgGetStringFromIni(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + ' 4 parametri: sSec, sKey, sDef, sIniFile + Dim sSec As String = "" + Dim sKey As String = "" + Dim sDef As String = 0 + Dim sIniFile As String = "" + LuaCheckParam(state, 1, sSec) + LuaCheckParam(state, 2, sKey) + LuaCheckParam(state, 3, sDef) + LuaCheckParam(state, 4, sIniFile) + LuaClearStack(state) + Dim sResult As String = "" + GetPluginPrivateProfileString(sSec, sKey, sDef, sResult) + ' restituisco il risultato + LuaSetParam(state, sResult) + Return 1 + End Function + + Private Function Lua_PlgWriteStringToIni(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + ' 4 parametri: sSec, sKey, sVal, sIniFile + Dim sSec As String = "" + Dim sKey As String = "" + Dim sVal As Integer = 0 + Dim sIniFile As String = "" + LuaCheckParam(state, 1, sSec) + LuaCheckParam(state, 2, sKey) + LuaCheckParam(state, 3, sVal) + LuaCheckParam(state, 4, sIniFile) + LuaClearStack(state) + Dim bResult As Boolean = WritePluginPrivateProfileString(sSec, sKey, sVal) + ' restituisco il risultato + LuaSetParam(state, bResult) + Return 1 + End Function Private Function Lua_PlgExecProcess(ByVal p As IntPtr) As Integer Dim state = Lua.FromIntPtr(p) @@ -60,12 +119,24 @@ Public Module Lua_General Return 0 End Function + Private Function Lua_PlgOpenRestartWnd(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + LuaClearStack(state) + Dim RestartWnd As New RestartWndV(Application.Current.MainWindow, New RestartWndVM()) + RestartWnd.ShowDialog() + Return 0 + End Function + Friend Function LuaInstallGeneral(state As Lua) As Boolean If IsNothing(state) Then Return False + state.Register("PlgGetNumberFromIni", func_PlgGetNumberFromIni) + state.Register("PlgGetStringFromIni", func_PlgGetStringFromIni) + state.Register("PlgWriteStringToIni", func_PlgWriteStringToIni) state.Register("PlgExecProcess", func_PlgExecProcess) state.Register("PlgExecProcessAsync", func_PlgExecProcessAsync) state.Register("PlgCheckExecProcessAsync", func_PlgCheckExecProcessAsync) state.Register("PlgGetNextDoor", func_PlgGetNextDoor) + state.Register("PlgOpenRestartWnd", func_PlgOpenRestartWnd) Return True End Function diff --git a/Supervisor.Plugin.FiveLakes/MachinePage/MachinePageV.xaml b/Supervisor.Plugin.FiveLakes/MachinePage/MachinePageV.xaml index f647987..d31a739 100644 --- a/Supervisor.Plugin.FiveLakes/MachinePage/MachinePageV.xaml +++ b/Supervisor.Plugin.FiveLakes/MachinePage/MachinePageV.xaml @@ -11,8 +11,9 @@ - + + @@ -47,8 +48,7 @@ - + @@ -109,8 +109,207 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +