907 lines
39 KiB
VB.net
907 lines
39 KiB
VB.net
Imports System.Windows.Forms.Integration
|
|
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Public Class MachiningDbWindowVM
|
|
Inherits VMBase
|
|
|
|
Friend Shared m_bActive As Boolean = False
|
|
|
|
Friend Shared m_ProjectSceneContext As Integer = 0
|
|
Public Shared m_sMachineIniPath As String = String.Empty
|
|
|
|
Friend Shared m_bVisibleSysNotes As Boolean = False
|
|
|
|
Public Event m_CloseWindow(bDialogResult As Boolean)
|
|
|
|
#Region "NEW INTERFACE PROPERTIES"
|
|
|
|
Private m_TextForegroundTxBl As Brush = Brushes.Black
|
|
Public Property TextForegroundTxBl As Brush
|
|
Get
|
|
Return m_TextForegroundTxBl
|
|
End Get
|
|
Set(value As Brush)
|
|
m_TextForegroundTxBl = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_BorderGrbThickness As Double = 1
|
|
Public Property BorderGrbThickness As Double
|
|
Get
|
|
Return m_BorderGrbThickness
|
|
End Get
|
|
Set(value As Double)
|
|
m_BorderGrbThickness = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TextBackgroundTxBx As Brush = Brushes.White
|
|
Public Property TextBackgroundTxBx As Brush
|
|
Get
|
|
Return m_TextBackgroundTxBx
|
|
End Get
|
|
Set(value As Brush)
|
|
m_TextBackgroundTxBx = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TextForegroundTxBx As Brush = Brushes.Black
|
|
Public Property TextForegroundTxBx As Brush
|
|
Get
|
|
Return m_TextForegroundTxBx
|
|
End Get
|
|
Set(value As Brush)
|
|
m_TextForegroundTxBx = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TextBorderBrushTxBx As Brush = Brushes.DarkGray
|
|
Public Property TextBorderBrushTxBx As Brush
|
|
Get
|
|
Return m_TextBorderBrushTxBx
|
|
End Get
|
|
Set(value As Brush)
|
|
m_TextBorderBrushTxBx = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' New interface properties
|
|
|
|
Private m_Title As String
|
|
Public ReadOnly Property Title As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 4)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NewMsg As String
|
|
Get
|
|
Return EgtMsg(31701)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SaveMsg As String
|
|
Get
|
|
Return EgtMsg(31702)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RemoveMsg As String
|
|
Get
|
|
Return EgtMsg(31703)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ImportMsg As String
|
|
Get
|
|
Return EgtMsg(31450)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ExportMsg As String
|
|
Get
|
|
Return EgtMsg(31451)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ResetMsg As String
|
|
Get
|
|
Return EgtMsg(31456)
|
|
End Get
|
|
End Property
|
|
|
|
' Lista delle lavorazioni
|
|
Private m_MachiningsList As New ObservableCollection(Of FamilyMachiningTreeViewItem)
|
|
Public Property MachiningsList As ObservableCollection(Of FamilyMachiningTreeViewItem)
|
|
Get
|
|
Return m_MachiningsList
|
|
End Get
|
|
Set(value As ObservableCollection(Of FamilyMachiningTreeViewItem))
|
|
m_MachiningsList = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property SelMachining As MachiningTreeViewItem
|
|
Get
|
|
For Each Family In m_MachiningsList
|
|
Dim Machining As InheritableTreeViewItem = Family.Items.FirstOrDefault(Function(x) x.IsSelected)
|
|
If Not IsNothing(Machining) Then
|
|
Return DirectCast(Machining, MachiningTreeViewItem)
|
|
End If
|
|
Next
|
|
Return Nothing
|
|
End Get
|
|
End Property
|
|
|
|
Private m_IsEnabledNewBtn As Boolean
|
|
Public ReadOnly Property IsEnabledNewBtn As Boolean
|
|
Get
|
|
Return m_IsEnabledNewBtn
|
|
End Get
|
|
End Property
|
|
|
|
Private m_IsEnabledSaveBtn As Boolean
|
|
Public ReadOnly Property IsEnabledSaveBtn As Boolean
|
|
Get
|
|
Return m_IsEnabledSaveBtn
|
|
End Get
|
|
End Property
|
|
|
|
Private m_IsEnabledRemoveBtn As Boolean
|
|
Public ReadOnly Property IsEnabledRemoveBtn As Boolean
|
|
Get
|
|
Return m_IsEnabledRemoveBtn
|
|
End Get
|
|
End Property
|
|
|
|
Dim StoneDrillParamPageV As StoneDrillingParamPageV
|
|
Dim WoodDrillParamPageV As WoodDrillingParamPageV
|
|
Dim StoneSawParamPageV As StoneSawingParamPageV
|
|
Dim WoodSawParamPageV As WoodSawingParamPageV
|
|
Dim StoneMillParamPageV As StoneMillingParamPageV
|
|
Dim WoodMillParamPageV As WoodMillingParamPageV
|
|
Dim BeamMillParamPageV As BeamMillingParamPageV
|
|
Dim PocketParamPageV As PocketingParamPageV
|
|
Dim MortiseParamPageV As MortisingParamPageV
|
|
Dim StoneSawRoughParamPageV As StoneSawRoughingParamPageV
|
|
Dim StoneSawFinishParamPageV As StoneSawFinishingParamPageV
|
|
Dim GenMachinParamPageV As GenMachiningParamPageV
|
|
Dim ChiselParamPageV As ChiselingParamPageV
|
|
Dim SurfFinishParamPageV As SurfFinishingParamPageV
|
|
Dim WjParamPageV As WaterjettingParamPageV
|
|
Dim Stone5DrillParamPageV As Stone5DrillingParamPageV
|
|
Dim Stone5SawParamPageV As Stone5SawingParamPageV
|
|
Dim Stone5MillParamPageV As Stone5MillingParamPageV
|
|
Dim Stone5SawRoughParamPageV As Stone5SawRoughingParamPageV
|
|
Dim Stone5SawFinishParamPageV As Stone5SawFinishingParamPageV
|
|
Dim Stone5WjParamPageV As Stone5WaterjettingParamPageV
|
|
|
|
Public ReadOnly Property ParamPageV As ContentControl
|
|
Get
|
|
Dim selMachiningFamily As FamilyMachiningTreeViewItem = Nothing
|
|
Dim selMachining As MachiningTreeViewItem = Nothing
|
|
For Each MachiningFamily In MachiningsList
|
|
For Each Machining In MachiningFamily.Items
|
|
If Machining.IsSelected Then
|
|
selMachining = DirectCast(Machining, MachiningTreeViewItem)
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not IsNothing(selMachining) Then Exit For
|
|
Next
|
|
|
|
If IsNothing(selMachining) Then Return Nothing
|
|
|
|
StoneDrillParamPageV.DataContext = Nothing
|
|
WoodDrillParamPageV.DataContext = Nothing
|
|
StoneSawParamPageV.DataContext = Nothing
|
|
WoodSawParamPageV.DataContext = Nothing
|
|
StoneMillParamPageV.DataContext = Nothing
|
|
WoodMillParamPageV.DataContext = Nothing
|
|
BeamMillParamPageV.DataContext = Nothing
|
|
PocketParamPageV.DataContext = Nothing
|
|
MortiseParamPageV.DataContext = Nothing
|
|
StoneSawRoughParamPageV.DataContext = Nothing
|
|
StoneSawFinishParamPageV.DataContext = Nothing
|
|
GenMachinParamPageV.DataContext = Nothing
|
|
ChiselParamPageV.DataContext = Nothing
|
|
SurfFinishParamPageV.DataContext = Nothing
|
|
WjParamPageV.DataContext = Nothing
|
|
Stone5DrillParamPageV.DataContext = Nothing
|
|
Stone5SawParamPageV.DataContext = Nothing
|
|
Stone5MillParamPageV.DataContext = Nothing
|
|
Stone5SawRoughParamPageV.DataContext = Nothing
|
|
Stone5SawFinishParamPageV.DataContext = Nothing
|
|
Stone5WjParamPageV.DataContext = Nothing
|
|
|
|
Select Case selMachining.Type
|
|
Case MCH_MY.DRILLING
|
|
If MachiningTreeViewItem.m_MatType = MaterialType.STONE5 Then
|
|
Stone5DrillParamPageV.DataContext = selMachining
|
|
Return Stone5DrillParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.STONE Then
|
|
StoneDrillParamPageV.DataContext = selMachining
|
|
Return StoneDrillParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.WOOD Or MachiningTreeViewItem.m_MatType = MaterialType.BEAM Then
|
|
WoodDrillParamPageV.DataContext = selMachining
|
|
Return WoodDrillParamPageV
|
|
End If
|
|
Case MCH_MY.SAWING
|
|
If MachiningTreeViewItem.m_MatType = MaterialType.STONE5 Then
|
|
Stone5SawParamPageV.DataContext = selMachining
|
|
Return Stone5SawParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.STONE Then
|
|
StoneSawParamPageV.DataContext = selMachining
|
|
|
|
' Imposto il colore delle TextBlock (definito nel programma chimamante)
|
|
StoneSawParamPageV.MyForegroundTxBl_ = m_TextForegroundTxBl
|
|
StoneSawParamPageV.MyBorderGrbThickness_ = m_BorderGrbThickness
|
|
StoneSawParamPageV.MyBackgroundTxBx_ = m_TextBackgroundTxBx
|
|
StoneSawParamPageV.MyForegroundTxBx_ = m_TextForegroundTxBx
|
|
StoneSawParamPageV.MyBorderBrushTxBx_ = m_TextBorderBrushTxBx
|
|
|
|
Return StoneSawParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.WOOD Or MachiningTreeViewItem.m_MatType = MaterialType.BEAM Then
|
|
WoodSawParamPageV.DataContext = selMachining
|
|
Return WoodSawParamPageV
|
|
End If
|
|
Case MCH_MY.MILLING
|
|
If MachiningTreeViewItem.m_MatType = MaterialType.STONE5 Then
|
|
Stone5MillParamPageV.DataContext = selMachining
|
|
Return Stone5MillParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.STONE Then
|
|
StoneMillParamPageV.DataContext = selMachining
|
|
|
|
' Imposto il colore delle TextBlock (definito nel programma chimamante)
|
|
StoneMillParamPageV.MyForegroundTxBl_ = m_TextForegroundTxBl
|
|
'StoneMillParamPageV.MyBorderGrbThickness_ = m_BorderGrbThickness
|
|
StoneMillParamPageV.MyBackgroundTxBx_ = m_TextBackgroundTxBx
|
|
'StoneMillParamPageV.MyForegroundTxBx_ = m_TextForegroundTxBx
|
|
'StoneMillParamPageV.MyBorderBrushTxBx_ = m_TextBorderBrushTxBx
|
|
|
|
Return StoneMillParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.WOOD Then
|
|
WoodMillParamPageV.DataContext = selMachining
|
|
Return WoodMillParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.BEAM Then
|
|
BeamMillParamPageV.DataContext = selMachining
|
|
Return BeamMillParamPageV
|
|
End If
|
|
Case MCH_MY.POCKETING
|
|
PocketParamPageV.DataContext = selMachining
|
|
Return PocketParamPageV
|
|
Case MCH_MY.MORTISING
|
|
MortiseParamPageV.DataContext = selMachining
|
|
Return MortiseParamPageV
|
|
Case MCH_MY.SAWROUGHING
|
|
If MachiningTreeViewItem.m_MatType = MaterialType.STONE5 Then
|
|
Stone5SawRoughParamPageV.DataContext = selMachining
|
|
Return Stone5SawRoughParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.STONE Then
|
|
StoneSawRoughParamPageV.DataContext = selMachining
|
|
Return StoneSawRoughParamPageV
|
|
End If
|
|
Case MCH_MY.SAWFINISHING
|
|
If MachiningTreeViewItem.m_MatType = MaterialType.STONE5 Then
|
|
Stone5SawFinishParamPageV.DataContext = selMachining
|
|
Return Stone5SawFinishParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.STONE Then
|
|
StoneSawFinishParamPageV.DataContext = selMachining
|
|
Return StoneSawFinishParamPageV
|
|
End If
|
|
Case MCH_MY.GENMACHINING
|
|
GenMachinParamPageV.DataContext = selMachining
|
|
Return GenMachinParamPageV
|
|
Case MCH_MY.CHISELING
|
|
ChiselParamPageV.DataContext = selMachining
|
|
Return ChiselParamPageV
|
|
Case MCH_MY.SURFFINISHING
|
|
SurfFinishParamPageV.DataContext = selMachining
|
|
Return SurfFinishParamPageV
|
|
Case MCH_MY.WATERJETTING
|
|
If MachiningTreeViewItem.m_MatType = MaterialType.STONE5 Then
|
|
Stone5WjParamPageV.DataContext = selMachining
|
|
Return Stone5WjParamPageV
|
|
ElseIf MachiningTreeViewItem.m_MatType = MaterialType.STONE Then
|
|
WjParamPageV.DataContext = selMachining
|
|
Return WjParamPageV
|
|
End If
|
|
End Select
|
|
|
|
Return Nothing
|
|
End Get
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdNew As ICommand
|
|
Private m_cmdSave As ICommand
|
|
Private m_cmdRemove As ICommand
|
|
Private m_cmdImport As ICommand
|
|
Private m_cmdExport As ICommand
|
|
Private m_cmdReloadMachining As ICommand
|
|
Private m_cmdCloseMachiningsDb As ICommand
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(sMachineIniPath As String, ProjectSceneContext As Integer, Optional sMatType As String = "Wood", Optional bVisibleSysNotes As Boolean = False, Optional bIsEgtCAM5 As Boolean = False)
|
|
|
|
m_bActive = True
|
|
m_ProjectSceneContext = ProjectSceneContext
|
|
m_sMachineIniPath = sMachineIniPath
|
|
m_bVisibleSysNotes = bVisibleSysNotes
|
|
|
|
EgtUILib.GetPrivateProfileString(S_GENERAL, K_MATERIAL, sMatType, sMatType, sMachineIniPath)
|
|
Select Case sMatType
|
|
Case "Stone"
|
|
If bIsEgtCAM5 Then
|
|
' Se bIsEgtCAM5 è True vuol dire che il Db Lav è stato aperto da EgtCAM5 perciò dovranno essere usate
|
|
' delle pagine dedicate (con prefisso "Stone5"), attraverso l'assegnazione del valore STONE5 a MatType
|
|
MachiningTreeViewItem.m_MatType = MaterialType.STONE5
|
|
Else
|
|
MachiningTreeViewItem.m_MatType = MaterialType.STONE
|
|
End If
|
|
Case "Wood"
|
|
MachiningTreeViewItem.m_MatType = MaterialType.WOOD
|
|
Case "Beam"
|
|
MachiningTreeViewItem.m_MatType = MaterialType.BEAM
|
|
Case "Additive"
|
|
MachiningTreeViewItem.m_MatType = MaterialType.WOOD
|
|
Case Else
|
|
' Se il materiale spcificato nel file INI della macchina non corrisponde a STONE, WOOD o BEAM (STONE5 è
|
|
' comunque STONE nell'INI ma prevede pagine esclusive per EgtCAM5) viene emesso un messaggio di errore
|
|
MachiningTreeViewItem.m_MatType = Nothing
|
|
MsgBox(EgtMsg(31409), MsgBoxStyle.Exclamation, EgtMsg(31551))
|
|
Exit Sub
|
|
End Select
|
|
|
|
' Passo all'item della lista il delegato alla funzuione che permette di cancellare una lavorazione
|
|
MachiningTreeViewItem.m_delRemoveMachining = AddressOf RemoveMachining
|
|
' Passo all'item della lista il delegato alla funzuione che permette di disattivare la lista delle lavorazioni
|
|
MachiningTreeViewItem.m_delErrorOnMachining = AddressOf ErrorOnMachining
|
|
' Passo all'item della lista il delegato alla funzuione che permette di disattivare la lista delle lavorazioni
|
|
MachiningTreeViewItem.m_delIsEnabledBtns = AddressOf IsEnabledBtns
|
|
FamilyMachiningTreeViewItem.m_delIsEnabledBtns = AddressOf IsEnabledBtns
|
|
MachiningTreeViewItem.m_delNotifyPropertyChanged = AddressOf ccc
|
|
FamilyMachiningTreeViewItem.m_delNotifyPropertyChanged = AddressOf ccc
|
|
|
|
' Carico la lista delle lavorazioni della macchina selezionata
|
|
LoadSelectedMachineMachinings()
|
|
|
|
StoneDrillParamPageV = New StoneDrillingParamPageV
|
|
WoodDrillParamPageV = New WoodDrillingParamPageV
|
|
StoneSawParamPageV = New StoneSawingParamPageV
|
|
WoodSawParamPageV = New WoodSawingParamPageV
|
|
StoneMillParamPageV = New StoneMillingParamPageV
|
|
WoodMillParamPageV = New WoodMillingParamPageV
|
|
BeamMillParamPageV = New BeamMillingParamPageV
|
|
PocketParamPageV = New PocketingParamPageV
|
|
MortiseParamPageV = New MortisingParamPageV
|
|
StoneSawRoughParamPageV = New StoneSawRoughingParamPageV
|
|
StoneSawFinishParamPageV = New StoneSawFinishingParamPageV
|
|
GenMachinParamPageV = New GenMachiningParamPageV
|
|
ChiselParamPageV = New ChiselingParamPageV
|
|
SurfFinishParamPageV = New SurfFinishingParamPageV
|
|
WjParamPageV = New WaterjettingParamPageV
|
|
Stone5DrillParamPageV = New Stone5DrillingParamPageV
|
|
Stone5SawParamPageV = New Stone5SawingParamPageV
|
|
Stone5MillParamPageV = New Stone5MillingParamPageV
|
|
Stone5SawRoughParamPageV = New Stone5SawRoughingParamPageV
|
|
Stone5SawFinishParamPageV = New Stone5SawFinishingParamPageV
|
|
Stone5WjParamPageV = New Stone5WaterjettingParamPageV
|
|
|
|
NotifyPropertyChanged("ParamPageV")
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Sub ccc()
|
|
NotifyPropertyChanged("ParamPageV")
|
|
End Sub
|
|
|
|
Private Sub IsEnabledBtns(bIsEnabledNewBtn As Boolean, bIsEnabledSaveBtn As Boolean, bIsEnabledDeleteBtn As Boolean)
|
|
m_IsEnabledNewBtn = bIsEnabledNewBtn
|
|
m_IsEnabledSaveBtn = bIsEnabledSaveBtn
|
|
m_IsEnabledRemoveBtn = bIsEnabledDeleteBtn
|
|
NotifyPropertyChanged("IsEnabledNewBtn")
|
|
NotifyPropertyChanged("IsEnabledSaveBtn")
|
|
NotifyPropertyChanged("IsEnabledRemoveBtn")
|
|
End Sub
|
|
|
|
' Quando chiamato, disattiva tutti gli item dell'albero o li riattiva a seconda che ci sia o meno un errore
|
|
Private Sub ErrorOnMachining(bIsEnabled As Boolean)
|
|
For Each FamilyMachiningItem In MachiningsList
|
|
FamilyMachiningItem.IsEnabled = Not bIsEnabled
|
|
Next
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Method that search the machines in the correct folder and add to the MachinesList those valid.
|
|
''' </summary>
|
|
Public Overridable Sub LoadSelectedMachineMachinings()
|
|
EgtSetCurrentContext(m_ProjectSceneContext)
|
|
Dim ActiveMachiningsTypes() As MachiningsType = MachineUtility.ReadMachiningFamilies(m_sMachineIniPath)
|
|
For Each MachiningsType In ActiveMachiningsTypes
|
|
Dim FamilyTreeView As New FamilyMachiningTreeViewItem(MachiningsType.Name, MachiningsType.Id, Nothing)
|
|
MachiningsList.Add(FamilyTreeView)
|
|
Dim MachiningName As String = String.Empty
|
|
EgtMdbGetFirstMachining(MachiningsType.Id, MachiningName)
|
|
While Not String.IsNullOrWhiteSpace(MachiningName)
|
|
' recupero tuuid
|
|
EgtMdbSetCurrMachining(MachiningName)
|
|
Dim sCurrMachTUUID As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sCurrMachTUUID)
|
|
FamilyTreeView.Items.Add(New MachiningTreeViewItem(MachiningName, MachiningsType.Id, ToolDbUtility.IsToolInDb(sCurrMachTUUID), FamilyTreeView))
|
|
EgtMdbGetNextMachining(MachiningsType.Id, MachiningName)
|
|
End While
|
|
FamilyTreeView.VerifyMachiningValidity()
|
|
Next
|
|
' Se esiste almeno una famiglia di lavorazioni, la seleziono
|
|
If MachiningsList.Count > 0 Then
|
|
MachiningsList(0).IsSelected = True
|
|
MachiningsList(0).NotifyPropertyChanged("IsSelected")
|
|
End If
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Method that search imported Machinings for the currently selected Machine and add it to the MachiningsList.
|
|
''' </summary>
|
|
Private Sub LoadImportedMachineMachinings(vsImportedMachinings As String())
|
|
' Leggo tutte le lavorazioni presenti nella Macchina (quindi anche quelli appena importati).
|
|
Dim ActiveMachiningsFamilies() As MachiningsType = MachineUtility.ReadMachiningFamilies(m_sMachineIniPath)
|
|
Dim MachiningsFamilyIndex As Integer = 0
|
|
For Each MachiningsFamily In ActiveMachiningsFamilies
|
|
Dim FamilyTreeView As New FamilyMachiningTreeViewItem(MachiningsFamily.Name, MachiningsFamily.Id, Nothing)
|
|
Dim MachiningFamilyItem = MachiningsList.FirstOrDefault(Function(MachiningFamily) MachiningFamily.MachiningType = FamilyTreeView.MachiningType)
|
|
If IsNothing(MachiningFamilyItem) Then
|
|
MachiningsList.Insert(MachiningsFamilyIndex, FamilyTreeView)
|
|
End If
|
|
Dim nType As Integer = 0
|
|
Dim MachiningName As String = String.Empty
|
|
Dim MachiningIndex As Integer = 0
|
|
EgtSetCurrentContext(MachiningDbWindowVM.m_ProjectSceneContext)
|
|
Dim bFound As Boolean = EgtMdbGetFirstMachining(MachiningsFamily.Id, MachiningName)
|
|
While bFound
|
|
Dim MachiningItem = MachiningsList(MachiningsFamilyIndex).Items.FirstOrDefault(Function(Machining) Machining.Name = MachiningName)
|
|
Dim bInList As Boolean = vsImportedMachinings.Contains(MachiningName)
|
|
If bInList Then
|
|
' Se una lavorazione è presente nella MachiningsList visualizzata ma nel contempo è nell'array vsImported
|
|
' vuol dire che è stata sovrascritta perciò la rimuovo
|
|
MachiningsList(MachiningsFamilyIndex).Items.Remove(MachiningsList(MachiningsFamilyIndex).Items.FirstOrDefault(Function(Machining) Machining.Name = MachiningName))
|
|
End If
|
|
If bInList OrElse IsNothing(MachiningItem) Then
|
|
' recupero tuuid
|
|
EgtMdbSetCurrMachining(MachiningName)
|
|
Dim sCurrMachTUUID As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sCurrMachTUUID)
|
|
' aggiungo la lavorazione importata
|
|
MachiningsList(MachiningsFamilyIndex).Items.Insert(MachiningIndex, New MachiningTreeViewItem(MachiningName, MachiningsFamily.Id, ToolDbUtility.IsToolInDb(sCurrMachTUUID), FamilyTreeView))
|
|
End If
|
|
MachiningIndex += 1
|
|
bFound = EgtMdbGetNextMachining(MachiningsFamily.Id, MachiningName)
|
|
End While
|
|
MachiningsFamilyIndex += 1
|
|
Next
|
|
End Sub
|
|
|
|
' Funzione che verifica modifica lavorazione selezionata ed eventualmente chiede se salvarla
|
|
Public Function VerifySelectedMachiningModification() As Boolean
|
|
' Se non c'è lavorazione selezionata, esco con continuazione
|
|
If IsNothing(SelMachining) Then Return True
|
|
' Se lavorazione selezionata non valida, esco con blocco
|
|
If Not SelMachining.IsValid Then Return False
|
|
' Verifico salvataggio
|
|
SelMachining.WriteMachiningParam()
|
|
If EgtMdbIsCurrMachiningModified() Or SelMachining.m_IsModifiedName Or SelMachining.NewMachining Then
|
|
Select Case MsgBox(EgtMsg(MSG_MACHININGDBERRORS + 1), MsgBoxStyle.YesNoCancel, EgtMsg(MSG_MACHININGDBERRORS + 2))
|
|
Case MsgBoxResult.Yes
|
|
SelMachining.NewMachining = False
|
|
SelMachining.m_Name = SelMachining.m_Name.Trim()
|
|
SelMachining.WriteMachiningName()
|
|
EgtMdbSaveCurrMachining()
|
|
Case MsgBoxResult.No
|
|
If SelMachining.NewMachining Then
|
|
RemoveMachining(SelMachining)
|
|
ElseIf SelMachining.m_IsModifiedName Then
|
|
Dim DbName As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.NAME, DbName)
|
|
SelMachining.NamePar = DbName
|
|
End If
|
|
Case MsgBoxResult.Cancel
|
|
Return False
|
|
End Select
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "NewCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new machining.
|
|
''' </summary>
|
|
Public ReadOnly Property NewCommand As ICommand
|
|
Get
|
|
If m_cmdNew Is Nothing Then
|
|
m_cmdNew = New Command(AddressOf NewPar)
|
|
End If
|
|
Return m_cmdNew
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new machining. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Overridable Sub NewPar(ByVal param As Object)
|
|
' Verifico se sia selezionata una famiglia
|
|
Dim NewMachiningItem As MachiningTreeViewItem
|
|
If TypeOf param Is FamilyMachiningTreeViewItem Then
|
|
Dim MachiningFamily As FamilyMachiningTreeViewItem = DirectCast(param, FamilyMachiningTreeViewItem)
|
|
Dim NewName As String = MachiningFamily.Name
|
|
EgtMdbGetMachiningNewName(NewName)
|
|
If EgtMdbAddMachining(NewName, MachiningFamily.MachiningType) Then
|
|
NewMachiningItem = New MachiningTreeViewItem(NewName, MachiningFamily.MachiningType, False, MachiningFamily)
|
|
MachiningFamily.Items.Add(NewMachiningItem)
|
|
EgtMdbSaveCurrMachining()
|
|
NewMachiningItem.NewMachining = True
|
|
If Not MachiningFamily.IsExpanded Then MachiningFamily.IsExpanded = True
|
|
NewMachiningItem.IsSelected = True
|
|
NewMachiningItem.NotifyPropertyChanged("IsSelected")
|
|
' Se il Materiale della nuova Lav. è Stone setto Lato Testa e Lato Lavoro a Destra di default
|
|
If NewMachiningItem.MatType = MaterialType.STONE Then
|
|
NewMachiningItem.SelectedHeadSide = IdNameStruct.IndFromId(MCH_SAW_HS.RIGHT, NewMachiningItem.HeadSideList)
|
|
NewMachiningItem.SelectedWorkSide = IdNameStruct.IndFromId(MCH_SAW_WS.RIGHT, NewMachiningItem.WorkSideList)
|
|
End If
|
|
End If
|
|
' Verifico se sia selezionata una lavorazione
|
|
ElseIf TypeOf param Is MachiningTreeViewItem Then
|
|
Dim MachiningCopied As MachiningTreeViewItem = DirectCast(param, MachiningTreeViewItem)
|
|
Dim NewName As String = MachiningCopied.Name
|
|
EgtMdbGetMachiningNewName(NewName)
|
|
If EgtMdbCopyMachining(MachiningCopied.Name, NewName) Then
|
|
Dim CurrType As Integer
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, CurrType)
|
|
For Each MachiningFamily In MachiningsList
|
|
If (MachiningFamily.MachiningType And CurrType) <> 0 Then
|
|
NewMachiningItem = New MachiningTreeViewItem(NewName, MachiningFamily.MachiningType, False, MachiningFamily)
|
|
MachiningFamily.Items.Add(NewMachiningItem)
|
|
EgtMdbSaveCurrMachining()
|
|
NewMachiningItem.NewMachining = True
|
|
' Reimposto la lavorazione vecchia nel Db per deselezionarla e fare le verifiche correttamente
|
|
EgtMdbSetCurrMachining(MachiningCopied.Name)
|
|
MachiningCopied.IsSelected = False
|
|
MachiningCopied.NotifyPropertyChanged("IsSelected")
|
|
NewMachiningItem.IsSelected = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region ' NewCommand
|
|
|
|
#Region "SaveCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that save the current selected machining.
|
|
''' </summary>
|
|
Public ReadOnly Property SaveCommand() As ICommand
|
|
Get
|
|
If m_cmdSave Is Nothing Then
|
|
m_cmdSave = New Command(AddressOf Save)
|
|
End If
|
|
Return m_cmdSave
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Saves the current machining. This method is invoked by the SaveCommand.
|
|
''' </summary>
|
|
Public Sub Save(ByVal param As Object)
|
|
Dim CurrMachining As MachiningTreeViewItem = DirectCast(param, MachiningTreeViewItem)
|
|
CurrMachining.WriteMachiningParam()
|
|
CurrMachining.m_Name = CurrMachining.m_Name.Trim()
|
|
CurrMachining.WriteMachiningName()
|
|
EgtMdbSaveCurrMachining()
|
|
CurrMachining.NewMachining = False
|
|
CurrMachining.IsModifiedReset()
|
|
IsEnabledBtns(CurrMachining.IsValid And Not CurrMachining.IsModified, CurrMachining.IsValid, True)
|
|
End Sub
|
|
|
|
#End Region ' SaveCommand
|
|
|
|
#Region "RemoveCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that remove the current selected machining.
|
|
''' </summary>
|
|
Public ReadOnly Property RemoveCommand() As ICommand
|
|
Get
|
|
If m_cmdRemove Is Nothing Then
|
|
m_cmdRemove = New Command(AddressOf Remove)
|
|
End If
|
|
Return m_cmdRemove
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Remove the current selected machining from Db and TreeView. This method is invoked by the RemoveCommand.
|
|
''' </summary>
|
|
Public Sub Remove(ByVal param As Object)
|
|
EgtSetCurrentContext(m_ProjectSceneContext)
|
|
Dim MachiningToRemove As MachiningTreeViewItem = DirectCast(param, MachiningTreeViewItem)
|
|
' Chiedo conferma cancellazione lavorazione
|
|
If MessageBox.Show(EgtMsg(MSG_MACHININGDBERRORS + 5) & " " & MachiningToRemove.Name & EgtMsg(MSG_MACHININGDBERRORS + 6), EgtMsg(MSG_MACHININGDBERRORS + 7), MessageBoxButton.YesNo, MessageBoxImage.Question) <> MessageBoxResult.Yes Then
|
|
Return
|
|
End If
|
|
RemoveMachining(MachiningToRemove)
|
|
End Sub
|
|
|
|
Public Sub RemoveMachining(MachiningToRemove As MachiningTreeViewItem)
|
|
' Salvo il tipo di lavorazione per poterla cancellare
|
|
Dim MachiningType As Integer = MachiningToRemove.Type
|
|
' Cancello la lavorazione
|
|
Dim CurrMachiningOriginalName As String = String.Empty
|
|
EgtMdbGetMachiningFromUUID(MachiningToRemove.Uuid, CurrMachiningOriginalName)
|
|
EgtMdbRemoveMachining(CurrMachiningOriginalName)
|
|
' Rimuovo il nome dall'albero
|
|
For Each MachiningFamily In MachiningsList
|
|
If (MachiningFamily.MachiningType And MachiningType) <> 0 Then
|
|
MachiningFamily.Items.Remove(MachiningToRemove)
|
|
End If
|
|
Next
|
|
ErrorOnMachining(False)
|
|
End Sub
|
|
|
|
#End Region ' RemoveCommand
|
|
|
|
#Region "ImportCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that remove the current selected machining.
|
|
''' </summary>
|
|
Public ReadOnly Property ImportCommand() As ICommand
|
|
Get
|
|
If m_cmdImport Is Nothing Then
|
|
m_cmdImport = New Command(AddressOf ImportMachining)
|
|
End If
|
|
Return m_cmdImport
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
|
|
''' </summary>
|
|
Public Sub ImportMachining(param As Object)
|
|
EgtSetCurrentContext(MachiningDbWindowVM.m_ProjectSceneContext)
|
|
' Se c'è lavorazione selezionata, ne verifico salvataggio
|
|
If Not VerifySelectedMachiningModification() Then Return
|
|
' apro dialogo di scelta file
|
|
Dim ImportFileDlg As New Microsoft.Win32.OpenFileDialog() With {
|
|
.Title = EgtMsg(31161) & " " & EgtMsg(31163),
|
|
.DefaultExt = ".data",
|
|
.Filter = "Machinings (.data)|*.data",
|
|
.CheckFileExists = True,
|
|
.ValidateNames = True
|
|
}
|
|
If ImportFileDlg.ShowDialog() <> True Then Return
|
|
Dim ImportFilePath As String = ImportFileDlg.FileName
|
|
' recupero liste lavorazioni da importare
|
|
Dim ImportFileMachiningNameList As String()
|
|
Dim ImportFileMachiningFamilyList As Integer()
|
|
EgtMdbToBeImported(ImportFilePath, ImportFileMachiningNameList, ImportFileMachiningFamilyList)
|
|
' li inserisco in lista per finestra di scelta
|
|
Dim MachiningToImportList As New ObservableCollection(Of ImpExpMachiningFamily)
|
|
' creo famiglie di lavorazioni in base a quelle trovate in lista importata
|
|
If Not IsNothing(ImportFileMachiningNameList) AndAlso Not IsNothing(ImportFileMachiningFamilyList) Then
|
|
For MachiningIndex As Integer = 0 To ImportFileMachiningNameList.Count - 1
|
|
Dim MachiningName As String = ImportFileMachiningNameList(MachiningIndex)
|
|
Dim MachiningFamily As Integer = ImportFileMachiningFamilyList(MachiningIndex)
|
|
MachiningFamily = MachiningFamily And
|
|
(MCH_MY.DRILLING Or
|
|
MCH_MY.DRILLING Or
|
|
MCH_MY.SAWING Or
|
|
MCH_MY.MILLING Or
|
|
MCH_MY.POCKETING Or
|
|
MCH_MY.MORTISING Or
|
|
MCH_MY.SAWROUGHING Or
|
|
MCH_MY.SAWFINISHING Or
|
|
MCH_MY.GENMACHINING Or
|
|
MCH_MY.CHISELING Or
|
|
MCH_MY.SURFROUGHING Or
|
|
MCH_MY.SURFFINISHING Or
|
|
MCH_MY.WATERJETTING)
|
|
Dim bFounded As Boolean = False
|
|
For Each MachiningToImportFamily In MachiningToImportList
|
|
If (MachiningFamily = MachiningToImportFamily.FamilyType) Then
|
|
MachiningToImportFamily.MachiningList.Add(New ImpExpMachiningItem(MachiningName, AlreadyExist(MachiningName)))
|
|
bFounded = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not bFounded Then
|
|
Dim NewFamily As New ImpExpMachiningFamily(GetMachiningFamilyName(MachiningFamily), MachiningFamily)
|
|
NewFamily.MachiningList.Add(New ImpExpMachiningItem(MachiningName, AlreadyExist(MachiningName)))
|
|
MachiningToImportList.Add(NewFamily)
|
|
End If
|
|
Next
|
|
End If
|
|
Dim ImportWndVM As New ImportExportMachiningWindowVM(MachiningToImportList, False, ImportFilePath, ImportFileMachiningNameList)
|
|
Dim ImportWnd As New ImportExportMachiningWindowV(Application.Current.MainWindow, ImportWndVM)
|
|
|
|
If ImportWnd.ShowDialog() Then
|
|
' Aggiungo all'albero visualizzato le lavorazioni appena importate
|
|
LoadImportedMachineMachinings(ImportWndVM.vsImported)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function AlreadyExist(MachiningName As String) As Boolean
|
|
For Each MachiningFamily In m_MachiningsList
|
|
For Each MachiningItem As MachiningTreeViewItem In MachiningFamily.Items
|
|
If MachiningName = MachiningItem.Name Then
|
|
Return True
|
|
End If
|
|
Next
|
|
Next
|
|
Return False
|
|
End Function
|
|
|
|
Private Function GetMachiningFamilyName(NewMachiningFamily As Integer) As String
|
|
For Each MachiningFamily In m_MachiningsList
|
|
If NewMachiningFamily = MachiningFamily.MachiningType Then
|
|
Return MachiningFamily.Name
|
|
End If
|
|
Next
|
|
Return ""
|
|
End Function
|
|
|
|
#End Region ' ImportCommand
|
|
|
|
#Region "ExportCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that remove the current selected machining.
|
|
''' </summary>
|
|
Public ReadOnly Property ExportCommand() As ICommand
|
|
Get
|
|
If m_cmdExport Is Nothing Then
|
|
m_cmdExport = New Command(AddressOf ExportMachining)
|
|
End If
|
|
Return m_cmdExport
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
|
|
''' </summary>
|
|
Public Sub ExportMachining(param As Object)
|
|
EgtSetCurrentContext(MachiningDbWindowVM.m_ProjectSceneContext)
|
|
' Se c'è lavorazione selezionata, ne verifico salvataggio
|
|
If Not VerifySelectedMachiningModification() Then Return
|
|
' creo lista lavorazioni per esportazione
|
|
Dim MachiningToExportList As New ObservableCollection(Of ImpExpMachiningFamily)
|
|
For Each Family In m_MachiningsList
|
|
Dim ImpExpMachiningFamily As New ImpExpMachiningFamily(Family.Name, Family.MachiningType)
|
|
For Each Machining In Family.Items
|
|
ImpExpMachiningFamily.MachiningList.Add(New ImpExpMachiningItem(Machining.Name, False))
|
|
Next
|
|
MachiningToExportList.Add(ImpExpMachiningFamily)
|
|
Next
|
|
Dim ExportWndVM As New ImportExportMachiningWindowVM(MachiningToExportList, True)
|
|
Dim ExportWnd As New ImportExportMachiningWindowV(Application.Current.MainWindow, ExportWndVM)
|
|
|
|
ExportWnd.ShowDialog()
|
|
|
|
End Sub
|
|
|
|
#End Region ' ExportCommand
|
|
|
|
#Region "ReloadMachiningCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that reload the current selected tool.
|
|
''' </summary>
|
|
Public ReadOnly Property ReloadMachiningCommand() As ICommand
|
|
Get
|
|
If m_cmdReloadMachining Is Nothing Then
|
|
m_cmdReloadMachining = New Command(AddressOf ReloadMachining)
|
|
End If
|
|
Return m_cmdReloadMachining
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Reload the current selected tools. This method is invoked by the RemoveCommand.
|
|
''' </summary>
|
|
Public Sub ReloadMachining(ByVal param As Object)
|
|
If TypeOf param Is FamilyMachiningTreeViewItem Then
|
|
Return
|
|
' Verifico se sia selezionata una lavorazione
|
|
ElseIf TypeOf param Is MachiningTreeViewItem Then
|
|
Dim MachiningToReload As MachiningTreeViewItem = DirectCast(param, MachiningTreeViewItem)
|
|
EgtSetCurrentContext(m_ProjectSceneContext)
|
|
MachiningToReload.ReadMachiningParam()
|
|
MachiningToReload.ReadMachiningName()
|
|
MachiningToReload.IsModifiedReset()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' ReloadMachiningCommand
|
|
|
|
#Region "CloseMachiningsDbCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that remove the current selected machining.
|
|
''' </summary>
|
|
Public ReadOnly Property CloseMachiningsDbCommand() As ICommand
|
|
Get
|
|
If m_cmdCloseMachiningsDb Is Nothing Then
|
|
m_cmdCloseMachiningsDb = New Command(AddressOf CloseMachiningsDb)
|
|
End If
|
|
Return m_cmdCloseMachiningsDb
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
|
|
''' </summary>
|
|
Public Sub CloseMachiningsDb(param As Object)
|
|
If (Keyboard.Modifiers And ModifierKeys.Alt) = ModifierKeys.Alt OrElse Keyboard.IsKeyDown(Key.F4) Then
|
|
Return
|
|
End If
|
|
m_bActive = False
|
|
' Se selezionata una lavorazione, verifico salvataggio
|
|
If TypeOf param Is MachiningTreeViewItem Then
|
|
Dim CurrMachining As MachiningTreeViewItem = DirectCast(param, MachiningTreeViewItem)
|
|
If CurrMachining.IsValid Then
|
|
CurrMachining.WriteMachiningParam()
|
|
If EgtMdbIsCurrMachiningModified() Or CurrMachining.m_IsModifiedName Or CurrMachining.NewMachining Then
|
|
Select Case MsgBox(EgtMsg(MSG_MACHININGDBERRORS + 1), MsgBoxStyle.YesNo, EgtMsg(MSG_MACHININGDBERRORS + 2))
|
|
Case MsgBoxResult.Yes
|
|
CurrMachining.NewMachining = False
|
|
CurrMachining.m_Name = CurrMachining.m_Name.Trim()
|
|
CurrMachining.WriteMachiningName()
|
|
EgtMdbSaveCurrMachining()
|
|
Case MsgBoxResult.No
|
|
If CurrMachining.NewMachining Then
|
|
RemoveMachining(CurrMachining)
|
|
ElseIf CurrMachining.m_IsModifiedName Then
|
|
Dim DbName As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.NAME, DbName)
|
|
CurrMachining.NamePar = DbName
|
|
End If
|
|
End Select
|
|
End If
|
|
Else
|
|
'Lavorazione non valida, correggerla o cancellarla prima di uscire. - Errore
|
|
MessageBox.Show( EgtMsg( 31410), EgtMsg( 31126))
|
|
Return
|
|
End If
|
|
End If
|
|
' Salvataggio DB lavorazioni
|
|
EgtMdbSave()
|
|
'' ''Application.Msn.NotifyColleagues(Application.UPDATEOPERATIONMACHININGLIST) ??? DA SISTEMARE PER EGTCAM5
|
|
' Verifico se ci sono lavorazioni senza utensile o con utensile cancellato
|
|
|
|
' Chiusura finestra
|
|
MachiningTreeViewItem.m_delRemoveMachining = Nothing
|
|
MachiningTreeViewItem.m_delErrorOnMachining = Nothing
|
|
MachiningTreeViewItem.m_delIsEnabledBtns = Nothing
|
|
FamilyMachiningTreeViewItem.m_delIsEnabledBtns = Nothing
|
|
RaiseEvent m_CloseWindow(True)
|
|
End Sub
|
|
|
|
#End Region ' CloseMachiningDbCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class |