ecf3821d08
-> gestione delle foto da databese OmagPHOTO con l'utilizzo della libreria EgtSTONELib.
882 lines
32 KiB
VB.net
882 lines
32 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class CompoParamPageVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Friend 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"
|
|
Friend 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"
|
|
Friend Const LUA_CMP_WITHINT As String = LUA_CMP_VARS & ".WithInt"
|
|
|
|
' Costanti layer componenti
|
|
Friend Const COMPO_LAYER_AUX As String = "LayAux"
|
|
Friend Const COMPO_LAYER_QUOTATURE As String = "Quotature"
|
|
Friend Const COMPO_LAYER_ETICHETTE As String = "Etichette"
|
|
|
|
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_Internal_Visibility As Visibility
|
|
Public Property Internal_Visibility As Visibility
|
|
Get
|
|
Return m_Internal_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_Internal_Visibility = value
|
|
NotifyPropertyChanged("Internal_Visibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_AddRemove_Visibility As Visibility
|
|
Public Property AddRemove_Visibility As Visibility
|
|
Get
|
|
Return m_AddRemove_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_AddRemove_Visibility = value
|
|
NotifyPropertyChanged("AddRemove_Visibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CompoManagerControl As CompoManagerV
|
|
Public Property CompoManagerControl As CompoManagerV
|
|
Get
|
|
Return m_CompoManagerControl
|
|
End Get
|
|
Set(value As CompoManagerV)
|
|
m_CompoManagerControl = value
|
|
NotifyPropertyChanged("CompoManagerControl")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CompoManagerControl_Visibility As Visibility
|
|
Public Property CompoManagerControl_Visibility As Visibility
|
|
Get
|
|
Return m_CompoManagerControl_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_CompoManagerControl_Visibility = value
|
|
NotifyPropertyChanged("CompoManagerControl_Visibility")
|
|
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_MsgColor As Brush = Brushes.Black
|
|
Public Property MsgColor As Brush
|
|
Get
|
|
Return m_MsgColor
|
|
End Get
|
|
Set(value As Brush)
|
|
m_MsgColor = value
|
|
NotifyPropertyChanged("MsgColor")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Back_Visibility As Visibility
|
|
Public Property Back_Visibility As Visibility
|
|
Get
|
|
Return m_Back_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_Back_Visibility = value
|
|
NotifyPropertyChanged("Back_Visibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Measure_Visibility As Visibility
|
|
Public Property Measure_Visibility As Visibility
|
|
Get
|
|
Return m_Measure_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_Measure_Visibility = value
|
|
NotifyPropertyChanged("Measure_Visibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SideEntity_Visibility As Visibility
|
|
Public Property SideEntity_Visibility As Visibility
|
|
Get
|
|
Return m_SideEntity_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_SideEntity_Visibility = value
|
|
NotifyPropertyChanged("SideEntity_Visibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SideAngle_IsChecked As Boolean
|
|
Private m_SideEntityControlVM As SideEntityControlVM
|
|
Public Property SideAngle_IsChecked As Boolean
|
|
Get
|
|
Return m_SideAngle_IsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
If m_Drip_IsChecked Then Return
|
|
m_SideAngle_IsChecked = value
|
|
If value Then
|
|
Drip_IsEnabled = False
|
|
Engrave_IsEnabled = False
|
|
Measure_Visibility = Visibility.Collapsed
|
|
CompoManagerControl_Visibility = Visibility.Collapsed
|
|
Back_Visibility = Visibility.Collapsed
|
|
' Nascondo layer delle misure
|
|
Dim PartId As Integer = EgtGetFirstPart()
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_AUX), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_QUOTATURE), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_ETICHETTE), GDB_ST.OFF)
|
|
' Imposto il loop esterno, non ci possono essere loop interni
|
|
CompoWindowMap.refCompoSceneHostV.SelectedLayer = EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_OUTLOOP)
|
|
m_SideEntityControlVM = New SideEntityControlVM(SideEntityControlVM.CallingWindowOpt.COMPO,
|
|
CompoWindowMap.refCompoSceneHostV.CompoScene,
|
|
SideEntityControlVM.ModeOpt.SIDEANGLE)
|
|
SideEntityControl = New SideEntityControlV(m_SideEntityControlVM)
|
|
Else
|
|
Drip_IsEnabled = OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.UNDER_CUT) And
|
|
Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrDripSaw)
|
|
Engrave_IsEnabled = True
|
|
m_SideEntityControlVM.Close()
|
|
m_SideEntityControlVM = Nothing
|
|
SideEntityControl = Nothing
|
|
Measure_Visibility = Visibility.Visible
|
|
CompoManagerControl_Visibility = Visibility.Visible
|
|
Back_Visibility = Visibility.Visible
|
|
' Deseleziono tutto
|
|
CompoWindowMap.refCompoSceneHostV.SelectedLayer = GDB_ID.NULL
|
|
' Attivo layer delle misure
|
|
Dim PartId As Integer = EgtGetFirstPart()
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_AUX), GDB_ST.ON_)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_QUOTATURE), GDB_ST.ON_)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_ETICHETTE), GDB_ST.ON_)
|
|
End If
|
|
NotifyPropertyChanged("SideAngle_IsChecked")
|
|
EgtZoom(ZM.ALL)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SideAngle_IsEnabled As Boolean = True
|
|
Public Property SideAngle_IsEnabled As Boolean
|
|
Get
|
|
Return m_SideAngle_IsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_SideAngle_IsEnabled = value
|
|
NotifyPropertyChanged("SideAngle_IsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Drip_IsChecked As Boolean
|
|
Public Property Drip_IsChecked As Boolean
|
|
Get
|
|
Return m_Drip_IsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
If m_SideAngle_IsChecked Then Return
|
|
m_Drip_IsChecked = value
|
|
If value Then
|
|
SideAngle_IsEnabled = False
|
|
Engrave_IsEnabled = False
|
|
Measure_Visibility = Visibility.Collapsed
|
|
CompoManagerControl_Visibility = Visibility.Collapsed
|
|
Back_Visibility = Visibility.Collapsed
|
|
' Nascondo layer delle misure
|
|
Dim PartId As Integer = EgtGetFirstPart()
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_AUX), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_QUOTATURE), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_ETICHETTE), GDB_ST.OFF)
|
|
' Imposto il loop esterno, non ci possono essere loop interni
|
|
CompoWindowMap.refCompoSceneHostV.SelectedLayer = EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_OUTLOOP)
|
|
m_SideEntityControlVM = New SideEntityControlVM(SideEntityControlVM.CallingWindowOpt.COMPO,
|
|
CompoWindowMap.refCompoSceneHostV.CompoScene,
|
|
SideEntityControlVM.ModeOpt.DRIP)
|
|
SideEntityControl = New SideEntityControlV(m_SideEntityControlVM)
|
|
Else
|
|
SideAngle_IsEnabled = True
|
|
Engrave_IsEnabled = True
|
|
m_SideEntityControlVM.Close()
|
|
m_SideEntityControlVM = Nothing
|
|
SideEntityControl = Nothing
|
|
Measure_Visibility = Visibility.Visible
|
|
CompoManagerControl_Visibility = Visibility.Visible
|
|
Back_Visibility = Visibility.Visible
|
|
' Deseleziono tutto
|
|
CompoWindowMap.refCompoSceneHostV.SelectedLayer = GDB_ID.NULL
|
|
' Attivo layer delle misure
|
|
Dim PartId As Integer = EgtGetFirstPart()
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_AUX), GDB_ST.ON_)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_QUOTATURE), GDB_ST.ON_)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_ETICHETTE), GDB_ST.ON_)
|
|
End If
|
|
NotifyPropertyChanged("Drip_IsChecked")
|
|
EgtZoom(ZM.ALL)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Drip_IsEnabled As Boolean
|
|
Public Property Drip_IsEnabled As Boolean
|
|
Get
|
|
Return m_Drip_IsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_Drip_IsEnabled = value
|
|
NotifyPropertyChanged("Drip_IsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Engrave_IsChecked As Boolean
|
|
Public Property Engrave_IsChecked As Boolean
|
|
Get
|
|
Return m_Engrave_IsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
If m_SideAngle_IsChecked Then Return
|
|
m_Engrave_IsChecked = value
|
|
If value Then
|
|
SideAngle_IsEnabled = False
|
|
Drip_IsEnabled = False
|
|
Measure_Visibility = Visibility.Collapsed
|
|
CompoManagerControl_Visibility = Visibility.Collapsed
|
|
Back_Visibility = Visibility.Collapsed
|
|
' Nascondo layer delle misure
|
|
Dim PartId As Integer = EgtGetFirstPart()
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_AUX), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_QUOTATURE), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_ETICHETTE), GDB_ST.OFF)
|
|
' Imposto il loop esterno, non ci possono essere loop interni
|
|
CompoWindowMap.refCompoSceneHostV.SelectedLayer = EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_OUTLOOP)
|
|
m_SideEntityControlVM = New SideEntityControlVM(SideEntityControlVM.CallingWindowOpt.COMPO,
|
|
CompoWindowMap.refCompoSceneHostV.CompoScene,
|
|
SideEntityControlVM.ModeOpt.ENGRAVE)
|
|
SideEntityControl = New SideEntityControlV(m_SideEntityControlVM)
|
|
Else
|
|
SideAngle_IsEnabled = True
|
|
Drip_IsEnabled = OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.UNDER_CUT) And
|
|
Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrDripSaw)
|
|
m_SideEntityControlVM.Close()
|
|
m_SideEntityControlVM = Nothing
|
|
SideEntityControl = Nothing
|
|
Measure_Visibility = Visibility.Visible
|
|
CompoManagerControl_Visibility = Visibility.Visible
|
|
Back_Visibility = Visibility.Visible
|
|
' Deseleziono tutto
|
|
CompoWindowMap.refCompoSceneHostV.SelectedLayer = GDB_ID.NULL
|
|
' Attivo layer delle misure
|
|
Dim PartId As Integer = EgtGetFirstPart()
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_AUX), GDB_ST.ON_)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_QUOTATURE), GDB_ST.ON_)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(PartId, COMPO_LAYER_ETICHETTE), GDB_ST.ON_)
|
|
End If
|
|
NotifyPropertyChanged("Engrave_IsChecked")
|
|
EgtZoom(ZM.ALL)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Engrave_IsEnabled As Boolean = True
|
|
Public Property Engrave_IsEnabled As Boolean
|
|
Get
|
|
Return m_Engrave_IsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_Engrave_IsEnabled = value
|
|
NotifyPropertyChanged("Engrave_IsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SideEntityControl As SideEntityControlV
|
|
Public Property SideEntityControl As SideEntityControlV
|
|
Get
|
|
Return m_SideEntityControl
|
|
End Get
|
|
Set(value As SideEntityControlV)
|
|
m_SideEntityControl = value
|
|
NotifyPropertyChanged("SideEntityControl")
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property InternalMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_COMPONENTPAGEUC + 47)
|
|
End Get
|
|
End Property
|
|
Private m_AddMsg As String
|
|
Public Property AddMsg As String
|
|
Get
|
|
Return m_AddMsg
|
|
End Get
|
|
Set(value As String)
|
|
m_AddMsg = value
|
|
NotifyPropertyChanged("AddMsg")
|
|
End Set
|
|
End Property
|
|
Public ReadOnly Property CancelMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_COMPONENTPAGEUC + 49)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property SideAngleMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_DRAWPAGEUC + 3)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property DripMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_IMPORTPAGEUC + 8)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property EngraveMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_DRAWPAGEUC + 17)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' definizione comandi
|
|
Private m_cmdInternal As ICommand
|
|
Private m_cmdAdd As ICommand
|
|
Private m_cmdCancel 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 CompoWindowMap.refCompoWindowVM.UpdateView
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub InitCompoParamPage()
|
|
' Pulisco l'ambiente lua
|
|
ResetLuaVariables()
|
|
' Carico il file ed eseguo in modalità anteprima
|
|
Dim bOk As Boolean = CompoWindowMap.refCompoWindowVM.ExecCompoFile()
|
|
Dim sMsg As String = String.Empty
|
|
' Verifico se ho selezionato un componente normale
|
|
If Not CompoWindowMap.refCompoSceneHostV.SelFromScene Then
|
|
' lo eseguo e ne restituisco il messaggio
|
|
bOk = bOk AndAlso CompoWindowMap.refCompoWindowVM.MakePreview(sMsg)
|
|
If Not bOk And IsNothing(CompoWindowMap.refCompoWindowVM.m_SelInternalCompo) Then
|
|
EgtNewFile()
|
|
End If
|
|
' scrivo messaggio
|
|
SetOutputMessage(sMsg, If(CompoWindowMap.refCompoWindowVM.m_bDrawOk, MSG_TYPE.INFO, MSG_TYPE.ERROR_))
|
|
CompoWindowMap.refCompoSceneHostV.CompoScene.ZoomAll()
|
|
' Imposto messaggio aggiungi
|
|
AddMsg = EgtMsg(MSG_COMPONENTPAGEUC + 48)
|
|
' altrimenti se è un compo interno
|
|
Else
|
|
If Not bOk Then
|
|
EgtOutLog("Error in Component " & CompoWindowMap.refCompoWindowVM.m_SelInternalCompo.LuaPath)
|
|
End If
|
|
ClearOutputMessage()
|
|
' Imposto messaggio conferma
|
|
AddMsg = EgtMsg(MSG_COMPONENTPAGEUC + 50)
|
|
End If
|
|
' leggo variabili e aggiorno griglia
|
|
ReadAndShowVariables()
|
|
' visualizzo/nascondo bottoni
|
|
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelInternalCompo) Then
|
|
AddRemove_Visibility = Visibility.Collapsed
|
|
Back_Visibility = Visibility.Visible
|
|
' Verifico se il compo selezionato ha i compo interni abilitati
|
|
Dim bHasInternalCompo As Boolean = False
|
|
EgtLuaGetGlobBoolVar(LUA_CMP_WITHINT, bHasInternalCompo)
|
|
Internal_Visibility = If(bHasInternalCompo, Visibility.Visible, Visibility.Collapsed)
|
|
SideEntity_Visibility = Visibility.Visible
|
|
Else
|
|
Internal_Visibility = Visibility.Collapsed
|
|
AddRemove_Visibility = Visibility.Visible
|
|
Back_Visibility = Visibility.Collapsed
|
|
SideEntity_Visibility = Visibility.Collapsed
|
|
End If
|
|
' porto in CompoParam il CompoManager
|
|
CompoWindowMap.refCompoListPageVM.CompoManagerControl = Nothing
|
|
CompoManagerControl = CompoWindowMap.refCompoWindowVM.CompoManagerV
|
|
' lancio inizializzazione CompoManager
|
|
CompoWindowMap.refCompoManagerVM.InitCompoManager()
|
|
End Sub
|
|
|
|
Private Function ResetLuaVariables() As Boolean
|
|
EgtLuaResetGlobVar(LUA_CMP_VARS)
|
|
EgtLuaResetGlobVar(LUA_CMP_DRAW)
|
|
Return False
|
|
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
|
|
|
|
Friend Function ReadSelInternalVariables(nId As Integer) As Boolean
|
|
' Imposto le variabili del componente
|
|
For i As Integer = 1 To m_CompoParamList.Count
|
|
' leggo il valore della variabile
|
|
If Not IsNothing(CompoParamList(i - 1)) Then
|
|
Dim sVar As String = String.Empty
|
|
If EgtGetInfo(nId, "V" & i.ToString(), sVar) Then
|
|
If CompoParamList(i - 1).m_nType = CompoParamItem.ParamType.BOOL Then
|
|
Dim CurrParam As CheckParamItem = DirectCast(CompoParamList(i - 1), CheckParamItem)
|
|
CurrParam.FromString(sVar, False)
|
|
' aggiorno la corrispondente variabile lua
|
|
If Not CurrParam.ToLua() Then
|
|
Dim sErr As String = String.Empty
|
|
EgtLuaGetLastError(sErr)
|
|
EgtOutLog(sErr)
|
|
End If
|
|
Else
|
|
Dim CurrParam As TextParamItem = DirectCast(CompoParamList(i - 1), TextParamItem)
|
|
CurrParam.FromString(sVar, False)
|
|
' aggiorno la corrispondente variabile lua
|
|
If Not CurrParam.ToLua() Then
|
|
Dim sErr As String = String.Empty
|
|
EgtLuaGetLastError(sErr)
|
|
EgtOutLog(sErr)
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Friend 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
|
|
|
|
Friend Overloads Sub SetOutputMessage(sMessage As String, Optional nMsgType As MSG_TYPE = MSG_TYPE.INFO)
|
|
SetMsgColor(nMsgType)
|
|
m_OutputMessage = sMessage
|
|
NotifyPropertyChanged("OutputMessage")
|
|
End Sub
|
|
|
|
Friend Sub ClearOutputMessage()
|
|
m_MsgColor = Brushes.Black
|
|
NotifyPropertyChanged("MsgColor")
|
|
m_OutputMessage = String.Empty
|
|
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 "InternalCommand"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property InternalCommand() As ICommand
|
|
Get
|
|
If m_cmdInternal Is Nothing Then
|
|
m_cmdInternal = New Command(AddressOf Internal)
|
|
End If
|
|
Return m_cmdInternal
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub Internal(ByVal param As Object)
|
|
CompoWindowMap.refCompoWindowVM.m_SelInternalCompo = Nothing
|
|
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.LIST
|
|
' Nascondo layer etichette e quotature
|
|
Dim Pz As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(Pz, "LayAux"), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(Pz, "Etichette"), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(Pz, "Quotature"), GDB_ST.OFF)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' InternalCommand
|
|
|
|
#Region "AddCommand"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property AddCommand() As ICommand
|
|
Get
|
|
If m_cmdAdd Is Nothing Then
|
|
m_cmdAdd = New Command(AddressOf Add)
|
|
End If
|
|
Return m_cmdAdd
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub Add(ByVal param As Object)
|
|
' Se componente errato, non faccio alcunché
|
|
If Not CompoWindowMap.refCompoWindowVM.m_bDrawOk Then Return
|
|
' Recupero indice componente corrente
|
|
Dim nCmp As Integer = 0
|
|
If EgtLuaGetGlobIntVar(LUA_CMP_INDEX, nCmp) And nCmp > 0 Then
|
|
' Nascondo eventuali etichette del componente
|
|
Dim nId As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(GDB_ID.ROOT), "HoleLabels")
|
|
While nId <> GDB_ID.NULL
|
|
Dim nCmpInfo As Integer = 0
|
|
If EgtGetInfo(nId, "ID", nCmpInfo) AndAlso nCmp = nCmpInfo Then
|
|
EgtSetStatus(nId, GDB_ST.OFF)
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextName(nId, "HoleLabels")
|
|
End While
|
|
End If
|
|
' Esco dal componente interno
|
|
CompoWindowMap.refCompoWindowVM.m_SelInternalCompo = Nothing
|
|
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.LIST
|
|
' Deseleziono oggetto corrente e aggiorno visualizzazione
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' AddCommand
|
|
|
|
#Region "CancelCommand"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property CancelCommand() As ICommand
|
|
Get
|
|
If m_cmdCancel Is Nothing Then
|
|
m_cmdCancel = New Command(AddressOf Cancel)
|
|
End If
|
|
Return m_cmdCancel
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub Cancel(ByVal param As Object)
|
|
' Cancello layer con contorno errato
|
|
Dim nId As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(GDB_ID.ROOT), "ErrorLay")
|
|
EgtErase(nId)
|
|
' Se trovo componente corrente, lo cancello
|
|
Dim nCmp As Integer = 0
|
|
If EgtLuaGetGlobIntVar(LUA_CMP_INDEX, nCmp) And nCmp > 0 Then
|
|
Dim sCmp As String = nCmp.ToString()
|
|
' Lancio cancellazione
|
|
If Not EgtLuaExecLine(LUA_REMOVEHOLE & "(" & nCmp & ")") Then
|
|
EgtOutLog("Error in RemoveHole execution")
|
|
Return
|
|
End If
|
|
' altrimenti è errato ed è già stato cancellato, resetto errore di disegno
|
|
Else
|
|
CompoWindowMap.refCompoWindowVM.m_bDrawOk = True
|
|
End If
|
|
' Esco dal componente interno
|
|
CompoWindowMap.refCompoWindowVM.m_SelInternalCompo = Nothing
|
|
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.LIST
|
|
' Deseleziono oggetto corrente e aggiorno visualizzazione
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' CancelCommand
|
|
|
|
#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 |