- corretto indice di creazione macchine per comunicazione

- gestito posizionamento e dimensione finestra
- aggiunta funzione SplitStrign per lua
- aggiunta barra sopra in MainWindow
- gestita finestra con riposizionamento, dimensioni, ecc
- gestita esecuzione asincrona
- aggiunta verifica esecuzione macchina stati
This commit is contained in:
Emmanuele Sassi
2024-09-03 11:27:59 +02:00
parent 84f191782b
commit f23608580f
18 changed files with 492 additions and 25 deletions
+2
View File
@@ -10,6 +10,8 @@ Public Interface IHost
Function PlgGetPrivateProfileString(lpAppName As String, lpKeyName As String, lpDefault As String, ByRef lpString As String, lpFileName As String) As Integer
Function PlgWritePrivateProfileString(lpAppName As String, lpKeyName As String, lpString As String, lpFileName As String) As Boolean
Function PlgExecProcess(sFileName As String, sMainLuaPath As String, sArguments As String) As Boolean
Function PlgExecProcessAsync(sFileName As String, sMainLuaPath As String, sArguments As String) As Boolean
Function PlgCheckExecProcessAsync(ByRef bHasExited As Boolean, ByRef nExitCode As Integer) As Boolean
Function ComReadShortVar(nVarAddr As Integer, ByRef nResult As Short, nMachine As Integer) As Boolean
Function ComReadBitVar(nVarAddr As Integer, nBit As Integer, ByRef bResult As Boolean, nMachine As Integer) As Boolean
Function ComReadDoubleVar(nVarAddr As Integer, ByRef dResult As Double, nMachine As Integer) As Boolean
+1 -1
View File
@@ -36,7 +36,7 @@ Public Class MachineManager
If sMachineSplit.Count >= 2 AndAlso Not String.IsNullOrWhiteSpace(sMachineSplit(1)) Then
Dim NewOsaiOpen As New NC.OsaiOpen
NewOsaiOpen.Connect(sMachineSplit(1))
m_MachineList(nMachineIndex) = NewOsaiOpen
m_MachineList(nMachineIndex - 1) = NewOsaiOpen
End If
End Select
End If
+1
View File
@@ -25,6 +25,7 @@ Module ConstIni
Public Const K_MACHINESTATE As String = "MachineState"
Public Const K_INITLUA As String = "InitLua"
Public Const K_PLUGINNAME As String = "PluginName"
Public Const K_WINPLACE = "WinPlace"
Public Const S_REDIS As String = "Redis"
Public Const K_ENABLED As String = "Enabled"
+10 -1
View File
@@ -1,6 +1,14 @@
Public Class FiniteStateMachine
Private m_bLuaExecuted As Boolean
Public ReadOnly Property bLuaExecuted As Boolean
Get
Return m_bLuaExecuted
End Get
End Property
Private m_State As Integer
Private m_sLuaPath As String
Friend ReadOnly Property sLuaPath As String
Get
@@ -10,7 +18,8 @@
Sub New(sLuaPath As String)
m_sLuaPath = sLuaPath
LuaManager.ExecFile(Map.refMainWindowVM.MainWindowM.sScriptDir & "\" & sLuaPath)
m_bLuaExecuted = LuaManager.ExecFile(Map.refMainWindowVM.MainWindowM.sScriptDir & "\" & sLuaPath)
EgtOutLog(m_sLuaPath & " execution " & If(m_bLuaExecuted, "ok", "failed"))
End Sub
End Class
@@ -66,8 +66,11 @@ Public Class FiniteStateMachineManager
'm_bFiniteStateMachineExecuting = True
' lancio esecuzione macchine a stati
For nMachineIndex = 0 To m_FiniteStateMachineList.Count - 1
LuaManager.ExecLuaFunction("MACHINE" & (nMachineIndex + 1).ToString() & "_Tick", -1, Nothing)
If m_FiniteStateMachineList(nMachineIndex).bLuaExecuted Then
LuaManager.ExecLuaFunction("MACHINE" & (nMachineIndex + 1).ToString() & "_Tick", -1, Nothing)
End If
Next
'' lancio esecuzione preprocessore
'LuaManager.SetGlobVar("PREPROC.ERROR", 0)
'LuaManager.SetGlobVar("PREPROC.ERROR_MSG", "")
+14
View File
@@ -107,6 +107,20 @@ Public Module Lua_Aux
Return True
End Function
Friend Function LuaSetParam(state As Lua, ByRef sValue() As String) As Boolean
Try
Dim nSize As Integer = sValue.Count()
state.CreateTable(nSize, 0)
For nIndex = 0 To nSize - 1
state.PushString(sValue(nIndex))
state.RawSetInteger(-2, nIndex)
Next
Catch ex As Exception
Return False
End Try
Return True
End Function
Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef bValue As Boolean) As Boolean
If Not state.IsTable(nIndex) Then Return False
state.GetField(nIndex, sVarName)
+18 -2
View File
@@ -31,6 +31,7 @@ Public Module Lua_General
Friend func_EntGetNumberFromIni As LuaFunction = AddressOf Lua_EntGetNumberFromIni
Friend func_EntGetStringFromIni As LuaFunction = AddressOf Lua_EntGetStringFromIni
Friend func_EntWriteStringToIni As LuaFunction = AddressOf Lua_EntWriteStringToIni
Friend func_EntSplitString As LuaFunction = AddressOf Lua_EntSplitString
Friend func_EntExecProcess As LuaFunction = AddressOf Lua_EntExecProcess
Friend func_RdsStringGet As LuaFunction = AddressOf Lua_RdsStringGet
Friend func_RdsStringSetAsync As LuaFunction = AddressOf Lua_RdsStringSetAsync
@@ -129,9 +130,9 @@ Public Module Lua_General
LuaCheckParam(state, 3, dDef)
LuaCheckParam(state, 4, sIniFile)
LuaClearStack(state)
Dim nResult As Integer = GetPrivateProfileInt(sSec, sKey, dDef, sIniFile)
Dim dResult As Double = GetPrivateProfileDouble(sSec, sKey, dDef, sIniFile)
' restituisco il risultato
LuaSetParam(state, nResult)
LuaSetParam(state, dResult)
Return 1
End Function
@@ -172,6 +173,20 @@ Public Module Lua_General
Return 1
End Function
Private Function Lua_EntSplitString(ByVal p As IntPtr) As Integer
Dim state = Lua.FromIntPtr(p)
' 4 parametri: sSec, sKey, sVal, sIniFile
Dim sVal As String = ""
Dim sSeparator As Char = ","c
LuaCheckParam(state, 1, sVal)
LuaGetParam(state, 2, sSeparator)
LuaClearStack(state)
Dim sSplitString() As String = sVal.Split(sSeparator)
' restituisco il risultato
LuaSetParam(state, sSplitString)
Return 1
End Function
Private Function Lua_RdsStringGet(ByVal p As IntPtr) As Integer
Dim state = Lua.FromIntPtr(p)
If IsNothing(Map.refMainWindowVM.RedisManager) OrElse IsNothing(Map.refMainWindowVM.RedisManager.Subscriber) Then
@@ -359,6 +374,7 @@ Public Module Lua_General
state.Register("EntGetNumberFromIni", func_EntGetNumberFromIni)
state.Register("EntGetStringFromIni", func_EntGetStringFromIni)
state.Register("EntWriteStringToIni", func_EntWriteStringToIni)
state.Register("EntSplitString", func_EntSplitString)
state.Register("EntExecProcess", func_EntExecProcess)
state.Register("RdsStringGet", func_RdsStringGet)
state.Register("RdsStringSetAsync", func_RdsStringSetAsync)
@@ -32,6 +32,15 @@ Public Class SupervisorFunctions
Public Function PlgExecProcess(sFileName As String, sMainLuaPath As String, sArguments As String) As Boolean Implements IHost.PlgExecProcess
Return ExecProcessManager.ExecProcess(sFileName, sMainLuaPath, sArguments)
End Function
Public Function PlgExecProcessAsync(sFileName As String, sMainLuaPath As String, sArguments As String) As Boolean Implements IHost.PlgExecProcessAsync
Return ExecProcessManager.ExecProcessAsync(sFileName, sMainLuaPath, sArguments)
End Function
Public Function PlgCheckExecProcessAsync(ByRef bHasExited As Boolean, ByRef nExitCode As Integer) As Boolean Implements IHost.PlgCheckExecProcessAsync
Return ExecProcessManager.CheckExecProcessAsync(bHasExited, nExitCode)
End Function
Public Function ComReadShortVar(nVarAddr As Integer, ByRef nResult As Short, nMachine As Integer) As Boolean Implements IHost.ComReadShortVar
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)) Then
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1).ReadShortVar(nVarAddr, nResult)
+87 -6
View File
@@ -1,13 +1,94 @@
<Window x:Class="MainWindowV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Supervisor"
mc:Ignorable="d"
Title="MainWindow" Height="950" Width="1600"
Title="MainWindow"
Style="{StaticResource MainWindow}">
<Grid>
<ContentControl Content="{Binding ContentPanel}"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0"
Width="22"
Height="22"
Margin="4"
Source="/Resources/Icon.png" />
<ContentControl Grid.Column="1"
Content="{Binding ContentMenu}"/>
<TextBlock Grid.Column="2"
Margin="4 0 0 0"
VerticalAlignment="Center"
FontSize="14"
Text="{Binding WindowTitle}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource AncestorType=Window}}" Value="False">
<Setter Property="Foreground" Value="{DynamicResource WindowTitleBarInactiveText}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<Button Grid.Column="3"
Click="OnMinimizeButtonClick"
RenderOptions.EdgeMode="Aliased"
Style="{StaticResource TitleBarButtonStyle}">
<Path Width="46"
Height="32"
Data="M 18,15 H 28"
Stroke="{Binding Path=Foreground,
RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1" />
</Button>
<Button Name="maximizeButton"
Grid.Column="4"
Click="OnMaximizeRestoreButtonClick"
Style="{StaticResource TitleBarButtonStyle}">
<Path Width="46"
Height="32"
Data="M 18.5,10.5 H 27.5 V 19.5 H 18.5 Z"
Stroke="{Binding Path=Foreground,
RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1" />
</Button>
<Button Name="restoreButton"
Grid.Column="4"
Click="OnMaximizeRestoreButtonClick"
Style="{StaticResource TitleBarButtonStyle}">
<Path Width="46"
Height="32"
Data="M 18.5,12.5 H 25.5 V 19.5 H 18.5 Z M 20.5,12.5 V 10.5 H 27.5 V 17.5 H 25.5"
Stroke="{Binding Path=Foreground,
RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1" />
</Button>
<Button Grid.Column="5"
Click="OnCloseButtonClick"
Style="{StaticResource TitleBarCloseButtonStyle}">
<Path Width="46"
Height="32"
Data="M 18,11 27,20 M 18,20 27,11"
Stroke="{Binding Path=Foreground,
RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1" />
</Button>
</Grid>
<ContentControl Grid.Row="2"
Content="{Binding ContentMenu}"/>
<ContentControl Grid.Row="1"
Content="{Binding ContentPanel}"/>
</Grid>
</Window>
+57 -1
View File
@@ -1,4 +1,6 @@
Class MainWindowV
Imports System.Windows.Interop
Class MainWindowV
Private m_MainWindowVM As MainWindowVM
@@ -9,15 +11,69 @@
InitializeComponent()
' Assegno al riferimento locale al VM il VM preso dal DataContext
m_MainWindowVM = DirectCast(Me.DataContext, MainWindowVM)
AddHandler Me.Loaded, AddressOf MainWindowV_Loaded
AddHandler Me.StateChanged, AddressOf Window_StateChanged
AddHandler Me.Closing, AddressOf MainWindowV_Closing
AddHandler Me.Closed, AddressOf MainWindowV_Closed
Me.RefreshMaximizeRestoreButton()
End Sub
#End Region ' CONSTRUCTOR
Private Sub RefreshMaximizeRestoreButton()
If Me.WindowState = WindowState.Maximized Then
Me.maximizeButton.Visibility = Visibility.Collapsed
Me.restoreButton.Visibility = Visibility.Visible
Else
Me.maximizeButton.Visibility = Visibility.Visible
Me.restoreButton.Visibility = Visibility.Collapsed
End If
End Sub
#Region "EVENTS"
Private Sub OnMinimizeButtonClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.WindowState = WindowState.Minimized
End Sub
Private Sub OnMaximizeRestoreButtonClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
If Me.WindowState = WindowState.Maximized Then
Me.WindowState = WindowState.Normal
Else
Me.WindowState = WindowState.Maximized
End If
End Sub
Private Sub Window_StateChanged(ByVal sender As Object, ByVal e As EventArgs)
Me.RefreshMaximizeRestoreButton()
End Sub
Private Sub OnCloseButtonClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.Close()
End Sub
Private Sub MainWindowV_Loaded(sender As Object, e As RoutedEventArgs)
' Carico e imposto posizione finestra
WinPosFromIniToWindow(S_GENERAL, K_WINPLACE, Me)
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
Return
End If
' Salvo posizione finestra (se non minimizzata)
If WindowState <> WindowState.Minimized Then
WinPosFromWindowToIni(Me, S_GENERAL, K_WINPLACE)
End If
End Sub
Private Sub MainWindowV_Closed(sender As Object, e As EventArgs)
If Not IsNothing(m_MainWindowVM) AndAlso Not IsNothing(m_MainWindowVM.FiniteStateMachineManager) Then m_MainWindowVM.FiniteStateMachineManager.ResetFiniteStateMachineTimer()
LuaManager.Close()
EgtOutLog("Exit")
End Sub
#End Region ' EVENTS
End Class
+10 -6
View File
@@ -40,13 +40,17 @@ Public Class MainWindowVM
End Property
Private m_ContentPanel As Panel
Public Property ContentPanel As Panel
Public ReadOnly Property ContentPanel As Panel
Get
Return m_ContentPanel
End Get
Set(value As Panel)
m_ContentPanel = value
End Set
End Property
Private m_ContentMenu As Panel
Public ReadOnly Property ContentMenu As Panel
Get
Return m_ContentMenu
End Get
End Property
Sub New()
@@ -74,13 +78,13 @@ Public Class MainWindowVM
Application.Current.Resources.MergedDictionaries.Add(PluginDictionary)
'' aggiungo MainMenu dal plugin
Dim PluginMainMenu As IPluginControl = GetControlByName(Of IPluginControl)(sPluginName, "MainMenu")
'ContentPanel = PluginMainMenu
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")
ContentPanel = ProjectPlugin
m_ContentPanel = ProjectPlugin
End If
End Sub
Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

