211 lines
8.4 KiB
VB.net
211 lines
8.4 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MoveVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property Conferma_Msg As String
|
|
Get
|
|
Return EgtMsg(110003)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Annulla_Msg As String
|
|
Get
|
|
Return EgtMsg(110004)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TopBar_Msg As String
|
|
Get
|
|
Return EgtMsg(110005)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Testo_Msg As String
|
|
Get
|
|
Return EgtMsg(110006)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
Private m_ConfermaCmd As ICommand
|
|
Public ReadOnly Property ConfermaCmd As ICommand
|
|
Get
|
|
If m_ConfermaCmd Is Nothing Then
|
|
m_ConfermaCmd = New Command(AddressOf Conferma)
|
|
End If
|
|
Return m_ConfermaCmd
|
|
End Get
|
|
End Property
|
|
|
|
Private m_PreviewCmd As ICommand
|
|
Public ReadOnly Property PreviewCmd As ICommand
|
|
Get
|
|
If m_PreviewCmd Is Nothing Then
|
|
m_PreviewCmd = New Command(AddressOf ShowPreview)
|
|
End If
|
|
Return m_PreviewCmd
|
|
End Get
|
|
End Property
|
|
|
|
Private m_AnnullaCmd As ICommand
|
|
Public ReadOnly Property AnnullaCmd As ICommand
|
|
Get
|
|
If m_AnnullaCmd Is Nothing Then
|
|
m_AnnullaCmd = New Command(AddressOf Annulla)
|
|
End If
|
|
Return m_AnnullaCmd
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Sub Conferma()
|
|
' se non avevo visualizzato la preview allora sposto il/i pezzo/i
|
|
If Not Map.refSceneHostV.m_bPreviewShown Then
|
|
If String.IsNullOrEmpty(Map.refSceneButtonV.m_MoveUC.TextX.Text) Then Map.refSceneButtonV.m_MoveUC.TextX.Text = "0"
|
|
If String.IsNullOrEmpty(Map.refSceneButtonV.m_MoveUC.TextY.Text) Then Map.refSceneButtonV.m_MoveUC.TextY.Text = "0"
|
|
If String.IsNullOrEmpty(Map.refSceneButtonV.m_MoveUC.TextZ.Text) Then Map.refSceneButtonV.m_MoveUC.TextZ.Text = "0"
|
|
Dim vtMove As New Vector3d(CDbl(Map.refSceneButtonV.m_MoveUC.TextX.Text),
|
|
CDbl(Map.refSceneButtonV.m_MoveUC.TextY.Text),
|
|
CDbl(Map.refSceneButtonV.m_MoveUC.TextZ.Text))
|
|
'''' 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 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
|
|
|
|
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
|
|
|
|
Public 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
|
|
|
|
' leggo i dati del vettore di movimento dalle TextBox in m_MoveUC
|
|
If Map.refSceneHostV.m_bPreviewShown Then Return
|
|
If String.IsNullOrEmpty(Map.refSceneButtonV.m_MoveUC.TextX.Text) Then Map.refSceneButtonV.m_MoveUC.TextX.Text = "0"
|
|
If String.IsNullOrEmpty(Map.refSceneButtonV.m_MoveUC.TextY.Text) Then Map.refSceneButtonV.m_MoveUC.TextY.Text = "0"
|
|
If String.IsNullOrEmpty(Map.refSceneButtonV.m_MoveUC.TextZ.Text) Then Map.refSceneButtonV.m_MoveUC.TextZ.Text = "0"
|
|
Dim vtMove As New Vector3d(CDbl(Map.refSceneButtonV.m_MoveUC.TextX.Text),
|
|
CDbl(Map.refSceneButtonV.m_MoveUC.TextY.Text),
|
|
CDbl(Map.refSceneButtonV.m_MoveUC.TextZ.Text))
|
|
'''' 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
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|