diff --git a/MTableDb/MTableDbV.xaml b/MTableDb/MTableDbV.xaml index a9fec47..949da33 100644 --- a/MTableDb/MTableDbV.xaml +++ b/MTableDb/MTableDbV.xaml @@ -20,19 +20,19 @@ - + + - - + - + - + - + - + - + @@ -101,7 +101,8 @@ + SelectedItem="{Binding Path=SelectedItem.SelMachine, ElementName=TablesListBox}" + Margin="5,5,5,5"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + - + - + + + + - + diff --git a/MTableDb/MTableDbV.xaml.vb b/MTableDb/MTableDbV.xaml.vb index 5c5fac1..fc6ac06 100644 --- a/MTableDb/MTableDbV.xaml.vb +++ b/MTableDb/MTableDbV.xaml.vb @@ -101,7 +101,11 @@ Public Class MTableDbV End Sub Private Sub CellMouseUp(sender As Object, e As MouseButtonEventArgs) - 'e.Handled = True + e.Handled = True + End Sub + + Private Sub TabControl_SelectionChanged() + End Sub Public Function GetCell(row As Integer, column As Integer) As DataGridCell diff --git a/MTableDb/MTableDbVM.vb b/MTableDb/MTableDbVM.vb index 1f6f02e..77e9a22 100644 --- a/MTableDb/MTableDbVM.vb +++ b/MTableDb/MTableDbVM.vb @@ -1,8 +1,9 @@ Imports System.Collections.ObjectModel Imports System.ComponentModel Imports System.IO -Imports EgtUILib Imports System.Text.RegularExpressions +Imports EgtUILib +Imports EgtWPFLib5 Public Class MTableDbVM Inherits VMBase diff --git a/MTableDb/MTableListBox.vb b/MTableDb/MTableListBox.vb index 5dbf7d6..d3fb329 100644 --- a/MTableDb/MTableListBox.vb +++ b/MTableDb/MTableListBox.vb @@ -3,10 +3,11 @@ Imports System.Collections.ObjectModel Imports System.Text.RegularExpressions Imports System.IO Imports EgtUILib +Imports EgtWPFLib5 Imports EgtCAM5.MachineModel Public Class MTableListBoxItem - Implements INotifyPropertyChanged + Inherits VMBase ' Actions Friend Shared m_delSaveMTable As Action(Of MTableListBoxItem) @@ -41,8 +42,8 @@ Public Class MTableListBoxItem m_delCloseMTableWnd() Return End If - ' resetto liste lavorazioni - MTableAssociationGridBoxItem.ResetMachiningList() + ' '' 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 @@ -231,24 +232,24 @@ Public Class MTableListBoxItem 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 - End Sub - - Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged - - Public Sub NotifyPropertyChanged(propName As String) - RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) + 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 - Implements INotifyPropertyChanged + Inherits VMBase ' Actions Friend Shared m_delCloseMTableWnd As Action @@ -268,25 +269,26 @@ Public Class MTableMachineListBoxItem End Property ' Lista di macchine per la ComboBox - Private Shared m_MachinesList As New ObservableCollection(Of String) - Public Property MachinesList As ObservableCollection(Of String) + Private Shared m_MachinesList As New List(Of MTableMachine) + Public Property MachinesList As List(Of MTableMachine) Get Return m_MachinesList End Get - Set(value As ObservableCollection(Of String)) + Set(value As List(Of MTableMachine)) m_MachinesList = value End Set End Property ' Macchina selezionata - Private m_SelectedMachine As String - Public Property SelectedMachine As String + Private m_SelectedMachine As MTableMachine + Public Property SelectedMachine As MTableMachine Get Return m_SelectedMachine End Get - Set(value As String) + Set(value As MTableMachine) m_IsModified = True m_SelectedMachine = value + If Not m_SelectedMachine.IsLoaded Then m_SelectedMachine.LoadMachining() End Set End Property @@ -324,9 +326,15 @@ Public Class MTableMachineListBoxItem Sub New(sMachName As String, bNcGenerate As Boolean, bMakeraw As Boolean, nMachId As Integer) If m_MachinesList.Count = 0 Then - If Not SearchMachine() Then Throw New Exception("Exception: Can't find machines dir!") + 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 - SelectedMachine = sMachName NcGenerate = bNcGenerate Makeraw = bMakeraw MachId = nMachId @@ -336,20 +344,26 @@ Public Class MTableMachineListBoxItem ' 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 - MachinesList.Add(String.Empty) + 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 - ' 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 + 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 @@ -362,16 +376,100 @@ Public Class MTableMachineListBoxItem End If End Sub - Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged +End Class - Public Sub NotifyPropertyChanged(propName As String) - RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) +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 + + ' 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 Shared m_DrillingList As New List(Of String) + Private Shared m_SawingList As New List(Of String) + Private Shared m_MillingList As New List(Of String) + Private Shared m_PocketingList As New List(Of String) + Private Shared m_MortisingList As New List(Of String) + Private Shared m_SawRoughingList As New List(Of String) + Private Shared m_SawFinishingList As New List(Of String) + Private Shared 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 - Implements INotifyPropertyChanged + Inherits VMBase Private m_refMTableMachine As MTableMachineListBoxItem @@ -490,6 +588,12 @@ Public Class MTableMachiningGridBoxItem 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 @@ -510,7 +614,6 @@ Public Class MTableMachiningGridBoxItem Set(value As Boolean) If value <> m_Join Then m_Join = value - NotifyPropertyChanged("grh_Join") End If End Set End Property @@ -578,16 +681,10 @@ Public Class MTableMachiningGridBoxItem Return New MTableMachiningGridBoxItem(Machining.m_GroupId, Machining.m_Geometry, Machining.m_Machining, Machining.m_Join, Machining.m_refMTableMachine) End Function - Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged - - Public Sub NotifyPropertyChanged(propName As String) - RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) - End Sub - End Class Public Class MTableAssociationGridBoxItem - Implements INotifyPropertyChanged + Inherits VMBase ' Actions Friend Shared m_delCloseMTableWnd As Action @@ -705,51 +802,43 @@ Public Class MTableAssociationGridBoxItem m_IsModified = True Dim nOldMachId As Integer = m_MachId m_MachId = value - ' Riverifico che il numero di macchine non sia cambiato - If m_MachId > 1 Then - If m_DrillingList.Count <> m_ActiveMachinesList.Count Then - For Index As Integer = m_DrillingList.Count To m_ActiveMachinesList.Count - 1 - m_DrillingList.Add(New List(Of String)) - m_SawingList.Add(New List(Of String)) - m_MillingList.Add(New List(Of String)) - m_PocketingList.Add(New List(Of String)) - m_MortisingList.Add(New List(Of String)) - m_SawRoughingList.Add(New List(Of String)) - m_SawFinishingList.Add(New List(Of String)) - m_ChiselingList.Add(New List(Of String)) - Next - End If - End If ' Aggiorno lista tipi di lavorazione - UpdateMachiningTypeLists() - If Not IsNothing(m_SelectedMachType) Then - ' Verifico che quella selezionata sia valida anche per la macchina corrente - Dim bFound As Boolean = False - For TypeIndex = 0 To m_MachTypeList.Count - 1 - If m_MachTypeList(TypeIndex).TypeId = m_SelectedMachType.TypeId Then - m_SelectedMachType = m_MachTypeList(TypeIndex) - bFound = True - NotifyPropertyChanged("SelectedMachType") - Exit For - End If - Next - If Not bFound Then - m_SelectedMachType = Nothing - NotifyPropertyChanged("SelectedMachType") + NotifyPropertyChanged("MachTypeList") + ' Verifico se tipo selezionato e lavorazione sono ancora validi + If Not IsNothing(m_SelectedMachType) AndAlso MachTypeList.Contains(m_SelectedMachType) Then + If Not IsNothing(m_Mach) AndAlso Not m_MachList.Contains(m_Mach) Then + m_Mach = Nothing End If - End If - ' Assegno alla lista delle lavorazioni della riga selezionata la lista di quelle del suo tipo - If IsNothing(m_SelectedMachType) Then - MachList = Nothing Else - If Not UpdateMachiningLists() Then Return + SelectedMachType = Nothing End If + If Not IsNothing(m_SelectedMachUpType) AndAlso MachTypeList.Contains(m_SelectedMachUpType) Then + 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 MachTypeList.Contains(m_SelectedMachDownType) Then + If Not IsNothing(m_MachDw) AndAlso Not m_MachList.Contains(m_MachDw) Then + m_MachDw = Nothing + End If + Else + SelectedMachDownType = Nothing + End If + + '' Assegno alla lista delle lavorazioni della riga selezionata la lista di quelle del suo tipo + 'If IsNothing(m_SelectedMachType) Then + ' MachList = Nothing + 'Else + ' If Not UpdateMachiningLists() Then Return + 'End If ' Verifico se i nomi già presenti per Mach, MachUp e MachDw sono validi per la nuova macchina - If Not String.IsNullOrWhiteSpace(m_ActiveMachinesList(value - 1).SelectedMachine) AndAlso Not EgtTrySettingCurrMachine(m_ActiveMachinesList(value - 1).SelectedMachine) Then + If Not IsNothing(m_ActiveMachinesList(value - 1).SelectedMachine) AndAlso Not EgtTrySettingCurrMachine(m_ActiveMachinesList(value - 1).SelectedMachine.Name) Then m_delCloseMTableWnd() Return End If - EgtSetCurrMachine(m_ActiveMachinesList(value - 1).SelectedMachine) + EgtSetCurrMachine(m_ActiveMachinesList(value - 1).SelectedMachine.Name) If Not IsNothing(m_SelectedMachType) Then m_RefMachItem = ManageOrderedMachining(Mach, nOldMachId, RefMachItem) m_RefMachUpItem = ManageOrderedMachining(MachUp, nOldMachId, RefMachUpItem) @@ -759,6 +848,12 @@ Public Class MTableAssociationGridBoxItem If String.IsNullOrWhiteSpace(m_MachUp) Then NotifyPropertyChanged("MachUp") If String.IsNullOrWhiteSpace(m_MachDw) Then NotifyPropertyChanged("MachDw") End If + m_Mach = Nothing + NotifyPropertyChanged("Mach") + m_MachUp = Nothing + NotifyPropertyChanged("MachUp") + m_MachDw = Nothing + NotifyPropertyChanged("MachDw") End If End Set End Property @@ -838,14 +933,10 @@ Public Class MTableAssociationGridBoxItem End Set End Property - Private Shared m_MachTypeList As ObservableCollection(Of MachineModel.MachiningsType) - Public Property MachTypeList As ObservableCollection(Of MachineModel.MachiningsType) + Public ReadOnly Property MachTypeList As List(Of MachineModel.MachiningsType) Get - Return m_MachTypeList + Return m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachTypeList End Get - Set(value As ObservableCollection(Of MachineModel.MachiningsType)) - m_MachTypeList = value - End Set End Property Private m_SelectedMachType As MachineModel.MachiningsType @@ -858,171 +949,81 @@ Public Class MTableAssociationGridBoxItem m_SelectedMachType = value ' Assegno alla lista delle lavorazioni della riga selezionata la lista di quelle del suo tipo If IsNothing(m_SelectedMachType) Then - MachList = Nothing + m_MachList = Nothing Else - If Not UpdateMachiningLists() Then Return + m_MachList = New ObservableCollection(Of String)(m_ActiveMachinesList(m_MachId - 1).SelectedMachine.MachiningListByType(m_SelectedMachType)) End If - ' Annullo i valori di Mach, MachUp e MachDw + 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 Sub UpdateMachiningTypeLists() - ' se la lista è vuota devo caricarla - If m_MachinesMachTypeList.Count < m_MachId OrElse m_MachinesMachTypeList(m_MachId - 1).Count = 0 Then - Dim sMachineName As String = m_ActiveMachinesList(m_MachId - 1).SelectedMachine - Dim sMachineIniPath As String = IniFile.m_sMachinesRoot & "\" & m_ActiveMachinesList(m_MachId - 1).SelectedMachine & "\" & m_ActiveMachinesList(m_MachId - 1).SelectedMachine & ".ini" - If File.Exists(sMachineIniPath) Then - For Index = m_MachinesMachTypeList.Count To m_MachId - 1 - m_MachinesMachTypeList.Add(New List(Of MachineModel.MachiningsType)) - Next - m_MachinesMachTypeList(m_MachId - 1) = New List(Of MachiningsType)(MachineModel.ReadMachiningsFamilies(sMachineIniPath)) - End If - ' aggiungo elemento stringa vuota(come primo elemento) per dare la possibilità di non selezionarne nessuna operazione - If Not IsNothing(m_MachinesMachTypeList(m_MachId - 1)) Then - m_MachinesMachTypeList(m_MachId - 1).Insert(0, New MachiningsType() With {.TypeId = MCH_MY.NONE, .TypeName = String.Empty}) - Else - m_MachinesMachTypeList(m_MachId - 1) = New List(Of MachiningsType)({New MachiningsType() With {.TypeId = MCH_MY.NONE, .TypeName = String.Empty}}) - End If - End If - MachTypeList = New ObservableCollection(Of MachiningsType)(m_MachinesMachTypeList(m_MachId - 1)) - End Sub - - ' Funzione che in base al tipo di lavorazione e alla macchina selezionati, imposta la lista delle lavorazioni per le combo - Private Function UpdateMachiningLists() As Boolean - Select Case m_SelectedMachType.TypeId - Case MCH_MY.DRILLING - ' se la lista è vuota devo caricarla - If m_DrillingList(m_MachId - 1).Count = 0 Then - m_DrillingList(m_MachId - 1) = New List(Of String) - If EgtTrySettingCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) Then - LoadMachiningListByType(m_DrillingList(m_MachId - 1), MCH_MY.DRILLING) - Else - m_delCloseMTableWnd() - Return False - End If - ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione - m_DrillingList(m_MachId - 1).Insert(0, String.Empty) - End If - MachList = New ObservableCollection(Of String)(m_DrillingList(m_MachId - 1)) - Case MCH_MY.SAWING - ' se la lista è vuota devo caricarla - If m_SawingList(m_MachId - 1).Count = 0 Then - m_SawingList(m_MachId - 1) = New List(Of String) - If EgtTrySettingCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) Then - LoadMachiningListByType(m_SawingList(m_MachId - 1), MCH_MY.SAWING) - Else - m_delCloseMTableWnd() - Return False - End If - ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione - m_SawingList(m_MachId - 1).Insert(0, String.Empty) - End If - MachList = New ObservableCollection(Of String)(m_SawingList(m_MachId - 1)) - Case MCH_MY.MILLING - ' se la lista è vuota devo caricarla - If m_MillingList(m_MachId - 1).Count = 0 Then - m_MillingList(m_MachId - 1) = New List(Of String) - If EgtTrySettingCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) Then - LoadMachiningListByType(m_MillingList(m_MachId - 1), MCH_MY.MILLING) - Else - m_delCloseMTableWnd() - Return False - End If - ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione - m_MillingList(m_MachId - 1).Insert(0, String.Empty) - End If - MachList = New ObservableCollection(Of String)(m_MillingList(m_MachId - 1)) - Case MCH_MY.POCKETING - ' se la lista è vuota devo caricarla - If m_PocketingList(m_MachId - 1).Count = 0 Then - m_PocketingList(m_MachId - 1) = New List(Of String) - If EgtTrySettingCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) Then - LoadMachiningListByType(m_PocketingList(m_MachId - 1), MCH_MY.POCKETING) - Else - m_delCloseMTableWnd() - Return False - End If - ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione - m_PocketingList(m_MachId - 1).Insert(0, String.Empty) - End If - MachList = New ObservableCollection(Of String)(m_PocketingList(m_MachId - 1)) - Case MCH_MY.MORTISING - ' se la lista è vuota devo caricarla - If m_MortisingList(m_MachId - 1).Count = 0 Then - m_MortisingList(m_MachId - 1) = New List(Of String) - If EgtTrySettingCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) Then - LoadMachiningListByType(m_MortisingList(m_MachId - 1), MCH_MY.MORTISING) - Else - m_delCloseMTableWnd() - Return False - End If - ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione - m_MortisingList(m_MachId - 1).Insert(0, String.Empty) - End If - MachList = New ObservableCollection(Of String)(m_MortisingList(m_MachId - 1)) - Case MCH_MY.SAWROUGHING - ' se la lista è vuota devo caricarla - If m_SawRoughingList(m_MachId - 1).Count = 0 Then - m_SawRoughingList(m_MachId - 1) = New List(Of String) - If EgtTrySettingCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) Then - LoadMachiningListByType(m_SawRoughingList(m_MachId - 1), MCH_MY.SAWROUGHING) - Else - m_delCloseMTableWnd() - Return False - End If - ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione - m_SawRoughingList(m_MachId - 1).Insert(0, String.Empty) - End If - MachList = New ObservableCollection(Of String)(m_SawRoughingList(m_MachId - 1)) - Case MCH_MY.SAWFINISHING - ' se la lista è vuota devo caricarla - If m_SawFinishingList(m_MachId - 1).Count = 0 Then - m_SawFinishingList(m_MachId - 1) = New List(Of String) - If EgtTrySettingCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) Then - LoadMachiningListByType(m_SawFinishingList(m_MachId - 1), MCH_MY.SAWFINISHING) - Else - m_delCloseMTableWnd() - Return False - End If - ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione - m_SawFinishingList(m_MachId - 1).Insert(0, String.Empty) - End If - MachList = New ObservableCollection(Of String)(m_SawFinishingList(m_MachId - 1)) - Case MCH_MY.CHISELING - ' se la lista è vuota devo caricarla - If m_ChiselingList(m_MachId - 1).Count = 0 Then - m_ChiselingList(m_MachId - 1) = New List(Of String) - If EgtTrySettingCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) Then - LoadMachiningListByType(m_ChiselingList(m_MachId - 1), MCH_MY.CHISELING) - Else - m_delCloseMTableWnd() - Return False - End If - ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione - m_ChiselingList(m_MachId - 1).Insert(0, String.Empty) - End If - MachList = New ObservableCollection(Of String)(m_ChiselingList(m_MachId - 1)) - End Select - Return True - End Function - Private m_MachList As ObservableCollection(Of String) - Public Property MachList As ObservableCollection(Of String) + Public ReadOnly Property MachList As ObservableCollection(Of String) Get Return m_MachList End Get - Set(value As ObservableCollection(Of String)) - If value IsNot m_MachList Then - m_MachList = value - End If - End Set + 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 @@ -1082,45 +1083,10 @@ Public Class MTableAssociationGridBoxItem End Set End Property - ' Liste per le lavorazioni - Private Shared m_DrillingList As New List(Of List(Of String)) - Private Shared m_SawingList As New List(Of List(Of String)) - Private Shared m_MillingList As New List(Of List(Of String)) - Private Shared m_PocketingList As New List(Of List(Of String)) - Private Shared m_MortisingList As New List(Of List(Of String)) - Private Shared m_SawRoughingList As New List(Of List(Of String)) - Private Shared m_SawFinishingList As New List(Of List(Of String)) - Private Shared m_ChiselingList As New List(Of List(Of String)) - Private Shared m_MachinesMachTypeList As New List(Of List(Of MachineModel.MachiningsType)) - - Friend Shared Sub ResetMachiningList() - m_DrillingList = New List(Of List(Of String)) - m_SawingList = New List(Of List(Of String)) - m_MillingList = New List(Of List(Of String)) - m_PocketingList = New List(Of List(Of String)) - m_MortisingList = New List(Of List(Of String)) - m_SawRoughingList = New List(Of List(Of String)) - m_SawFinishingList = New List(Of List(Of String)) - m_ChiselingList = New List(Of List(Of String)) - 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, ByRef ActiveMachinesList As ObservableCollection(Of MTableMachineListBoxItem), ByRef AssociationList As ObservableCollection(Of MTableAssociationGridBoxItem)) - ' Inizializzo la lista delle lavorazioni solo la prima volta - If m_DrillingList.Count = 0 Then - For Index As Integer = 0 To ActiveMachinesList.Count - 1 - m_DrillingList.Add(New List(Of String)) - m_SawingList.Add(New List(Of String)) - m_MillingList.Add(New List(Of String)) - m_PocketingList.Add(New List(Of String)) - m_MortisingList.Add(New List(Of String)) - m_SawRoughingList.Add(New List(Of String)) - m_SawFinishingList.Add(New List(Of String)) - m_ChiselingList.Add(New List(Of String)) - Next - End If OnPar = bOn ' Inizializzo la lista dei nomi solo la prima volta If IsNothing(m_NamesList) Then @@ -1158,43 +1124,58 @@ Public Class MTableAssociationGridBoxItem Else Shift = 0 End If - '' Inizializzo la lista delle operazioni solo la prima volta - 'If IsNothing(m_OperationsList) Then - ' 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() - ' OperationsList = New ObservableCollection(Of String)(TempOperList) - 'End If + ' Assegno l'operazione Oper = sOper ' dall'MId recupero la macchina a cui si riferisce questa associazione e la imposto come corrente - EgtSetCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine) + EgtSetCurrMachine(m_ActiveMachinesList(m_MachId - 1).SelectedMachine.Name) ' Imposto MachType selezionato cercando il tipo delle lavorazioni - If EgtMdbSetCurrMachining(sMach) OrElse EgtMdbSetCurrMachining(sMachUp) OrElse EgtMdbSetCurrMachining(sMachDw) Then + If EgtMdbSetCurrMachining(sMach) Then Dim nMachType As Integer = GDB_ID.NULL EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, nMachType) - For Index As Integer = 0 To m_MachTypeList.Count - 1 - If nMachType = m_MachTypeList(Index).TypeId Then - SelectedMachType = m_MachTypeList(Index) + 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") If Not IsNothing(m_SelectedMachType) Then ' Imposto i Mach selezionati m_Mach = sMach + End If + If Not IsNothing(m_SelectedMachUpType) Then m_MachUp = sMachUp + End If + If Not IsNothing(m_SelectedMachDownType) Then m_MachDw = sMachDw End If If Not String.IsNullOrWhiteSpace(Mach) Then @@ -1261,10 +1242,4 @@ Public Class MTableAssociationGridBoxItem m_OperationsList = New ObservableCollection(Of String)(TempOperList) End Sub - Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged - - Public Sub NotifyPropertyChanged(propName As String) - RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) - End Sub - End Class diff --git a/MTableDb/TableUtility.vb b/MTableDb/TableUtility.vb index b3390a5..23948be 100644 --- a/MTableDb/TableUtility.vb +++ b/MTableDb/TableUtility.vb @@ -370,7 +370,7 @@ Module TableUtility Private Sub PrintActiveMachineList(SelectedTable As MTableListBoxItem, NewTableFileContent As List(Of String)) For Index As Integer = 0 To SelectedTable.ActiveMachinesList.Count - 1 - Dim CurrentLine As String = " { MachName = '" & SelectedTable.ActiveMachinesList(Index).SelectedMachine & "', NcGenerate = " & SelectedTable.ActiveMachinesList(Index).NcGenerate.ToString.ToLower _ + Dim CurrentLine As String = " { MachName = '" & SelectedTable.ActiveMachinesList(Index).SelectedMachine.Name & "', NcGenerate = " & SelectedTable.ActiveMachinesList(Index).NcGenerate.ToString.ToLower _ & ", MakeRaw = " & SelectedTable.ActiveMachinesList(Index).Makeraw.ToString.ToLower & " }" If Index < SelectedTable.ActiveMachinesList.Count - 1 Then CurrentLine &= " ," diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 671e389..3b1410e 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -70,5 +70,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderVM.vb b/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderVM.vb index 286566e..96eeb6e 100644 --- a/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderVM.vb +++ b/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderVM.vb @@ -3,8 +3,6 @@ Public Class DispositionParameterExpanderVM Inherits ViewModelBase - - Public Enum ObjectType As Integer RAWPART = 1 PART = 2 @@ -319,6 +317,7 @@ Public Class DispositionParameterExpanderVM End Select m_MoveWithFixture = False OnPropertyChanged("MoveWithFixture") + Map.refFixtureParametersVM.UpdateFixtureTypeList() End Sub #End Region ' METHODS diff --git a/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/FixtureParameters/FixtureParametersVM.vb b/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/FixtureParameters/FixtureParametersVM.vb index 7194bc4..15e9ed5 100644 --- a/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/FixtureParameters/FixtureParametersVM.vb +++ b/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/FixtureParameters/FixtureParametersVM.vb @@ -43,6 +43,8 @@ Public Class FixtureParametersVM #End Region ' Messages Sub New(ByRef ExpandFixtureFunction As Action) + ' Creo riferimento a questa classe in EgtCAM5Map + Map.SetRefFixtureParametersVM(Me) ExpandFixtureFunction = AddressOf UpdateFixtureCount ' seleziono secondo elemento se presente perchè primo è categoria SelectedFixtureType = Nothing @@ -72,6 +74,11 @@ Public Class FixtureParametersVM End While End Sub + Friend Sub UpdateFixtureTypeList() + m_FixtureTypeList = New ObservableCollection(Of FixtureListItem)(FixtureType.ReadFixtureTypeFromMachIni()) + OnPropertyChanged("FixtureTypeList") + End Sub + ' Definizione comandi Private m_cmdAdd As ICommand Private m_cmdRemove As ICommand diff --git a/Utility/Map.vb b/Utility/Map.vb index 98856f8..fbf5e6d 100644 --- a/Utility/Map.vb +++ b/Utility/Map.vb @@ -6,6 +6,7 @@ Private m_refStatusBarVM As StatusBarVM Private m_refTopCommandBarVM As TopCommandBarVM Private m_refProjectVM As ProjectVM + Private m_refFixtureParametersVM As FixtureParametersVM #Region "Get" @@ -29,6 +30,11 @@ Return m_refProjectVM End Get End Property + Public ReadOnly Property refFixtureParametersVM As FixtureParametersVM + Get + Return m_refFixtureParametersVM + End Get + End Property #End Region ' Get @@ -46,6 +52,10 @@ m_refProjectVM = ProjectVM Return Not IsNothing(m_refProjectVM) End Function + Friend Function SetRefFixtureParametersVM(FixtureParametersVM As FixtureParametersVM) As Boolean + m_refFixtureParametersVM = FixtureParametersVM + Return Not IsNothing(m_refFixtureParametersVM) + End Function #End Region ' Set @@ -57,7 +67,8 @@ End Function Friend Function EndInit() As Boolean ' Verifico se tutti i pezzi necessari sono stati caricati - Return Not IsNothing(m_refMainWindowVM) AndAlso Not IsNothing(m_refStatusBarVM) AndAlso Not IsNothing(m_refProjectVM) AndAlso Not IsNothing(m_refTopCommandBarVM) + Return Not IsNothing(m_refMainWindowVM) AndAlso Not IsNothing(m_refStatusBarVM) AndAlso Not IsNothing(m_refProjectVM) AndAlso Not IsNothing(m_refTopCommandBarVM) AndAlso + Not IsNothing(m_refFixtureParametersVM) End Function #End Region ' Init