e4044e0670
- riportate migliorie per VeinMatching - riportate migliorie per gocciolatoio - riportate migliorie in gestione Next di Split.
667 lines
21 KiB
VB.net
667 lines
21 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class CompoParamPageVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
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"
|
|
Private Const INFO_CMP As String = "CMP"
|
|
Private Const INFO_ID As String = "ID"
|
|
Friend Const LUA_CMP_INDEX As String = LUA_CMP_VARS & ".Ind"
|
|
Friend Const LUA_CMP_INTERNAL As String = LUA_CMP_VARS & ".Int"
|
|
Friend Const LUA_REMOVEHOLE As String = "RemoveHole"
|
|
|
|
Private m_sCompoDir As String = String.Empty
|
|
Private m_bDrawOk As Boolean = False
|
|
|
|
Private m_CompoParamList As New ObservableCollection(Of CompoParamItem)
|
|
Public ReadOnly Property CompoParamList As ObservableCollection(Of CompoParamItem)
|
|
Get
|
|
Return m_CompoParamList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_TopIsChecked As Boolean
|
|
Public Property TopIsChecked As Boolean
|
|
Get
|
|
Return m_TopIsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_TopIsChecked = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TopVisibility As Visibility
|
|
Public Property TopVisibility As Visibility
|
|
Get
|
|
Return m_TopVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_TopVisibility = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_PartName As String
|
|
Public Property PartName As String
|
|
Get
|
|
Return m_PartName
|
|
End Get
|
|
Set(value As String)
|
|
m_PartName = value
|
|
NotifyPropertyChanged("PartName")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_PartNameVisibility As Visibility
|
|
Public Property PartNameVisibility As Visibility
|
|
Get
|
|
Return m_PartNameVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_PartNameVisibility = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_PartNum As String
|
|
Public Property PartNum As String
|
|
Get
|
|
Return m_PartNum
|
|
End Get
|
|
Set(value As String)
|
|
m_PartNum = value
|
|
NotifyPropertyChanged("PartNum")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_PartNumVisibility As Visibility
|
|
Public Property PartNumVisibility As Visibility
|
|
Get
|
|
Return m_PartNumVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_PartNumVisibility = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_OutputMessage As String
|
|
Public Property OutputMessage As String
|
|
Get
|
|
Return m_OutputMessage
|
|
End Get
|
|
Set(value As String)
|
|
m_OutputMessage = value
|
|
NotifyPropertyChanged("OutputMessage")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_OkIsEnabled As Boolean
|
|
Public Property OkIsEnabled As Boolean
|
|
Get
|
|
Return m_OkIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_OkIsEnabled = value
|
|
NotifyPropertyChanged("OkIsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_MsgColor As SolidColorBrush = Brushes.Black
|
|
Public Property MsgColor As SolidColorBrush
|
|
Get
|
|
Return m_MsgColor
|
|
End Get
|
|
Set(value As SolidColorBrush)
|
|
m_MsgColor = value
|
|
NotifyPropertyChanged("MsgColor")
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property TopMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_DRAWPAGEUC + 4)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property PartNameMsg As String
|
|
Get
|
|
Return "Nome"
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property PartNumMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_DRAWPAGEUC + 1)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property OkMsg As String
|
|
Get
|
|
Return "Ok"
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ExitMsg As String
|
|
Get
|
|
Return "Exit"
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' definizione comandi
|
|
Private m_cmdOk As ICommand
|
|
Private m_cmdBack As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in CompoWindowMap
|
|
CompoWindowMap.SetRefCompoParamPageVM(Me)
|
|
' Recupero path cartella che contiene i componenti
|
|
GetMainPrivateProfileString("Compo", "CompoDir", "", m_sCompoDir)
|
|
' Passo funzione UpdateView ad oggetti della lista parametri
|
|
CompoParamItem.m_refUpdateView = AddressOf UpdateView
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub InitCompoListPage()
|
|
' Pulisco l'ambiente lua
|
|
ResetLuaVariables()
|
|
' Carico il file ed eseguo in modalità anteprima
|
|
Dim bOk As Boolean = ExecCompoFile()
|
|
Dim sMsg As String = String.Empty
|
|
' Verifico se compo interno o esterno
|
|
Dim InternalCompo As Integer = -1
|
|
EgtLuaGetGlobIntVar(LUA_CMP_INTERNAL, InternalCompo)
|
|
bOk = bOk AndAlso MakePreview(sMsg)
|
|
If Not bOk And InternalCompo <> 1 Then
|
|
EgtNewFile()
|
|
End If
|
|
'MessageTxBl.Text = sMsg
|
|
'MessageGrid.Background = If(m_bDrawOk, Brushes.Transparent, Application.Current.FindResource("OmagCut_Red"))
|
|
CompoWindowMap.refCompoSceneHostV.CompoScene.ZoomAll()
|
|
' leggo variabili e aggiorno griglia
|
|
ReadAndShowVariables()
|
|
' assegno valori di default numero e nome pezzi
|
|
PartNum = 1.ToString
|
|
PartName = String.Empty
|
|
End Sub
|
|
|
|
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 ExecCompoFile() As Boolean
|
|
' Costruisco path completa del componente
|
|
Dim sPath = m_sCompoDir & "\" & CompoWindowMap.refCompoWindowVM.m_SelCompo.LuaPath
|
|
' Carico il file
|
|
Return EgtLuaExecFile(sPath)
|
|
End Function
|
|
|
|
Private Function ReadAndShowVariables() As Boolean
|
|
' Pulisco lista variabili
|
|
m_CompoParamList.Clear()
|
|
' Recupero nome, tipo e valore delle variabili globali
|
|
For i As Integer = 1 To NUM_VAR
|
|
Dim NewCompo As CompoParamItem = Nothing
|
|
If CompoParamItem.NameTypeValueFromLua(i, NewCompo) Then
|
|
m_CompoParamList.Add(NewCompo)
|
|
End If
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Public Sub UpdateView()
|
|
' verifico ci sia un componente corrente
|
|
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompo) Then
|
|
Return
|
|
End If
|
|
' aggiorno le variabili dalla griglia
|
|
UpdateVariables()
|
|
' ricalcolo il disegno
|
|
Dim sMsg As String = String.Empty
|
|
MakePreview(sMsg)
|
|
SetOutputMessage(sMsg, If(m_bDrawOk, MSG_TYPE.INFO, MSG_TYPE.ERROR_))
|
|
' aggiorno visualizzazione
|
|
EgtSetView(VT.TOP, False)
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Function UpdateVariables() As Boolean
|
|
' aggiorno le variabili
|
|
For i As Integer = 0 To m_CompoParamList.Count - 1
|
|
If m_CompoParamList(i).m_nType <> CompoParamItem.ParamType.BOOL Then
|
|
Dim ParamItem As TextParamItem = DirectCast(m_CompoParamList(i), TextParamItem)
|
|
If Not ParamItem.ToLua() Then
|
|
Dim sErr As String = String.Empty
|
|
EgtLuaGetLastError(sErr)
|
|
EgtOutLog(sErr)
|
|
End If
|
|
Else
|
|
Dim ParamItem As CheckParamItem = DirectCast(m_CompoParamList(i), CheckParamItem)
|
|
If Not ParamItem.ToLua() Then
|
|
Dim sErr As String = String.Empty
|
|
EgtLuaGetLastError(sErr)
|
|
EgtOutLog(sErr)
|
|
End If
|
|
End If
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Private Function MakeInsert(nNbr As Integer, sName As String) As Boolean
|
|
' ricarico componente corrente
|
|
ExecCompoFile()
|
|
' aggiorno variabili
|
|
UpdateVariables()
|
|
' Recupero flag per inserimento diretto in grezzo (altrimenti in parcheggio)
|
|
Dim bDirect As Boolean = (GetMainPrivateProfileInt(S_NEST, K_DIRECT, 0) <> 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()
|
|
' Ne recupero il layer OutLoop
|
|
Dim nOutLoopLayer As Integer = EgtGetFirstNameInGroup(nId2, NAME_OUTLOOP)
|
|
' Calcolo dimensione ingombro OutLoop
|
|
Dim ptMin, ptMax As Point3d
|
|
EgtGetBBoxGlob(nOutLoopLayer, GDB_BB.STANDARD, ptMin, ptMax)
|
|
Dim dBBoxRad As Double = 0.5 * Point3d.DistXY(ptMin, ptMax)
|
|
' Ricavo nome layer con testi inclinazioni
|
|
Dim TextLayer As Integer = EgtGetFirstNameInGroup(nId2, SIDE_ANGLE_LAYER)
|
|
' Se presente lo svuoto
|
|
If TextLayer <> GDB_ID.NULL Then
|
|
EgtEmptyGroup(TextLayer)
|
|
' altrimenti lo creo
|
|
Else
|
|
TextLayer = EgtCreateGroup(nId2)
|
|
EgtSetName(TextLayer, SIDE_ANGLE_LAYER)
|
|
End If
|
|
'' Modifico inclinazione lati
|
|
'For Each Entity In m_SideAngle.m_SideAngleEntityList
|
|
' Dim nCurrEntityName As Integer = EgtGetFirstNameInGroup(nOutLoopLayer, Entity.sEntityName)
|
|
' If Math.Abs(Entity.dSideAngle) > EPS_ANG_SMALL Then
|
|
' ' Scrivo nuovo angolo nelle info
|
|
' EgtSetInfo(nCurrEntityName, INFO_SIDE_ANGLE, Entity.dSideAngle)
|
|
' ' Creo testo con angolo di inclinazione per nesting
|
|
' Dim sText As String = DoubleToString(Entity.dSideAngle, 1) & "°"
|
|
' SideAngleUC.AddTextToLine(sText, TextLayer, nCurrEntityName, 10, dBBoxRad, False)
|
|
' Else
|
|
' ' Cancello inclinazione nell'apposito campo info
|
|
' EgtRemoveInfo(nCurrEntityName, INFO_SIDE_ANGLE)
|
|
' End If
|
|
'Next
|
|
'' Sistemo gocciolatoi
|
|
'm_SideAngle.CreateDripGeom(nId2)
|
|
' 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)
|
|
' Se definito nome lo inserisco nel testo
|
|
If Not String.IsNullOrWhiteSpace(sName) Then
|
|
Dim nTextId = EgtGetFirstInGroup(nRegId)
|
|
While nTextId <> GDB_ID.NULL
|
|
If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then
|
|
Dim sText As String = String.Empty
|
|
EgtTextGetContent(nTextId, sText)
|
|
Dim sNewText = sName & " " & sText
|
|
EgtModifyText(nTextId, sNewText)
|
|
Exit While
|
|
End If
|
|
nTextId = EgtGetNext(nTextId)
|
|
End While
|
|
End If
|
|
' Eventuale testo per indicare il sopra (solo nel caso di rettangolo)
|
|
If m_TopIsChecked Then
|
|
Dim dDimX As Double = ptMax.x - ptMin.x
|
|
Dim dDimY As Double = ptMax.y - ptMin.y
|
|
Dim dH As Double = Math.Min(0.15 * dDimY, 30)
|
|
Dim nText As Integer = EgtCreateTextAdv(nRegId, New Point3d(dDimX / 2, dDimY - dH, 0), 0, "*TOP*", "", 500, False, dH, 1, 0, INS_POS.MC)
|
|
EgtSetColor(nText, New Color3d())
|
|
End If
|
|
' Aggiusto per lavorazioni
|
|
AdjustFlatPart(nId2)
|
|
' Inserisco in parcheggio
|
|
EstCalc.StoreOnePart(nId2, True)
|
|
' Se richiesto posizionamento diretto, lo eseguo
|
|
If bDirect Then
|
|
If EstCalc.InsertOnePart(nId2, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then
|
|
' Eventuale notifica al VeinMatching
|
|
VeinMatching.OnInsertPartInRaw(nId2)
|
|
End If
|
|
End If
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Friend Overloads Sub SetOutputMessage(sMessage As String, Optional nMsgType As MSG_TYPE = MSG_TYPE.INFO)
|
|
SetMsgColor(nMsgType)
|
|
m_OutputMessage = sMessage
|
|
NotifyPropertyChanged("OutputMessage")
|
|
End Sub
|
|
|
|
Private Sub SetMsgColor(nMsgType As MSG_TYPE)
|
|
Select Case nMsgType
|
|
Case MSG_TYPE.INFO
|
|
m_MsgColor = Brushes.Black
|
|
Case MSG_TYPE.WARNING
|
|
m_MsgColor = Brushes.SaddleBrown
|
|
Case MSG_TYPE.ERROR_
|
|
m_MsgColor = Brushes.Red
|
|
End Select
|
|
NotifyPropertyChanged("MsgColor")
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "OkCommand"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property OkCommand() As ICommand
|
|
Get
|
|
If m_cmdOk Is Nothing Then
|
|
m_cmdOk = New Command(AddressOf Ok)
|
|
End If
|
|
Return m_cmdOk
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub Ok(ByVal param As Object)
|
|
' se errore esco
|
|
If Not m_bDrawOk Then
|
|
Return
|
|
End If
|
|
' Leggo numero di pezzi da inserire
|
|
Dim InsNbr As Integer
|
|
StringToInt(m_PartNum, InsNbr)
|
|
' Passo al contesto principale
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostV.OmagOFFICEScene.GetCtx())
|
|
' Inserisco il componente nel DB geometrico principale
|
|
MakeInsert(InsNbr, m_PartName)
|
|
' Aggiorno ambiente principale
|
|
EgtZoom(ZM.ALL)
|
|
' Chiudo la finestra Compo
|
|
For WndIndex = 0 To Application.Current.Windows.Count - 1
|
|
If TypeOf Application.Current.Windows(WndIndex) Is CompoWindowV Then
|
|
Application.Current.Windows(WndIndex).Close()
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' OkCommand
|
|
|
|
#Region "BackCommand"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property BackCommand() As ICommand
|
|
Get
|
|
If m_cmdBack Is Nothing Then
|
|
m_cmdBack = New Command(AddressOf Back)
|
|
End If
|
|
Return m_cmdBack
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub Back(ByVal param As Object)
|
|
If CompoWindowMap.refCompoWindowVM.m_SelCompoFamily Is CompoWindowMap.refCompoWindowVM.m_SelCompo Then
|
|
CompoWindowMap.refCompoWindowVM.m_SelCompoFamily = Nothing
|
|
End If
|
|
CompoWindowMap.refCompoWindowVM.m_SelCompo = Nothing
|
|
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.LIST
|
|
EgtNewFile()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' BackCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|
|
|
|
Public Class CompoParamItem
|
|
|
|
Public Enum ParamType As Integer
|
|
BOOL = 1
|
|
INT = 2
|
|
LEN = 3
|
|
DOUB = 4
|
|
STR = 5
|
|
End Enum
|
|
|
|
Friend Shared m_refUpdateView As action
|
|
' Constants
|
|
Private Const LUA_CMP_VARS As String = "CMP"
|
|
Const LUA_NAME As String = LUA_CMP_VARS & ".N"
|
|
Const LUA_TYPE As String = LUA_CMP_VARS & ".T"
|
|
Friend Const LUA_VALUE As String = LUA_CMP_VARS & ".V"
|
|
|
|
Public m_nInd As Integer
|
|
|
|
Private m_sName As String
|
|
Public ReadOnly Property Name As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
End Property
|
|
|
|
Public m_nType As ParamType
|
|
Friend ReadOnly Property Type As ParamType
|
|
Get
|
|
Return m_nType
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(nInd As Integer, sName As String, nType As ParamType)
|
|
m_nInd = nInd
|
|
m_sName = sName
|
|
m_nType = nType
|
|
End Sub
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Shared Function FromLua(nInd As Integer, sName As String, nType As Integer, ByRef NewCompo As CompoParamItem) As Boolean
|
|
Select Case nType
|
|
Case ParamType.BOOL
|
|
Dim Compo As New CheckParamItem(nInd, sName, nType)
|
|
NewCompo = Compo
|
|
Return EgtLuaGetGlobBoolVar(LUA_VALUE & nInd.ToString(), Compo.m_bVal)
|
|
Case ParamType.INT
|
|
Dim Compo As New TextParamItem(nInd, sName, nType)
|
|
NewCompo = Compo
|
|
Return EgtLuaGetGlobIntVar(LUA_VALUE & nInd.ToString(), Compo.m_nVal)
|
|
Case ParamType.LEN, ParamType.DOUB
|
|
Dim Compo As New TextParamItem(nInd, sName, nType)
|
|
NewCompo = Compo
|
|
Return EgtLuaGetGlobNumVar(LUA_VALUE & nInd.ToString(), Compo.m_dVal)
|
|
Case ParamType.STR
|
|
Dim Compo As New TextParamItem(nInd, sName, nType)
|
|
NewCompo = Compo
|
|
Return EgtLuaGetGlobStringVar(LUA_VALUE & nInd.ToString(), Compo.m_sVal)
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
Public Shared Function NameTypeValueFromLua(nInd As Integer, ByRef NewCompo As CompoParamItem) 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, NewCompo)
|
|
End Function
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|
|
|
|
Public Class TextParamItem
|
|
Inherits CompoParamItem
|
|
|
|
Friend m_nVal As Integer
|
|
Friend m_dVal As Double
|
|
Friend m_sVal As String
|
|
|
|
Public Property Value As String
|
|
Get
|
|
Return Me.ToString()
|
|
End Get
|
|
Set(value As String)
|
|
FromString(value)
|
|
m_refUpdateView()
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(nInd As Integer, sName As String, nType As ParamType)
|
|
MyBase.New(nInd, sName, nType)
|
|
End Sub
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Overrides Function ToString() As String
|
|
Select Case m_nType
|
|
Case ParamType.INT ' intero
|
|
Return m_nVal.ToString()
|
|
Case ParamType.LEN ' lunghezza
|
|
Return DoubleToString(EgtToUiUnits(m_dVal), 4)
|
|
Case ParamType.DOUB ' double
|
|
Return DoubleToString(m_dVal, 4)
|
|
Case ParamType.STR ' stringa
|
|
Return m_sVal
|
|
End Select
|
|
Return ""
|
|
End Function
|
|
|
|
Public Function FromString(ByVal sVal As String, Optional bConvertUnits As Boolean = True) As Boolean
|
|
Select Case m_nType
|
|
Case ParamType.INT ' intero
|
|
Dim nVal As Integer
|
|
If StringToInt(sVal, nVal) Then
|
|
m_nVal = nVal
|
|
Return True
|
|
End If
|
|
Case ParamType.LEN ' lunghezza
|
|
Dim dVal As Double
|
|
If StringToDouble(sVal, dVal) Then
|
|
If bConvertUnits Then
|
|
m_dVal = EgtFromUiUnits(dVal)
|
|
Else
|
|
m_dVal = dVal
|
|
End If
|
|
Return True
|
|
End If
|
|
Case ParamType.DOUB ' double
|
|
Dim dVal As Double
|
|
If StringToDouble(sVal, dVal) Then
|
|
m_dVal = dVal
|
|
Return True
|
|
End If
|
|
Case ParamType.STR ' stringa
|
|
m_sVal = sVal
|
|
Return True
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
Public Function ToLua() As Boolean
|
|
Select Case m_nType
|
|
Case ParamType.INT
|
|
Return EgtLuaSetGlobIntVar(LUA_VALUE & m_nInd.ToString(), m_nVal)
|
|
Case ParamType.LEN, ParamType.DOUB
|
|
Return EgtLuaSetGlobNumVar(LUA_VALUE & m_nInd.ToString(), m_dVal)
|
|
Case ParamType.STR
|
|
Return EgtLuaSetGlobStringVar(LUA_VALUE & m_nInd.ToString(), m_sVal)
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|
|
|
|
Public Class CheckParamItem
|
|
Inherits CompoParamItem
|
|
|
|
Friend m_bVal As Boolean
|
|
|
|
Public Property Value As String
|
|
Get
|
|
Return ToString()
|
|
End Get
|
|
Set(value As String)
|
|
FromString(value)
|
|
m_refUpdateView()
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(nInd As Integer, sName As String, nType As ParamType)
|
|
MyBase.New(nInd, sName, nType)
|
|
End Sub
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Overrides Function ToString() As String
|
|
Select Case m_nType
|
|
Case ParamType.BOOL ' booleano
|
|
Return m_bVal.ToString()
|
|
End Select
|
|
Return ""
|
|
End Function
|
|
|
|
Public Function FromString(ByVal sVal As String, Optional bConvertUnits As Boolean = True) As Boolean
|
|
Select Case m_nType
|
|
Case ParamType.BOOL ' booleano
|
|
Dim bVal As Boolean = False
|
|
If Boolean.TryParse(sVal, bVal) Then
|
|
m_bVal = bVal
|
|
Return True
|
|
End If
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
Public Function ToLua() As Boolean
|
|
Select Case m_nType
|
|
Case ParamType.BOOL
|
|
Return EgtLuaSetGlobBoolVar(LUA_VALUE & m_nInd.ToString(), m_bVal)
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class |