+6
View File
@@ -108,6 +108,7 @@
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
<Private>True</Private>
@@ -132,6 +133,7 @@
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System" />
@@ -168,6 +170,7 @@
<Compile Include="LUA\Lua_General.vb" />
<Compile Include="Utility\Map.vb" />
<Compile Include="Utility\RedisManager.vb" />
<Compile Include="Utility\WinPos.vb" />
<Page Include="MainWindow\MainWindowV.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -256,6 +259,9 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icon.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">
+88 -7
View File
@@ -60,8 +60,10 @@
<Style x:Key="MainWindow" TargetType="{x:Type Window}">
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome GlassFrameThickness="35"
ResizeBorderThickness="3"/>
<WindowChrome CaptionHeight="32"
GlassFrameThickness="0"
CornerRadius="0"
ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}"/>
</Setter.Value>
</Setter>
<Setter Property="Template">
@@ -70,14 +72,16 @@
<Border BorderThickness="0"
BorderBrush="LightGray"
Background="{TemplateBinding Background}">
<Grid>
<!--<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="1"
Content="{TemplateBinding Content}"/>
</Grid>
</Grid>-->
<ContentPresenter Grid.Row="1"
Content="{TemplateBinding Content}"/>
</Border>
</ControlTemplate>
</Setter.Value>
@@ -90,9 +94,16 @@
<Border BorderThickness="7"
BorderBrush="LightGray"
Background="{TemplateBinding Background}">
<Grid>
<ContentPresenter Content="{TemplateBinding Content}"/>
</Grid>
<!--<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="1"
Content="{TemplateBinding Content}"/>
</Grid>-->
<ContentPresenter Grid.Row="1"
Content="{TemplateBinding Content}"/>
</Border>
</ControlTemplate>
</Setter.Value>
@@ -101,4 +112,74 @@
</Style.Triggers>
</Style>
<Style x:Key="TitleBarButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource WindowTextBrush}" />
<Setter Property="Padding" Value="0" />
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
x:Name="border"
Background="Transparent"
BorderThickness="0"
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="contentPresenter"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
RecognizesAccessKey="True" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Background" Value="{DynamicResource MouseOverOverlayBackgroundBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="{DynamicResource PressedOverlayBackgroundBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TitleBarCloseButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="Padding" Value="0" />
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
x:Name="border"
Background="Transparent"
BorderThickness="0"
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="contentPresenter"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
RecognizesAccessKey="True" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Background" Value="{DynamicResource MouseOverWindowCloseButtonBackgroundBrush}" />
<Setter Property="Foreground" Value="{DynamicResource MouseOverWindowCloseButtonForegroundBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="{DynamicResource PressedWindowCloseButtonBackgroundBrush}" />
<Setter Property="Foreground" Value="{DynamicResource MouseOverWindowCloseButtonForegroundBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
+30
View File
@@ -1,5 +1,7 @@
Module ExecProcessManager
Private m_ExecProcess As Process
Friend Function ExecProcess(sFileName As String, sMainLuaPath As String, sArguments As String) As Boolean
' lancio esecuzione programma
Dim bResult As Boolean = True
@@ -25,4 +27,32 @@
Return bResult
End Function
Friend Function ExecProcessAsync(sFileName As String, sMainLuaPath As String, sArguments As String) As Boolean
If Not IsNothing(m_ExecProcess) Then
If Not m_ExecProcess.HasExited Then
m_ExecProcess.Kill()
End If
End If
' lancio esecuzione programma
Dim bResult As Boolean = True
m_ExecProcess = New Process()
m_ExecProcess.StartInfo.FileName = sFileName
m_ExecProcess.StartInfo.RedirectStandardInput = False
m_ExecProcess.StartInfo.RedirectStandardOutput = False
m_ExecProcess.StartInfo.Arguments = 1.ToString() & " """ & sMainLuaPath & """ """ & sArguments & """"
m_ExecProcess.StartInfo.UseShellExecute = False
m_ExecProcess.StartInfo.CreateNoWindow = True
Return m_ExecProcess.Start()
End Function
Friend Function CheckExecProcessAsync(ByRef bHasExited As Boolean, ByRef nExitCode As Integer) As Boolean
If IsNothing(m_ExecProcess) Then Return False
bHasExited = m_ExecProcess.HasExited
If bHasExited Then
nExitCode = m_ExecProcess.ExitCode
End If
Threading.Thread.Sleep(100)
Return True
End Function
End Module
+53
View File
@@ -52,6 +52,45 @@ Public Module GenInterface
Return nRet
End Function
Public Function GetPrivateProfileWinPos(
lpAppName As String,
lpKeyName As String,
ByRef nFlag As Integer,
ByRef nLeft As Integer,
ByRef nTop As Integer,
ByRef nWidth As Integer,
ByRef nHeight As Integer,
lpFileName As String) As Boolean
Dim sVal As String = String.Empty
GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName)
Dim sItems() As String = sVal.Split(",".ToCharArray)
If sItems.Count() >= 5 Then
Dim bOk As Boolean = True
If Not Integer.TryParse(sItems(0), nFlag) Then
nFlag = 0
bOk = False
End If
If Not Integer.TryParse(sItems(1), nLeft) Then
nLeft = 0
bOk = False
End If
If Not Integer.TryParse(sItems(2), nTop) Then
nTop = 0
bOk = False
End If
If Not Integer.TryParse(sItems(3), nWidth) Then
nWidth = 1024
bOk = False
End If
If Not Integer.TryParse(sItems(4), nHeight) Then
nHeight = 768
bOk = False
End If
Return bOk
End If
Return False
End Function
'-------------------------------- IniFile : Write ------------------------------------------------
<DllImport("kernel32.dll", CharSet:=CharSet.Unicode)>
Public Function WritePrivateProfileString(
@@ -61,6 +100,20 @@ Public Module GenInterface
lpFileName As String) As Boolean
End Function
Public Function WritePrivateProfileWinPos(
lpAppName As String,
lpKeyName As String,
nFlag As Integer,
nLeft As Integer,
nTop As Integer,
nWidth As Integer,
nHeight As Integer,
lpFileName As String) As Boolean
Dim sVal As String
sVal = nFlag.ToString & "," & nLeft.ToString & "," & nTop.ToString & "," & nWidth.ToString & "," & nHeight.ToString
Return WritePrivateProfileString(lpAppName, lpKeyName, sVal, lpFileName)
End Function
'-------------------------------- Windows --------------------------------------------------------
Public Enum SW As Integer
HIDE = 0
+8
View File
@@ -39,6 +39,10 @@ Public Module IniFile
Return GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_sPath)
End Function
Public Function GetMainPrivateProfileWinPos(IpAppName As String, IpKeyName As String, ByRef nFlag As Integer, ByRef nLeft As Integer, ByRef nTop As Integer, ByRef nWidth As Integer, ByRef nHeight As Integer) As Boolean
Return GetPrivateProfileWinPos(IpAppName, IpKeyName, nFlag, nLeft, nTop, nWidth, nHeight, m_sPath)
End Function
'Public Function GetPrivateProfileLanguage(lpAppName As String, lpKeyName As String, lpFileName As String) As Language
' Dim sVal As String = String.Empty
' GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName)
@@ -63,4 +67,8 @@ Public Module IniFile
Return WritePrivateProfileString(IpAppName, IpKeyName, IpString, m_sPath)
End Function
Public Function WriteMainPrivateProfileWinPos(IpAppName As String, IpKeyName As String, ByRef nFlag As Integer, ByRef nLeft As Integer, ByRef nTop As Integer, ByRef nWidth As Integer, ByRef nHeight As Integer) As Boolean
Return WritePrivateProfileWinPos(IpAppName, IpKeyName, nFlag, nLeft, nTop, nWidth, nHeight, m_sPath)
End Function
End Module
+94
View File
@@ -0,0 +1,94 @@
'----------------------------------------------------------------------------
' EgalTech 2017-2017
'----------------------------------------------------------------------------
' File : WinPos.vb Data : 08.04.17 Versione : 1.8d1
' Contenuto : Classe WinPos per gestione posizione e dimensioni finestra.
'
'
'
' Modifiche : 08.04.17 ES Creazione modulo.
'
'
'----------------------------------------------------------------------------
Public Module WinPosition
Public Class WinPos
' Membri
Public nFlag As Integer
Public nLeft As Integer
Public nTop As Integer
Public nWidth As Integer
Public nHeight As Integer
Public Sub ToWindow(Window As Window)
' Verifico che il punto in alto a sinistra stia nello schermo
Dim PtTL = New System.Drawing.Point(nLeft, nTop)
Dim s As System.Windows.Forms.Screen = System.Windows.Forms.Screen.FromPoint(PtTL)
If Not s.Bounds.Contains(PtTL) Then Return
' Imposto posizione e dimensioni
Window.WindowStartupLocation = WindowStartupLocation.Manual
Window.Top = nTop
Window.Left = nLeft
Window.Height = nHeight
Window.Width = nWidth
Window.WindowState = If(nFlag = 1, WindowState.Maximized, WindowState.Normal)
End Sub
Public Sub FromWindow(Window As Window)
nTop = CInt(Window.Top)
nLeft = CInt(Window.Left)
nHeight = CInt(Window.Height)
nWidth = CInt(Window.Width)
nFlag = If(Window.WindowState = WindowState.Maximized, 1, 0)
If Window.WindowState = WindowState.Maximized Then
nHeight = CInt(Window.RestoreBounds.Height)
nWidth = CInt(Window.RestoreBounds.Width)
End If
End Sub
Public Overloads Function FromIni(sSection As String, sKey As String) As Boolean
Return GetMainPrivateProfileWinPos(sSection, sKey, nFlag, nLeft, nTop, nWidth, nHeight)
End Function
Public Overloads Function FromIni(sSection As String, sKey As String, IpFileName As String) As Boolean
Return GetMainPrivateProfileWinPos(sSection, sKey, nFlag, nLeft, nTop, nWidth, nHeight)
End Function
Public Overloads Function ToIni(sSection As String, sKey As String) As Boolean
Return WriteMainPrivateProfileWinPos(sSection, sKey, nFlag, nLeft, nTop, nWidth, nHeight)
End Function
Public Overloads Function ToIni(sSection As String, sKey As String, IpFileName As String) As Boolean
Return WriteMainPrivateProfileWinPos(sSection, sKey, nFlag, nLeft, nTop, nWidth, nHeight)
End Function
End Class
Public Function WinPosFromIniToWindow(sSection As String, sKey As String, Window As Window) As Boolean
Dim WinPos As New WinPos
If Not WinPos.FromIni(sSection, sKey) Then Return False
WinPos.ToWindow(Window)
Return True
End Function
Public Function WinPosFromIniToWindow(sSection As String, sKey As String, Window As Window, IpFileName As String) As Boolean
Dim WinPos As New WinPos
If Not WinPos.FromIni(sSection, sKey, IpFileName) Then Return False
WinPos.ToWindow(Window)
Return True
End Function
Public Function WinPosFromWindowToIni(Window As Window, sSection As String, sKey As String) As Boolean
Dim WinPos As New WinPos
WinPos.FromWindow(Window)
Return WinPos.ToIni(sSection, sKey)
End Function
Public Function WinPosFromWindowToIni(Window As Window, sSection As String, sKey As String, IpFileName As String) As Boolean
Dim WinPos As New WinPos
WinPos.FromWindow(Window)
Return WinPos.ToIni(sSection, sKey, IpFileName)
End Function
End Module