-aggiunta lettura generica parametri disegno
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
Imports System.IO
|
||||
Imports System.Windows.Forms.AxHost
|
||||
Imports EgtUILib.EgtInterface
|
||||
Imports EgtWPFLib5
|
||||
|
||||
Public Class ParametricCompoVM
|
||||
Inherits SceneUserControlVM
|
||||
|
||||
Public Enum ParamType As Integer
|
||||
BOOL = 1
|
||||
INT = 2
|
||||
LEN = 3
|
||||
DOUB = 4
|
||||
STR = 5
|
||||
End Enum
|
||||
|
||||
Private Const LUA_CMP_VARS As String = "CMP"
|
||||
Friend Const LUA_VALUE As String = LUA_CMP_VARS & ".V"
|
||||
Const LUA_NAME As String = LUA_CMP_VARS & ".N"
|
||||
Const LUA_TYPE As String = LUA_CMP_VARS & ".T"
|
||||
|
||||
Private sLuaPath As String = String.Empty
|
||||
|
||||
Sub New(sFile As String)
|
||||
' Recupero path cartella che contiene i componenti
|
||||
GetMainPrivateProfileString(K_COMPO, COMPO_DIR, "", sLuaPath)
|
||||
sLuaPath &= sFile
|
||||
LoadParamList()
|
||||
' aggiorno visualizzazione
|
||||
EgtSetView(VT.TOP, False)
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub LoadParamList()
|
||||
ParamList.Clear()
|
||||
EgtLuaExecFile(sLuaPath)
|
||||
Dim sPar As String = "0"
|
||||
EgtLuaGetGlobStringVar("CMP.Npar", sPar)
|
||||
Dim nPar As Integer = CInt(sPar)
|
||||
ParamList.Add(New _TextBlockParam("Messaggio", "RETTANGOLO", Visibility.Visible))
|
||||
'ParamList.Add(New _TextBoxParam("L", "300", Visibility.Visible))
|
||||
'ParamList.Add(New _TextBoxParam("H", "200", Visibility.Visible))
|
||||
' Pulisco lista variabili
|
||||
' Recupero nome, tipo e valore delle variabili globali
|
||||
For i As Integer = 1 To nPar
|
||||
Dim NewCompo As GenericParam = Nothing
|
||||
If NameTypeValueFromLua(i, NewCompo) Then
|
||||
ParamList.Add(NewCompo)
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub ExecLua()
|
||||
'' recupero i valori nelle box
|
||||
'Dim l_TextBox As _TextBoxParam = DirectCast(ParamList(1), _TextBoxParam)
|
||||
'Dim h_TextBox As _TextBoxParam = DirectCast(ParamList(2), _TextBoxParam)
|
||||
'' verifico che siano validi
|
||||
'If String.IsNullOrEmpty(l_TextBox.sValue) Then l_TextBox.sValue = "0"
|
||||
'If String.IsNullOrEmpty(h_TextBox.sValue) Then h_TextBox.sValue = "0"
|
||||
|
||||
Dim nVeinCtx As Integer = Map.refSceneHostVM.MainScene.GetCtx()
|
||||
If Not File.Exists(sLuaPath) Then
|
||||
EgtOutLog("Matching error: missing file (" & sLuaPath & ")")
|
||||
Return
|
||||
End If
|
||||
' Parsing
|
||||
EgtLuaExecFile(sLuaPath)
|
||||
EgtSetCurrentContext(nVeinCtx)
|
||||
For Index As Integer = 0 To ParamList.Count - 1
|
||||
If TypeOf ParamList(Index) Is _TextBoxParam Then
|
||||
Dim _TextBox As _TextBoxParam = DirectCast(ParamList(Index), _TextBoxParam)
|
||||
EgtLuaSetGlobNumVar("CMP.V" & Index, CDbl(_TextBox.sValue))
|
||||
ElseIf TypeOf ParamList(Index) Is _CheckBoxParam Then
|
||||
Dim _CheckBox As _CheckBoxParam = DirectCast(ParamList(Index), _CheckBoxParam)
|
||||
EgtLuaSetGlobBoolVar("CMP.V" & Index, _CheckBox.IsChecked)
|
||||
End If
|
||||
Next
|
||||
EgtLuaExecLine("CMP_Draw" & "(true)")
|
||||
EgtLuaResetGlobVar("CMP")
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Conferma()
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Annulla()
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub ShowPreview()
|
||||
ExecLua()
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub Close()
|
||||
End Sub
|
||||
|
||||
Private Function NameTypeValueFromLua(nInd As Integer, ByRef Param As GenericParam) As Boolean
|
||||
Dim bOk As Boolean = True
|
||||
Dim sName As String = String.Empty
|
||||
Dim nType As Integer = 0
|
||||
bOk = bOk AndAlso EgtLuaGetGlobStringVar(LUA_NAME & nInd.ToString(), sName)
|
||||
bOk = bOk AndAlso EgtLuaGetGlobIntVar(LUA_TYPE & nInd.ToString(), nType)
|
||||
Return bOk AndAlso FromLua(nInd, sName, nType, Param)
|
||||
End Function
|
||||
|
||||
Private Function FromLua(nInd As Integer, sName As String, nType As Integer, ByRef Param As GenericParam) As Boolean
|
||||
Select Case nType
|
||||
Case ParamType.BOOL
|
||||
Dim Compo As New _CheckBoxParam(sName, ParamType.BOOL)
|
||||
Param = Compo
|
||||
Return EgtLuaGetGlobBoolVar(LUA_VALUE & nInd.ToString(), Compo.IsChecked)
|
||||
Case ParamType.INT
|
||||
Dim Compo As New _TextBoxParam(sName, ParamType.INT)
|
||||
Param = Compo
|
||||
Return EgtLuaGetGlobIntVar(LUA_VALUE & nInd.ToString(), Compo.sValue)
|
||||
Case ParamType.LEN
|
||||
Dim Compo As New _TextBoxParam(sName, ParamType.LEN)
|
||||
Param = Compo
|
||||
Return EgtLuaGetGlobNumVar(LUA_VALUE & nInd.ToString(), Compo.sValue)
|
||||
Case ParamType.DOUB
|
||||
Dim Compo As New _TextBoxParam(sName, ParamType.DOUB)
|
||||
Param = Compo
|
||||
Return EgtLuaGetGlobNumVar(LUA_VALUE & nInd.ToString(), Compo.sValue)
|
||||
Case ParamType.STR
|
||||
Dim Compo As New _TextBoxParam(sName, ParamType.STR)
|
||||
Param = Compo
|
||||
Return EgtLuaGetGlobStringVar(LUA_VALUE & nInd.ToString(), Compo.sValue)
|
||||
End Select
|
||||
Return False
|
||||
End Function
|
||||
|
||||
End Class
|
||||
@@ -32,6 +32,8 @@
|
||||
Public Const MACHINES_DFL_DIR As String = "Machines"
|
||||
' Sottodirettorio di default per toolmakers
|
||||
Public Const TOOLMAKERS_DFL_DIR As String = "ToolMakers"
|
||||
' Sottodirettorio di configurazione
|
||||
Public Const COMPO_DIR As String = "Compo_Dir"
|
||||
|
||||
' Sottodirettorio del Vein 3D
|
||||
Public Const VEIND3D_DIR As String = "Vein3D_Dir"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
Public Const K_LINEWIDTH As String = "LineWidth"
|
||||
Public Const K_CUSTOMCOLORS As String = "CustomColors"
|
||||
Public Const K_VEIND3D As String = "Vein3D"
|
||||
Public Const K_COMPO As String = "Compo"
|
||||
Public Const K_THEMA As String = "Thema"
|
||||
Public Const K_LASTNGEDIR As String = "LastNgeDir"
|
||||
Public Const K_LASTIMPDIR As String = "LastImpDir"
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
<Compile Include="AboutBoxWindow\AboutBoxV.xaml.vb">
|
||||
<DependentUpon>AboutBoxV.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CompoLib\ParametricCompoVM.vb" />
|
||||
<Compile Include="Constants\ConstEgtStone3D.vb" />
|
||||
<Compile Include="EgtColorPicker\EgtColorPickerV.xaml.vb">
|
||||
<DependentUpon>EgtColorPickerV.xaml</DependentUpon>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
Public m_RotateUC As SceneUserControlV
|
||||
Public m_MoveUC As SceneUserControlV
|
||||
Public m_PanelUC As SceneUserControlV
|
||||
Public m_ParametricCompoUC As SceneUserControlV
|
||||
|
||||
#End Region ' Fields & Properties
|
||||
|
||||
@@ -112,6 +113,25 @@
|
||||
m_PanelUC = Nothing
|
||||
End Sub
|
||||
|
||||
Public Sub LoadParametricCompoUC(sFileName As String)
|
||||
If IsNothing(m_ParametricCompoUC) Then
|
||||
m_ParametricCompoUC = New SceneUserControlV
|
||||
Dim m_ParametricCompoVM As New ParametricCompoVM(sFileName)
|
||||
m_ParametricCompoUC.DataContext = m_ParametricCompoVM
|
||||
Grid.SetColumn(m_ParametricCompoUC, 0)
|
||||
Grid.SetRow(m_ParametricCompoUC, 0)
|
||||
Grid.SetColumnSpan(m_ParametricCompoUC, 2)
|
||||
Grid.SetRowSpan(m_ParametricCompoUC, 3)
|
||||
MainGrid.Children.Add(m_ParametricCompoUC)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub RemoveParametricCompoUC()
|
||||
MainGrid.Children.Remove(m_ParametricCompoUC)
|
||||
m_ParametricCompoUC = Nothing
|
||||
End Sub
|
||||
|
||||
|
||||
#End Region ' Methods
|
||||
|
||||
End Class
|
||||
|
||||
@@ -400,8 +400,7 @@ Module SceneCmd
|
||||
#Region "METHODS"
|
||||
|
||||
Public Sub Exec(Flag)
|
||||
Dim _SceneHostVM As SceneHostVM = DirectCast(Map.refSceneHostV.DataContext, SceneHostVM)
|
||||
Dim nVeinCtx As Integer = _SceneHostVM.MainScene.GetCtx()
|
||||
Dim nVeinCtx As Integer = Map.refSceneHostVM.MainScene.GetCtx()
|
||||
Select Case Flag
|
||||
Case EGT_AUTOPAIR
|
||||
EgtSetCurrentContext(nVeinCtx)
|
||||
@@ -436,6 +435,10 @@ Module SceneCmd
|
||||
ExportProjectNge()
|
||||
Case "Delete"
|
||||
SolidManagerM.Delete(Map.refSceneHostVM.m_nIdPart)
|
||||
Case "Rettangolo"
|
||||
Map.refSceneButtonV.LoadParametricCompoUC("Rettangolo" & ".lua")
|
||||
Case "Poligono"
|
||||
Map.refSceneButtonV.LoadParametricCompoUC("Poligono" & ".lua")
|
||||
Case Else
|
||||
Dim x As Boolean = False
|
||||
End Select
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
Imports EgtUILib
|
||||
Imports EgtUILib.EgtInterface
|
||||
Imports EgtWPFLib5
|
||||
Imports EgtUILib.EgtInterface
|
||||
|
||||
Public Class SceneHostV
|
||||
|
||||
|
||||
@@ -372,7 +372,6 @@ End Class
|
||||
Public Class _CheckBoxParam
|
||||
Inherits GenericParam
|
||||
|
||||
|
||||
#Region "FIELDS & PROPERTIES"
|
||||
|
||||
Public Event CheckChanged(sender As Object, checked As Boolean)
|
||||
|
||||
Reference in New Issue
Block a user