c99654dbf0
- Milgiorie lavorazioni.
309 lines
11 KiB
VB.net
309 lines
11 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
|
|
Namespace EgtCAM5
|
|
|
|
Public Class OperationExpanderViewModel
|
|
Inherits ViewModelBase
|
|
|
|
' Modalità di aggiunta attiva/disattiva
|
|
Private m_NewMachining As Boolean = False
|
|
Public Property NewMachining As Boolean
|
|
Get
|
|
Return m_NewMachining
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_NewMachining Then
|
|
If value Then
|
|
' Smarco la geometria eventualmente marcata
|
|
If Not IsNothing(m_LastMarkedOperationId) Then EgtResetMark(m_LastMarkedOperationId)
|
|
' Deseleziono eventuali geometrie selezionate
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' Blocco la lista operazioni
|
|
IsEnabledOperationList = False
|
|
' Abilito ed apro l'expander con l'albero delle lavorazioni
|
|
Application.Msn.NotifyColleagues(Application.MACHININGTREEVIEWEXPANDERISENABLED, True)
|
|
Else
|
|
' Deseleziono eventuali geometrie selezionate
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' Sblocco la lista operazioni
|
|
IsEnabledOperationList = True
|
|
' Disbilito e chiudo l'expander con l'albero delle lavorazioni
|
|
Application.Msn.NotifyColleagues(Application.MACHININGTREEVIEWEXPANDERISENABLED, False)
|
|
End If
|
|
m_NewMachining = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
Private m_NewPositioning As Boolean = False
|
|
|
|
' Ultima lavorazione evidenziata
|
|
Private m_LastMarkedOperationId As Integer = GDB_ID.NULL
|
|
|
|
Private m_IsExpanded As Boolean
|
|
Public Property IsExpanded As Boolean
|
|
Get
|
|
Return m_IsExpanded
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_IsExpanded Then
|
|
m_IsExpanded = value
|
|
OnPropertyChanged("IsExpanded")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsEnabledOperationList As Boolean = True
|
|
Public Property IsEnabledOperationList As Boolean
|
|
Get
|
|
Return m_IsEnabledOperationList
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_IsEnabledOperationList Then
|
|
m_IsEnabledOperationList = value
|
|
OnPropertyChanged("IsEnabledOperationList")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_OperationList As New ObservableCollection(Of OperationListBoxItem)
|
|
Public Property OperationList As ObservableCollection(Of OperationListBoxItem)
|
|
Get
|
|
Return m_OperationList
|
|
End Get
|
|
Set(value As ObservableCollection(Of OperationListBoxItem))
|
|
m_OperationList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelectedOperation As OperationListBoxItem
|
|
Public Property SelectedOperation As OperationListBoxItem
|
|
Get
|
|
Return m_SelectedOperation
|
|
End Get
|
|
Set(value As OperationListBoxItem)
|
|
If value IsNot m_SelectedOperation Then
|
|
' Verifico se c'è l'operazione precedente
|
|
If m_LastMarkedOperationId <> GDB_ID.NULL Then
|
|
' La deevidenzio
|
|
EgtResetMark(m_LastMarkedOperationId)
|
|
' Ne deseleziono la geometria
|
|
EgtDeselectAll()
|
|
End If
|
|
' Verifico se l'operazione è una disposizione
|
|
If EgtGetOperationType(value.Id) = MCH_OY.DISP Then
|
|
|
|
' L'operazione è una lavorazione
|
|
Else
|
|
' Imposto come corrente la lavorazione(operazione) selezionata
|
|
Dim x = EgtSetCurrMachining(value.Id)
|
|
'value.NotifyPropertyChanged("Depth")
|
|
' Evidenzio la lavorazione(operazione) selezionata
|
|
EgtSetMark(value.Id)
|
|
EgtDraw()
|
|
' Seleziono la geometria della lavorazione
|
|
Dim CountIndex = 0
|
|
Dim EntityIndex As Integer = 0
|
|
Dim SubEntityIndex As Integer = 0 ' Nell'interfaccia non si usa ma devo comunque definirla perchè la funzione la restituisce obbligatoriamente
|
|
While EgtGetMachiningGeometry(CountIndex, EntityIndex, SubEntityIndex)
|
|
If SubEntityIndex = GDB_ID.NULL Then
|
|
EgtSelectObj(EntityIndex)
|
|
End If
|
|
CountIndex += 1
|
|
End While
|
|
' La salvo come ultima operazione selezionata
|
|
m_LastMarkedOperationId = value.Id
|
|
' Notifico l'operazione selezionata all'expander dei parametri operazione
|
|
Application.Msn.NotifyColleagues(Application.SELECTEDOPERATION, value)
|
|
End If
|
|
m_SelectedOperation = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
'Proprietà che richiama OperationPropertyExpander
|
|
Private m_OperationPropertyExpander As OperationPropertyExpanderView
|
|
Public ReadOnly Property OperationPropertyExpander As ContentControl
|
|
Get
|
|
If IsNothing(m_OperationPropertyExpander) Then
|
|
m_OperationPropertyExpander = New OperationPropertyExpanderView
|
|
m_OperationPropertyExpander.DataContext = New OperationPropertyExpanderViewModel
|
|
End If
|
|
Return m_OperationPropertyExpander
|
|
End Get
|
|
End Property
|
|
|
|
#Region "Messaggi per parametri operazioni"
|
|
|
|
Public ReadOnly Property InvertTxBl As String
|
|
Get
|
|
Return EgtMsg(MSG_MACHININGSDBPAGE + 51)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DepthTxBl As String
|
|
Get
|
|
Return EgtMsg(MSG_MACHININGSDBPAGE + 51)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property WorkSideTxBl As String
|
|
Get
|
|
Return EgtMsg(MSG_MACHININGSDBPAGE + 54)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
' Definizione comandi
|
|
Private m_cmdNewMachining As ICommand
|
|
Private m_cmdNewPositioning As ICommand
|
|
Private m_cmdCancelOperation As ICommand
|
|
|
|
Sub New()
|
|
Application.Msn.Register(Application.LOADOPERATIONLIST, Sub()
|
|
LoadOperationList()
|
|
End Sub)
|
|
Application.Msn.Register(Application.REMOVEMARKFROMLASTOPERATION, Sub()
|
|
EgtResetMark(m_LastMarkedOperationId)
|
|
End Sub)
|
|
Application.Msn.Register(Application.NEWMACHININGMODEISACTIVE, Sub(bValue As Boolean)
|
|
NewMachining = bValue
|
|
End Sub)
|
|
|
|
End Sub
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "NewMachiningCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property NewMachiningCommand As ICommand
|
|
Get
|
|
If m_cmdNewMachining Is Nothing Then
|
|
m_cmdNewMachining = New RelayCommand(AddressOf NewMachiningCmd, AddressOf CanNewMachining)
|
|
End If
|
|
Return m_cmdNewMachining
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub NewMachiningCmd(ByVal param As Object)
|
|
NewMachining = True
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanNewMachining(ByVal param As Object) As Boolean
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' NewMachiningCommand
|
|
|
|
#Region "NewPositioningCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property NewPositioningCommand As ICommand
|
|
Get
|
|
If m_cmdNewPositioning Is Nothing Then
|
|
m_cmdNewPositioning = New RelayCommand(AddressOf NewPositioning, AddressOf CanNewPositioning)
|
|
End If
|
|
Return m_cmdNewPositioning
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub NewPositioning(ByVal param As Object)
|
|
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanNewPositioning(ByVal param As Object) As Boolean
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' NewPositioningCommand
|
|
|
|
#Region "CancelOperationCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property CancelOperationCommand As ICommand
|
|
Get
|
|
If m_cmdCancelOperation Is Nothing Then
|
|
m_cmdCancelOperation = New RelayCommand(AddressOf CancelOperation, AddressOf CanCancelOperation)
|
|
End If
|
|
Return m_cmdCancelOperation
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub CancelOperation(ByVal param As Object)
|
|
If m_NewMachining Then
|
|
NewMachining = False
|
|
Else
|
|
If Not IsNothing(SelectedOperation) Then
|
|
' Rimuovo l'operazione selezionata
|
|
EgtRemoveOperation(SelectedOperation.Id)
|
|
' Ricarico la lista delle operazioni
|
|
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanCancelOperation(ByVal param As Object) As Boolean
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' CancelOperationCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Sub LoadOperationList()
|
|
OperationList.Clear()
|
|
Dim Id As Integer
|
|
Dim OpName As String = String.Empty
|
|
Dim OpType As Integer = 0
|
|
Dim OpTool As String = String.Empty
|
|
Id = EgtGetFirstOperation()
|
|
While Id <> GDB_ID.NULL
|
|
EgtGetOperationName(Id, OpName)
|
|
OpType = EgtGetOperationType(Id)
|
|
Select Case OpType
|
|
Case MCH_OY.DRILLING, MCH_OY.SAWING, MCH_OY.MILLING, MCH_OY.POCKETING, MCH_OY.MORTISING, MCH_OY.SAWROUGHING, MCH_OY.SAWFINISHING
|
|
EgtSetCurrMachining(Id)
|
|
EgtGetMachiningParam(MCH_MP.TOOL, OpTool)
|
|
Case MCH_OY.DISP
|
|
OpTool = String.Empty
|
|
End Select
|
|
OperationList.Add(New OperationListBoxItem(Id, OpName, OpType, OpTool))
|
|
Id = EgtGetNextOperation(Id)
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
End Namespace |