8cdfa8252c
- Introdotto SetupDb e modificato CurrSetup di conseguenza.
1262 lines
54 KiB
VB.net
1262 lines
54 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Public Class OperationExpanderVM
|
|
Inherits ViewModelBase
|
|
|
|
' Modalità di aggiunta attiva/disattiva
|
|
Private m_NewMachining As Boolean = False
|
|
|
|
Private Sub StartNewMachining()
|
|
m_NewMachining = True
|
|
' Deseleziono le geometrie
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' Reset lista facce
|
|
SelData.ClearIdSub()
|
|
' Blocco la lista operazioni
|
|
IsEnabledOperationList = False
|
|
' Abilito la selezione delle geometrie da lavorare
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.MACHINING)
|
|
' Abilito la selezione di curve e superfici
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.PARTCURVESANDSURFACES)
|
|
' Abilito ed apro l'expander con l'albero delle lavorazioni
|
|
Application.Msn.NotifyColleagues(Application.MACHININGTREEVIEWEXPANDERISENABLED, True)
|
|
End Sub
|
|
|
|
Private Sub EndNewMachining(SelOpId As Integer)
|
|
' Deseleziono eventuali geometrie selezionate
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' Sblocco la lista operazioni
|
|
IsEnabledOperationList = True
|
|
' Disabilito e chiudo l'expander con l'albero delle lavorazioni
|
|
Application.Msn.NotifyColleagues(Application.MACHININGTREEVIEWEXPANDERISENABLED, False)
|
|
' Disabilito la selezione
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.NULL)
|
|
' Disabilito la selezione di curve e superfici del pezzo
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.NULL)
|
|
' Apro i parametri della lavorazione aggiunta
|
|
ParametersIsExpanded = True
|
|
m_NewMachining = False
|
|
' Riseleziono geometria della lavorazione
|
|
If SelOpId <> GDB_ID.NULL Then
|
|
For Index = 0 To OperationList.Count - 1
|
|
If OperationList(Index).Id = SelOpId Then
|
|
OperationList(Index).IsSelected = True
|
|
Else
|
|
OperationList(Index).IsSelected = False
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Private m_NewPositioning As Boolean = False
|
|
|
|
'Expander aperto tra quelli presenti nel MachiningOptionPanel
|
|
Friend m_CurrExpandedExpander As MachiningOptionPanelExpander = MachiningOptionPanelExpander.OPERATIONLIST
|
|
Friend Enum MachiningOptionPanelExpander
|
|
OPERATIONLIST
|
|
OPERATIONPARAMETERS
|
|
SIMULATION
|
|
ESTIMATIONS
|
|
End Enum
|
|
|
|
Private m_OperViewIsEnabled As Boolean = True
|
|
Public Property OperViewIsEnabled As Boolean
|
|
Get
|
|
Return m_OperViewIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_OperViewIsEnabled = value
|
|
OnPropertyChanged("OperViewIsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ListIsExpanded As Boolean
|
|
Public Property ListIsExpanded As Boolean
|
|
Get
|
|
Return m_ListIsExpanded
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_ListIsExpanded Then
|
|
m_ListIsExpanded = value
|
|
If value Then
|
|
If m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONPARAMETERS Then
|
|
ParametersIsExpanded = False
|
|
ElseIf m_CurrExpandedExpander = MachiningOptionPanelExpander.SIMULATION Then
|
|
Application.Msn.NotifyColleagues(Application.SIMULATIONEXPANDER_SET_ISEXPANDED, False)
|
|
ElseIf m_CurrExpandedExpander = MachiningOptionPanelExpander.ESTIMATIONS Then
|
|
Application.Msn.NotifyColleagues(Application.ESTIMATIONSEXPANDER_SET_ISEXPANDED, False)
|
|
End If
|
|
m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONLIST
|
|
End If
|
|
OnPropertyChanged("ListIsExpanded")
|
|
End If
|
|
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
|
|
m_ParametersIsExpanded = value
|
|
' Cerco l'operazione selezionata all'interno di OperationList
|
|
Dim selOperation As OperationListBoxItem = Nothing
|
|
For Each Operation In OperationList
|
|
If (Operation.IsSelected) Then
|
|
selOperation = Operation
|
|
End If
|
|
Next
|
|
If value Then
|
|
If m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONLIST Then
|
|
ListIsExpanded = False
|
|
ElseIf m_CurrExpandedExpander = MachiningOptionPanelExpander.SIMULATION Then
|
|
m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONPARAMETERS
|
|
Application.Msn.NotifyColleagues(Application.SIMULATIONEXPANDER_SET_ISEXPANDED, False)
|
|
ElseIf m_CurrExpandedExpander = MachiningOptionPanelExpander.ESTIMATIONS Then
|
|
m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONPARAMETERS
|
|
Application.Msn.NotifyColleagues(Application.ESTIMATIONSEXPANDER_SET_ISEXPANDED, False)
|
|
End If
|
|
m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONPARAMETERS
|
|
If IsValidDispositionType(selOperation.m_Type) Then
|
|
ParametersExpanderName = selOperation.Name
|
|
' Abilito la selezione di tutti i tipi di geometria
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, 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
|
|
' 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
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.MACHINING)
|
|
' Abilito la selezione dei giusti tipi di geometria
|
|
Select Case OperationType
|
|
Case MCH_OY.SAWING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomSawing)
|
|
Case MCH_OY.DRILLING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomDrilling)
|
|
Case MCH_OY.MILLING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomMilling)
|
|
Case MCH_OY.POCKETING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomPocketing)
|
|
Case MCH_OY.MORTISING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomMortising)
|
|
Case MCH_OY.SAWROUGHING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomSawRoughing)
|
|
Case MCH_OY.SAWFINISHING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomSawFinishing)
|
|
Case MCH_OY.GENMACHINING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomGenMachining)
|
|
Case MCH_OY.CHISELING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomChiseling)
|
|
Case MCH_OY.SURFFINISHING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomSurfFinishing)
|
|
Case MCH_OY.WATERJETTING
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomWaterJetting)
|
|
End Select
|
|
' Imposto visualizzazione utensile
|
|
DirectCast(m_MachiningParameterExpander.DataContext, MachiningParameterExpanderVM).ViewTool = True
|
|
End If
|
|
Else
|
|
If m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONLIST Then
|
|
ListIsExpanded = True
|
|
End If
|
|
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
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.NULL)
|
|
' Resetto il tipo di selezione
|
|
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.NULL)
|
|
End If
|
|
OnPropertyChanged("ParametersIsExpanded")
|
|
End If
|
|
Application.Msn.NotifyColleagues(Application.EMITTITLE)
|
|
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
|
|
|
|
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
|
|
|
|
Public ReadOnly Property DuplicateCmd_IsEnabled As Boolean
|
|
Get
|
|
Dim SelType As Integer = MCH_OY.NONE
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
If SelType <> MCH_OY.NONE Then Return False
|
|
SelType = Operation.Type
|
|
If SelType = MCH_OY.DISP Then Return False
|
|
End If
|
|
Next
|
|
Return SelType <> MCH_OY.NONE
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MachToDb_IsEnabled As Boolean
|
|
Get
|
|
Dim SelType As Integer = MCH_OY.NONE
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
If SelType <> MCH_OY.NONE Then Return False
|
|
SelType = Operation.Type
|
|
If SelType = MCH_OY.DISP Then Return False
|
|
End If
|
|
Next
|
|
Return SelType <> MCH_OY.NONE
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Rename_IsEnabled As Boolean
|
|
Get
|
|
Dim SelType As Integer = MCH_OY.NONE
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
If SelType <> MCH_OY.NONE Then Return False
|
|
SelType = Operation.Type
|
|
If SelType = MCH_OY.DISP Then Return False
|
|
End If
|
|
Next
|
|
Return SelType <> MCH_OY.NONE
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MoveUp_IsEnabled As Boolean
|
|
Get
|
|
Return MoveUp_SelectionOperation()
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MoveDown_IsEnabled As Boolean
|
|
Get
|
|
Return MoveDown_SelectionOperation()
|
|
End Get
|
|
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 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_MachiningParameterExpander.DataContext = New MachiningParameterExpanderVM(m_UpdateParamValues)
|
|
End If
|
|
m_UpdateParamValues()
|
|
Return m_MachiningParameterExpander
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
' Actions
|
|
Private m_UpdateParamValues As Action
|
|
Private m_OpenDispositionFunction As Action(Of Boolean)
|
|
|
|
Private m_MachiningParameterExpander As MachiningParameterExpanderV
|
|
Private m_DispositionParameterExpander As DispositionParameterExpanderV
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property OperationListHeader As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 1)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NewMachiningBtnContent As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 4)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NewPositioningBtnContent As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 5)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CancelOperationBtnContent As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 6)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MoveUpMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 8)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MoveDownMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 9)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property UpdateMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 10)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SetUpMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SETUP + 1)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DuplicateMachMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 16)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MachToDbMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 17)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RenameMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_OPERATION + 20)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' Definizione comandi
|
|
Private m_cmdNewMachining As ICommand
|
|
Private m_cmdNewPositioning As ICommand
|
|
Private m_cmdCancelOperation As ICommand
|
|
Private m_cmdOperationListDoubleClick As ICommand
|
|
Private m_cmdMoveUp As ICommand
|
|
Private m_cmdMoveDown As ICommand
|
|
Private m_cmdUpdate As ICommand
|
|
Private m_cmdSetUp As ICommand
|
|
Private m_cmdDuplicateMach As ICommand
|
|
Private m_cmdMachToDb As ICommand
|
|
Private m_cmdRename As ICommand
|
|
|
|
Sub New()
|
|
Me.ListIsExpanded = True
|
|
OperationListBoxItem.m_RefOperationExpanderVM = Me
|
|
SimulationExpanderVM.m_RefOperationExpanderVM = Me
|
|
Application.Msn.Register(Application.LOADOPERATIONLIST, Sub(nSelectedOperation As Integer)
|
|
LoadOperationList()
|
|
SelectOperation(nSelectedOperation)
|
|
ListIsExpanded = True
|
|
End Sub)
|
|
Application.Msn.Register(Application.NEWMACHININGMODEISACTIVE, Sub(Params As NewMachOpParam)
|
|
If Params.bActive Then
|
|
StartNewMachining()
|
|
Else
|
|
EndNewMachining(Params.SelMachOpId)
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.OPERATIONVIEWEXPANDERISENABLED, Sub(bEnable As Boolean)
|
|
OperViewIsEnabled = bEnable
|
|
End Sub)
|
|
|
|
Application.Msn.Register(Application.SIMULATIONEXPANDER_GET_ISEXPANDED, Sub(bValue As Boolean)
|
|
If bValue Then
|
|
If m_NewMachining Then EndNewMachining(GDB_ID.NULL)
|
|
ListIsExpanded = False
|
|
ParametersIsExpanded = False
|
|
m_CurrExpandedExpander = MachiningOptionPanelExpander.SIMULATION
|
|
Else
|
|
ListIsExpanded = True
|
|
' Deseleziono e riseleziono le operazioni correnti per ripristinare il mark
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
Operation.IsSelected = False
|
|
Operation.IsSelected = True
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.ESTIMATIONEXPANDER_GET_ISEXPANDED, Sub(bValue As Boolean)
|
|
If bValue Then
|
|
If m_NewMachining Then EndNewMachining(GDB_ID.NULL)
|
|
ListIsExpanded = False
|
|
ParametersIsExpanded = False
|
|
m_CurrExpandedExpander = MachiningOptionPanelExpander.ESTIMATIONS
|
|
Else
|
|
ListIsExpanded = True
|
|
' Deseleziono e riseleziono le operazioni correnti per ripristinare il mark
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
Operation.IsSelected = False
|
|
Operation.IsSelected = True
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.DRAWMODE_ISCHECKED, Sub()
|
|
' Annullo creazione nuova lavorazione
|
|
If m_NewMachining Then EndNewMachining(GDB_ID.NULL)
|
|
' Disabilito visualizzazione utensile
|
|
If Not IsNothing(m_MachiningParameterExpander) Then
|
|
DirectCast(m_MachiningParameterExpander.DataContext, MachiningParameterExpanderVM).ViewTool = False
|
|
End If
|
|
' Deseleziono le operazioni correnti per eliminare il mark
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
Operation.IsSelected = False
|
|
End If
|
|
Next
|
|
End Sub)
|
|
Application.Msn.Register(Application.CANCELOPERATIONCOMMAND, Sub()
|
|
CancelOperation(String.Empty)
|
|
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)
|
|
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)
|
|
StartNewMachining()
|
|
End Sub
|
|
|
|
#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)
|
|
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)
|
|
' Recupero grezzi e bloccaggi dell'ultima fase
|
|
Dim nLastPhase As Integer = EgtGetPhaseCount()
|
|
EgtSetCurrPhase(nLastPhase)
|
|
Dim vRawId As New List(Of Integer)
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
If EgtVerifyRawPartPhase(nRawId, nLastPhase) Then
|
|
vRawId.Add(nRawId)
|
|
End If
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
Dim vFxtId As New List(Of Integer)
|
|
Dim nFxtId As Integer = EgtGetFirstFixture()
|
|
While nFxtId <> GDB_ID.NULL
|
|
vFxtId.Add(nFxtId)
|
|
nFxtId = EgtGetNextFixture(nFxtId)
|
|
End While
|
|
' Aggiungo la nuova fase
|
|
Dim nPhase As Integer = EgtAddPhase()
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(nPhase)
|
|
' Confermo grezzi e bloccaggi sopra salvati
|
|
For Each nId As Integer In vRawId
|
|
EgtKeepRawPart(nId, nLastPhase)
|
|
Next
|
|
For Each nId As Integer In vFxtId
|
|
EgtKeepFixture(nId, nLastPhase)
|
|
Next
|
|
' Ricarico la lista delle operazioni
|
|
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, nDispId)
|
|
End Sub
|
|
|
|
#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)
|
|
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)
|
|
' Se viene premuto il tasto Esc
|
|
If DirectCast(param, String) = "Escape" Then
|
|
If m_NewMachining Then
|
|
EndNewMachining(GDB_ID.NULL)
|
|
ListIsExpanded = True
|
|
End If
|
|
Return
|
|
End If
|
|
' Se sto inserendo una nuova lavorazione
|
|
If m_NewMachining Then
|
|
EndNewMachining(GDB_ID.NULL)
|
|
ListIsExpanded = True
|
|
' altrimenti sto cancellandone una vecchia
|
|
Else
|
|
Dim nPrevOperId As Integer = -1
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
' Salvo indice operazione precedente a selezionata
|
|
nPrevOperId = EgtGetPrevOperation(Operation.Id)
|
|
If Operation.Type = MCH_OY.DISP Then
|
|
' Posso cancellare solo l'ultima disposizione
|
|
If EgtGetOperationPhase(Operation.Id) = EgtGetPhaseCount() Then
|
|
EgtRemoveLastPhase()
|
|
'Else
|
|
' Return
|
|
End If
|
|
Else
|
|
' Deseleziono la geometria selezionata
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' Rimuovo l'operazione selezionata
|
|
EgtRemoveOperation(Operation.Id)
|
|
End If
|
|
End If
|
|
Next
|
|
' Ricarico la lista delle operazioni
|
|
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, nPrevOperId)
|
|
Application.Msn.NotifyColleagues(Application.EMITTITLE)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' CancelOperationCommand
|
|
|
|
#Region "OperationListDoubleClickCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property OperationListDoubleClickCommand As ICommand
|
|
Get
|
|
If m_cmdOperationListDoubleClick Is Nothing Then
|
|
m_cmdOperationListDoubleClick = New RelayCommand(AddressOf OperationListDoubleClick)
|
|
End If
|
|
Return m_cmdOperationListDoubleClick
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub OperationListDoubleClick()
|
|
' Cerco l'operazione selezionata all'interno di OperationList
|
|
Dim selOperation As OperationListBoxItem = Nothing
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
selOperation = Operation
|
|
End If
|
|
Next
|
|
|
|
If EgtGetOperationMode(selOperation.Id) Then
|
|
ParametersIsExpanded = True
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' OperationListDoubleClickCommand
|
|
|
|
#Region "MoveUpCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property MoveUpCommand As ICommand
|
|
Get
|
|
If m_cmdMoveUp Is Nothing Then
|
|
m_cmdMoveUp = New RelayCommand(AddressOf MoveUp)
|
|
End If
|
|
Return m_cmdMoveUp
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the MoveUp. This method is invoked by the MoveUpCommand.
|
|
''' </summary>
|
|
Public Sub MoveUp()
|
|
' Verifico il numero di elementi selezionati
|
|
Dim indexes As New List(Of Integer)()
|
|
For index As Integer = 0 To OperationList.Count - 1
|
|
' Verifico gli elementi selezionati
|
|
If OperationList.Item(index).IsSelected Then
|
|
' Se presente una disposizione esco
|
|
if EgtGetOperationType(OperationList.Item(index).Id) = MCH_OY.DISP Then Return
|
|
' Aggiungo l'operazione
|
|
indexes.Add(index)
|
|
End If
|
|
Next
|
|
Dim lenIndexes As Integer = indexes.Count
|
|
' Recupero Id ultima entità selezionata e precedente a quelle selezionate
|
|
Dim LastSelectedId As Integer = OperationList(indexes(lenIndexes - 1)).Id
|
|
Dim PreviousId As Integer = OperationList(indexes(0) - 1).Id
|
|
' Sposto l'operazione precedente a quelle selezionate nell'ambiente Egt
|
|
If EgtRelocate(PreviousId, LastSelectedId, GDB_POS.AFTER) Then
|
|
' Sposto l'operazione precedente a quelle selezionate nella grafica
|
|
OperationList.Move(indexes(0) - 1, indexes(lenIndexes - 1)) ' + 1)
|
|
' Ricalcolo la lavorazioni selezionate e quella che era precedente (e ora è seguente)
|
|
For index As Integer = 0 To indexes.Count - 1
|
|
EgtSetCurrMachining(OperationList(indexes(index)).Id)
|
|
EgtApplyMachining(False)
|
|
Next
|
|
EgtSetCurrMachining(PreviousId)
|
|
EgtApplyMachining(False)
|
|
EgtDraw()
|
|
OnPropertyChanged("MoveUp_IsEnabled")
|
|
OnPropertyChanged("MoveDown_IsEnabled")
|
|
Application.Msn.NotifyColleagues(Application.EMITTITLE)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' MoveUpCommand
|
|
|
|
#Region "MoveDownCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property MoveDownCommand As ICommand
|
|
Get
|
|
If m_cmdMoveDown Is Nothing Then
|
|
m_cmdMoveDown = New RelayCommand(AddressOf MoveDown)
|
|
End If
|
|
Return m_cmdMoveDown
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the MoveDown. This method is invoked by the MoveDownCommand.
|
|
''' </summary>
|
|
Public Sub MoveDown()
|
|
' Verifico il numero di elementi selezionati
|
|
Dim indexes As New List(Of Integer)()
|
|
For index As Integer = 0 To OperationList.Count - 1
|
|
' Verifico gli elementi selezionati
|
|
If OperationList.Item(index).IsSelected Then
|
|
' Se presente una disposizione esco
|
|
if EgtGetOperationType(OperationList.Item(index).Id) = MCH_OY.DISP Then Return
|
|
' Aggiungo l'operazione
|
|
indexes.Add(index)
|
|
End If
|
|
Next
|
|
Dim lenIndexes As Integer = indexes.Count
|
|
' Recupero Id prima entità selezionata e successiva a quelle selezionate
|
|
Dim FirstSelectedId As Integer = OperationList(indexes(0)).Id
|
|
Dim NextId As Integer = OperationList(indexes(lenIndexes - 1) + 1).Id
|
|
' Sposto l'operazione successiva a quelle selezionate nell'ambiente Egt
|
|
If EgtRelocate(NextId, FirstSelectedId, GDB_POS.BEFORE) Then
|
|
' Sposto l'operazione successiva a quelle selezionate nella grafica
|
|
OperationList.Move(indexes(lenIndexes - 1) + 1, indexes(0))
|
|
' Ricalcolo la lavorazioni selezionate e quella che era seguente (e ora è precedente)
|
|
For index As Integer = 0 To indexes.Count - 1
|
|
EgtSetCurrMachining(OperationList(indexes(index)).Id)
|
|
EgtApplyMachining(False)
|
|
Next
|
|
EgtSetCurrMachining(NextId)
|
|
EgtApplyMachining(False)
|
|
EgtDraw()
|
|
OnPropertyChanged("MoveUp_IsEnabled")
|
|
OnPropertyChanged("MoveDown_IsEnabled")
|
|
Application.Msn.NotifyColleagues(Application.EMITTITLE)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' MoveDownCommand
|
|
|
|
#Region "UpdateCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property UpdateCommand As ICommand
|
|
Get
|
|
If m_cmdUpdate Is Nothing Then
|
|
m_cmdUpdate = New RelayCommand(AddressOf Update)
|
|
End If
|
|
Return m_cmdUpdate
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub Update()
|
|
' Cursore di attesa
|
|
Application.Current.MainWindow.ForceCursor = True
|
|
Application.Current.MainWindow.Cursor = Cursors.Wait
|
|
' Eseguo ricalcolo
|
|
Dim bRecalc As Boolean = ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift)
|
|
Dim sErr As String = String.Empty
|
|
Dim bOk As Boolean = EgtApplyAllMachinings(bRecalc, False, sErr)
|
|
EgtSetModified()
|
|
' Aggiorno visualizzazione e ritorno a cursore standard
|
|
EgtDraw()
|
|
Application.Current.MainWindow.ForceCursor = False
|
|
Application.Current.MainWindow.Cursor = Cursors.Arrow
|
|
' In caso di errori, li segnalo
|
|
If Not bOk Then
|
|
If Not String.IsNullOrEmpty(sErr) Then
|
|
MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
Else
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATION + 6), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
Else
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_OPERATION + 11))
|
|
End If
|
|
Application.Msn.NotifyColleagues(Application.EMITTITLE)
|
|
End Sub
|
|
|
|
#End Region ' UpdateCommand
|
|
|
|
#Region "SetUpCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property SetUpCommand As ICommand
|
|
Get
|
|
If m_cmdSetUp Is Nothing Then
|
|
m_cmdSetUp = New RelayCommand(AddressOf SetUp)
|
|
End If
|
|
Return m_cmdSetUp
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub SetUp()
|
|
' verifico che il file di configurazione attrezzaggio (lua) della macchina esista
|
|
If Not File.Exists(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA) Then
|
|
EgtOutLog("SetUp error: SetUp configuration file doesn't exist ")
|
|
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato,
|
|
' e testa e uscita dell'utensile attrezzato
|
|
EgtLuaExecFile(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA)
|
|
' verifico che le teste riportate in configurazione esistano
|
|
Dim Index As Integer = 1
|
|
Dim nErr As Integer = 0
|
|
While nErr = 0
|
|
Dim sHead As String = String.Empty
|
|
nErr = 999
|
|
EgtLuaSetGlobIntVar("STU.INDEX", Index)
|
|
EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos")
|
|
' Leggo variabili
|
|
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
|
|
EgtLuaGetGlobIntVar("STU.ERR", nErr)
|
|
If nErr = 0 Then
|
|
If EgtGetHeadExitCount(sHead) = 0 Then
|
|
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
End If
|
|
Index += 1
|
|
End While
|
|
' creo ed apro finestra SetUp
|
|
Dim SetUpDbWindow As New CurrSetUpV(Application.Current.MainWindow, New CurrSetUpVM)
|
|
SetUpDbWindow.ShowDialog()
|
|
Application.Msn.NotifyColleagues(Application.EMITTITLE)
|
|
End Sub
|
|
|
|
#End Region ' SetUpCommand
|
|
|
|
#Region "DuplicateMachCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property DuplicateMachCommand As ICommand
|
|
Get
|
|
If m_cmdDuplicateMach Is Nothing Then
|
|
m_cmdDuplicateMach = New RelayCommand(AddressOf DuplicateMach)
|
|
End If
|
|
Return m_cmdDuplicateMach
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub DuplicateMach()
|
|
' Cerco l'operazione selezionata all'interno di OperationList
|
|
Dim selOperation As OperationListBoxItem = Nothing
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
selOperation = Operation
|
|
End If
|
|
Next
|
|
' Verifico che l'operazione selezionata sia una lavorazione
|
|
If IsNothing(selOperation) OrElse
|
|
selOperation.m_Type = MCH_OY.NONE OrElse
|
|
selOperation.m_Type = MCH_OY.DISP Then Return
|
|
' Tolgo Mark da lavorazione originale
|
|
EgtResetMark(EgtGetFirstNameInGroup(selOperation.Id, MCH_MGR_CL))
|
|
' Eseguo la copia
|
|
Dim MachiningId As Integer = EgtCopyMachining(selOperation.Name, selOperation.Name)
|
|
' Se è abilitata l'opzione
|
|
If Not OptionModule.m_bNewMachiningIsLastOne Then
|
|
' Sposto la lavorazione aggiunta subito dopo quella appena selezionata
|
|
EgtRelocate(MachiningId, selOperation.Id, GDB_POS.AFTER)
|
|
End If
|
|
' Ricarico la lista operazioni aggiornata
|
|
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, MachiningId)
|
|
End Sub
|
|
|
|
#End Region ' DuplicateMachCommand
|
|
|
|
#Region "MachToDbCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property MachToDbCommand As ICommand
|
|
Get
|
|
If m_cmdMachToDb Is Nothing Then
|
|
m_cmdMachToDb = New RelayCommand(AddressOf MachToDb)
|
|
End If
|
|
Return m_cmdMachToDb
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub MachToDb()
|
|
' Cerco l'operazione selezionata all'interno di OperationList
|
|
Dim selOperation As OperationListBoxItem = Nothing
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
selOperation = Operation
|
|
Exit For
|
|
End If
|
|
Next
|
|
'verifico che l'operazione selezionata sia una lavorazione
|
|
If IsNothing(selOperation) OrElse
|
|
selOperation.m_Type = MCH_OY.NONE OrElse
|
|
selOperation.m_Type = MCH_OY.DISP Then Return
|
|
' apro la finetra che chiede il nome e verifica che non sia già utilizzato (Nome lavorazione nel Db)
|
|
Dim NameDialogVM As New EgtWPFLib5.NameDialogVM With {
|
|
.VerifyChars = False,
|
|
.Title = EgtMsg(MSG_OPERATION + 18),
|
|
.Name = TryCast(selOperation, MachiningOpListBoxItem).LibMach,
|
|
.NameVerifyer = AddressOf NameVerifyer}
|
|
Dim NameWnd As New EgtWPFLib5.NameDialogV(Application.Current.MainWindow, NameDialogVM)
|
|
If Not NameWnd.ShowDialog() Then Return
|
|
' creo lavorazione nel Db
|
|
EgtMdbAddMachining(NameDialogVM.Name, selOperation.m_Type)
|
|
' copio i parametri
|
|
Dim bMachParList As Integer() = {MCH_MP.INVERT,
|
|
MCH_MP.LEAVETAB,
|
|
MCH_MP.TOOLINVERT}
|
|
Dim nMachParList As Integer() = {MCH_MP.TYPE,
|
|
MCH_MP.WORKSIDE,
|
|
MCH_MP.HEADSIDE,
|
|
MCH_MP.LEADINTYPE,
|
|
MCH_MP.EXTLINKTYPE,
|
|
MCH_MP.LEADOUTTYPE,
|
|
MCH_MP.CURVEUSE,
|
|
MCH_MP.STEPTYPE,
|
|
MCH_MP.SUBTYPE,
|
|
MCH_MP.LEADLINKTYPE,
|
|
MCH_MP.SOLCHOICETYPE,
|
|
MCH_MP.FACEUSE}
|
|
Dim dMachParList As Integer() = {MCH_MP.SPEED,
|
|
MCH_MP.FEED,
|
|
MCH_MP.STARTFEED,
|
|
MCH_MP.ENDFEED,
|
|
MCH_MP.TIPFEED,
|
|
MCH_MP.OFFSR,
|
|
MCH_MP.OFFSL,
|
|
MCH_MP.DEPTH,
|
|
MCH_MP.SIDEANGLE,
|
|
MCH_MP.APPROX,
|
|
MCH_MP.STARTPOS,
|
|
MCH_MP.STARTSLOWLEN,
|
|
MCH_MP.ENDSLOWLEN,
|
|
MCH_MP.THROUADDLEN,
|
|
MCH_MP.STEP_,
|
|
MCH_MP.RETURNPOS,
|
|
MCH_MP.OVERLAP,
|
|
MCH_MP.TABLEN,
|
|
MCH_MP.TABDIST,
|
|
MCH_MP.TABHEIGHT,
|
|
MCH_MP.TABANGLE,
|
|
MCH_MP.LITANG,
|
|
MCH_MP.LIPERP,
|
|
MCH_MP.LIELEV,
|
|
MCH_MP.LICOMPLEN,
|
|
MCH_MP.LOTANG,
|
|
MCH_MP.LOPERP,
|
|
MCH_MP.LOELEV,
|
|
MCH_MP.LOCOMPLEN,
|
|
MCH_MP.STARTADDLEN,
|
|
MCH_MP.ENDADDLEN,
|
|
MCH_MP.OFFSET,
|
|
MCH_MP.STEPEXTARC,
|
|
MCH_MP.STEPINTARC,
|
|
MCH_MP.SIDESTEP,
|
|
MCH_MP.VERTFEED,
|
|
MCH_MP.STEPSIDEANG,
|
|
MCH_MP.OVERL,
|
|
MCH_MP.STEPBACK,
|
|
MCH_MP.STEPSIDEANGBACK,
|
|
MCH_MP.BACKFEED}
|
|
Dim sMachParList As Integer() = {MCH_MP.NAME,
|
|
MCH_MP.TOOL,
|
|
MCH_MP.DEPTH_STR,
|
|
MCH_MP.TUUID,
|
|
MCH_MP.UUID,
|
|
MCH_MP.SYSNOTES,
|
|
MCH_MP.USERNOTES,
|
|
MCH_MP.OVERLAP_STR,
|
|
MCH_MP.OFFSET_STR,
|
|
MCH_MP.INITANGS,
|
|
MCH_MP.BLOCKEDAXIS}
|
|
For Each Parameter In bMachParList
|
|
Dim bTemp As Boolean = False
|
|
EgtGetMachiningParam(Parameter, bTemp)
|
|
EgtMdbSetCurrMachiningParam(Parameter, bTemp)
|
|
Next
|
|
For Each Parameter In nMachParList
|
|
Dim nTemp As Integer = 0
|
|
EgtGetMachiningParam(Parameter, nTemp)
|
|
EgtMdbSetCurrMachiningParam(Parameter, nTemp)
|
|
Next
|
|
For Each Parameter In dMachParList
|
|
Dim dTemp As Double = 0
|
|
EgtGetMachiningParam(Parameter, dTemp)
|
|
EgtMdbSetCurrMachiningParam(Parameter, dTemp)
|
|
Next
|
|
For Each Parameter In sMachParList
|
|
Dim sTemp As String = ""
|
|
EgtGetMachiningParam(Parameter, sTemp)
|
|
EgtMdbSetCurrMachiningParam(Parameter, sTemp)
|
|
Next
|
|
EgtMdbSaveCurrMachining()
|
|
EgtMdbSave()
|
|
End Sub
|
|
|
|
' verifico che il nome non sia già utilizzato
|
|
Private Function NameVerifyer(Name As String) As Boolean
|
|
If String.IsNullOrWhiteSpace(Name) Then
|
|
MessageBox.Show(EgtMsg(MSG_EGTSAVEFILEDIALOG + 8),
|
|
EgtMsg(MSG_EGTSAVEFILEDIALOG + 7),
|
|
MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return False
|
|
End If
|
|
Dim TempName As String = Name
|
|
EgtMdbGetMachiningNewName(TempName)
|
|
If String.Compare(TempName, Name, True) = 0 Then Return True
|
|
MessageBox.Show(Name & " " &
|
|
EgtMsg(MSG_EGTSAVEFILEDIALOG + 3),
|
|
EgtMsg(MSG_EGTSAVEFILEDIALOG + 7),
|
|
MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return False
|
|
End Function
|
|
|
|
#End Region ' MachToDbCommand
|
|
|
|
#Region "RenameCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property RenameCommand As ICommand
|
|
Get
|
|
If m_cmdRename Is Nothing Then
|
|
m_cmdRename = New RelayCommand(AddressOf Rename)
|
|
End If
|
|
Return m_cmdRename
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub Rename()
|
|
' Cerco l'operazione selezionata all'interno di OperationList
|
|
Dim selOperation As OperationListBoxItem = Nothing
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
selOperation = Operation
|
|
Exit For
|
|
End If
|
|
Next
|
|
' verifico che l'operazione selezionata sia una lavorazione
|
|
If IsNothing(selOperation) OrElse
|
|
selOperation.m_Type = MCH_OY.NONE OrElse
|
|
selOperation.m_Type = MCH_OY.DISP Then Return
|
|
' lancio modalità rinomina
|
|
If Not TypeOf selOperation Is MachiningOpListBoxItem Then Return
|
|
Dim SelectedOperation As MachiningOpListBoxItem = TryCast(selOperation, MachiningOpListBoxItem)
|
|
If IsNothing(SelectedOperation) Then Return
|
|
SelectedOperation.IsActive_ModifyName = True
|
|
' apro la finetra che chiede il nome e verifica che non sia già utilizzato
|
|
'Dim NewName As String = m_SelectedOperation.Name
|
|
'Dim NameDialogVM As New EgtWPFLib5.NameDialogVM With {
|
|
' .Title = "Nome lavorazione in Db",
|
|
' .Name = m_SelectedOperation.Name,
|
|
' .NameVerifyer = AddressOf NameVerifyer}
|
|
'Dim NameWnd As New EgtWPFLib5.NameDialogV(Application.Current.MainWindow, NameDialogVM)
|
|
'If Not NameWnd.ShowDialog() Then Return
|
|
'' creo lavorazione nel Db
|
|
'EgtMdbAddMachining(NameDialogVM.Name, m_SelectedOperation.m_Type)
|
|
End Sub
|
|
|
|
'' verifico che il nome non sia già utilizzato
|
|
'Private Function NameVerifyer(Name As String) As Boolean
|
|
' If String.IsNullOrWhiteSpace(Name) Then
|
|
' MessageBox.Show(EgtMsg(MSG_EGTSAVEFILEDIALOG + 8),
|
|
' EgtMsg(MSG_EGTSAVEFILEDIALOG + 7),
|
|
' MessageBoxButton.OK, MessageBoxImage.Error)
|
|
' Return False
|
|
' End If
|
|
' Dim TempName As String = Name
|
|
' 'EgtGetMachiningNewName(TempName)
|
|
' If String.Compare(TempName, Name, True) = 0 Then Return True
|
|
' MessageBox.Show(Name & " " &
|
|
' EgtMsg(MSG_EGTSAVEFILEDIALOG + 3),
|
|
' EgtMsg(MSG_EGTSAVEFILEDIALOG + 7),
|
|
' MessageBoxButton.OK, MessageBoxImage.Error)
|
|
' Return False
|
|
'End Function
|
|
|
|
#End Region ' RenameCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Sub LoadOperationList()
|
|
OperationList.Clear()
|
|
Dim Id As Integer
|
|
Dim OpStatus As Boolean = True
|
|
Dim OpName As String = String.Empty
|
|
Dim OpType As Integer = 0
|
|
Dim OpTool As String = String.Empty
|
|
Dim OpMach As String = String.Empty
|
|
Id = EgtGetFirstOperation()
|
|
While Id <> GDB_ID.NULL
|
|
EgtGetOperationName(Id, OpName)
|
|
OpType = EgtGetOperationType(Id)
|
|
If IsValidMachiningType(OpType) Then
|
|
EgtSetCurrMachining(Id)
|
|
OpStatus = EgtGetOperationMode(Id)
|
|
EgtGetMachiningParam(MCH_MP.TOOL, OpTool)
|
|
EgtGetMachiningParam(MCH_MP.NAME, OpMach)
|
|
OperationList.Add(New MachiningOpListBoxItem(Id, OpStatus, OpName, OpType, OpTool, OpMach))
|
|
ElseIf IsValidDispositionType(OpType) Then
|
|
OpStatus = True
|
|
OpTool = String.Empty
|
|
OpMach = String.Empty
|
|
OperationList.Add(New DispositionOpListBoxItem(Id, OpName, OpType))
|
|
End If
|
|
Id = EgtGetNextOperation(Id)
|
|
End While
|
|
End Sub
|
|
|
|
Private Sub SelectOperation(nSelectedOperation As Integer)
|
|
If nSelectedOperation < 0 Then
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
Operation.IsSelected = False
|
|
End If
|
|
Next
|
|
OperationList(0).IsSelected = True
|
|
Else
|
|
Dim OperationFound = False
|
|
For Each Operation In OperationList
|
|
If Operation.Id = nSelectedOperation Then
|
|
OperationFound = True
|
|
Operation.IsSelected = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not OperationFound Then
|
|
For Each Operation In OperationList
|
|
If Operation.IsSelected Then
|
|
Operation.IsSelected = False
|
|
End If
|
|
Next
|
|
OperationList(0).IsSelected = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
' Abilita/Disabilita il bottone MoveUp in base agli elementi selezionati
|
|
Private Function MoveUp_SelectionOperation() As Boolean
|
|
' Inserisco in una lista le operazioni selezionate
|
|
Dim indexes As New List(Of Integer)()
|
|
For index As Integer = 0 To OperationList.Count - 1
|
|
If OperationList.Item(index).IsSelected Then
|
|
indexes.Add(index)
|
|
End If
|
|
Next
|
|
' Se non ci sono operazioni selezionate, non va bene
|
|
If indexes.Count = 0 Then Return False
|
|
|
|
' Se le operazioni non sono consecutive, non va bene
|
|
For index As Integer = 1 To indexes.Count - 1
|
|
If indexes(index) - indexes(index - 1) <> 1 Then Return False
|
|
Next
|
|
|
|
' Se tra le operazioni c'è una disposizione, non va bene
|
|
For index As Integer = 0 To indexes.Count - 1
|
|
If EgtGetOperationType(OperationList.Item(indexes(index)).Id) = MCH_OY.DISP Then Return False
|
|
Next
|
|
|
|
' Se prima della prima selezionata c'è una disposizione, non va bene
|
|
If indexes(0) = 0 OrElse EgtGetOperationType(OperationList.Item(indexes(0) - 1).Id) = MCH_OY.DISP Then Return False
|
|
|
|
Return True
|
|
End Function
|
|
|
|
' Abilita/Disabilita il bottone MoveDown in base agli elementi selezionati
|
|
Private Function MoveDown_SelectionOperation() As Boolean
|
|
' Inserisco in una lista le operazioni selezionate
|
|
Dim indexes As New List(Of Integer)()
|
|
For index As Integer = 0 To OperationList.Count - 1
|
|
If OperationList.Item(index).IsSelected Then
|
|
indexes.Add(index)
|
|
End If
|
|
Next
|
|
' Se non ci sono operazioni selezionate, non va bene
|
|
If indexes.Count = 0 Then Return False
|
|
|
|
' Se le operazioni non sono consecutive, non va bene
|
|
For index As Integer = 1 To indexes.Count - 1
|
|
If indexes(index) - indexes(index - 1) <> 1 Then Return False
|
|
Next
|
|
|
|
' Se tra le operazioni c'è una disposizione, non va bene
|
|
For index As Integer = 0 To indexes.Count - 1
|
|
If EgtGetOperationType(OperationList.Item(indexes(index)).Id) = MCH_OY.DISP Then Return False
|
|
Next
|
|
|
|
' Se dopo l'ultima selezionata c'è una disposizione, non va bene
|
|
Dim nLast As Integer = indexes.Count - 1
|
|
If indexes(nLast) = OperationList.Count - 1 OrElse
|
|
EgtGetOperationType(OperationList.Item(indexes(nLast) + 1).Id) = MCH_OY.DISP Then Return False
|
|
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class |