c544d00a7b
- aggiunte info nei contorni dei pezzi piatti.
590 lines
22 KiB
VB.net
590 lines
22 KiB
VB.net
Imports System.Globalization
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib
|
|
|
|
Public Class DrawPageUC
|
|
|
|
' Constants
|
|
Private Const NUM_VAR As Integer = 10
|
|
Private Const LUA_CMP_VARS As String = "CMP"
|
|
Private Const LUA_CMP_DRAW As String = "CMP_Draw"
|
|
Private Const INFO_VAR As String = "Var"
|
|
|
|
'Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
|
|
'Dichiarazione delle Page UserControl
|
|
Friend m_MainComponentPage As MainComponentPageUC
|
|
|
|
' Properties
|
|
Private m_sCompoDir As String = String.Empty
|
|
Private m_sCompoName As String = String.Empty
|
|
Private m_CVars(NUM_VAR - 1) As CompoVar
|
|
Private m_bDrawOk As Boolean = False
|
|
Private m_bFirst As Boolean = True
|
|
|
|
' Dichiarazione Scene
|
|
Friend WithEvents DrawScene As New Scene
|
|
Dim DrawSceneHost As New System.Windows.Forms.Integration.WindowsFormsHost
|
|
|
|
'Riferimento alla pagina correntemente attiva
|
|
Friend m_ActiveComponentPage As Pages
|
|
|
|
' Modalità aggiornamento variabili
|
|
Friend m_bShowVar As Boolean = False
|
|
|
|
Enum Pages
|
|
MainComponent
|
|
SecondaryComponent
|
|
Draw
|
|
End Enum
|
|
|
|
Private Sub DrawPage_Initialized(sender As Object, e As EventArgs)
|
|
|
|
'Creazione delle Page UserControl
|
|
m_MainComponentPage = New MainComponentPageUC
|
|
'Posizionemento nella griglia delle Page UserControl
|
|
m_MainComponentPage.SetValue(Grid.ColumnProperty, 0)
|
|
m_MainComponentPage.SetValue(Grid.RowSpanProperty, 2)
|
|
|
|
'Assegnazione scena all'host e posizionamento nella ImportPageGrid
|
|
DrawSceneHost.Child = DrawScene
|
|
DrawSceneHost.SetValue(Grid.ColumnProperty, 1)
|
|
DrawSceneHost.SetValue(Grid.RowProperty, 0)
|
|
Me.LeftButtonGrid.Children.Add(DrawSceneHost)
|
|
|
|
'Associazione tag textbox e label per visualizzare nome nella calcolatrice
|
|
TextBox1.Tag = Label1
|
|
TextBox2.Tag = Label2
|
|
TextBox3.Tag = Label3
|
|
TextBox4.Tag = Label4
|
|
TextBox5.Tag = Label5
|
|
TextBox6.Tag = Label6
|
|
TextBox7.Tag = Label7
|
|
TextBox8.Tag = Label8
|
|
TextBox9.Tag = Label9
|
|
TextBox10.Tag = Label10
|
|
|
|
'Imposto i messaggi letti dal file dei messaggi
|
|
PartNumTxBl.Text = EgtMsg(MSG_DRAWPAGEUC + 1) 'Part Number - Numero pezzi
|
|
|
|
End Sub
|
|
|
|
Private Sub DrawPage_Loaded(sender As Object, e As RoutedEventArgs)
|
|
|
|
If m_bFirst Then
|
|
' imposto colore di default
|
|
Dim DefColor As New Color3d(0, 0, 0)
|
|
GetPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor, m_MainWindow.GetIniFile())
|
|
DrawScene.SetDefaultMaterial(DefColor)
|
|
' imposto colori sfondo
|
|
Dim BackTopColor As New Color3d(192, 192, 192)
|
|
GetPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor, m_MainWindow.GetIniFile())
|
|
Dim BackBotColor As New Color3d(BackTopColor)
|
|
GetPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor, m_MainWindow.GetIniFile())
|
|
DrawScene.SetViewBackground(BackTopColor, BackBotColor)
|
|
' imposto colore di evidenziazione
|
|
Dim MarkColor As New Color3d(255, 255, 0)
|
|
GetPrivateProfileColor(S_SCENE, K_MARK, MarkColor, m_MainWindow.GetIniFile())
|
|
DrawScene.SetMarkMaterial(MarkColor)
|
|
' imposto colore per superfici selezionate
|
|
Dim SelSurfColor As New Color3d(255, 255, 192)
|
|
GetPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor, m_MainWindow.GetIniFile())
|
|
DrawScene.SetSelSurfMaterial(SelSurfColor)
|
|
' imposto tipo e colore del rettangolo di zoom
|
|
Dim bOutline As Boolean = True
|
|
Dim ZwColor As New Color3d(0, 0, 0)
|
|
GetPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor, m_MainWindow.GetIniFile())
|
|
DrawScene.SetZoomWinAttribs(bOutline, ZwColor)
|
|
' imposto colore della linea di distanza
|
|
Dim DstLnColor As New Color3d(255, 0, 0)
|
|
GetPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor, m_MainWindow.GetIniFile())
|
|
DrawScene.SetDistLineMaterial(DstLnColor)
|
|
' imposto parametri OpenGL
|
|
Dim nDriver As Integer = GetPrivateProfileInt(S_OPENGL, K_DRIVER, 3, m_MainWindow.GetIniFile())
|
|
Dim b2Buff As Boolean = (GetPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1, m_MainWindow.GetIniFile()) <> 0)
|
|
Dim nColorBits As Integer = GetPrivateProfileInt(S_OPENGL, K_COLORBITS, 32, m_MainWindow.GetIniFile())
|
|
Dim nDepthBits As Integer = GetPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32, m_MainWindow.GetIniFile())
|
|
DrawScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
|
|
' inizializzo la scena (DB geometrico + visualizzazione)
|
|
DrawScene.Init()
|
|
' Imposto griglia
|
|
LoadGridData()
|
|
' leggo direttorio componenti
|
|
GetPrivateProfileString(S_COMPO, K_COMPODIR, "", m_sCompoDir, m_MainWindow.GetIniFile())
|
|
m_bFirst = False
|
|
Else
|
|
EgtSetCurrentContext(DrawScene.GetCtx())
|
|
End If
|
|
|
|
' inibisco selezione diretta da Scene
|
|
DrawScene.SetStatusNull()
|
|
' pulisco la scena e relativo db
|
|
EgtNewFile()
|
|
EgtDraw()
|
|
|
|
'Seleziono la Tab e la Page di apertura
|
|
LeftButtonGrid.Children.Add(m_MainComponentPage)
|
|
m_ActiveComponentPage = Pages.MainComponent
|
|
InternComponentBtn.Visibility = Windows.Visibility.Hidden
|
|
AddBtn.Visibility = Windows.Visibility.Hidden
|
|
CancelBtn.Visibility = Windows.Visibility.Hidden
|
|
VariablesCompoGrid.Visibility = Windows.Visibility.Hidden
|
|
|
|
'Valore di default del numero pezzi
|
|
PartNumTxBx.Text = 1
|
|
|
|
End Sub
|
|
|
|
Private Sub LoadGridData()
|
|
Dim dSnapStep As Double = GetPrivateProfileDouble(S_GRID, K_SNAPSTEP, 10, m_MainWindow.GetIniFile())
|
|
Dim nMinLineSStep As Integer = GetPrivateProfileInt(S_GRID, K_MINLINESSTEP, 1, m_MainWindow.GetIniFile())
|
|
Dim nMajLineSStep As Integer = GetPrivateProfileInt(S_GRID, K_MAJLINESSTEP, 10, m_MainWindow.GetIniFile())
|
|
Dim nExtSStep As Integer = GetPrivateProfileInt(S_GRID, K_EXTSSTEP, 50, m_MainWindow.GetIniFile())
|
|
Dim MinLnColor As New Color3d(160, 160, 160)
|
|
GetPrivateProfileColor(S_GRID, K_MINLNCOLOR, MinLnColor, m_MainWindow.GetIniFile())
|
|
Dim MajLnColor As New Color3d(160, 160, 160)
|
|
GetPrivateProfileColor(S_GRID, K_MAJLNCOLOR, MajLnColor, m_MainWindow.GetIniFile())
|
|
EgtSetGridFrame(Frame3d.GLOB)
|
|
EgtSetGridGeo(dSnapStep, nMinLineSStep, nMajLineSStep, nExtSStep)
|
|
EgtSetGridColor(MinLnColor, MajLnColor)
|
|
Dim bShowGrid As Boolean = (GetPrivateProfileInt(S_GRID, K_SHOWGRID, 1, m_MainWindow.GetIniFile()) <> 0)
|
|
EgtSetGridShow(bShowGrid, False)
|
|
End Sub
|
|
|
|
Public Sub SelectedComponent(sCompo As String)
|
|
' Carico componente
|
|
LoadCurrentCompo(sCompo)
|
|
End Sub
|
|
|
|
Private Sub LoadCurrentCompo(ByVal sCompo As String)
|
|
' Verifico se cambiato
|
|
If sCompo = m_sCompoName Then
|
|
Return
|
|
End If
|
|
m_sCompoName = sCompo
|
|
' Pulisco l'ambiente lua
|
|
ResetLuaVariables()
|
|
' Carico il file ed eseguo in modalità anteprima
|
|
Dim bOk As Boolean = ExecCompoFile()
|
|
Dim sMsg As String = String.Empty
|
|
bOk = bOk AndAlso MakePreview(sMsg)
|
|
If Not bOk Then
|
|
EgtNewFile()
|
|
End If
|
|
MessageTxBl.Text = sMsg
|
|
MessageGrid.Background = If(m_bDrawOk, Brushes.Transparent, Application.Current.FindResource("OmagCut_Red"))
|
|
DrawScene.ZoomAll()
|
|
' se componenti con buchi interni visualizzo bottoni appositi
|
|
If sCompo = "Pianocucina.lua" Or sCompo = "Pianobagno.lua" Then
|
|
ShowInternalBtn()
|
|
End If
|
|
' leggo variabili e aggiorno griglia
|
|
ReadAndShowVariables()
|
|
' abilito bottoni Vista e Inserisci
|
|
OkBtn.IsEnabled = True
|
|
' un pezzo da inserire
|
|
'tbNbr.Text = "1"
|
|
End Sub
|
|
|
|
Private Sub BackBtn_Click(sender As Object, e As RoutedEventArgs) Handles BackBtn.Click
|
|
DrawPage_Unloaded(sender, e)
|
|
DrawPage_Loaded(sender, e)
|
|
End Sub
|
|
|
|
Public Sub UpdateView()
|
|
' verifico ci sia un componente corrente
|
|
If String.IsNullOrWhiteSpace(m_sCompoName) Then
|
|
Return
|
|
End If
|
|
' aggiorno le variabili dalla griglia
|
|
UpdateVariables()
|
|
' ricalcolo il disegno
|
|
Dim sMsg As String = String.Empty
|
|
MakePreview(sMsg)
|
|
MessageTxBl.Text = sMsg
|
|
MessageGrid.Background = If(m_bDrawOk, Brushes.Transparent, Application.Current.FindResource("OmagCut_Red"))
|
|
' aggiorno visualizzazione
|
|
EgtSetView(VT.TOP, False)
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Function ExecCompoFile() As Boolean
|
|
' Costruisco path completa del componente
|
|
Dim sPath = m_sCompoDir & "\" & m_sCompoName
|
|
' Carico il file
|
|
Return EgtLuaExecFile(sPath)
|
|
End Function
|
|
|
|
Private Function ShowInternalBtn() As Boolean
|
|
InternComponentBtn.Visibility = Windows.Visibility.Visible
|
|
AddBtn.Visibility = Windows.Visibility.Visible
|
|
CancelBtn.Visibility = Windows.Visibility.Visible
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ReadAndShowVariables() As Boolean
|
|
' Recupero nome, tipo e valore delle variabili globali
|
|
For i As Integer = 1 To NUM_VAR
|
|
Dim CVar = New CompoVar
|
|
CVar.m_nInd = i
|
|
If CVar.NameTypeValueFromLua() Then
|
|
m_CVars(i - 1) = CVar
|
|
Else
|
|
m_CVars(i - 1) = Nothing
|
|
End If
|
|
Next
|
|
|
|
' Aggiorno la griglia dalle variabili
|
|
m_bShowVar = True
|
|
|
|
' Conto numero variabili definite e da nascondere
|
|
Dim nShow As Integer = GetDefinedVarCount()
|
|
Dim nHide As Integer = NUM_VAR - nShow
|
|
|
|
For i As Integer = 1 To nHide
|
|
GetNameEdit(i).Visibility = Windows.Visibility.Hidden
|
|
GetValueEdit(i).Visibility = Windows.Visibility.Hidden
|
|
Next
|
|
For i As Integer = 1 To nShow
|
|
Dim j As Integer = nHide + i
|
|
GetNameEdit(j).Text = m_CVars(i - 1).m_sName
|
|
GetNameEdit(j).Visibility = Windows.Visibility.Visible
|
|
GetValueEdit(j).Text = m_CVars(i - 1).ToString()
|
|
GetValueEdit(j).Visibility = Windows.Visibility.Visible
|
|
Next
|
|
m_bShowVar = False
|
|
Return True
|
|
End Function
|
|
|
|
Private Function UpdateVariables() As Boolean
|
|
' Conto numero variabili definite e da nascondere
|
|
Dim nShow As Integer = GetDefinedVarCount()
|
|
Dim nHide As Integer = NUM_VAR - nShow
|
|
' aggiorno le variabili
|
|
For i As Integer = 1 To nShow
|
|
Dim j As Integer = nHide + i
|
|
' interpreto il valore, se non riesco ripristino default
|
|
If Not m_CVars(i - 1).FromString(GetValueEdit(j).Text) Then
|
|
GetValueEdit(j).Text = m_CVars(i - 1).ToString()
|
|
End If
|
|
' aggiorno la corrispondente variabile lua
|
|
If Not m_CVars(i - 1).ToLua() Then
|
|
Dim sErr As String = String.Empty
|
|
EgtLuaGetLastError(sErr)
|
|
EgtOutLog(sErr)
|
|
End If
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Private Function GetDefinedVarCount() As Integer
|
|
Dim nCount As Integer = 0
|
|
For i As Integer = 1 To NUM_VAR
|
|
If m_CVars(i - 1) IsNot Nothing Then
|
|
nCount += 1
|
|
End If
|
|
Next
|
|
Return nCount
|
|
End Function
|
|
|
|
Private Function ResetLuaVariables() As Boolean
|
|
EgtLuaResetGlobVar(LUA_CMP_VARS)
|
|
EgtLuaResetGlobVar(LUA_CMP_DRAW)
|
|
Return False
|
|
End Function
|
|
|
|
Private Function MakePreview(ByRef sMsg As String) As Boolean
|
|
If Not EgtLuaExecLine(LUA_CMP_DRAW & "(true)") Then
|
|
sMsg = "Error in component execution"
|
|
m_bDrawOk = False
|
|
Else
|
|
EgtLuaGetGlobStringVar(LUA_CMP_VARS & ".MSG", sMsg)
|
|
Dim nErr As Integer = 0
|
|
EgtLuaGetGlobIntVar(LUA_CMP_VARS & ".ERR", nErr)
|
|
m_bDrawOk = (nErr = 0)
|
|
End If
|
|
Return m_bDrawOk
|
|
End Function
|
|
|
|
Private Function MakeInsert(ByVal nNbr As Integer) As Boolean
|
|
' ricarico componente corrente
|
|
ExecCompoFile()
|
|
' aggiorno variabili
|
|
UpdateVariables()
|
|
' Recupero flag per inserimento diretto in grezzo (altrimenti in parcheggio)
|
|
Dim bDirect As Boolean = (GetPrivateProfileInt(S_NEST, K_DIRECT, 0, m_MainWindow.GetIniFile()) <> 0)
|
|
' elimino eventuali precedenti pezzi vuoti
|
|
EgtEraseEmptyParts()
|
|
' eseguo inserimento
|
|
For i As Integer = 1 To nNbr
|
|
' Inserisco il componente
|
|
If Not EgtLuaExecLine(LUA_CMP_DRAW & "(false)") Then
|
|
Dim sErr As String = String.Empty
|
|
EgtLuaGetLastError(sErr)
|
|
EgtOutLog(sErr)
|
|
Exit For
|
|
End If
|
|
' Ne recupero l'Id
|
|
Dim nId2 As Integer = EgtGetLastPart()
|
|
' Muovo la regione in Z per evitare problemi in visualizzazione
|
|
Dim nRegId = EgtGetFirstNameInGroup(nId2, NAME_REGION)
|
|
EgtMove(nRegId, New Vector3d(0, 0, DELTAZ_REG), GDB_RT.GLOB)
|
|
' Aggiusto per lavorazioni
|
|
AdjustFlatPart(nId2)
|
|
' Inserisco in parcheggio
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.StoreOnePart(nId2, True)
|
|
' Se richiesto posizionamento diretto, lo eseguo
|
|
If bDirect Then
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.InsertOnePart(nId2)
|
|
End If
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Private Function GetNameEdit(ByVal nInd As Integer) As TextBlock
|
|
Select Case nInd
|
|
Case 1
|
|
Return Label1
|
|
Case 2
|
|
Return Label2
|
|
Case 3
|
|
Return Label3
|
|
Case 4
|
|
Return Label4
|
|
Case 5
|
|
Return Label5
|
|
Case 6
|
|
Return Label6
|
|
Case 7
|
|
Return Label7
|
|
Case 8
|
|
Return Label8
|
|
Case 9
|
|
Return Label9
|
|
Case Else
|
|
Return Label10
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetValueEdit(ByVal nInd As Integer) As TextBox
|
|
Select Case nInd
|
|
Case 1
|
|
Return TextBox1
|
|
Case 2
|
|
Return TextBox2
|
|
Case 3
|
|
Return TextBox3
|
|
Case 4
|
|
Return TextBox4
|
|
Case 5
|
|
Return TextBox5
|
|
Case 6
|
|
Return TextBox6
|
|
Case 7
|
|
Return TextBox7
|
|
Case 8
|
|
Return TextBox8
|
|
Case 9
|
|
Return TextBox9
|
|
Case Else
|
|
Return TextBox10
|
|
End Select
|
|
End Function
|
|
|
|
Private Sub EgtTextBox_EgtOpening(sender As Object, e As RoutedEventArgs) Handles TextBox9.EgtOpening, TextBox10.EgtOpening
|
|
Dim SelectedTextBox As TextBox = e.Source
|
|
Select Case SelectedTextBox.Name
|
|
Case "TextBox9"
|
|
' Indice variabile associata al bottone
|
|
Dim nI As Integer = GetDefinedVarCount() - (NUM_VAR - 9) - 1
|
|
' Recupero tipo della variabile associata
|
|
If m_CVars(nI).m_nType = 1 Then
|
|
TextBox9.IsReadOnly = True
|
|
If TextBox9.Text = "False" Then
|
|
TextBox9.Text = "True"
|
|
Else
|
|
TextBox9.Text = "False"
|
|
End If
|
|
TextBox9.ActivateCalculator = False
|
|
UpdateView()
|
|
Else
|
|
TextBox9.ActivateCalculator = True
|
|
TextBox9.IsReadOnly = False
|
|
End If
|
|
Case "TextBox10"
|
|
' Indice variabile associata al bottone
|
|
Dim nI As Integer = GetDefinedVarCount() - (NUM_VAR - 10) - 1
|
|
' Recupero tipo della variabile associata
|
|
If m_CVars(nI).m_nType = 1 Then
|
|
TextBox10.IsReadOnly = True
|
|
If TextBox10.Text = "False" Then
|
|
TextBox10.Text = "True"
|
|
Else
|
|
TextBox10.Text = "False"
|
|
End If
|
|
TextBox10.ActivateCalculator = False
|
|
UpdateView()
|
|
Else
|
|
TextBox10.ActivateCalculator = True
|
|
TextBox10.IsReadOnly = False
|
|
End If
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
|
|
' se errore esco
|
|
If Not m_bDrawOk Then
|
|
Return
|
|
End If
|
|
' Leggo numero di pezzi da inserire
|
|
Dim InsNbr As Integer = Int32.Parse(PartNumTxBx.Text)
|
|
' Passo al contesto principale
|
|
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
|
|
' Inserisco il componente nel DB geometrico principale
|
|
MakeInsert(InsNbr)
|
|
' Aggiorno ambiente principale
|
|
EgtZoom(ZM.ALL)
|
|
'Istruzioni per chiudere ImportPageUC e aprire CadCutPageUC
|
|
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_DrawPageUC)
|
|
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_CurrentProjectPageUC)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut
|
|
|
|
End Sub
|
|
|
|
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
|
|
'Istruzioni per chiudere ImportPageUC e aprire CadCutPageUC
|
|
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_DrawPageUC)
|
|
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_CurrentProjectPageUC)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut
|
|
End Sub
|
|
|
|
Private Sub DrawPage_Unloaded(sender As Object, e As RoutedEventArgs)
|
|
'Seleziono la Tab e la Page di apertura
|
|
Select Case m_ActiveComponentPage
|
|
Case Pages.MainComponent
|
|
LeftButtonGrid.Children.Remove(m_MainComponentPage)
|
|
Case Pages.SecondaryComponent
|
|
LeftButtonGrid.Children.Remove(m_MainComponentPage.m_SecondaryComponentPage)
|
|
Case Else
|
|
End Select
|
|
|
|
' Pulisco l'ambiente lua
|
|
ResetLuaVariables()
|
|
m_sCompoName = String.Empty
|
|
|
|
End Sub
|
|
|
|
Private Sub EgtCalculator_EgtClosed(sender As Object, e As EventArgs) Handles TextBox1.EgtClosed, TextBox2.EgtClosed, TextBox3.EgtClosed, TextBox4.EgtClosed, TextBox5.EgtClosed, TextBox6.EgtClosed, TextBox7.EgtClosed, TextBox8.EgtClosed,
|
|
TextBox9.EgtClosed, TextBox10.EgtClosed
|
|
UpdateView()
|
|
End Sub
|
|
|
|
Private Class CompoVar
|
|
|
|
' Public Members
|
|
Public m_nInd As Integer
|
|
Public m_sName As String
|
|
Public m_nType As Integer
|
|
Public m_bVal As Boolean
|
|
Public m_nVal As Integer
|
|
Public m_dVal As Double
|
|
Public m_sVal As String
|
|
|
|
' Constants
|
|
Const LUA_NAME As String = LUA_CMP_VARS & ".N"
|
|
Const LUA_TYPE As String = LUA_CMP_VARS & ".T"
|
|
Const LUA_VALUE As String = LUA_CMP_VARS & ".V"
|
|
|
|
Public Sub New()
|
|
m_nInd = 0
|
|
m_nType = 0
|
|
End Sub
|
|
|
|
Public Overrides Function ToString() As String
|
|
Select Case m_nType
|
|
Case 1 ' booleano
|
|
Return m_bVal.ToString()
|
|
Case 2 ' intero
|
|
Return m_nVal.ToString()
|
|
Case 3 ' lunghezza
|
|
Return DoubleToString(EgtToUiUnits(m_dVal), 4)
|
|
Case 4 ' double
|
|
Return DoubleToString(m_dVal, 4)
|
|
Case 5 ' stringa
|
|
Return m_sVal
|
|
End Select
|
|
Return ""
|
|
End Function
|
|
|
|
Public Function FromString(ByVal sVal As String) As Boolean
|
|
Select Case m_nType
|
|
Case 1 ' booleano
|
|
Dim bVal As Boolean = False
|
|
If Boolean.TryParse(sVal, bVal) Then
|
|
m_bVal = bVal
|
|
Return True
|
|
End If
|
|
Case 2 ' intero
|
|
Dim dVal As Double
|
|
If StringToDouble(sVal, dVal) Then
|
|
m_nVal = CInt(dVal)
|
|
Return True
|
|
End If
|
|
Case 3 ' lunghezza
|
|
Dim dVal As Double
|
|
If StringToDouble(sVal, dVal) Then
|
|
m_dVal = EgtFromUiUnits(dVal)
|
|
Return True
|
|
End If
|
|
Case 4 ' double
|
|
Dim dVal As Double
|
|
If StringToDouble(sVal, dVal) Then
|
|
m_dVal = dVal
|
|
Return True
|
|
End If
|
|
Case 5 'stringa
|
|
m_sVal = sVal
|
|
Return True
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
Public Function ToLua() As Boolean
|
|
Select Case m_nType
|
|
Case 1
|
|
Return EgtLuaSetGlobBoolVar(LUA_VALUE & m_nInd.ToString(), m_bVal)
|
|
Case 2
|
|
Return EgtLuaSetGlobIntVar(LUA_VALUE & m_nInd.ToString(), m_nVal)
|
|
Case 3, 4
|
|
Return EgtLuaSetGlobNumVar(LUA_VALUE & m_nInd.ToString(), m_dVal)
|
|
Case 5
|
|
Return EgtLuaSetGlobStringVar(LUA_VALUE & m_nInd.ToString(), m_sVal)
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
Public Function FromLua() As Boolean
|
|
Select Case m_nType
|
|
Case 1
|
|
Return EgtLuaGetGlobBoolVar(LUA_VALUE & m_nInd.ToString(), m_bVal)
|
|
Case 2
|
|
Return EgtLuaGetGlobIntVar(LUA_VALUE & m_nInd.ToString(), m_nVal)
|
|
Case 3, 4
|
|
Return EgtLuaGetGlobNumVar(LUA_VALUE & m_nInd.ToString(), m_dVal)
|
|
Case 5
|
|
Return EgtLuaGetGlobStringVar(LUA_VALUE & m_nInd.ToString(), m_sVal)
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
Public Function NameTypeValueFromLua() As Boolean
|
|
Dim bOk As Boolean = True
|
|
bOk = bOk AndAlso EgtLuaGetGlobStringVar(LUA_NAME & m_nInd.ToString(), m_sName)
|
|
bOk = bOk AndAlso EgtLuaGetGlobIntVar(LUA_TYPE & m_nInd.ToString(), m_nType)
|
|
Return bOk AndAlso FromLua()
|
|
End Function
|
|
|
|
End Class
|
|
|
|
End Class |