Files
egtstone3d/Move/MoveVM.vb
T
2025-01-13 15:42:39 +01:00

177 lines
7.6 KiB
VB.net

Imports EgtUILib
Public Class MoveVM
Inherits SceneUserControlVM
#Region "CONTRUCTOR"
Public Sub New()
MyBase.New()
LoadParamList()
End Sub
#End Region ' Contructor
#Region "METHODS"
Public Overrides Sub LoadParamList()
Title = EgtMsg(110018).ToUpper()
ParamList.Add(New _TextBlockParam("Messaggio", EgtMsg(110005)))
ParamList.Add(New _TextBoxParam("X", "0"))
ParamList.Add(New _TextBoxParam("Y", "0"))
ParamList.Add(New _TextBoxParam("Z", "0"))
End Sub
Public Overrides Sub Conferma()
' se non avevo visualizzato la preview allora sposto il/i pezzo/i
If Not Map.refSceneHostV.m_bPreviewShown Then
Dim x_TextBox As _TextBoxParam = DirectCast(ParamList(1), _TextBoxParam)
Dim y_TextBox As _TextBoxParam = DirectCast(ParamList(2), _TextBoxParam)
Dim z_TextBox As _TextBoxParam = DirectCast(ParamList(3), _TextBoxParam)
If String.IsNullOrEmpty(x_TextBox.Value) Then x_TextBox.Value = "0"
If String.IsNullOrEmpty(y_TextBox.Value) Then y_TextBox.Value = "0"
If String.IsNullOrEmpty(z_TextBox.Value) Then z_TextBox.Value = "0"
Dim vtMove As New Vector3d(CDbl(x_TextBox.Value),
CDbl(y_TextBox.Value),
CDbl(z_TextBox.Value))
'''' gestione dell'opzione 'AllSelected
'If Not AreSameVectorExact(vtMove, New Vector3d) Then
' If Not AllOption_Move.IsChecked Then
' Move(m_nIdPart, vtMove, True, False)
' Else
' Dim ListSelected As List(Of PartSolid)
' ListSelected = GetAllSelected()
' For Each PartSolidInSel As PartSolid In ListSelected
' Move(PartSolidInSel.PartId, vtMove, True, False)
' Next
' End If
' m_bPreview = True
'End If
If Map.refSceneHostV.m_nIdPart <> GDB_ID.NULL And Not AreSameVectorExact(vtMove, New Vector3d) Then
SolidManagerM.Move(Map.refSceneHostV.m_nIdPart, vtMove, False, True)
End If
End If
' se avevo già fatto lo spostamento semplicemente salvo l'operazione nella storia
If Map.refSceneHostV.m_bPreviewShown Then
''''' gestione dell'opzione 'AllSelected
'If Not AllOption_Move.IsChecked Then
' ' AddEvent(New ObjectEvent(m_nIdPart, LastTempTransf()))
' If EgtLuaSetGlobIntVar("ASS.nTempToSave", -1) Then AssLog("ASS.nTempToSave = -1")
' If EgtLuaCallFunction("ASS.AddEventFromTemp") Then AssLog("ASS.AddEventFromTemp()")
'Else
' Dim ListSelected As List(Of PartSolid)
' ListSelected = GetAllSelected()
' 'For Each PartSolidInSel As PartSolid In ListSelected
' 'AddEvent(New ObjectEvent(PartSolidInSel.PartId, LastTempTransf()))
' For nTrasf As Integer = -ListSelected.Count() To 0 Step +1
' If EgtLuaSetGlobIntVar("ASS.nTempToSave", nTrasf) Then AssLog("ASS.nTempToSave = " & nTrasf.ToString)
' If EgtLuaCallFunction("ASS.AddEventFromTemp") Then AssLog("ASS.AddEventFromTemp()")
' Next
'End If
'' devo salvare le operazioni svolte durante l'accoppiamento come parte della storia globale
For nItTime As Integer = -Map.refSceneHostV.m_nTransfNum To -1 Step 1
'' scorro le ultime trasformazioni temporanee
If EgtLuaSetGlobIntVar("ASS.nTempToSave", nItTime) Then AssLog("ASS.nTempToSave = " & nItTime.ToString)
If EgtLuaCallFunction("ASS.AddEventFromTemp") Then AssLog("ASS.AddEventFromTemp()")
Next
End If
DeselectAll()
Map.refSceneHostV.m_bPreviewShown = False
' gestisco le attivazioni di undo/redo
SolidManagerM.ManageUndoRedo()
Close()
End Sub
Public Overrides Sub Annulla()
' faccio il reset del pairing
If Map.refSceneHostV.m_nTransfNum > Map.refSceneHostV.m_MaxTempTime Then
Map.refSceneHostV.m_nTransfNum = Map.refSceneHostV.m_MaxTempTime
End If
For op As Integer = Map.refSceneHostV.m_nTransfNum To 0 Step -1
If EgtLuaCallFunction("ASS.UndoTemp") Then AssLog("ASS.UndoTemp()")
Next
Close()
End Sub
Public Overrides Sub ShowPreview()
If Map.refSceneHostV.m_bPreviewShown = False Then
Dim Btn As SceneBtn = DirectCast(Map.refSceneButtonV.DataContext, SceneButtonVM).GetButton(EGT_MOVE)
If TypeOf (Btn) Is _ToggleButton Then
If Not DirectCast(Btn, _ToggleButton).IsChecked Then Return
Else
EgtOutLog("CONFIG ERR: Il pulsante di Move è stato definito come Button anziché ToggleButton")
Return
End If
Dim x_TextBox As _TextBoxParam = DirectCast(ParamList(1), _TextBoxParam)
Dim y_TextBox As _TextBoxParam = DirectCast(ParamList(2), _TextBoxParam)
Dim z_TextBox As _TextBoxParam = DirectCast(ParamList(3), _TextBoxParam)
' leggo i dati del vettore di movimento dalle TextBox in m_MoveUC
If Map.refSceneHostV.m_bPreviewShown Then Return
If String.IsNullOrEmpty(x_TextBox.Value) Then x_TextBox.Value = "0"
If String.IsNullOrEmpty(y_TextBox.Value) Then y_TextBox.Value = "0"
If String.IsNullOrEmpty(z_TextBox.Value) Then z_TextBox.Value = "0"
Dim vtMove As New Vector3d(CDbl(x_TextBox.Value),
CDbl(y_TextBox.Value),
CDbl(z_TextBox.Value))
'''' eventuale gestione di un'opzione 'All Selected
'If Not AllOption_Move.IsChecked And m_nIdPart <> -1 Then
' Dim PartSolidSelected As PartSolid = GetPartSolid(m_nIdPart)
' If IsNothing(PartSolidSelected) Then Return
' Move(m_nIdPart, vtMove, False, True)
'Else
' Dim ListSelected As List(Of PartSolid)
' ListSelected = GetAllSelected()
' For Each PartSolidInSel As PartSolid In ListSelected
' If IsNothing(PartSolidInSel) Then Return
' Move(PartSolidInSel.PartId, vtMove, False, True)
' Next
'End If
If Map.refSceneHostV.m_nIdPart <> GDB_ID.NULL And Not AreSameVectorExact(vtMove, New Vector3d) Then
SolidManagerM.Move(Map.refSceneHostV.m_nIdPart, vtMove, False, True)
Else
Annulla()
End If
Map.refSceneHostV.m_bPreviewShown = True
EgtDraw()
End If
End Sub
Private Sub Close()
SolidManagerM.ResetOperationMarks(Map.refSceneHostV.m_nIdPart)
EgtDraw()
Dim Btn As SceneBtn = Map.refSceneButtonVM.GetButton(EGT_MOVE)
If TypeOf (Btn) Is _ToggleButton Then
DirectCast(Btn, _ToggleButton).IsChecked = False
Else
EgtOutLog("CONFIG ERR: Il pulsante di Move è stato definito come Button anziché ToggleButton")
End If
' resetto la storia temporanea
If EgtLuaCallFunction("ASS.ResetTempStory") Then AssLog("ASS.ResetTempStory()")
' resetto il contatore per le operazioni temporanee e la variabile che indica se è stata visualizzata la preview
Map.refSceneHostV.m_nTransfNum = 0
Map.refSceneHostV.m_bPreviewShown = False
' setto le variabili per il salvataggio della storia normale
Dim bSave As Boolean = True
If EgtLuaSetGlobBoolVar("ASS.bSaveHist", bSave) Then AssLog("ASS.bSaveHist = " & bSave.ToString)
Dim bSaveTemp As Boolean = False
If EgtLuaSetGlobBoolVar("ASS.bSaveTemp", bSaveTemp) Then AssLog("ASS.bSaveTemp = " & bSaveTemp.ToString)
' rimuovo lo UC dalla griglia
Map.refSceneButtonV.RemoveMoveUC()
End Sub
#End Region ' Methods
End Class