Files
DarioS 2dd55286c1 EgtCAM5 2.4f1 :
- quando si apre una lavorazione per modificarne i parametri si imposta sempre anche la sua fase.
2022-06-06 07:05:36 +02:00

220 lines
9.2 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class OperationParametersExpanderVM
Inherits ViewModelBase
Private m_OperParamsViewIsEnabled As Boolean = True
Public Property OperParamsViewIsEnabled As Boolean
Get
Return m_OperParamsViewIsEnabled
End Get
Set(value As Boolean)
m_OperParamsViewIsEnabled = value
OnPropertyChanged("OperParamsViewIsEnabled")
End Set
End Property
Private m_ParametersIsExpanded As Boolean
Public Property ParametersIsExpanded As Boolean
Get
Return m_ParametersIsExpanded
End Get
Set(value As Boolean)
If value <> m_ParametersIsExpanded Then
Map.refMachiningOptionPanelVM.Set_IsExpanded(MachiningOptionPanelVM.MachiningOptionPanelExpander.OPERATIONPARAMETERS, value)
End If
Map.refProjectVM.EmitTitle()
' disattivo database utensili, lavorazioni e setup se vado sulla modifica di una lavorazione
Map.refMachinePanelVM.ToolMachSetUpIsEnabled(Not m_ParametersIsExpanded, Not m_ParametersIsExpanded, Not m_ParametersIsExpanded)
' disattivo MTable e SpecialPanel se vado sulla modifica di una lavorazione
Map.refDoorPanelVM.MTableIsEnabled(Not m_ParametersIsExpanded)
Map.refSpecialPanelVM.SpecialPanelIsEnabled(Not m_ParametersIsExpanded)
End Set
End Property
Private m_ParametersExpanderName As String
Public Property ParametersExpanderName As String
Get
If String.IsNullOrEmpty(m_ParametersExpanderName) Then
Return EgtMsg(MSG_OPERATION + 2)
Else
Return m_ParametersExpanderName
End If
End Get
Set(value As String)
If value <> m_ParametersExpanderName Then
m_ParametersExpanderName = value
End If
OnPropertyChanged("ParametersExpanderName")
End Set
End Property
Public ReadOnly Property OperationParameters As ContentControl
Get
' Cerco l'operazione selezionata all'interno di OperationList
Dim selOperation As OperationListBoxItem = Nothing
For Each Operation In Map.refOperationsListExpanderVM.OperationList
If Operation.IsSelected Then
selOperation = Operation
Exit For
End If
Next
If selOperation.m_Type = MCH_OY.DISP Then
If IsNothing(m_DispositionParameterExpander) Then
m_DispositionParameterExpander = New DispositionParameterExpanderV
m_DispositionParameterExpander.DataContext = New DispositionParameterExpanderVM(m_OpenDispositionFunction)
End If
Return m_DispositionParameterExpander
Else
If IsNothing(m_MachiningParameterExpander) Then
m_MachiningParameterExpander = New MachiningParameterExpanderV
m_MachiningParameterExpanderVM = New MachiningParameterExpanderVM()
m_MachiningParameterExpander.DataContext = m_MachiningParameterExpanderVM
End If
m_MachiningParameterExpanderVM.NotifyPropertyChanged("ParamExpanderPageV")
Return m_MachiningParameterExpander
End If
End Get
End Property
' Actions
Private m_OpenDispositionFunction As Action(Of Boolean)
Private m_MachiningParameterExpander As MachiningParameterExpanderV
Private m_MachiningParameterExpanderVM As MachiningParameterExpanderVM
Private m_DispositionParameterExpander As DispositionParameterExpanderV
#Region "CONSTRUCTOR"
Sub New()
' Creo riferimento a questa classe in Map
Map.SetRefOperationParametersExpanderVM(Me)
Map.refOperationsListExpanderVM.ListIsExpanded = True
End Sub
#End Region ' Constructor
#Region "METHODS"
Friend Function InitOperationParameters() As Boolean
m_ParametersIsExpanded = True
' Cerco l'operazione selezionata all'interno di OperationList
Dim selOperation As OperationListBoxItem = Nothing
For Each Operation In Map.refOperationsListExpanderVM.OperationList
If Operation.IsSelected Then
selOperation = Operation
Exit For
End If
Next
If IsNothing(selOperation) Then Return False
If IsValidDispositionType(selOperation.m_Type) Then
ParametersExpanderName = selOperation.Name
' Abilito la selezione di tutti i tipi di geometria
Map.refProjectVM.SceneSelMode = SceneSelModeOpt.ALL
' Verifico se c'è un grezzo nella disposizione corrente
Dim bFirstRaw As Boolean = True
Dim nRawPartId As Integer = EgtGetFirstRawPart()
While nRawPartId <> GDB_ID.NULL
If EgtVerifyRawPartCurrPhase(nRawPartId) Then
bFirstRaw = False
Exit While
End If
nRawPartId = EgtGetNextRawPart(nRawPartId)
End While
' Lancio funzione che inizializza la disposizione
m_OpenDispositionFunction(bFirstRaw)
' Nascondo tutte le lavorazioni
Dim nOpId As Integer = EgtGetFirstOperation()
While nOpId <> GDB_ID.NULL
If IsValidMachiningType(EgtGetOperationType(nOpId)) Then
EgtSetOperationStatus(nOpId, False)
End If
nOpId = EgtGetNextOperation(nOpId)
End While
EgtDraw()
ElseIf IsValidMachiningType(selOperation.m_Type) Then
' Imposto la fase di lavorazione corrente
EgtSetCurrPhase(EgtGetOperationPhase(selOperation.m_Id))
' Leggo il tipo di operazione per impostare il tipo di selezione
EgtSetCurrMachining(selOperation.m_Id)
Dim sOpMach As String = String.Empty
EgtGetMachiningParam(MCH_MP.NAME, sOpMach)
ParametersExpanderName = selOperation.Name & " (" & sOpMach & ")"
Dim OperationType As Integer = -1
EgtGetMachiningParam(MCH_MP.TYPE, OperationType)
' Abilito la selezione delle lavorazioni
Map.refProjectVM.SceneSelType = SceneSelTypeOpt.MACHINING
' Abilito la selezione dei giusti tipi di geometria
Select Case OperationType
Case MCH_OY.SAWING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomSawing
Case MCH_OY.DRILLING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomDrilling
Case MCH_OY.MILLING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomMilling
Case MCH_OY.POCKETING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomPocketing
Case MCH_OY.MORTISING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomMortising
Case MCH_OY.SAWROUGHING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomSawRoughing
Case MCH_OY.SAWFINISHING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomSawFinishing
Case MCH_OY.GENMACHINING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomGenMachining
Case MCH_OY.CHISELING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomChiseling
Case MCH_OY.SURFFINISHING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomSurfFinishing
Case MCH_OY.WATERJETTING
Map.refProjectVM.SceneSelMode = OptionModule.m_SelGeomWaterJetting
End Select
' Imposto visualizzazione utensile
DirectCast(m_MachiningParameterExpander.DataContext, MachiningParameterExpanderVM).ViewTool = True
End If
OnPropertyChanged("ParametersIsExpanded")
Return True
End Function
Friend Function ExitOperationParameters() As Boolean
m_ParametersIsExpanded = False
' Cerco l'operazione selezionata all'interno di OperationList
Dim selOperation As OperationListBoxItem = Nothing
For Each Operation In Map.refOperationsListExpanderVM.OperationList
If Operation.IsSelected Then
selOperation = Operation
Exit For
End If
Next
If selOperation.m_Type = MCH_OY.DISP Then
' Visualizzo tutte le lavorazioni della fase corrente
Dim nCurrPhase = EgtGetCurrPhase()
Dim nOpId As Integer = EgtGetFirstOperation()
While nOpId <> GDB_ID.NULL
If IsValidMachiningType(EgtGetOperationType(nOpId)) Then
EgtSetOperationStatus(nOpId, (EgtGetOperationPhase(nOpId) = nCurrPhase))
End If
nOpId = EgtGetNextOperation(nOpId)
End While
EgtDraw()
Else
' Nascondo visualizzazione utensile
DirectCast(m_MachiningParameterExpander.DataContext, MachiningParameterExpanderVM).ViewTool = False
End If
ParametersExpanderName = String.Empty
' Disabilito la selezione delle lavorazioni
Map.refProjectVM.SceneSelType = SceneSelTypeOpt.NULL
' Resetto il tipo di selezione
Map.refProjectVM.SceneSelMode = SceneSelModeOpt.NULL
OnPropertyChanged("ParametersIsExpanded")
Return True
End Function
#End Region
End Class