Files
Emmanuele Sassi 125e7346d4 EgtCAM5 2.7b1 :
- Modifiche ad MTable
2025-02-06 10:42:23 +01:00

1302 lines
48 KiB
VB.net

Imports System.ComponentModel
Imports System.Collections.ObjectModel
Imports System.Text.RegularExpressions
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Imports EgtCAM5.MachineModel
Imports System.Collections.Specialized
Public Class MTableListBoxItem
Inherits VMBase
' Actions
Friend Shared m_delSaveMTable As Action(Of MTableListBoxItem)
Friend Shared m_delCloseMTableWnd As Action
Friend Shared m_delSearchInMTable As Action(Of MTableListBoxItem)
' Parametro che indica se sono state apportate modifiche alla tabella lavorazioni ordinata tramite i comandi sposta, posiziona o ordina
Friend m_IsMachiningOrdModified As Boolean = False
Private m_Visibility As Visibility
Public Property Visibility As Visibility
Get
Return m_Visibility
End Get
Set(value As Visibility)
m_Visibility = value
NotifyPropertyChanged("Visibility")
End Set
End Property
Private m_IsSelected As Boolean
Public Property IsSelected As Boolean
Get
Return m_IsSelected
End Get
Set(value As Boolean)
If value <> m_IsSelected Then
m_IsSelected = value
If value Then
' verifico di essere collegato alla cartella doors
If Not VerifyDoorsDir() Then
m_delCloseMTableWnd()
Return
End If
' '' resetto liste lavorazioni
''MTableAssociationGridBoxItem.ResetMachiningList()
' resetto stato bottoni di modifica della tabella delle lavorazioni ordinate (posiziona, raggruppa, sposta su e giù)
m_IsMachiningOrdModified = False
' leggo la tabella
If Not ReadMTableFile() Then
m_IsSelected = False
Return
End If
SelectedAssociation = If(m_AssociationList.Count > 0, m_AssociationList(0), Nothing)
SelMachine = m_ActiveMachinesList(0)
m_delSearchInMTable(Me)
ElseIf IsModified() OrElse String.IsNullOrEmpty(m_TableNamePath) Then
' chiedo se salvare la tabella corrente prima di passare alla successiva
If MessageBox.Show(EgtMsg(MSG_DOORS + 7), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then
m_delSaveMTable(Me)
ElseIf String.IsNullOrEmpty(m_TableNamePath) Then
Visibility = Windows.Visibility.Collapsed
End If
End If
NotifyPropertyChanged("IsSelected")
End If
End Set
End Property
Friend SharedMachIndex As Integer = 0
Friend Shared NewMTableIndex As Integer = 0
Friend m_TableNamePath As String
Public ReadOnly Property TableNamePath As String
Get
Return m_TableNamePath
End Get
End Property
Private m_TableName As String
Public Property TableName As String
Get
Return m_TableName
End Get
Set(value As String)
m_TableName = value
End Set
End Property
Private m_ActiveTable As Boolean
Public Property ActiveTable As Boolean
Get
Return m_ActiveTable
End Get
Set(value As Boolean)
If value <> m_ActiveTable Then
m_ActiveTable = value
NotifyPropertyChanged("StateColor")
End If
m_ActiveTable = value
End Set
End Property
Public ReadOnly Property StateColor As Brush
Get
If ActiveTable Then
Return IniFile.EgaltechBlue1
Else
Return Brushes.Transparent
End If
End Get
End Property
Private m_ActiveMachinesList As New ObservableCollection(Of MTableMachineListBoxItem)
Public Property ActiveMachinesList As ObservableCollection(Of MTableMachineListBoxItem)
Get
Return m_ActiveMachinesList
End Get
Set(value As ObservableCollection(Of MTableMachineListBoxItem))
m_ActiveMachinesList = value
End Set
End Property
Private m_SelMachine As MTableMachineListBoxItem
Public Property SelMachine As MTableMachineListBoxItem
Get
Return m_SelMachine
End Get
Set(value As MTableMachineListBoxItem)
If Not IsNothing(value) Then
m_SelMachine = value
End If
NotifyPropertyChanged("SelMachine")
End Set
End Property
Private m_AssociationList As New ObservableCollection(Of MTableAssociationGridBoxItem)
Public Property AssociationList As ObservableCollection(Of MTableAssociationGridBoxItem)
Get
Return m_AssociationList
End Get
Set(value As ObservableCollection(Of MTableAssociationGridBoxItem))
m_AssociationList = value
End Set
End Property
Private m_SelectedAssociation As MTableAssociationGridBoxItem
Public Property SelectedAssociation As MTableAssociationGridBoxItem
Get
Return m_SelectedAssociations(0)
End Get
Set(value As MTableAssociationGridBoxItem)
Dim bFound As Boolean = False
For ItemIndex = m_SelectedAssociations.Count - 1 To 0 Step -1
If m_SelectedAssociations(ItemIndex) Is value Then
bFound = True
Else
m_SelectedAssociations.RemoveAt(ItemIndex)
End If
If Not bFound Then
m_SelectedAssociations.Add(value)
End If
Next
End Set
End Property
Private m_SelectedAssociations As New ObservableCollection(Of MTableAssociationGridBoxItem)
Public Property SelectedAssociations As ObservableCollection(Of MTableAssociationGridBoxItem)
Get
Return m_SelectedAssociations
End Get
Set(value As ObservableCollection(Of MTableAssociationGridBoxItem))
m_SelectedAssociations = value
End Set
End Property
' Lista dei MachId per ComboBox nella DataGrid
Friend m_MachIdList As New ObservableCollection(Of Integer)
Public Property MachIdList As ObservableCollection(Of Integer)
Get
Return m_MachIdList
End Get
Set(value As ObservableCollection(Of Integer))
m_MachIdList = value
End Set
End Property
Sub New(sTableName As String, sTableNamePath As String)
TableName = sTableName
m_TableNamePath = sTableNamePath
AddHandler m_SelectedAssociations.CollectionChanged, AddressOf SelectedAssociations_CollectionChanged
End Sub
Private Sub SelectedAssociations_CollectionChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
End Sub
Private Function ReadMTableFile() As Boolean
If String.IsNullOrEmpty(m_TableNamePath) Then
SharedMachIndex += 1
ActiveMachinesList.Add(New MTableMachineListBoxItem(String.Empty, False, False, SharedMachIndex))
m_MachIdList.Add(SharedMachIndex)
AssociationList.Add(New MTableAssociationGridBoxItem(False, String.Empty, Nothing, 0, String.Empty, Nothing, String.Empty, Nothing, String.Empty, Nothing, String.Empty, 0, ActiveMachinesList, m_AssociationList))
Return True
End If
' resetto indici macchine impostati in tabella
SharedMachIndex = 0
m_MachIdList.Clear()
' resetto lista macchine ed associazioni prima di rileggerle
m_ActiveMachinesList.Clear()
m_AssociationList.Clear()
' verifico che siano disponibili le macchine
If Not EgtVerifyMachinesDir() Then
m_delCloseMTableWnd()
Return False
End If
Return ReadDoorsTable(Me)
End Function
Public Function IsModified() As Boolean
Dim CurrIsModified As Boolean = False
' verifico se ci sono stati cambiamenti nell'ordine delle lavorazioni
If m_IsMachiningOrdModified Then Return True
' verifico se ci sono state modifiche nella lista macchine
For Index As Integer = 0 To m_ActiveMachinesList.Count - 1
If m_ActiveMachinesList(Index).m_IsModified = True Then
Return True
End If
Next
' verifico se ci sono state modifiche nella lista associazioni
For Index = 0 To m_AssociationList.Count - 1
If m_AssociationList(Index).m_IsModified = True Then
Return True
End If
Next
' verifico se ci sono state modifiche nella lista lavorazioni ordinate
For MachineIndex As Integer = 0 To m_ActiveMachinesList.Count - 1
For MachiningIndex = 0 To m_ActiveMachinesList(MachineIndex).MachiningList.Count - 1
If m_ActiveMachinesList(MachineIndex).MachiningList(MachiningIndex).m_IsModified = True Then
Return True
End If
Next
Next
Return False
End Function
Public Sub IsModifiedReset()
m_IsMachiningOrdModified = False
For Index As Integer = 0 To m_ActiveMachinesList.Count - 1
m_ActiveMachinesList(Index).m_IsModified = False
Next
For Index = 0 To m_AssociationList.Count - 1
m_AssociationList(Index).m_IsModified = False
Next
For MachineIndex As Integer = 0 To m_ActiveMachinesList.Count - 1
For MachiningIndex = 0 To m_ActiveMachinesList(MachineIndex).MachiningList.Count - 1
m_ActiveMachinesList(MachineIndex).MachiningList(MachiningIndex).m_IsModified = False
Next
Next
End Sub
End Class
Public Class MTableMachineListBoxItem
Inherits VMBase
' Actions
Friend Shared m_delCloseMTableWnd As Action
' Variabile che indica se questo oggetto è stato modificato
Friend m_IsModified As Boolean = False
' Indice della macchina
Private m_MachId As Integer
Public Property MachId As Integer
Get
Return m_MachId
End Get
Set(value As Integer)
m_MachId = value
End Set
End Property
' Lista di macchine per la ComboBox
Private Shared m_MachinesList As New List(Of MTableMachine)
Public Shared Property MachinesList As List(Of MTableMachine)
Get
Return m_MachinesList
End Get
Set(value As List(Of MTableMachine))
m_MachinesList = value
End Set
End Property
' Macchina selezionata
Private m_SelectedMachine As MTableMachine
Public Property SelectedMachine As MTableMachine
Get
Return m_SelectedMachine
End Get
Set(value As MTableMachine)
m_IsModified = True
m_SelectedMachine = value
If Not m_SelectedMachine.IsLoaded Then m_SelectedMachine.LoadMachining()
End Set
End Property
Private m_NcGenerate As Boolean
Public Property NcGenerate As Boolean
Get
Return m_NcGenerate
End Get
Set(value As Boolean)
m_IsModified = True
m_NcGenerate = value
End Set
End Property
Private m_Makeraw As Boolean
Public Property Makeraw As Boolean
Get
Return m_Makeraw
End Get
Set(value As Boolean)
m_IsModified = True
m_Makeraw = value
End Set
End Property
Private WithEvents m_MachiningList As New ObservableCollection(Of MTableMachiningGridBoxItem)
Public Property MachiningList As ObservableCollection(Of MTableMachiningGridBoxItem)
Get
Return m_MachiningList
End Get
Set(value As ObservableCollection(Of MTableMachiningGridBoxItem))
m_MachiningList = value
End Set
End Property
Sub New(sMachName As String, bNcGenerate As Boolean, bMakeraw As Boolean, nMachId As Integer)
If m_MachinesList.Count = 0 Then
If Not SearchMachine() Then MessageBox.Show("Error: Can't find machines dir!")
End If
If Not String.IsNullOrWhiteSpace(sMachName) Then
For Index = 0 To m_MachinesList.Count - 1
If m_MachinesList(Index).Name = sMachName Then
SelectedMachine = m_MachinesList(Index)
End If
Next
End If
NcGenerate = bNcGenerate
Makeraw = bMakeraw
MachId = nMachId
m_IsModified = False
End Sub
' Funzione che cerca tutte le macchine disponibili per aggiungerle alla lista della ComboBox
Private Function SearchMachine() As Boolean
' aggiungo elemento stringa vuota per dare la possibilità di non selezionarne nessuna macchina
m_MachinesList = New List(Of MTableMachine)
m_MachinesList.Add(New MTableMachine())
' verifico l'esistenza della cartella Machines
If Not EgtVerifyMachinesDir() Then
m_delCloseMTableWnd()
Return False
End If
Dim TempList As New List(Of Machine)
Machine.MachineListInit(IniFile.m_sMachinesRoot, TempList)
For Each Machine In TempList
m_MachinesList.Add(New MTableMachine(Machine.DirPath, Machine.IniPath))
Next
' aggiungo tutte le macchine
'Dim TempArray As String() = Directory.GetDirectories(IniFile.m_sMachinesRoot)
'For i As Integer = 0 To TempArray.Count - 1
' Dim MachinePathIni As String = TempArray(i) & "\" & Path.GetFileName(TempArray(i)) & ".ini"
' If File.Exists(MachinePathIni) Then
' MachinesList.Add(Path.GetFileName(TempArray(i)))
' End If
'Next
Return True
End Function
' Quando la lista viene modificata, verifico che ci sia almeno un elemento con indice deiverso da zero
Private Sub MachiningList_CollectionChanged(sender As Object, e As Collections.Specialized.NotifyCollectionChangedEventArgs) Handles m_MachiningList.CollectionChanged
If e.Action = Specialized.NotifyCollectionChangedAction.Remove Or e.Action = Specialized.NotifyCollectionChangedAction.Reset Then
If MachiningList.Count > 0 AndAlso m_MachiningList(m_MachiningList.Count - 1).GroupId = 0 Then
m_MachiningList(m_MachiningList.Count - 1).GroupId = 1
End If
End If
End Sub
End Class
Public Class MTableMachine
Inherits Machine
' Variabile che indica se tipi e lavorazioni sono già stati caricati
Private m_IsLoaded As Boolean = False
Friend ReadOnly Property IsLoaded As Boolean
Get
Return m_IsLoaded
End Get
End Property
Friend Sub ResetIsLoaded()
m_IsLoaded = False
End Sub
' Lista tipi di lavorazione
Private m_MachTypeList As New List(Of MachineModel.MachiningsType)
Friend ReadOnly Property MachTypeList As List(Of MachineModel.MachiningsType)
Get
Return m_MachTypeList
End Get
End Property
' Liste per le lavorazioni
Private m_DrillingList As New List(Of String)
Private m_SawingList As New List(Of String)
Private m_MillingList As New List(Of String)
Private m_PocketingList As New List(Of String)
Private m_MortisingList As New List(Of String)
Private m_SawRoughingList As New List(Of String)
Private m_SawFinishingList As New List(Of String)
Private m_ChiselingList As New List(Of String)
Sub New(sDirPath As String, sIniPath As String)
MyBase.New(sDirPath, sIniPath)
If Not EgtTrySettingCurrMachine(Me.Name) Then
'm_delCloseMTableWnd()
End If
End Sub
Sub New()
MyBase.New("", "")
End Sub
Friend Sub LoadMachining()
m_MachTypeList = New List(Of MachineModel.MachiningsType)(MachineModel.ReadMachiningsFamilies(Me.IniPath))
' imposto questa macchina come corrente
EgtSetCurrMachine(Me.Name)
' carico liste lavorazioni
LoadMachiningListByType(m_DrillingList, MCH_MY.DRILLING)
LoadMachiningListByType(m_SawingList, MCH_MY.SAWING)
LoadMachiningListByType(m_MillingList, MCH_MY.MILLING)
LoadMachiningListByType(m_PocketingList, MCH_MY.POCKETING)
LoadMachiningListByType(m_MortisingList, MCH_MY.MORTISING)
LoadMachiningListByType(m_SawRoughingList, MCH_MY.SAWROUGHING)
LoadMachiningListByType(m_SawFinishingList, MCH_MY.SAWFINISHING)
LoadMachiningListByType(m_ChiselingList, MCH_MY.CHISELING)
' aggiungo elementi vuoti per poter non impostare alcuna lavorazione
m_DrillingList.Insert(0, String.Empty)
m_SawingList.Insert(0, String.Empty)
m_MillingList.Insert(0, String.Empty)
m_PocketingList.Insert(0, String.Empty)
m_MortisingList.Insert(0, String.Empty)
m_SawRoughingList.Insert(0, String.Empty)
m_SawFinishingList.Insert(0, String.Empty)
m_ChiselingList.Insert(0, String.Empty)
m_IsLoaded = True
End Sub
Friend Function MachiningListByType(MachiningType As MachineModel.MachiningsType) As List(Of String)
Select Case MachiningType.TypeId
Case MCH_MY.DRILLING
Return m_DrillingList
Case MCH_MY.SAWING
Return m_SawingList
Case MCH_MY.MILLING
Return m_MillingList
Case MCH_MY.POCKETING
Return m_PocketingList
Case MCH_MY.MORTISING
Return m_MortisingList
Case MCH_MY.SAWROUGHING
Return m_SawRoughingList
Case MCH_MY.SAWFINISHING
Return m_SawFinishingList
Case MCH_MY.CHISELING
Return m_ChiselingList
Case Else
Return Nothing
End Select
End Function
End Class
Public Class MTableMachiningGridBoxItem
Inherits VMBase
Private m_refMTableMachine As MTableMachineListBoxItem
' Variabile che indica se questo oggetto è stato modificato
Friend m_IsModified As Boolean = False
Private m_RWGroupId As Integer
Public Property RWGroupId As Integer
Get
Return m_RWGroupId
End Get
Set(value As Integer)
m_RWGroupId = value
End Set
End Property
Private m_GroupId As Integer
Public Property GroupId As Integer
Get
Return m_GroupId
End Get
Set(value As Integer)
m_GroupId = value
NotifyPropertyChanged("GroupId")
NotifyPropertyChanged("IsGroupEven")
End Set
End Property
Private m_IsSelected As Boolean
Public Property IsSelected As Boolean
Get
Return m_IsSelected
End Get
Set(value As Boolean)
If value <> m_IsSelected Then
m_IsSelected = value
End If
NotifyPropertyChanged("IsSelected")
End Set
End Property
Private m_IsGroupEven As Boolean
Public ReadOnly Property IsGroupEven As Boolean
Get
Return m_GroupId Mod 2 = 0
End Get
End Property
Private Shared m_PropertyList As ObservableCollection(Of String)
Public ReadOnly Property PropertyList As ObservableCollection(Of String)
Get
Return m_PropertyList
End Get
End Property
Private m_Property As String
Public Property grh_PropertyPar As String
Get
Return m_Property
End Get
Set(value As String)
m_IsModified = True
m_Property = value
' lo modifico anche a tutti gli altri elementi del gruppo
Dim PositionIndex As Integer = m_refMTableMachine.MachiningList.IndexOf(Me)
For MachiningIndex = PositionIndex To m_refMTableMachine.MachiningList.Count - 1
If m_refMTableMachine.MachiningList(MachiningIndex).GroupId = GroupId Then
m_refMTableMachine.MachiningList(MachiningIndex).SetProperty(m_Property)
Else
Exit For
End If
Next
End Set
End Property
Public Property PropertyPar As String
Get
Return m_Property
End Get
Set(value As String)
m_Property = value
' lo modifico anche a tutti gli altri elementi del gruppo
Dim PositionIndex As Integer = m_refMTableMachine.MachiningList.IndexOf(Me)
For MachiningIndex = PositionIndex To m_refMTableMachine.MachiningList.Count - 1
If m_refMTableMachine.MachiningList(MachiningIndex).GroupId = GroupId Then
m_refMTableMachine.MachiningList(MachiningIndex).SetProperty(m_Property)
Else
Exit For
End If
Next
End Set
End Property
Friend Sub SetProperty(value As String)
m_Property = value
NotifyPropertyChanged("PropertyPar")
End Sub
Private m_Geometry As String
Public Property Geometry As String
Get
Return m_Geometry
End Get
Set(value As String)
m_Geometry = value
NotifyPropertyChanged("Geometry")
End Set
End Property
Private m_Machining As String
Public Property Machining As String
Get
Return m_Machining
End Get
Set(value As String)
m_Machining = value
NotifyPropertyChanged("Machining")
End Set
End Property
'Public ReadOnly Property Tool As String
' Get
' Return
' End Get
'End Property
Private m_Join As Boolean
Public Property grh_Join As Boolean
Get
Return m_Join
End Get
Set(value As Boolean)
If value <> m_Join Then
m_IsModified = True
m_Join = value
NotifyPropertyChanged("grh_Join")
End If
End Set
End Property
Public Property Join As Boolean
Get
Return m_Join
End Get
Set(value As Boolean)
If value <> m_Join Then
m_Join = value
End If
End Set
End Property
' Variabile che indica se il nome dell'associazione corrisponde ai criteri di ricerca
Private m_IsValidForSearch As Boolean
Public Property IsValidForSearch As Boolean
Get
Return m_IsValidForSearch
End Get
Set(value As Boolean)
m_IsValidForSearch = value
NotifyPropertyChanged("IsValidForSearch")
End Set
End Property
Sub New(dGroup As Integer, sGeometry As String, sMachining As String, bJoin As Boolean, ByRef refMTableMachine As MTableMachineListBoxItem)
m_RWGroupId = dGroup
m_GroupId = dGroup \ 100
m_Geometry = sGeometry
m_Machining = sMachining
m_Join = bJoin
m_refMTableMachine = refMTableMachine
End Sub
Friend Shared Sub LoadPropertyList()
Dim TempOperList As New List(Of String)
' aggiungo elemento stringa vuota per dare la possibilità di non selezionarne nessuna proprietà
TempOperList.Add(String.Empty)
' aggiungo tutte le altre
Dim OperationFilePath As String = IniFile.m_sTablesRoot & "/" & OPERATIONLIST_FILE
Dim Index As Integer = 1
Dim sRaedOperation As String = String.Empty
While EgtUILib.GetPrivateProfileString(S_PROPERTIES, Index.ToString, "", sRaedOperation, OperationFilePath) > 0
TempOperList.Add(sRaedOperation)
Index += 1
End While
'TempOperList.Sort()
m_PropertyList = New ObservableCollection(Of String)(TempOperList)
End Sub
Public Shared Sub Remove(Item As MTableMachiningGridBoxItem, MachiningList As ObservableCollection(Of MTableMachiningGridBoxItem))
' recupero indice dell'Item all'interno della lista
Dim ItemIndex As Integer = MachiningList.IndexOf(Item)
If ItemIndex < 0 Then Return
Dim bIncrementFollowingGroup As Boolean = False
If MachiningList.Count = 1 OrElse MachiningList(ItemIndex).GroupId = 0 Then
bIncrementFollowingGroup = False
ElseIf ItemIndex = 0 Then
If MachiningList(ItemIndex + 1).m_GroupId <> Item.m_GroupId Then
bIncrementFollowingGroup = True
End If
ElseIf ItemIndex = MachiningList.Count - 1 AndAlso MachiningList(ItemIndex - 1).m_GroupId <> Item.m_GroupId Then
bIncrementFollowingGroup = True
ElseIf (MachiningList(ItemIndex - 1).m_GroupId <> Item.m_GroupId AndAlso MachiningList(ItemIndex + 1).m_GroupId <> Item.m_GroupId) Then
bIncrementFollowingGroup = True
End If
MachiningList.Remove(Item)
If bIncrementFollowingGroup Then
For ListIndex = ItemIndex To MachiningList.Count - 1
MachiningList(ListIndex).GroupId -= 1
Next
End If
End Sub
Public Shared Function Copy(Machining As MTableMachiningGridBoxItem) As MTableMachiningGridBoxItem
Return New MTableMachiningGridBoxItem(Machining.m_GroupId, Machining.m_Geometry, Machining.m_Machining, Machining.m_Join, Machining.m_refMTableMachine)
End Function
End Class
Public Class MTableAssociationGridBoxItem
Inherits VMBase
' Actions
Friend Shared m_delCloseMTableWnd As Action
' Variabile che indica se questo oggetto è stato modificato
Friend m_IsModified As Boolean = False
' Variabile che indica se il nome dell'associazione corrisponde ai criteri di ricerca
Private m_IsValidForSearch As Boolean
Public Property IsValidForSearch As Boolean
Get
Return m_IsValidForSearch
End Get
Set(value As Boolean)
m_IsValidForSearch = value
NotifyPropertyChanged("IsValidForSearch")
End Set
End Property
Private m_IsSelected As Boolean
Public Property IsSelected As Boolean
Get
Return m_IsSelected
End Get
Set(value As Boolean)
If value <> m_IsSelected Then
m_IsSelected = value
MTableDbVM.refMTableDbVM.ManageMachiningButtons(True, False, False, True)
NotifyPropertyChanged("IsSelected")
End If
End Set
End Property
' Riferimento alla lista di macchine attive per la tabella a cui appartiene questa associazione
Private m_ActiveMachinesList As ObservableCollection(Of MTableMachineListBoxItem)
' Riferimento alla lista di associazioni attive per la tabella a cui appartiene questa associazione
Private m_AssociationList As ObservableCollection(Of MTableAssociationGridBoxItem)
Private m_OnPar As Boolean
Public Property OnPar As Boolean
Get
Return m_OnPar
End Get
Set(value As Boolean)
m_IsModified = True
m_OnPar = value
End Set
End Property
Private Shared m_NamesList As ObservableCollection(Of String)
Public Property NamesList As ObservableCollection(Of String)
Get
Return m_NamesList
End Get
Set(value As ObservableCollection(Of String))
If value IsNot m_NamesList Then
m_NamesList = value
End If
End Set
End Property
Private m_Name As String
Public Property Name As String
Get
Return m_Name
End Get
Set(value As String)
If m_NamesList.Contains(value) Then
m_IsModified = True
m_Name = value
Else
m_Name = String.Empty
End If
' Aggiorno Item in lista ordinata lavorazioni
If Not IsNothing(m_RefMachItem) Then
m_RefMachItem.Geometry = m_Name
End If
If Not IsNothing(m_RefMachUpItem) Then
m_RefMachUpItem.Geometry = m_Name
End If
If Not IsNothing(m_RefMachDwItem) Then
m_RefMachDwItem.Geometry = m_Name
End If
End Set
End Property
Private Shared m_OperationsList As ObservableCollection(Of String)
Public Property OperationsList As ObservableCollection(Of String)
Get
Return m_OperationsList
End Get
Set(value As ObservableCollection(Of String))
m_OperationsList = value
End Set
End Property
Private m_Oper As String
Public Property Oper As String
Get
Return m_Oper
End Get
Set(value As String)
m_IsModified = True
m_Oper = value
End Set
End Property
Private m_MachId As Integer
Public Property MachId As Integer
Get
Return m_MachId
End Get
Set(value As Integer)
If value <> m_MachId Then
m_IsModified = True
Dim nOldMachId As Integer = m_MachId
m_MachId = value
' Verifico se macchina selezionata attivabile
If Not IsNothing(m_ActiveMachinesList(value - 1).SelectedMachine) AndAlso
Not EgtTrySettingCurrMachine(m_ActiveMachinesList(value - 1).SelectedMachine.Name) Then
m_delCloseMTableWnd()
Return
End If
' Aggiorno lista tipi di lavorazione
NotifyPropertyChanged("MachTypeList")
' Verifico se tipo selezionato e lavorazione sono ancora validi
If Not IsNothing(m_SelectedMachType) AndAlso Not IsNothing(MachTypeList.Find(Function(f) f.TypeId = m_SelectedMachType.TypeId)) Then
m_MachList = New ObservableCollection(Of String)(m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachiningListByType(m_SelectedMachType))
NotifyPropertyChanged("MachList")
If Not IsNothing(m_Mach) AndAlso Not m_MachList.Contains(m_Mach) Then
m_Mach = Nothing
End If
Else
SelectedMachType = Nothing
End If
If Not IsNothing(m_SelectedMachUpType) AndAlso Not IsNothing(MachTypeList.Find(Function(f) f.TypeId = m_SelectedMachUpType.TypeId)) Then
m_MachUpList = New ObservableCollection(Of String)(m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachiningListByType(m_SelectedMachUpType))
NotifyPropertyChanged("MachUpList")
If Not IsNothing(m_MachUp) AndAlso Not m_MachList.Contains(m_MachUp) Then
m_MachUp = Nothing
End If
Else
SelectedMachUpType = Nothing
End If
If Not IsNothing(m_SelectedMachDownType) AndAlso Not IsNothing(MachTypeList.Find(Function(f) f.TypeId = m_SelectedMachDownType.TypeId)) Then
m_MachDownList = New ObservableCollection(Of String)(m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachiningListByType(m_SelectedMachDownType))
NotifyPropertyChanged("MachDownList")
If Not IsNothing(m_MachDw) AndAlso Not m_MachList.Contains(m_MachDw) Then
m_MachDw = Nothing
End If
Else
SelectedMachDownType = Nothing
End If
' Verifico se i nomi già presenti per Mach, MachUp e MachDw sono validi per la nuova macchina
If Not IsNothing(m_SelectedMachType) Then
m_RefMachItem = ManageOrderedMachining(Mach, nOldMachId, RefMachItem)
If String.IsNullOrWhiteSpace(m_Mach) Then NotifyPropertyChanged("Mach")
End If
If Not IsNothing(m_SelectedMachUpType) Then
m_RefMachUpItem = ManageOrderedMachining(MachUp, nOldMachId, RefMachUpItem)
If String.IsNullOrWhiteSpace(m_MachUp) Then NotifyPropertyChanged("MachUp")
End If
If Not IsNothing(m_SelectedMachDownType) Then
m_RefMachDwItem = ManageOrderedMachining(MachDw, nOldMachId, RefMachDwItem)
If String.IsNullOrWhiteSpace(m_MachDw) Then NotifyPropertyChanged("MachDw")
End If
End If
End Set
End Property
Private Function ManageOrderedMachining(ByRef Mach As String, nOldMachId As Integer, ByRef CurrRefMachItem As MTableMachiningGridBoxItem) As MTableMachiningGridBoxItem
If Not String.IsNullOrEmpty(Mach) Then
' se non usata da altre lavorazioni sulla stessa macchina
Dim bFound As Boolean = False
For AssIndex = 0 To m_AssociationList.Count - 1
If m_AssociationList(AssIndex) IsNot Me And m_AssociationList(AssIndex).RefMachItem Is CurrRefMachItem And m_AssociationList(AssIndex).MachId = nOldMachId Then
bFound = True
Exit For
End If
Next
If Not bFound Then
' Cancello relativa lavorazione ordinata
For MachIndex = 0 To m_ActiveMachinesList.Count - 1
If m_ActiveMachinesList(MachIndex).MachId = nOldMachId Then
MTableMachiningGridBoxItem.Remove(CurrRefMachItem, m_ActiveMachinesList(MachIndex).MachiningList)
End If
Next
End If
If Not EgtMdbSetCurrMachining(Mach) Then
CurrRefMachItem = Nothing
Mach = String.Empty
Else
' se lavorazione mantenuta nella tabella della macchina precedente,
If bFound Then
' allora devo farne una copia
CurrRefMachItem = MTableMachiningGridBoxItem.Copy(CurrRefMachItem)
End If
' Reinserisco lavorazione ordinata nella lista della macchina giusta
CurrRefMachItem.GroupId = 0
CurrRefMachItem.SetProperty(String.Empty)
For MachIndex = 0 To m_ActiveMachinesList.Count - 1
If m_ActiveMachinesList(MachIndex).MachId = m_MachId Then
' se lista vuota metto gruppo uguale a 1
If m_ActiveMachinesList(MachIndex).MachiningList.Count = 0 Then
CurrRefMachItem.GroupId = 1
m_ActiveMachinesList(MachIndex).MachiningList.Insert(0, CurrRefMachItem)
Else
' verifico se esiste già
Dim bExist As Boolean = False
For MachiningIndex = 0 To m_ActiveMachinesList(MachIndex).MachiningList.Count - 1
Dim CurrMachining As MTableMachiningGridBoxItem = m_ActiveMachinesList(MachIndex).MachiningList(MachiningIndex)
If CurrMachining.Geometry = CurrRefMachItem.Geometry And CurrMachining.Machining = CurrRefMachItem.Machining Then
CurrRefMachItem = CurrMachining
bExist = True
End If
Next
If Not bExist Then
m_ActiveMachinesList(MachIndex).MachiningList.Insert(0, CurrRefMachItem)
End If
End If
End If
Next
End If
End If
Return CurrRefMachItem
End Function
Private Shared m_ShiftList As New ObservableCollection(Of Integer)({0, 1})
Public ReadOnly Property ShiftList As ObservableCollection(Of Integer)
Get
Return m_ShiftList
End Get
End Property
Private m_Shift As Integer
Public Property Shift As Integer
Get
Return m_Shift
End Get
Set(value As Integer)
m_IsModified = True
m_Shift = value
End Set
End Property
Public ReadOnly Property MachTypeList As List(Of MachineModel.MachiningsType)
Get
Return m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachTypeList
End Get
End Property
Private m_SelectedMachType As MachineModel.MachiningsType
Public Property SelectedMachType As MachineModel.MachiningsType
Get
Return m_SelectedMachType
End Get
Set(value As MachineModel.MachiningsType)
If Not IsNothing(value) Then
m_SelectedMachType = value
' Assegno alla lista delle lavorazioni della riga selezionata la lista di quelle del suo tipo
If IsNothing(m_SelectedMachType) Then
m_MachList = Nothing
Else
m_MachList = New ObservableCollection(Of String)(m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachiningListByType(m_SelectedMachType))
End If
NotifyPropertyChanged("MachList")
' Annullo il valore di Mach
Mach = String.Empty
NotifyPropertyChanged("Mach")
End If
End Set
End Property
Private m_SelectedMachUpType As MachineModel.MachiningsType
Public Property SelectedMachUpType As MachineModel.MachiningsType
Get
Return m_SelectedMachUpType
End Get
Set(value As MachineModel.MachiningsType)
If Not IsNothing(value) Then
m_SelectedMachUpType = value
' Assegno alla lista delle lavorazioni della riga selezionata la lista di quelle del suo tipo
If IsNothing(m_SelectedMachUpType) Then
m_MachUpList = Nothing
Else
m_MachUpList = New ObservableCollection(Of String)(m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachiningListByType(m_SelectedMachUpType))
End If
NotifyPropertyChanged("MachUpList")
' Annullo il valore di MachUp
MachUp = String.Empty
NotifyPropertyChanged("MachUp")
End If
End Set
End Property
Private m_SelectedMachDownType As MachineModel.MachiningsType
Public Property SelectedMachDownType As MachineModel.MachiningsType
Get
Return m_SelectedMachDownType
End Get
Set(value As MachineModel.MachiningsType)
If Not IsNothing(value) Then
m_SelectedMachDownType = value
' Assegno alla lista delle lavorazioni della riga selezionata la lista di quelle del suo tipo
If IsNothing(m_SelectedMachDownType) Then
m_MachDownList = Nothing
Else
m_MachDownList = New ObservableCollection(Of String)(m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachiningListByType(m_SelectedMachDownType))
End If
NotifyPropertyChanged("MachDownList")
' Annullo il valore di MachDw
MachDw = String.Empty
NotifyPropertyChanged("MachDw")
End If
End Set
End Property
Private m_MachList As ObservableCollection(Of String)
Public ReadOnly Property MachList As ObservableCollection(Of String)
Get
Return m_MachList
End Get
End Property
Private m_MachUpList As ObservableCollection(Of String)
Public ReadOnly Property MachUpList As ObservableCollection(Of String)
Get
Return m_MachUpList
End Get
End Property
Private m_MachDownList As ObservableCollection(Of String)
Public ReadOnly Property MachDownList As ObservableCollection(Of String)
Get
Return m_MachDownList
End Get
End Property
Private m_RefMachItem As MTableMachiningGridBoxItem
Public ReadOnly Property RefMachItem As MTableMachiningGridBoxItem
Get
Return m_RefMachItem
End Get
End Property
Private m_Mach As String
Public Property Mach As String
Get
Return m_Mach
End Get
Set(value As String)
m_IsModified = True
m_Mach = value
RefreshMachItem(m_RefMachItem, m_Mach)
End Set
End Property
Private m_RefMachUpItem As MTableMachiningGridBoxItem
Public ReadOnly Property RefMachUpItem As MTableMachiningGridBoxItem
Get
Return m_RefMachUpItem
End Get
End Property
Private m_MachUp As String
Public Property MachUp As String
Get
Return m_MachUp
End Get
Set(value As String)
m_IsModified = True
m_MachUp = value
RefreshMachItem(m_RefMachUpItem, m_MachUp)
End Set
End Property
Private m_RefMachDwItem As MTableMachiningGridBoxItem
Public ReadOnly Property RefMachDwItem As MTableMachiningGridBoxItem
Get
Return m_RefMachDwItem
End Get
End Property
Private m_MachDw As String
Public Property MachDw As String
Get
Return m_MachDw
End Get
Set(value As String)
m_IsModified = True
m_MachDw = value
RefreshMachItem(m_RefMachDwItem, m_MachDw)
End Set
End Property
Private m_Link As Integer
Public Property Link As String
Get
Return m_Link.ToString()
End Get
Set(value As String)
Dim nValue As Integer = 0
If Integer.TryParse(value, nValue) Then
m_IsModified = True
m_Link = nValue
Else
NotifyPropertyChanged(NameOf(Link))
End If
End Set
End Property
Public ReadOnly Property nLink As Integer
Get
Return m_Link
End Get
End Property
Public Sub SetLink(value As Integer)
m_Link = value
NotifyPropertyChanged(NameOf(Link))
End Sub
Sub New(bOn As Boolean, sName As String, nMachId As Integer, nShift As Integer, sOper As String,
RefMachItem As MTableMachiningGridBoxItem, sMach As String, RefMachUpItem As MTableMachiningGridBoxItem, sMachUp As String, RefMachDwItem As MTableMachiningGridBoxItem, sMachDw As String, nLink As Integer,
ByRef ActiveMachinesList As ObservableCollection(Of MTableMachineListBoxItem), ByRef AssociationList As ObservableCollection(Of MTableAssociationGridBoxItem))
OnPar = bOn
' Inizializzo la lista dei nomi solo la prima volta
If IsNothing(m_NamesList) Then
Dim NameFilePath As String = IniFile.m_sTablesRoot & "/" & GEONAMELIST_FILE
Dim TempNameList As New List(Of String)
Dim Index As Integer = 1
Dim sReadName As String = String.Empty
While EgtUILib.GetPrivateProfileString(S_GEOMETRYNAMES, Index.ToString(), "", sReadName, NameFilePath) > 0
' elimino tutto quello che viene dopo il primo ";"
Dim nCut As Integer = sReadName.IndexOf(";"c)
If nCut > 0 Then sReadName = sReadName.Remove(nCut)
' elimino eventuali spazi iniziali e finali
sReadName = sReadName.Trim()
' se stringa non vuota la inserisco nell'elenco
If Not String.IsNullOrEmpty(sReadName) Then TempNameList.Add(sReadName)
' passo alla successiva
Index += 1
End While
TempNameList.Sort()
NamesList = New ObservableCollection(Of String)(TempNameList)
End If
Name = sName
'Imposto il riferimento alla lista di macchine di questa tabella
m_ActiveMachinesList = ActiveMachinesList
' imposto il riferimento alla lista di associazioni di questa tabella
m_AssociationList = AssociationList
' Verifico che il valore di MachId sia valido altrimento imposto la prima macchina
If nMachId = 0 Then
MachId = 1
Else
MachId = nMachId
End If
If nShift = 1 Then
Shift = 1
Else
Shift = 0
End If
' Assegno l'operazione
Oper = sOper
' dall'MId recupero la macchina a cui si riferisce questa associazione e la imposto come corrente
If Not IsNothing(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) Then
EgtSetCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine.Name)
' Imposto MachType selezionato cercando il tipo delle lavorazioni
If EgtMdbSetCurrMachining(sMach) Then
Dim nMachType As Integer = GDB_ID.NULL
EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, nMachType)
For Each MachType In m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachTypeList
If nMachType = MachType.TypeId Then
SelectedMachType = MachType
Exit For
End If
Next
Else
SelectedMachType = Nothing
End If
If EgtMdbSetCurrMachining(sMachUp) Then
Dim nMachType As Integer = GDB_ID.NULL
EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, nMachType)
For Each MachType In m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachTypeList
If nMachType = MachType.TypeId Then
SelectedMachUpType = MachType
Exit For
End If
Next
Else
SelectedMachUpType = Nothing
End If
If EgtMdbSetCurrMachining(sMachDw) Then
Dim nMachType As Integer = GDB_ID.NULL
EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, nMachType)
For Each MachType In m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachTypeList
If nMachType = MachType.TypeId Then
SelectedMachDownType = MachType
Exit For
End If
Next
Else
SelectedMachDownType = Nothing
End If
NotifyPropertyChanged("SelectedMachType")
NotifyPropertyChanged("SelectedMachUpType")
NotifyPropertyChanged("SelectedMachDownType")
' Per Log lavorazione non trovata
Dim sOutLog As String = ""
' Imposto i Mach selezionati
If Not IsNothing(m_SelectedMachType) Then
m_Mach = sMach
ElseIf Not String.IsNullOrWhiteSpace(sMach) Then
sOutLog &= sMach & " (Std), "
End If
If Not IsNothing(m_SelectedMachUpType) Then
m_MachUp = sMachUp
ElseIf Not String.IsNullOrWhiteSpace(sMachUp) Then
sOutLog &= sMachUp & " (Up), "
End If
If Not IsNothing(m_SelectedMachDownType) Then
m_MachDw = sMachDw
ElseIf Not String.IsNullOrWhiteSpace(sMachDw) Then
sOutLog &= sMachDw & " (Dw), "
End If
If Not String.IsNullOrWhiteSpace(sOutLog) Then
EgtOutLog(sName & " : " & sOutLog & " not found")
End If
If Not String.IsNullOrWhiteSpace(Mach) Then
m_RefMachItem = RefMachItem
End If
If Not String.IsNullOrWhiteSpace(MachUp) Then
m_RefMachUpItem = RefMachUpItem
End If
If Not String.IsNullOrWhiteSpace(MachDw) Then
m_RefMachDwItem = RefMachDwItem
End If
End If
m_Link = nLink
m_IsModified = False
End Sub
' Funzione che aggiorna gli item nella lista lavorazioni ordinata
Private Sub RefreshMachItem(ByRef RefMachItem As MTableMachiningGridBoxItem, Mach As String)
' Se il nuovo valore è nullo
If String.IsNullOrWhiteSpace(Mach) Then
' Se esiste già il rispettivo item nella lista lavorazioni ordinata lo cancello
If Not IsNothing(RefMachItem) Then
For MachIndex = 0 To m_ActiveMachinesList.Count - 1
If m_ActiveMachinesList(MachIndex).MachId = m_MachId Then
MTableMachiningGridBoxItem.Remove(RefMachItem, m_ActiveMachinesList(MachIndex).MachiningList)
RefMachItem = Nothing
End If
Next
End If
' Se il nuovo valore è valido
Else
' Se non esiste già il rispettivo item nella lista lavorazioni ordinata lo creo
If IsNothing(RefMachItem) Then
For MachIndex = 0 To m_ActiveMachinesList.Count - 1
If m_ActiveMachinesList(MachIndex).MachId = m_MachId Then
Dim CurrMachItem As MTableMachiningGridBoxItem = New MTableMachiningGridBoxItem(0, m_Name, Mach, False, m_ActiveMachinesList(MachIndex))
' se la lista è vuota
If m_ActiveMachinesList(MachIndex).MachiningList.Count = 0 Then
' do indice 1 al nuovo elemento da aggiungere
CurrMachItem.GroupId = 1
End If
RefMachItem = CurrMachItem
m_ActiveMachinesList(MachIndex).MachiningList.Insert(0, RefMachItem)
End If
Next
' altrimenti lo aggiorno con la nuova lavorazione
Else
RefMachItem.Machining = Mach
End If
End If
End Sub
Friend Shared Sub LoadOperationList()
Dim TempOperList As New List(Of String)
' aggiungo elemento stringa vuota per dare la possibilità di non selezionarne nessuna operazione
TempOperList.Add(String.Empty)
' aggiungo tutte le altre
Dim OperationFilePath As String = IniFile.m_sTablesRoot & "/" & OPERATIONLIST_FILE
Dim Index As Integer = 1
Dim sRaedOperation As String = String.Empty
While EgtUILib.GetPrivateProfileString(S_OPERATIONS, Index.ToString, "", sRaedOperation, OperationFilePath) > 0
TempOperList.Add(sRaedOperation)
Index += 1
End While
TempOperList.Sort()
m_OperationsList = New ObservableCollection(Of String)(TempOperList)
End Sub
End Class