diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb
index af092be..23fab54 100644
--- a/Constants/ConstIni.vb
+++ b/Constants/ConstIni.vb
@@ -103,6 +103,7 @@ Module ConstIni
Public Const K_DDFMACHEXEC As String = "DdfMachExec"
Public Const K_TABLESDIR As String = "TablesDir"
Public Const K_CURRMTABLE As String = "CurrMTable"
+ Public Const K_MTABLEWINPLACE As String = "MTableWinPlace"
Public Const S_GUNSTOCK As String = "GunStock"
Public Const K_GUNSTOCKENABLE As String = "GsEnable"
diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj
index d63cb41..64e2bd8 100644
--- a/EgtCAM5.vbproj
+++ b/EgtCAM5.vbproj
@@ -160,10 +160,10 @@
MachOptionsView.xaml
-
- MTableDbView.xaml
+
+ MTableDbV.xaml
-
+
@@ -314,6 +314,7 @@
+ Designer
@@ -323,7 +324,7 @@
DesignerMSBuild:Compile
-
+ DesignerMSBuild:Compile
diff --git a/MTableDb/MTableDbV.xaml b/MTableDb/MTableDbV.xaml
new file mode 100644
index 0000000..51ec8a0
--- /dev/null
+++ b/MTableDb/MTableDbV.xaml
@@ -0,0 +1,549 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MTableDb/MTableDbV.xaml.vb b/MTableDb/MTableDbV.xaml.vb
new file mode 100644
index 0000000..1395170
--- /dev/null
+++ b/MTableDb/MTableDbV.xaml.vb
@@ -0,0 +1,138 @@
+Imports System.Windows
+Imports System.Windows.Controls.Primitives
+Imports EgtCAM5.EgtCAM5
+Imports EgtWPFLib5
+
+Public Class MTableDbV
+
+ Private m_MTableDbVM As MTableDbVM
+ Private m_EditCell As DataGridCell
+
+ Sub New(Owner As Window, MTableDbVM As MTableDbVM)
+ MyBase.New(Owner)
+ ' This call is required by the designer.
+ InitializeComponent()
+ Me.DataContext = MTableDbVM
+ ' Assegno al riferimento locale al VM il VM preso dal DataContext
+ m_MTableDbVM = MTableDbVM
+ End Sub
+
+ Private Sub RowLeftClick(sender As Object, e As MouseButtonEventArgs)
+ e.Handled = True
+ End Sub
+
+ Private Sub RowRightClick(sender As Object, e As MouseButtonEventArgs)
+ e.Handled = True
+ End Sub
+
+ Private Sub CellLeftClick(sender As Object, e As MouseButtonEventArgs)
+ Dim CurrCell As DataGridCell = Nothing
+ If TypeOf sender Is DataGridCell Then
+ CurrCell = DirectCast(sender, DataGridCell)
+ End If
+ Dim SelectedRow As MTableMachiningGridBoxItem = DirectCast(CurrCell.DataContext, MTableMachiningGridBoxItem)
+ Dim bFirstInGroup As Boolean = True
+ For TableIndex = 0 To MTableDbVM.refMTableDbVM.TablesList.Count - 1
+ Dim CurrTable As MTableListBoxItem = MTableDbVM.refMTableDbVM.TablesList(TableIndex)
+ If CurrTable.IsSelected Then
+ Dim CurrMachiningIndex As Integer = CurrTable.SelMachine.MachiningList.IndexOf(SelectedRow)
+ If CurrMachiningIndex > 0 AndAlso CurrTable.SelMachine.MachiningList(CurrMachiningIndex - 1).GroupId = SelectedRow.GroupId Then
+ bFirstInGroup = False
+ End If
+ End If
+ Next
+ Dim bSelCell As Boolean = False
+ If Not IsNothing(CurrCell) AndAlso TypeOf CurrCell.DataContext Is MTableMachiningGridBoxItem Then
+ If CurrCell.IsSelected And SelectedRow.GroupId <> 0 Then
+ If (bFirstInGroup And (CurrCell.Column Is MachiningDataGrid.Columns(1))) Then
+ CurrCell.IsEditing = True
+ m_EditCell = CurrCell
+ bSelCell = True
+ ElseIf Not CurrCell.IsEditing And CurrCell.Column Is MachiningDataGrid.Columns(4) Then
+ SelectedRow.Join = Not SelectedRow.Join
+ End If
+ End If
+ If Not CurrCell.IsSelected Or ((Not bFirstInGroup Or CurrCell.Column IsNot MachiningDataGrid.Columns(1)) And CurrCell.Column IsNot MachiningDataGrid.Columns(4)) Or SelectedRow.GroupId = 0 Then
+ If Not IsNothing(m_EditCell) AndAlso m_EditCell.IsEditing Then
+ m_EditCell.IsEditing = False
+ Else
+ m_MTableDbVM.LeftSelect(SelectedRow)
+ End If
+ End If
+ End If
+ If Not bSelCell And Not CurrCell.IsEditing Or CurrCell.Column Is MachiningDataGrid.Columns(4) Then
+ m_EditCell.IsEditing = False
+ Keyboard.ClearFocus()
+ MachiningDataGrid.Focus()
+ e.Handled = True
+ End If
+ End Sub
+
+ Private Sub CellRightClick(sender As Object, e As MouseButtonEventArgs)
+ Dim CurrRow As DataGridCell = Nothing
+ If TypeOf sender Is DataGridCell Then
+ CurrRow = DirectCast(sender, DataGridCell)
+ End If
+ If Not IsNothing(CurrRow) AndAlso TypeOf CurrRow.DataContext Is MTableMachiningGridBoxItem Then
+ Dim SelectedRow As MTableMachiningGridBoxItem = DirectCast(CurrRow.DataContext, MTableMachiningGridBoxItem)
+ m_MTableDbVM.RightSelect(SelectedRow)
+ End If
+ m_EditCell.IsEditing = False
+ e.Handled = True
+ End Sub
+
+ Private Sub RowMouseUp(sender As Object, e As MouseButtonEventArgs)
+ 'e.Handled = True
+ End Sub
+
+ Private Sub CellMouseUp(sender As Object, e As MouseButtonEventArgs)
+ 'e.Handled = True
+ End Sub
+
+ Public Function GetCell(row As Integer, column As Integer) As DataGridCell
+ Dim rowContainer As DataGridRow = GetRow(row)
+
+ If rowContainer IsNot Nothing Then
+ Dim presenter As DataGridCellsPresenter = FindChild(Of DataGridCellsPresenter)(rowContainer)
+
+ ' try to get the cell but it may possibly be virtualized
+ Dim cell As DataGridCell = DirectCast(presenter.ItemContainerGenerator.ContainerFromIndex(column), DataGridCell)
+ If cell Is Nothing Then
+ ' now try to bring into view and retreive the cell
+ MachiningDataGrid.ScrollIntoView(rowContainer, MachiningDataGrid.Columns(column))
+ cell = DirectCast(presenter.ItemContainerGenerator.ContainerFromIndex(column), DataGridCell)
+ End If
+ Return cell
+ End If
+ Return Nothing
+ End Function
+
+ Public Function GetRow(index As Integer) As DataGridRow
+ Dim row As DataGridRow = DirectCast(MachiningDataGrid.ItemContainerGenerator.ContainerFromIndex(index), DataGridRow)
+ If row Is Nothing Then
+ ' may be virtualized, bring into view and try again
+ MachiningDataGrid.ScrollIntoView(MachiningDataGrid.Items(index))
+ row = DirectCast(MachiningDataGrid.ItemContainerGenerator.ContainerFromIndex(index), DataGridRow)
+ End If
+ Return row
+ End Function
+
+ Public Function FindChild(Of T As Class)(dependencyObject As DependencyObject) As T
+ Dim target As DependencyObject = dependencyObject
+ Do
+ target = DirectCast(VisualTreeHelper.GetChild(target, 0), DependencyObject)
+ Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
+ Return TryCast(target, T)
+ End Function
+
+ Private Sub CsvWindowV_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
+ ' Carico e imposto posizione finestra
+ WinPosFromIniToWindow(S_DOORS, K_MTABLEWINPLACE, Me)
+ End Sub
+
+ Private Sub CsvWindowV_Unloaded(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles Me.Closing
+ ' Salvo posizione finestra
+ WinPosFromWindowToIni(Me, S_DOORS, K_MTABLEWINPLACE)
+ End Sub
+
+End Class
diff --git a/MTableDb/MTableDbVM.vb b/MTableDb/MTableDbVM.vb
new file mode 100644
index 0000000..e087f6f
--- /dev/null
+++ b/MTableDb/MTableDbVM.vb
@@ -0,0 +1,1691 @@
+Imports System.Collections.ObjectModel
+Imports System.ComponentModel
+Imports System.IO
+Imports EgtUILib
+Imports System.Text.RegularExpressions
+
+Public Class MTableDbVM
+ Inherits VMBase
+
+ Private Shared m_refMTableDbVM As MTableDbVM
+ Public Shared ReadOnly Property refMTableDbVM As MTableDbVM
+ Get
+ Return m_refMTableDbVM
+ End Get
+ End Property
+ Friend Function SetRefMTableDbVM(MTableDbVM As MTableDbVM) As Boolean
+ m_refMTableDbVM = MTableDbVM
+ Return Not IsNothing(m_refMTableDbVM)
+ End Function
+
+ Private m_sPreviousActiveMachine As String
+
+ Private m_TablesList As New ObservableCollection(Of MTableListBoxItem)
+ Public Property TablesList As ObservableCollection(Of MTableListBoxItem)
+ Get
+ Return m_TablesList
+ End Get
+ Set(value As ObservableCollection(Of MTableListBoxItem))
+ m_TablesList = value
+ End Set
+ End Property
+
+ Private m_TextToSearch As String
+ Public Property TextToSearch As String
+ Get
+ Return m_TextToSearch
+ End Get
+ Set(value As String)
+ If value <> m_TextToSearch Then
+ If Not String.IsNullOrWhiteSpace(value) Then
+ Dim SelectedMTable As MTableListBoxItem = Nothing
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ SelectedMTable = m_TablesList(TableIndex)
+ End If
+ Next
+ If Not IsNothing(SelectedMTable) Then
+ SearchText(value, SelectedMTable)
+ IsEnabledResetSearch = True
+ End If
+ SearchText(value, SelectedMTable)
+ IsEnabledResetSearch = True
+ Else
+ ResetSearchedRow()
+ IsEnabledResetSearch = False
+ End If
+ m_TextToSearch = value
+ NotifyPropertyChanged("TextToSearch")
+ End If
+ End Set
+ End Property
+
+ Private m_IsEnabledResetSearch As Boolean
+ Public Property IsEnabledResetSearch As Boolean
+ Get
+ Return m_IsEnabledResetSearch
+ End Get
+ Set(value As Boolean)
+ If value <> m_IsEnabledResetSearch Then
+ m_IsEnabledResetSearch = value
+ NotifyPropertyChanged("IsEnabledResetSearch")
+ End If
+ End Set
+ End Property
+
+ Private m_FocusSearchTextState As Boolean
+ Public Property FocusSearchTextState As Boolean
+ Get
+ Return m_FocusSearchTextState
+ End Get
+ Set(value As Boolean)
+ m_FocusSearchTextState = value
+ NotifyPropertyChanged("FocusSearchTextState")
+ End Set
+ End Property
+
+ Private m_MoveRowUp_IsEnabled As Boolean
+ Public Property MoveRowUp_IsEnabled As Boolean
+ Get
+ Return m_MoveRowUp_IsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_MoveRowUp_IsEnabled Then
+ m_MoveRowUp_IsEnabled = value
+ NotifyPropertyChanged("MoveRowUp_IsEnabled")
+ End If
+ End Set
+ End Property
+
+ Private m_MoveRowDown_IsEnabled As Boolean
+ Public Property MoveRowDown_IsEnabled As Boolean
+ Get
+ Return m_MoveRowDown_IsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_MoveRowDown_IsEnabled Then
+ m_MoveRowDown_IsEnabled = value
+ NotifyPropertyChanged("MoveRowDown_IsEnabled")
+ End If
+ End Set
+ End Property
+
+ Private m_Group_IsEnabled As Boolean
+ Public Property Group_IsEnabled As Boolean
+ Get
+ Return m_Group_IsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_Group_IsEnabled Then
+ m_Group_IsEnabled = value
+ NotifyPropertyChanged("Group_IsEnabled")
+ End If
+ End Set
+ End Property
+
+ Private m_Position_IsEnabled As Boolean
+ Public Property Position_IsEnabled As Boolean
+ Get
+ Return m_Position_IsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_Position_IsEnabled Then
+ m_Position_IsEnabled = value
+ NotifyPropertyChanged("Position_IsEnabled")
+ End If
+ End Set
+ End Property
+
+#Region "Messages"
+
+ Public ReadOnly Property Title As String
+ Get
+ Return EgtMsg(MSG_MAINWINDOW + 20)
+ End Get
+ End Property
+
+ Public ReadOnly Property MachListHeader As String
+ Get
+ Return EgtMsg(MSG_DOORS + 8)
+ End Get
+ End Property
+
+ Public ReadOnly Property MachineNameTxBl As String
+ Get
+ Return EgtMsg(MSG_DOORS + 9)
+ End Get
+ End Property
+
+ Public ReadOnly Property NcGenerateTxBl As String
+ Get
+ Return EgtMsg(MSG_DOORS + 10)
+ End Get
+ End Property
+
+ Public ReadOnly Property MakeRawTxBl As String
+ Get
+ Return EgtMsg(MSG_DOORS + 11)
+ End Get
+ End Property
+
+ Public ReadOnly Property OnHdr As String
+ Get
+ Return EgtMsg(MSG_DOORS + 12)
+ End Get
+ End Property
+
+ Public ReadOnly Property GeomNameHdr As String
+ Get
+ Return EgtMsg(MSG_DOORS + 13)
+ End Get
+ End Property
+
+ Public ReadOnly Property OperationHdr As String
+ Get
+ Return EgtMsg(MSG_DOORS + 14)
+ End Get
+ End Property
+
+ Public ReadOnly Property MIdHdr As String
+ Get
+ Return EgtMsg(MSG_DOORS + 15)
+ End Get
+ End Property
+
+ Public ReadOnly Property ShiftHdr As String
+ Get
+ Return EgtMsg(MSG_DOORS + 16)
+ End Get
+ End Property
+
+ Public ReadOnly Property MachTypeHdr As String
+ Get
+ Return EgtMsg(MSG_DOORS + 17)
+ End Get
+ End Property
+
+ Public ReadOnly Property MachHdr As String
+ Get
+ Return EgtMsg(MSG_DOORS + 18)
+ End Get
+ End Property
+
+ Public ReadOnly Property MachUpHdr As String
+ Get
+ Return EgtMsg(MSG_DOORS + 19)
+ End Get
+ End Property
+
+ Public ReadOnly Property MachDownHdr As String
+ Get
+ Return EgtMsg(MSG_DOORS + 20)
+ End Get
+ End Property
+
+ Public ReadOnly Property AddMachBtn As String
+ Get
+ Return EgtMsg(MSG_DOORS + 21)
+ End Get
+ End Property
+
+ Public ReadOnly Property RemoveMachBtn As String
+ Get
+ Return EgtMsg(MSG_DOORS + 22)
+ End Get
+ End Property
+
+ Public ReadOnly Property AddMachiningBtn As String
+ Get
+ Return EgtMsg(MSG_DOORS + 23)
+ End Get
+ End Property
+
+ Public ReadOnly Property RemoveMachiningBtn As String
+ Get
+ Return EgtMsg(MSG_DOORS + 24)
+ End Get
+ End Property
+
+ Public ReadOnly Property CurrMsg As String
+ Get
+ Return EgtMsg(MSG_DOORS + 25)
+ End Get
+ End Property
+
+#End Region ' Messages
+
+#Region "ToolTip"
+
+ 'Proprietà ToolTip
+ Public ReadOnly Property NewTableToolTip As String
+ Get
+ Return EgtMsg(MSG_DOORS + 1)
+ End Get
+ End Property
+ Public ReadOnly Property SaveTableToolTip As String
+ Get
+ Return EgtMsg(MSG_DOORS + 2)
+ End Get
+ End Property
+ Public ReadOnly Property SaveAsTableToolTip As String
+ Get
+ Return EgtMsg(MSG_DOORS + 3)
+ End Get
+ End Property
+ Public ReadOnly Property RemoveTableToolTip As String
+ Get
+ Return EgtMsg(MSG_DOORS + 4)
+ End Get
+ End Property
+ Public ReadOnly Property SetActiveTableToolTip As String
+ Get
+ Return EgtMsg(MSG_DOORS + 26)
+ End Get
+ End Property
+
+#End Region ' ToolTip
+
+ ' Definizione comandi
+ Private m_cmdNewTable As ICommand
+ Private m_cmdSaveTable As ICommand
+ Private m_cmdSaveTableAs As ICommand
+ Private m_cmdRemoveTable As ICommand
+ Private m_cmdSetActiveTable As ICommand
+ Private m_cmdResetSearch As ICommand
+ Private m_cmdSearchPrevious As ICommand
+ Private m_cmdSearchNext As ICommand
+ Private m_cmdFocusSearch As ICommand
+ Private m_cmdAddMach As ICommand
+ Private m_cmdRemoveMach As ICommand
+ Private m_cmdAddRow As ICommand
+ Private m_cmdRemoveRow As ICommand
+ Private m_cmdMoveRowUp As ICommand
+ Private m_cmdMoveRowDown As ICommand
+ Private m_cmdGroup As ICommand
+ Private m_cmdPosition As ICommand
+ Private m_cmdCloseMTableWindow As ICommand
+
+#Region "CONSTRUCTOR"
+
+ Sub New()
+ ' Creo riferimento a questa classe
+ SetRefMTableDbVM(Me)
+ ' Passo all'item della lista il delegato alla funzuione che permette di cancellare una lavorazione
+ MTableListBoxItem.m_delSaveMTable = AddressOf SaveTable
+ MTableMachineListBoxItem.m_delCloseMTableWnd = AddressOf CloseWindow
+ MTableListBoxItem.m_delCloseMTableWnd = AddressOf CloseWindow
+ MTableAssociationGridBoxItem.m_delCloseMTableWnd = AddressOf CloseWindow
+ MTableListBoxItem.m_delSearchInMTable = AddressOf SearchInNewlySelectedMTable
+ ' recupero macchina corrente all'apertura della finestra per poterla ripristinare alla fine
+ EgtGetCurrMachineName(m_sPreviousActiveMachine)
+ MTableListBoxItem.NewMTableIndex = 0
+ UpdateTables()
+ Dim bActiveMTableFound As Boolean = False
+ For Index = 0 To m_TablesList.Count - 1
+ If m_TablesList(Index).ActiveTable Then
+ m_TablesList(Index).IsSelected = True
+ m_TablesList(Index).SelMachine = m_TablesList(Index).ActiveMachinesList(0)
+ bActiveMTableFound = True
+ Exit For
+ End If
+ Next
+ If EgtVerifyMachinesDir() AndAlso Not bActiveMTableFound AndAlso m_TablesList.Count > 0 Then
+ m_TablesList(0).IsSelected = True
+ m_TablesList(0).SelMachine = m_TablesList(0).ActiveMachinesList(0)
+ End If
+ End Sub
+
+#End Region
+
+#Region "METHODS"
+
+ Private Sub UpdateTables()
+ m_TablesList.Clear()
+ ' se trovo la cartella carico la lista di tabelle
+ Dim FileTableList As ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles(IniFile.m_sTablesRoot)
+ For Index As Integer = 0 To FileTableList.Count - 1
+ If Path.GetExtension(FileTableList(Index)).ToLower = ".mtl" Then
+ m_TablesList.Add(New MTableListBoxItem(Path.GetFileNameWithoutExtension(FileTableList(Index)), FileTableList(Index)))
+ VerifyNewName(Path.GetFileNameWithoutExtension(FileTableList(Index)))
+ End If
+ Next
+ SetActiveTable()
+ End Sub
+
+ Private Sub VerifyNewName(sNewName As String)
+ Dim sNameIndex As String = Regex.Match(sNewName, "MTable_(\d+)").Groups(1).Value
+ Dim nNameIndex As Integer = 0
+ If Not String.IsNullOrEmpty(sNameIndex) Then
+ Integer.TryParse(sNameIndex, nNameIndex)
+ End If
+ If nNameIndex > MTableListBoxItem.NewMTableIndex Then
+ MTableListBoxItem.NewMTableIndex = nNameIndex
+ End If
+ End Sub
+
+ Private Const MTABLENAME As String = "MTableName"
+ Private Const MTNAME As String = "MTName"
+
+ Private Sub SetActiveTable()
+ Dim ActiveMTableName As String = String.Empty
+ GetPrivateProfileString(S_DOORS, K_CURRMTABLE, "", ActiveMTableName)
+ 'Dim ActiveMTableFilePath As String = Path.GetDirectoryName(IniFile.m_sTablesRoot) & "\CurrMTable.lua"
+ 'If File.Exists(ActiveMTableFilePath) Then
+ ' Dim ReadFile As String() = File.ReadAllLines(ActiveMTableFilePath)
+ ' For LineIndex As Integer = 0 To ReadFile.Count - 1
+ ' If ReadFile(LineIndex).Contains(MTABLENAME) Then
+ ' ActiveMTableName = TableUtility.SearchKey(ReadFile(LineIndex), MTNAME)
+ ' Exit For
+ ' End If
+ ' Next
+ For Index As Integer = 0 To m_TablesList.Count - 1
+ If m_TablesList(Index).TableName = ActiveMTableName Then
+ m_TablesList(Index).ActiveTable = True
+ Exit For
+ End If
+ Next
+ 'End If
+ End Sub
+
+ Private Sub SearchText(sText As String, SelectedMTable As MTableListBoxItem)
+ Dim bFirst As Boolean = True
+ For AssociationIndex = 0 To SelectedMTable.AssociationList.Count - 1
+ Dim CurrAssociation As MTableAssociationGridBoxItem = SelectedMTable.AssociationList(AssociationIndex)
+ If CurrAssociation.Name.ToLower.Contains(sText) Then
+ If bFirst Then
+ CurrAssociation.IsSelected = True
+ bFirst = False
+ End If
+ CurrAssociation.IsValidForSearch = True
+ Else
+ CurrAssociation.IsValidForSearch = False
+ End If
+ Next
+ End Sub
+
+ Private Sub SearchInNewlySelectedMTable(SelectedMTable As MTableListBoxItem)
+ If Not String.IsNullOrWhiteSpace(m_TextToSearch) Then
+ SearchText(m_TextToSearch, SelectedMTable)
+ IsEnabledResetSearch = True
+ End If
+ End Sub
+
+#Region "SelectRow"
+
+ Friend Sub LeftSelect(SelectedRow As MTableMachiningGridBoxItem)
+ ' se è già selezionato, lo deseleziono
+ If SelectedRow.IsSelected Then
+ ' verifico se è in mezzo a due gruppi selezionati
+ Dim bIsPrevSel As Boolean = False
+ Dim bIsNextSel As Boolean = False
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ ' trovo posizione dell'elemento selezionato
+ Dim nSelItemIndex As Integer = m_TablesList(TableIndex).SelMachine.MachiningList.IndexOf(SelectedRow)
+ ' cerco il primo precedente non dello stesso gruppo
+ For MachiningIndex = nSelItemIndex - 1 To 0 Step -1
+ Dim CurrMachining As MTableMachiningGridBoxItem = m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.GroupId <> SelectedRow.GroupId Then
+ bIsPrevSel = CurrMachining.IsSelected
+ Exit For
+ End If
+ Next
+ ' verifico se i successivi sono dello stesso gruppo
+ For MachiningIndex = nSelItemIndex + 1 To m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.GroupId <> SelectedRow.GroupId Then
+ bIsNextSel = CurrMachining.IsSelected
+ Exit For
+ End If
+ Next
+ Exit For
+ End If
+ Next
+ If bIsPrevSel And bIsNextSel Then Return
+ SelectGroup(SelectedRow)
+ ' verifico cosa è rimasto selezionato e gestisco di conseguenza i bottoni
+ VerifyDeselection()
+ Return
+ End If
+ ' verifico se ci sono elementi già selezionati
+ Dim bFirstIsGroup As Boolean = False
+ Dim bLastIsGroup As Boolean = False
+ Dim bZeroItemFound As Boolean = False
+ Dim bItemFound As Boolean = False
+ Dim nSelFirstGroupId As Integer = -1
+ Dim nSelLastGroupId As Integer = -1
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ For MachiningIndex = 0 To m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.IsSelected Then
+ If CurrMachining.GroupId = 0 Then
+ ' se cerco di selezionare un secondo elemento di gruppo zero, esco
+ If SelectedRow.GroupId = 0 Then
+ Return
+ Else
+ bZeroItemFound = True
+ End If
+ Else
+ ' se ci sono già un elemento con gruppo zero ed un gruppo ordinato selezionati, esco
+ If bZeroItemFound Then
+ Return
+ End If
+ If nSelFirstGroupId = -1 Then
+ ' se c'è già un altro gruppo ordinato selezionato
+ nSelFirstGroupId = CurrMachining.GroupId
+ nSelLastGroupId = CurrMachining.GroupId
+ bItemFound = True
+ ' verifico se sono selezionati gruppi o singole lavorazioni
+ If MachiningIndex >= 1 Then
+ If m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex - 1).GroupId <> CurrMachining.GroupId Then
+ bFirstIsGroup = True
+ End If
+ Else
+ bFirstIsGroup = True
+ End If
+ If MachiningIndex < m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1 Then
+ If m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex + 1).GroupId <> CurrMachining.GroupId Then
+ bLastIsGroup = True
+ End If
+ Else
+ bLastIsGroup = True
+ End If
+ ElseIf CurrMachining.GroupId = nSelLastGroupId Or (CurrMachining.GroupId = nSelLastGroupId + 1 And CurrMachining.IsSelected) Then
+ ' se il successivo ha lo stesso gruppo, o il gruppo successivo ed è selezionato
+ nSelLastGroupId = CurrMachining.GroupId
+ ' verifico se sono selezionati gruppi o singole lavorazioni
+ If MachiningIndex = m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1 Then
+ bLastIsGroup = True
+ ElseIf m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex + 1).GroupId <> CurrMachining.GroupId Then
+ bLastIsGroup = True
+ End If
+ End If
+ End If
+ End If
+ Next
+ Exit For
+ End If
+ Next
+ ' se ho trovato un elemento
+ If bItemFound Then
+ ' se non è adiacente e ( non ha gruppo zero e indice inizio e fine selezione coincidono) e indice di inizio e fine non sono gruppi, esco
+ If (Not (SelectedRow.GroupId <> 0 And (nSelFirstGroupId - 1 = SelectedRow.GroupId Or nSelLastGroupId + 1 = SelectedRow.GroupId)) And
+ Not (SelectedRow.GroupId = 0 And nSelFirstGroupId = nSelLastGroupId)) Or
+ Not (bFirstIsGroup And bLastIsGroup And nSelFirstGroupId <> -1) Then
+ Return
+ End If
+ End If
+ ' procedo con la selezione dell'elemento
+ SelectGroup(SelectedRow)
+ ' gestisco bottoni
+ ' se ho selezionato un gruppo 0 e c'è un gruppo già selezionato
+ If SelectedRow.GroupId = 0 And nSelFirstGroupId = nSelLastGroupId And bItemFound Then
+ ManageMachiningButtons(True, False, False)
+ ElseIf SelectedRow.GroupId <> 0 And nSelFirstGroupId = nSelLastGroupId And bZeroItemFound Then
+ ManageMachiningButtons(True, False, False)
+ ElseIf SelectedRow.GroupId <> 0 And bItemFound Then
+ ManageMachiningButtons(False, True, False)
+ ElseIf SelectedRow.GroupId <> 0 And Not bItemFound Then
+ ManageMachiningButtons(False, False, True)
+ Else
+ ManageMachiningButtons(False, False, False)
+ End If
+ End Sub
+
+ Private Sub VerifyDeselection()
+ ' verifico se ci sono elementi già selezionati
+ Dim bFirstIsGroup As Boolean = False
+ Dim bLastIsGroup As Boolean = False
+ Dim bZeroItemFound As Boolean = False
+ Dim bItemFound As Boolean = False
+ Dim nSelFirstGroupId As Integer = -1
+ Dim nSelLastGroupId As Integer = -1
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ For MachiningIndex = 0 To m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.IsSelected Then
+ If CurrMachining.GroupId = 0 Then
+ bZeroItemFound = True
+ Else
+ If nSelFirstGroupId = -1 Then
+ nSelFirstGroupId = CurrMachining.GroupId
+ nSelLastGroupId = CurrMachining.GroupId
+ bItemFound = True
+ ' verifico se sono selezionati gruppi o singole lavorazioni
+ If MachiningIndex >= 1 Then
+ If m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex - 1).GroupId <> CurrMachining.GroupId Then
+ bFirstIsGroup = True
+ End If
+ Else
+ bFirstIsGroup = True
+ End If
+ If MachiningIndex < m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1 Then
+ If m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex + 1).GroupId <> CurrMachining.GroupId Then
+ bLastIsGroup = True
+ End If
+ Else
+ bLastIsGroup = True
+ End If
+ ElseIf CurrMachining.GroupId = nSelLastGroupId Or (CurrMachining.GroupId = nSelLastGroupId + 1 And CurrMachining.IsSelected) Then
+ ' se il successivo ha lo stesso gruppo, o il gruppo successivo ed è selezionato
+ nSelLastGroupId = CurrMachining.GroupId
+ ' verifico se sono selezionati gruppi o singole lavorazioni
+ If m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1 = MachiningIndex OrElse m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex + 1).GroupId <> CurrMachining.GroupId Then
+ bLastIsGroup = True
+ End If
+ End If
+ End If
+ End If
+ Next
+ Exit For
+ End If
+ Next
+ ' gestisco bottoni
+ ' se ho selezionato un gruppo 0 e c'è un gruppo già selezionato
+ If bItemFound And nSelFirstGroupId = nSelLastGroupId Then
+ ManageMachiningButtons(False, False, True)
+ Else
+ ManageMachiningButtons(False, False, False)
+ End If
+
+ End Sub
+
+ Private Sub SelectGroup(SelectedRow As MTableMachiningGridBoxItem)
+ If IsNothing(SelectedRow) Then Return
+ ' seleziono l'elemento cliccato
+ SelectedRow.IsSelected = Not SelectedRow.IsSelected
+ ' se il gruppo è zero non seleziono le altre righe
+ If SelectedRow.GroupId = 0 Then Return
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ ' trovo posizione dell'elemento selezionato
+ Dim nSelItemIndex As Integer = m_TablesList(TableIndex).SelMachine.MachiningList.IndexOf(SelectedRow)
+ ' verifico se i precedenti sono dello stesso gruppo
+ For MachiningIndex = nSelItemIndex - 1 To 0 Step -1
+ Dim CurrMachining As MTableMachiningGridBoxItem = m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.GroupId = SelectedRow.GroupId Then
+ CurrMachining.IsSelected = SelectedRow.IsSelected
+ Else
+ Exit For
+ End If
+ Next
+ ' verifico se i successivi sono dello stesso gruppo
+ For MachiningIndex = nSelItemIndex + 1 To m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.GroupId = SelectedRow.GroupId Then
+ CurrMachining.IsSelected = SelectedRow.IsSelected
+ Else
+ Exit For
+ End If
+ Next
+ Exit For
+ End If
+ Next
+ End Sub
+
+ Friend Sub RightSelect(SelectedRow As MTableMachiningGridBoxItem)
+ ' deseleziono tutto
+ ResetSelection()
+ ' seleziono la lavorazione clickata
+ SelectedRow.IsSelected = True
+ ' attivo solo tasti di movimento
+ ManageMachiningButtons(False, False, True)
+ End Sub
+
+ Private Sub ResetSelection()
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ For MachiningIndex = 0 To m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = m_TablesList(TableIndex).SelMachine.MachiningList(MachiningIndex)
+ CurrMachining.IsSelected = False
+ Next
+ Exit For
+ End If
+ Next
+ End Sub
+
+#End Region ' SelectGroupCommand
+
+ Private Sub ManageMachiningButtons(bPosition As Boolean, bGroup As Boolean, bMove As Boolean)
+ Position_IsEnabled = bPosition
+ Group_IsEnabled = bGroup
+ MoveRowDown_IsEnabled = bMove
+ MoveRowUp_IsEnabled = bMove
+ End Sub
+
+#End Region
+
+#Region "COMMANDS"
+
+#Region "NewTableCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property NewTableCommand As ICommand
+ Get
+ If m_cmdNewTable Is Nothing Then
+ m_cmdNewTable = New Command(AddressOf NewTable)
+ End If
+ Return m_cmdNewTable
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub NewTable(param As Object)
+ Dim NewMTable As MTableListBoxItem = New MTableListBoxItem("MTable_" & (MTableListBoxItem.NewMTableIndex + 1).ToString, String.Empty)
+ m_TablesList.Add(NewMTable)
+ MTableListBoxItem.NewMTableIndex += 1
+ If Not IsNothing(param) Then
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ SelectedMTable.IsSelected = False
+ End If
+ NewMTable.IsSelected = True
+ End Sub
+
+#End Region ' NewTableCommand
+
+#Region "SaveTableCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property SaveTableCommand As ICommand
+ Get
+ If m_cmdSaveTable Is Nothing Then
+ m_cmdSaveTable = New Command(AddressOf SaveTable)
+ End If
+ Return m_cmdSaveTable
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub SaveTable(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If IsNothing(SelectedMTable) Then Return
+ If String.IsNullOrEmpty(SelectedMTable.TableNamePath) Then
+ SaveTableAs(SelectedMTable)
+ Else
+ ' verifico di essere collegato alla cartella doors
+ If Not VerifyDoorsDir() Then
+ CloseWindow()
+ Return
+ End If
+ TableUtility.WriteDoorTable(SelectedMTable, SelectedMTable.TableNamePath)
+ SelectedMTable.IsModifiedReset()
+ End If
+ End Sub
+
+#End Region ' SaveTableCommand
+
+#Region "SaveTableAsCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property SaveTableAsCommand As ICommand
+ Get
+ If m_cmdSaveTableAs Is Nothing Then
+ m_cmdSaveTableAs = New Command(AddressOf SaveTableAs)
+ End If
+ Return m_cmdSaveTableAs
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub SaveTableAs(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If IsNothing(SelectedMTable) Then Return
+ ' verifico di essere collegato alla cartella doors
+ If Not VerifyDoorsDir() Then
+ CloseWindow()
+ Return
+ End If
+ Dim sFile As String = String.Empty
+ If SaveTableAsDialog(sFile, SelectedMTable.TableName) Then
+ SelectedMTable.IsModifiedReset()
+ VerifyNewName(Path.GetFileNameWithoutExtension(sFile))
+ TableUtility.WriteDoorTable(SelectedMTable, sFile)
+ UpdateTables()
+ ' seleziono la tabella appena salvata
+ For Index As Integer = 0 To m_TablesList.Count - 1
+ If m_TablesList(Index).TableNamePath = sFile Then
+ m_TablesList(Index).IsSelected = True
+ End If
+ Next
+ End If
+ End Sub
+
+ Public Function SaveTableAsDialog(ByRef sPath As String, sTableName As String) As Boolean
+ ' Direttorio corrente per MTable
+ Dim sDir As String = IniFile.m_sTablesRoot
+ ' Apertura dialogo di scelta file DDF
+ Dim SaveFileDialogView As New EgtWPFLib5.EgtSaveFileDialog
+ SaveFileDialogView.Title = EgtMsg(MSG_DOORS + 5)
+ SaveFileDialogView.Extension = ".mtl"
+ SaveFileDialogView.Directory = sDir
+ SaveFileDialogView.FileName = sTableName
+ If Not SaveFileDialogView.EgtShowDialog Then
+ Return False
+ End If
+ sPath = SaveFileDialogView.FileName
+ Return True
+ End Function
+
+#End Region ' SaveTableAsCommand
+
+#Region "RemoveTableCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property RemoveTableCommand As ICommand
+ Get
+ If m_cmdRemoveTable Is Nothing Then
+ m_cmdRemoveTable = New Command(AddressOf RemoveTable)
+ End If
+ Return m_cmdRemoveTable
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub RemoveTable(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If IsNothing(SelectedMTable) Then Return
+ ' verifico di essere collegato alla cartella doors
+ If Not VerifyDoorsDir() Then
+ CloseWindow()
+ Return
+ End If
+ ' cancello tutte le tavole nella lista impostate su non visibili (quelle rimaste quando viene creata una nuova tabella e passando ad un altra non la si salva)
+ Dim Index As Integer = m_TablesList.Count - 1
+ While Index >= 0
+ If m_TablesList(Index).Visibility <> Visibility.Visible Then
+ m_TablesList.RemoveAt(Index)
+ End If
+ Index -= 1
+ End While
+ ' verifico se la tabella selezionata è quella attiva
+ If SelectedMTable.ActiveTable Then
+ MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 8) & vbCrLf & EgtMsg(MSG_DOORSERRORS + 9), "", MessageBoxButton.OK, MessageBoxImage.Stop)
+ Exit Sub
+ End If
+ ' chiedo conferma prima di cancellare la tabella
+ If MessageBox.Show(EgtMsg(MSG_DOORS + 6), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then
+ If Not String.IsNullOrEmpty(SelectedMTable.TableNamePath) Then
+ File.Delete(SelectedMTable.TableNamePath)
+ End If
+ Dim SelectedTableIndex As Integer = m_TablesList.IndexOf(SelectedMTable)
+ m_TablesList.RemoveAt(SelectedTableIndex)
+ If SelectedTableIndex > 0 Then
+ TablesList(SelectedTableIndex - 1).IsSelected = True
+ End If
+ End If
+ End Sub
+
+#End Region ' RemoveTableCommand
+
+#Region "SetActiveTableCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property SetActiveTableCommand As ICommand
+ Get
+ If m_cmdSetActiveTable Is Nothing Then
+ m_cmdSetActiveTable = New Command(AddressOf SetActiveTable)
+ End If
+ Return m_cmdSetActiveTable
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub SetActiveTable(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If IsNothing(SelectedMTable) Then Return
+ If WritePrivateProfileString(S_DOORS, K_CURRMTABLE, SelectedMTable.TableName) Then
+ For Index As Integer = 0 To m_TablesList.Count - 1
+ If m_TablesList(Index).TableName = SelectedMTable.TableName Then
+ m_TablesList(Index).ActiveTable = True
+ Else
+ m_TablesList(Index).ActiveTable = False
+ End If
+ Next
+ End If
+ '' Scrivo il file di configurazione con il nome di questa tavola
+ 'Dim FileContent As String() = File.ReadAllLines(Path.GetDirectoryName(IniFile.m_sTablesRoot) & "\" & CURRMTABLE_FILE)
+ 'Dim NewTableFileContent As New List(Of String)
+ 'For LineIndex As Integer = 0 To FileContent.Count - 1
+ ' Dim sCurrLine As String = FileContent(LineIndex)
+ ' sCurrLine = sCurrLine.Replace(TableUtility.DATETIME, System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"))
+ ' sCurrLine = sCurrLine.Replace(TableUtility.TABLENAME, SelectedMTable.TableName)
+ ' NewTableFileContent.Add(sCurrLine)
+ 'Next
+ 'File.WriteAllLines(Path.ChangeExtension(Path.GetDirectoryName(IniFile.m_sTablesRoot) & "\" & CURRMTABLE_FILE, ".lua"), NewTableFileContent, Text.Encoding.UTF8)
+
+ End Sub
+
+#End Region ' SetActiveTableCommand
+
+#Region "ResetSearchCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property ResetSearchCommand As ICommand
+ Get
+ If m_cmdResetSearch Is Nothing Then
+ m_cmdResetSearch = New Command(AddressOf ResetSearch)
+ End If
+ Return m_cmdResetSearch
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub ResetSearch()
+ TextToSearch = String.Empty
+ End Sub
+
+ Public Sub ResetSearchedRow()
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ For AssociationIndex = 0 To m_TablesList(TableIndex).AssociationList.Count - 1
+ Dim CurrAssociation As MTableAssociationGridBoxItem = m_TablesList(TableIndex).AssociationList(AssociationIndex)
+ CurrAssociation.IsValidForSearch = False
+ Next
+ Exit For
+ End If
+ Next
+ End Sub
+
+
+#End Region ' ResetSearchCommand
+
+#Region "SearchPreviousCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property SearchPreviousCommand As ICommand
+ Get
+ If m_cmdSearchPrevious Is Nothing Then
+ m_cmdSearchPrevious = New Command(AddressOf SearchPrevious)
+ End If
+ Return m_cmdSearchPrevious
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub SearchPrevious()
+ If String.IsNullOrWhiteSpace(m_TextToSearch) Then
+ Return
+ End If
+ Dim bFound As Boolean = False
+ Dim LastSearchedRow As MTableAssociationGridBoxItem = Nothing
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ For AssociationIndex = 0 To m_TablesList(TableIndex).AssociationList.Count - 1
+ Dim CurrAssociation As MTableAssociationGridBoxItem = m_TablesList(TableIndex).AssociationList(AssociationIndex)
+ If CurrAssociation.IsSelected Then
+ If Not IsNothing(LastSearchedRow) Then
+ LastSearchedRow.IsSelected = True
+ End If
+ Return
+ End If
+ If CurrAssociation.IsValidForSearch Then
+ LastSearchedRow = CurrAssociation
+ End If
+ Next
+ Exit For
+ End If
+ Next
+ End Sub
+
+#End Region ' SearchPreviousCommand
+
+#Region "SearchNextCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property SearchNextCommand As ICommand
+ Get
+ If m_cmdSearchNext Is Nothing Then
+ m_cmdSearchNext = New Command(AddressOf SearchNext)
+ End If
+ Return m_cmdSearchNext
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub SearchNext()
+ If String.IsNullOrWhiteSpace(m_TextToSearch) Then
+ Return
+ End If
+ Dim bFound As Boolean = False
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ For AssociationIndex = 0 To m_TablesList(TableIndex).AssociationList.Count - 1
+ Dim CurrAssociation As MTableAssociationGridBoxItem = m_TablesList(TableIndex).AssociationList(AssociationIndex)
+ If bFound AndAlso CurrAssociation.IsValidForSearch Then
+ CurrAssociation.IsSelected = True
+ Return
+ End If
+ If CurrAssociation.IsSelected Then
+ bFound = True
+ End If
+ Next
+ Exit For
+ End If
+ Next
+ End Sub
+
+#End Region ' SearchNextCommand
+
+#Region "FocusSearchCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property FocusSearchCommand As ICommand
+ Get
+ If m_cmdFocusSearch Is Nothing Then
+ m_cmdFocusSearch = New Command(AddressOf FocusSearch)
+ End If
+ Return m_cmdFocusSearch
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub FocusSearch()
+ FocusSearchTextState = Not m_FocusSearchTextState
+ End Sub
+
+#End Region ' FocusSearchCommand
+
+#Region "AddMachCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property AddMachCommand As ICommand
+ Get
+ If m_cmdAddMach Is Nothing Then
+ m_cmdAddMach = New Command(AddressOf AddMach)
+ End If
+ Return m_cmdAddMach
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub AddMach(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If IsNothing(SelectedMTable) Then Return
+ SelectedMTable.SharedMachIndex += 1
+ SelectedMTable.ActiveMachinesList.Add(New MTableMachineListBoxItem(String.Empty, False, False, SelectedMTable.SharedMachIndex))
+ SelectedMTable.MachIdList.Add(SelectedMTable.SharedMachIndex)
+ End Sub
+
+#End Region ' AddMachCommand
+
+#Region "RemoveMachCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property RemoveMachCommand As ICommand
+ Get
+ If m_cmdRemoveMach Is Nothing Then
+ m_cmdRemoveMach = New Command(AddressOf RemoveMach)
+ End If
+ Return m_cmdRemoveMach
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub RemoveMach(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If Not IsNothing(SelectedMTable) AndAlso SelectedMTable.ActiveMachinesList.Count > 1 Then
+ ' Chiedo conferma cancellazione associazione macchina
+ If MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 12), EgtMsg(MSG_DOORSERRORS + 11), MessageBoxButton.YesNo, MessageBoxImage.Question) <> MessageBoxResult.Yes Then
+ Return
+ End If
+ SelectedMTable.ActiveMachinesList.RemoveAt(SelectedMTable.SharedMachIndex - 1)
+ SelectedMTable.MachIdList.RemoveAt(SelectedMTable.SharedMachIndex - 1)
+ SelectedMTable.SharedMachIndex -= 1
+ End If
+ End Sub
+
+#End Region ' RemoveMachCommand
+
+#Region "AddRowCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property AddRowCommand As ICommand
+ Get
+ If m_cmdAddRow Is Nothing Then
+ m_cmdAddRow = New Command(AddressOf AddRow)
+ End If
+ Return m_cmdAddRow
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub AddRow(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If Not IsNothing(SelectedMTable) AndAlso Not IsNothing(SelectedMTable.SelectedAssociation) Then
+ Dim SelectedIndex As Integer = SelectedMTable.AssociationList.IndexOf(SelectedMTable.SelectedAssociation)
+ Dim NewEmptyRow As MTableAssociationGridBoxItem = New MTableAssociationGridBoxItem(False, String.Empty, 1, 0, String.Empty, Nothing, String.Empty, Nothing, String.Empty, Nothing, String.Empty, SelectedMTable.ActiveMachinesList, SelectedMTable.AssociationList)
+ SelectedMTable.AssociationList.Insert(SelectedIndex + 1, NewEmptyRow)
+ SelectedMTable.SelectedAssociation = NewEmptyRow
+ SelectedMTable.NotifyPropertyChanged("SelectedAssociation")
+ End If
+ End Sub
+
+#End Region ' AddRowCommand
+
+#Region "RemoveRowCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property RemoveRowCommand As ICommand
+ Get
+ If m_cmdRemoveRow Is Nothing Then
+ m_cmdRemoveRow = New Command(AddressOf RemoveRow)
+ End If
+ Return m_cmdRemoveRow
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub RemoveRow(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If Not IsNothing(SelectedMTable) AndAlso SelectedMTable.AssociationList.Count > 1 Then
+ ' Chiedo conferma cancellazione riga di associazione
+ If MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 10), EgtMsg(MSG_DOORSERRORS + 11), MessageBoxButton.YesNo, MessageBoxImage.Question) <> MessageBoxResult.Yes Then
+ Return
+ End If
+ Dim SelectedIndex As Integer = SelectedMTable.AssociationList.IndexOf(SelectedMTable.SelectedAssociation)
+ ' rimuovo Item associati dalla lisa lavorazioni ordinata
+ RemoveMachItem(SelectedIndex, SelectedMTable, SelectedMTable.AssociationList(SelectedIndex).RefMachItem)
+ RemoveMachItem(SelectedIndex, SelectedMTable, SelectedMTable.AssociationList(SelectedIndex).RefMachUpItem)
+ RemoveMachItem(SelectedIndex, SelectedMTable, SelectedMTable.AssociationList(SelectedIndex).RefMachDwItem)
+ SelectedMTable.AssociationList.RemoveAt(SelectedIndex)
+ If Not SelectedIndex < SelectedMTable.AssociationList.Count Then
+ SelectedIndex = SelectedMTable.AssociationList.Count - 1
+ End If
+ SelectedMTable.SelectedAssociation = SelectedMTable.AssociationList(SelectedIndex)
+ SelectedMTable.NotifyPropertyChanged("SelectedAssociation")
+ End If
+ End Sub
+
+ Private Sub RemoveMachItem(SelectedIndex As Integer, SelectedMTable As MTableListBoxItem, RefMachItem As MTableMachiningGridBoxItem)
+ ' Se ha un Item a cui si riferisce nella lista ordinata delle lavorazioni
+ If Not IsNothing(RefMachItem) Then
+ ' verifico se viene usato anche da altre associazioni
+ For AssIndex = 0 To SelectedMTable.AssociationList.Count - 1
+ If SelectedIndex <> AssIndex And (SelectedMTable.AssociationList(AssIndex).RefMachItem Is RefMachItem Or
+ SelectedMTable.AssociationList(AssIndex).RefMachUpItem Is RefMachItem Or
+ SelectedMTable.AssociationList(AssIndex).RefMachDwItem Is RefMachItem) Then
+ Return
+ End If
+ Next
+ For MachIndex = 0 To SelectedMTable.ActiveMachinesList.Count - 1
+ If SelectedMTable.ActiveMachinesList(MachIndex).MachId = SelectedMTable.AssociationList(SelectedIndex).MachId Then
+ MTableMachiningGridBoxItem.Remove(RefMachItem, SelectedMTable.ActiveMachinesList(MachIndex).MachiningList)
+ End If
+ Next
+ End If
+ End Sub
+
+#End Region ' RemoveRowCommand
+
+#Region "MoveRowUpCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property MoveRowUpCommand As ICommand
+ Get
+ If m_cmdMoveRowUp Is Nothing Then
+ m_cmdMoveRowUp = New Command(AddressOf MoveRowUp)
+ End If
+ Return m_cmdMoveRowUp
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub MoveRowUp(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If IsNothing(SelectedMTable) Then Return
+ MoveRow(SelectedMTable, True)
+ End Sub
+
+ Private Sub MoveRow(SelectedMTable As MTableListBoxItem, bMoveUp As Boolean)
+ Dim bIsSingleSelected As Boolean = False
+ Dim bIsGroupSelected As Boolean = False
+ Dim nLastItemIndex As Integer = -1
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ Dim bFirstSelItem As Boolean = True
+ For MachiningIndex = 0 To m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.IsSelected Then
+ If bIsSingleSelected Then
+ bIsGroupSelected = True
+ Exit For
+ Else
+ bIsSingleSelected = True
+ nLastItemIndex = CurrMachining.GroupId
+ If MachiningIndex > 0 AndAlso SelectedMTable.SelMachine.MachiningList(MachiningIndex - 1).GroupId = CurrMachining.GroupId Then
+ Exit For
+ ElseIf MachiningIndex = SelectedMTable.SelMachine.MachiningList.Count - 1 Then
+ bIsGroupSelected = True
+ ElseIf SelectedMTable.SelMachine.MachiningList(MachiningIndex + 1).GroupId <> CurrMachining.GroupId Then
+ bIsGroupSelected = True
+ Exit For
+ End If
+ End If
+ Else
+ If bIsGroupSelected Then
+ Exit For
+ End If
+ End If
+ Next
+ End If
+ Next
+ For TableIndex = 0 To m_TablesList.Count - 1
+ If m_TablesList(TableIndex).IsSelected Then
+ If bMoveUp Then
+ MoveUp(TableIndex, bIsGroupSelected, SelectedMTable)
+ Else
+ MoveDown(TableIndex, bIsGroupSelected, SelectedMTable)
+ End If
+ Exit For
+ End If
+ Next
+ End Sub
+
+ Private Function CalcPrevGroup(SelectedIndex As Integer, SelMachining As MTableMachiningGridBoxItem, bIsGroupSelected As Boolean, SelectedMTable As MTableListBoxItem) As Integer
+ Dim PositionIndex As Integer = 0
+ ' cerco il primo precedente non dello stesso gruppo
+ Dim nPrevGroupIndex As Integer = -1
+ For MachiningIndex = SelectedIndex - 1 To 0 Step -1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachiningIndex)
+ If nPrevGroupIndex = -1 Then
+ If CurrMachining.GroupId <> SelMachining.GroupId Then
+ nPrevGroupIndex = CurrMachining.GroupId
+ PositionIndex += 1
+ If bIsGroupSelected Then
+ 'aumento di uno l'indice di gruppo del gruppo precedente
+ CurrMachining.GroupId += 1
+ End If
+ End If
+ Else
+ If CurrMachining.GroupId = nPrevGroupIndex Then
+ PositionIndex += 1
+ If bIsGroupSelected Then
+ 'aumento di uno l'indice di gruppo del gruppo precedente
+ CurrMachining.GroupId += 1
+ End If
+ Else
+ Exit For
+ End If
+ End If
+ Next
+ Return PositionIndex
+ End Function
+
+ Private Function CalcNextGroup(SelectedIndex As Integer, SelMachining As MTableMachiningGridBoxItem, bIsGroupSelected As Boolean, SelectedMTable As MTableListBoxItem) As Integer
+ Dim PositionIndex As Integer = 0
+ ' cerco il primo successivo non dello stesso gruppo
+ Dim nNextGroupIndex As Integer = -1
+ For MachiningIndex = SelectedIndex + 1 To SelectedMTable.SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachiningIndex)
+ If nNextGroupIndex = -1 Then
+ If CurrMachining.GroupId <> SelMachining.GroupId Then
+ nNextGroupIndex = CurrMachining.GroupId
+ PositionIndex += 1
+ If bIsGroupSelected Then
+ 'aumento di uno l'indice di gruppo del gruppo precedente
+ CurrMachining.GroupId -= 1
+ End If
+ End If
+ Else
+ If CurrMachining.GroupId = nNextGroupIndex Then
+ PositionIndex += 1
+ If bIsGroupSelected Then
+ 'aumento di uno l'indice di gruppo del gruppo precedente
+ CurrMachining.GroupId -= 1
+ End If
+ Else
+ Exit For
+ End If
+ End If
+ Next
+ Return PositionIndex
+ End Function
+
+ Private Sub MoveUp(TableIndex As Integer, bIsGroupSelected As Boolean, SelectedMTable As MTableListBoxItem)
+ Dim nFirstMovedIndex As Integer = -1
+ Dim nLastMovedIndex As Integer = -1
+ Dim bExitFromGroup As Boolean = False
+ Dim nDelta As Integer = -1
+ For MachiningIndex = 0 To m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachiningIndex)
+ ' se singola lavorazione che esce dal gruppo, incremento tutte le successive
+ If bExitFromGroup Then
+ CurrMachining.GroupId += 1
+ End If
+ If CurrMachining.IsSelected And Not bExitFromGroup Then
+ ' calcolo indice item corrente
+ Dim SelectedIndex As Integer = SelectedMTable.SelMachine.MachiningList.IndexOf(CurrMachining)
+ If SelectedIndex >= 1 AndAlso SelectedMTable.SelMachine.MachiningList(SelectedIndex - 1).GroupId > 0 Then
+ If bIsGroupSelected Then
+ ' Calcolo dimensione gruppo precedente per sapere di quante posizioni spostarlo
+ nDelta = If(nDelta = -1, CalcPrevGroup(SelectedIndex, CurrMachining, bIsGroupSelected, SelectedMTable), nDelta)
+ ' diminuisco di uno l'indice di quello selezionato
+ CurrMachining.GroupId -= 1
+ Else
+ ' assegno spostamento se singola lavorazione selezionata
+ nDelta = 1
+ ' se il precedente ha gruppo diverso
+ If SelectedMTable.SelMachine.MachiningList(SelectedIndex - 1).GroupId <> CurrMachining.GroupId Then
+ bExitFromGroup = True
+ End If
+ End If
+ If nFirstMovedIndex = -1 Then
+ nFirstMovedIndex = SelectedIndex
+ nLastMovedIndex = SelectedIndex
+ Else
+ nLastMovedIndex = SelectedIndex
+ End If
+ If Not bExitFromGroup Then SelectedMTable.SelMachine.MachiningList.Move(SelectedIndex, SelectedIndex - nDelta)
+ ElseIf SelectedIndex = 0 And Not bIsGroupSelected Then
+ nFirstMovedIndex = SelectedIndex
+ bExitFromGroup = True
+ Else
+ Return
+ End If
+ End If
+ Next
+ ' Aggiorno visualizzazione indici spostati (per converter che li nasconde)
+ For Index = nFirstMovedIndex - nDelta To nLastMovedIndex
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(Index)
+ CurrMachining.NotifyPropertyChanged("GroupId")
+ CurrMachining.NotifyPropertyChanged("PropertyPar")
+ Next
+ End Sub
+
+ Private Sub MoveDown(TableIndex As Integer, bIsGroupSelected As Boolean, SelectedMTable As MTableListBoxItem)
+ Dim nFirstMovedIndex As Integer = -1
+ Dim nLastMovedIndex As Integer = -1
+ Dim bExitFromGroup As Boolean = False
+ Dim nDelta As Integer = -1
+ For MachiningIndex = m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1 To 0 Step -1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.IsSelected And Not bExitFromGroup Then
+ ' calcolo indice item corrente
+ Dim SelectedIndex As Integer = SelectedMTable.SelMachine.MachiningList.IndexOf(CurrMachining)
+ If SelectedIndex < SelectedMTable.SelMachine.MachiningList.Count - 1 AndAlso SelectedMTable.SelMachine.MachiningList(SelectedIndex + 1).GroupId > 0 Then
+ If bIsGroupSelected Then
+ ' Calcolo dimensione gruppo precedente per sapere di quante posizioni spostarlo
+ nDelta = If(nDelta = -1, CalcNextGroup(SelectedIndex, CurrMachining, bIsGroupSelected, SelectedMTable), nDelta)
+ ' diminuisco di uno l'indice di quello selezionato
+ CurrMachining.GroupId += 1
+ Else
+ ' assegno spostamento se singola lavorazione selezionata
+ nDelta = 1
+ ' se il successivo ha gruppo diverso
+ If SelectedMTable.SelMachine.MachiningList(SelectedIndex + 1).GroupId <> CurrMachining.GroupId Then
+ bExitFromGroup = True
+ End If
+ End If
+ If nFirstMovedIndex = -1 Then
+ nFirstMovedIndex = SelectedIndex
+ nLastMovedIndex = SelectedIndex
+ Else
+ nLastMovedIndex = SelectedIndex
+ End If
+ If Not bExitFromGroup Then SelectedMTable.SelMachine.MachiningList.Move(SelectedIndex, SelectedIndex + nDelta)
+ ElseIf SelectedIndex = SelectedMTable.SelMachine.MachiningList.Count - 1 And Not bIsGroupSelected Then
+ nFirstMovedIndex = SelectedIndex
+ bExitFromGroup = True
+ Exit For
+ Else
+ Return
+ End If
+ End If
+ Next
+ ' se singola lavorazione che esce dal gruppo, incremento tutte le successive
+ If bExitFromGroup Then
+ For MachiningIndex = nFirstMovedIndex To m_TablesList(TableIndex).SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachiningIndex)
+ CurrMachining.GroupId += 1
+ Next
+ End If
+ ' Aggiorno visualizzazione indici spostati (per converter che li nasconde)
+ For Index = nFirstMovedIndex + nDelta To nLastMovedIndex Step -1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(Index)
+ CurrMachining.NotifyPropertyChanged("GroupId")
+ CurrMachining.NotifyPropertyChanged("PropertyPar")
+ Next
+ End Sub
+
+#End Region ' MoveRowUpCommand
+
+#Region "MoveRowDownCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property MoveRowDownCommand As ICommand
+ Get
+ If m_cmdMoveRowDown Is Nothing Then
+ m_cmdMoveRowDown = New Command(AddressOf MoveRowDown)
+ End If
+ Return m_cmdMoveRowDown
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub MoveRowDown(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If IsNothing(SelectedMTable) Then Return
+ MoveRow(SelectedMTable, False)
+ End Sub
+
+#End Region ' MoveRowDownCommand
+
+#Region "GroupCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property GroupCommand As ICommand
+ Get
+ If m_cmdGroup Is Nothing Then
+ m_cmdGroup = New Command(AddressOf Group)
+ End If
+ Return m_cmdGroup
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub Group(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If IsNothing(SelectedMTable) Then Return
+ Dim bGroupStarted As Boolean = False
+ Dim bGroupEnded As Boolean = False
+ Dim nGroupIndex As Integer = 0
+ Dim nFirstGroupIndex As Integer = -1
+ Dim nLastGroupIndex As Integer = -1
+ For MachIndex = 0 To SelectedMTable.SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachIndex)
+ If CurrMachining.IsSelected Then
+ If CurrMachining.GroupId = 0 Then
+ ' Bisogna posizionare le lavorazioni prima di raggrupparle
+ Return
+ End If
+ If bGroupStarted Then
+ nLastGroupIndex = SelectedMTable.SelMachine.MachiningList.IndexOf(CurrMachining)
+ CurrMachining.GroupId = nGroupIndex
+ Else
+ nFirstGroupIndex = CurrMachining.GroupId
+ nGroupIndex = CurrMachining.GroupId
+ bGroupStarted = True
+ End If
+ Else
+ If bGroupStarted And Not bGroupEnded Then
+ bGroupEnded = True
+ nLastGroupIndex = SelectedMTable.SelMachine.MachiningList.IndexOf(CurrMachining) - 1
+ nGroupIndex = CurrMachining.GroupId - nGroupIndex - 1
+ End If
+ End If
+ If bGroupEnded Then
+ CurrMachining.GroupId = CurrMachining.GroupId - nGroupIndex
+ End If
+ Next
+ ' se solo uno dei due gruppi ha una proprietà la tengo, altrimenti la cancello
+ Dim FirstGroupItem As MTableMachiningGridBoxItem = Nothing
+ Dim LastGroupItem As MTableMachiningGridBoxItem = Nothing
+ For MachiningIndex = 0 To SelectedMTable.SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.GroupId = nFirstGroupIndex Then
+ FirstGroupItem = CurrMachining
+ Exit For
+ End If
+ Next
+ LastGroupItem = SelectedMTable.SelMachine.MachiningList(nLastGroupIndex)
+ If FirstGroupItem.PropertyPar = String.Empty Then
+ FirstGroupItem.PropertyPar = LastGroupItem.PropertyPar
+ ElseIf LastGroupItem.PropertyPar = String.Empty Or FirstGroupItem.PropertyPar = LastGroupItem.PropertyPar Then
+ FirstGroupItem.PropertyPar = FirstGroupItem.PropertyPar
+ Else
+ FirstGroupItem.PropertyPar = String.Empty
+ End If
+ For MachiningIndex = 0 To SelectedMTable.SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachiningIndex)
+ If CurrMachining.GroupId = nFirstGroupIndex Then
+ CurrMachining.NotifyPropertyChanged("PropertyPar")
+ End If
+ Next
+ End Sub
+
+#End Region ' GroupCommand
+
+#Region "PositionCommand"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property PositionCommand As ICommand
+ Get
+ If m_cmdPosition Is Nothing Then
+ m_cmdPosition = New Command(AddressOf Position)
+ End If
+ Return m_cmdPosition
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub Position(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If IsNothing(SelectedMTable) Then Return
+ Dim MachToMove As MTableMachiningGridBoxItem = Nothing
+ Dim MachRef As MTableMachiningGridBoxItem = Nothing
+ Dim OldIndex As Integer = -1
+ Dim NewIndex As Integer = -1
+ Dim bMoved As Boolean = False
+ For MachIndex = 0 To SelectedMTable.SelMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedMTable.SelMachine.MachiningList(MachIndex)
+ If Not bMoved Then
+ If NewIndex > 0 Then
+ If CurrMachining.GroupId <> MachRef.GroupId Then
+ SelectedMTable.SelMachine.MachiningList.Move(OldIndex, NewIndex)
+ MachToMove.GroupId = CurrMachining.GroupId
+ CurrMachining.GroupId += 1
+ bMoved = True
+ End If
+ End If
+ If CurrMachining.IsSelected Then
+ If OldIndex >= 0 Then
+ NewIndex = SelectedMTable.SelMachine.MachiningList.IndexOf(CurrMachining)
+ MachRef = CurrMachining
+ CurrMachining.IsSelected = False
+ End If
+ If CurrMachining.GroupId = 0 Then
+ MachToMove = CurrMachining
+ OldIndex = SelectedMTable.SelMachine.MachiningList.IndexOf(CurrMachining)
+ ElseIf NewIndex = 0 Then
+ NewIndex = SelectedMTable.SelMachine.MachiningList.IndexOf(CurrMachining)
+ End If
+ End If
+ If NewIndex > 0 And Not bMoved Then
+ If SelectedMTable.SelMachine.MachiningList.IndexOf(CurrMachining) = SelectedMTable.SelMachine.MachiningList.Count - 1 Then
+ SelectedMTable.SelMachine.MachiningList.Move(OldIndex, NewIndex)
+ MachToMove.GroupId = CurrMachining.GroupId + 1
+ bMoved = True
+ End If
+ End If
+ Else
+ CurrMachining.GroupId += 1
+ End If
+ Next
+ ' Rivaluto bottoni che dipendono da selezione
+ ManageMachiningButtons(False, False, True)
+ End Sub
+
+#End Region ' PositionCommand
+
+#Region "CloseMTableWindowCommand"
+
+ '''
+ ''' Returns a command that remove the current selected machining.
+ '''
+ Public ReadOnly Property CloseMTableWindowCommand() As ICommand
+ Get
+ If m_cmdCloseMTableWindow Is Nothing Then
+ m_cmdCloseMTableWindow = New Command(AddressOf CloseMTableWindow)
+ End If
+ Return m_cmdCloseMTableWindow
+ End Get
+ End Property
+
+ '''
+ ''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
+ '''
+ Public Sub CloseMTableWindow(param As Object)
+ Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
+ If Not IsNothing(SelectedMTable) AndAlso (SelectedMTable.IsModified() OrElse String.IsNullOrEmpty(SelectedMTable.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
+ SaveTable(SelectedMTable)
+ End If
+ End If
+ CloseWindow()
+ End Sub
+
+ Public Sub CloseWindow()
+ ' ripristino la macchina selezionata all'apertura della finestra
+ EgtSetCurrMachine(m_sPreviousActiveMachine)
+ ' Chiusura finestra
+ MTableListBoxItem.m_delSaveMTable = Nothing
+ MTableMachineListBoxItem.m_delCloseMTableWnd = Nothing
+ MTableAssociationGridBoxItem.m_delCloseMTableWnd = Nothing
+ For Each Window In Application.Current.Windows
+ If TypeOf Window Is MTableDbV Then
+ Dim MTableDbView As MTableDbV = DirectCast(Window, MTableDbV)
+ MTableDbView.DataContext = Nothing
+ MTableDbView.Close()
+ End If
+ Next
+
+ End Sub
+
+#End Region ' CloseMTableWindowCommand
+
+#End Region
+
+End Class
+
+Public Class GroupConverter
+ Implements IMultiValueConverter
+
+ Public Function Convert(value() As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IMultiValueConverter.Convert
+ Dim CurrItem As MTableMachiningGridBoxItem = DirectCast(value(1), MTableMachiningGridBoxItem)
+ Dim CurrItemIndex As Integer = -1
+ For TableIndex = 0 To MTableDbVM.refMTableDbVM.TablesList.Count - 1
+ If MTableDbVM.refMTableDbVM.TablesList(TableIndex).IsSelected Then
+ CurrItemIndex = MTableDbVM.refMTableDbVM.TablesList(TableIndex).SelMachine.MachiningList.IndexOf(CurrItem)
+ If CurrItem.GroupId = 0 Then
+ Return CurrItem.GroupId.ToString
+ End If
+ If CurrItemIndex >= 1 Then
+ If MTableDbVM.refMTableDbVM.TablesList(TableIndex).SelMachine.MachiningList(CurrItemIndex - 1).GroupId = CurrItem.GroupId Then
+ Return String.Empty
+ Else
+ Return CurrItem.GroupId.ToString
+ End If
+ Else
+ Return CurrItem.GroupId.ToString
+ End If
+ End If
+ Next
+ Return CurrItem.GroupId.ToString
+ End Function
+
+ Public Function ConvertBack(value As Object, targetType() As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object() Implements IMultiValueConverter.ConvertBack
+ Throw New NotImplementedException
+ End Function
+End Class
+
+Public Class PropertyConverter
+ Implements IMultiValueConverter
+
+ Public Function Convert(value() As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IMultiValueConverter.Convert
+ Dim CurrItem As MTableMachiningGridBoxItem = DirectCast(value(1), MTableMachiningGridBoxItem)
+ Dim CurrItemIndex As Integer = -1
+ For TableIndex = 0 To MTableDbVM.refMTableDbVM.TablesList.Count - 1
+ If MTableDbVM.refMTableDbVM.TablesList(TableIndex).IsSelected Then
+ CurrItemIndex = MTableDbVM.refMTableDbVM.TablesList(TableIndex).SelMachine.MachiningList.IndexOf(CurrItem)
+ If CurrItemIndex >= 1 Then
+ If CurrItem.PropertyPar = String.Empty Then
+ Return String.Empty
+ End If
+ If MTableDbVM.refMTableDbVM.TablesList(TableIndex).SelMachine.MachiningList(CurrItemIndex - 1).GroupId = CurrItem.GroupId Then
+ Return String.Empty
+ Else
+ Return CurrItem.PropertyPar
+ End If
+ Else
+ Return CurrItem.PropertyPar
+ End If
+ End If
+ Next
+ Return CurrItem.PropertyPar
+ End Function
+
+ Public Function ConvertBack(value As Object, targetType() As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object() Implements IMultiValueConverter.ConvertBack
+ Throw New NotImplementedException
+ End Function
+End Class
diff --git a/MTableDb/MTableDbView.xaml b/MTableDb/MTableDbView.xaml
deleted file mode 100644
index 18b3064..0000000
--- a/MTableDb/MTableDbView.xaml
+++ /dev/null
@@ -1,395 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/MTableDb/MTableDbView.xaml.vb b/MTableDb/MTableDbView.xaml.vb
deleted file mode 100644
index 8f37f4d..0000000
--- a/MTableDb/MTableDbView.xaml.vb
+++ /dev/null
@@ -1,3 +0,0 @@
-Public Class MTableDbView
-
-End Class
diff --git a/MTableDb/MTableDbViewModel.vb b/MTableDb/MTableDbViewModel.vb
deleted file mode 100644
index 306399a..0000000
--- a/MTableDb/MTableDbViewModel.vb
+++ /dev/null
@@ -1,948 +0,0 @@
-Imports System.Collections.ObjectModel
-Imports System.ComponentModel
-Imports System.IO
-Imports EgtUILib
-Imports System.Text.RegularExpressions
-
-Namespace EgtCAM5
-
- Public Class MTableDbViewModel
- Inherits TabViewModel
-
- Private m_sPreviousActiveMachine As String
-
- Private m_TablesList As New ObservableCollection(Of MTableListBoxItem)
- Public Property TablesList As ObservableCollection(Of MTableListBoxItem)
- Get
- Return m_TablesList
- End Get
- Set(value As ObservableCollection(Of MTableListBoxItem))
- m_TablesList = value
- End Set
- End Property
-
- Private m_TextToSearch As String
- Public Property TextToSearch As String
- Get
- Return m_TextToSearch
- End Get
- Set(value As String)
- If value <> m_TextToSearch Then
- If Not String.IsNullOrWhiteSpace(value) Then
- Dim SelectedMTable As MTableListBoxItem = Nothing
- For TableIndex = 0 To m_TablesList.Count - 1
- If m_TablesList(TableIndex).IsSelected Then
- SelectedMTable = m_TablesList(TableIndex)
- End If
- Next
- If Not IsNothing(SelectedMTable) Then
- SearchText(value, SelectedMTable)
- IsEnabledResetSearch = True
- End If
- SearchText(value, SelectedMTable)
- IsEnabledResetSearch = True
- Else
- ResetSearchedRow()
- IsEnabledResetSearch = False
- End If
- m_TextToSearch = value
- OnPropertyChanged("TextToSearch")
- End If
- End Set
- End Property
-
- Private m_IsEnabledResetSearch As Boolean
- Public Property IsEnabledResetSearch As Boolean
- Get
- Return m_IsEnabledResetSearch
- End Get
- Set(value As Boolean)
- If value <> m_IsEnabledResetSearch Then
- m_IsEnabledResetSearch = value
- OnPropertyChanged("IsEnabledResetSearch")
- End If
- End Set
- End Property
-
- Private m_FocusSearchTextState As Boolean
- Public Property FocusSearchTextState As Boolean
- Get
- Return m_FocusSearchTextState
- End Get
- Set(value As Boolean)
- m_FocusSearchTextState = value
- OnPropertyChanged("FocusSearchTextState")
- End Set
- End Property
-
-
-
-#Region "Messages"
-
- Public ReadOnly Property Title As String
- Get
- Return EgtMsg(MSG_MAINWINDOW + 20)
- End Get
- End Property
-
- Public ReadOnly Property MachListHeader As String
- Get
- Return EgtMsg(MSG_DOORS + 8)
- End Get
- End Property
-
- Public ReadOnly Property MachineNameTxBl As String
- Get
- Return EgtMsg(MSG_DOORS + 9)
- End Get
- End Property
-
- Public ReadOnly Property NcGenerateTxBl As String
- Get
- Return EgtMsg(MSG_DOORS + 10)
- End Get
- End Property
-
- Public ReadOnly Property MakeRawTxBl As String
- Get
- Return EgtMsg(MSG_DOORS + 11)
- End Get
- End Property
-
- Public ReadOnly Property OnHdr As String
- Get
- Return EgtMsg(MSG_DOORS + 12)
- End Get
- End Property
-
- Public ReadOnly Property GeomNameHdr As String
- Get
- Return EgtMsg(MSG_DOORS + 13)
- End Get
- End Property
-
- Public ReadOnly Property OperationHdr As String
- Get
- Return EgtMsg(MSG_DOORS + 14)
- End Get
- End Property
-
- Public ReadOnly Property MIdHdr As String
- Get
- Return EgtMsg(MSG_DOORS + 15)
- End Get
- End Property
-
- Public ReadOnly Property ShiftHdr As String
- Get
- Return EgtMsg(MSG_DOORS + 16)
- End Get
- End Property
-
- Public ReadOnly Property MachTypeHdr As String
- Get
- Return EgtMsg(MSG_DOORS + 17)
- End Get
- End Property
-
- Public ReadOnly Property MachHdr As String
- Get
- Return EgtMsg(MSG_DOORS + 18)
- End Get
- End Property
-
- Public ReadOnly Property MachUpHdr As String
- Get
- Return EgtMsg(MSG_DOORS + 19)
- End Get
- End Property
-
- Public ReadOnly Property MachDownHdr As String
- Get
- Return EgtMsg(MSG_DOORS + 20)
- End Get
- End Property
-
- Public ReadOnly Property AddMachBtn As String
- Get
- Return EgtMsg(MSG_DOORS + 21)
- End Get
- End Property
-
- Public ReadOnly Property RemoveMachBtn As String
- Get
- Return EgtMsg(MSG_DOORS + 22)
- End Get
- End Property
-
- Public ReadOnly Property AddMachiningBtn As String
- Get
- Return EgtMsg(MSG_DOORS + 23)
- End Get
- End Property
-
- Public ReadOnly Property RemoveMachiningBtn As String
- Get
- Return EgtMsg(MSG_DOORS + 24)
- End Get
- End Property
-
- Public ReadOnly Property CurrMsg As String
- Get
- Return EgtMsg(MSG_DOORS + 25)
- End Get
- End Property
-
-#End Region ' Messages
-
-#Region "ToolTip"
-
- 'Proprietà ToolTip
- Public ReadOnly Property NewTableToolTip As String
- Get
- Return EgtMsg(MSG_DOORS + 1)
- End Get
- End Property
- Public ReadOnly Property SaveTableToolTip As String
- Get
- Return EgtMsg(MSG_DOORS + 2)
- End Get
- End Property
- Public ReadOnly Property SaveAsTableToolTip As String
- Get
- Return EgtMsg(MSG_DOORS + 3)
- End Get
- End Property
- Public ReadOnly Property RemoveTableToolTip As String
- Get
- Return EgtMsg(MSG_DOORS + 4)
- End Get
- End Property
- Public ReadOnly Property SetActiveTableToolTip As String
- Get
- Return EgtMsg(MSG_DOORS + 26)
- End Get
- End Property
-
-#End Region ' ToolTip
-
- ' Definizione comandi
- Private m_cmdNewTable As ICommand
- Private m_cmdSaveTable As ICommand
- Private m_cmdSaveTableAs As ICommand
- Private m_cmdRemoveTable As ICommand
- Private m_cmdSetActiveTable As ICommand
- Private m_cmdResetSearch As ICommand
- Private m_cmdSearchPrevious As ICommand
- Private m_cmdSearchNext As ICommand
- Private m_cmdFocusSearch As ICommand
- Private m_cmdAddMach As ICommand
- Private m_cmdRemoveMach As ICommand
- Private m_cmdAddRow As ICommand
- Private m_cmdRemoveRow As ICommand
- Private m_cmdMoveRowUp As ICommand
- Private m_cmdMoveRowDown As ICommand
- Private m_cmdCloseMTableWindow As ICommand
-
-#Region "CONSTRUCTOR"
-
- Sub New()
- ' Passo all'item della lista il delegato alla funzuione che permette di cancellare una lavorazione
- MTableListBoxItem.m_delSaveMTable = AddressOf SaveTable
- MTableMachineListBoxItem.m_delCloseMTableWnd = AddressOf CloseWindow
- MTableListBoxItem.m_delCloseMTableWnd = AddressOf CloseWindow
- MTableAssociationGridBoxItem.m_delCloseMTableWnd = AddressOf CloseWindow
- MTableListBoxItem.m_delSearchInMTable = AddressOf SearchInNewlySelectedMTable
- ' recupero macchina corrente all'apertura della finestra per poterla ripristinare alla fine
- EgtGetCurrMachineName(m_sPreviousActiveMachine)
- MTableListBoxItem.NewMTableIndex = 0
- UpdateTables()
- Dim bActiveMTableFound As Boolean = False
- For Index = 0 To m_TablesList.Count - 1
- If m_TablesList(Index).ActiveTable Then
- m_TablesList(Index).IsSelected = True
- bActiveMTableFound = True
- Exit For
- End If
- Next
- If EgtVerifyMachinesDir() AndAlso Not bActiveMTableFound AndAlso m_TablesList.Count > 0 Then
- m_TablesList(0).IsSelected = True
- End If
- End Sub
-
-#End Region
-
-#Region "METHODS"
-
- Private Sub UpdateTables()
- m_TablesList.Clear()
- ' se trovo la cartella carico la lista di tabelle
- Dim FileTableList As ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles(IniFile.m_sTablesRoot)
- For Index As Integer = 0 To FileTableList.Count - 1
- If Path.GetExtension(FileTableList(Index)).ToLower = ".mtl" Then
- m_TablesList.Add(New MTableListBoxItem(Path.GetFileNameWithoutExtension(FileTableList(Index)), FileTableList(Index)))
- VerifyNewName(Path.GetFileNameWithoutExtension(FileTableList(Index)))
- End If
- Next
- SetActiveTable()
- End Sub
-
- Private Sub VerifyNewName(sNewName As String)
- Dim sNameIndex As String = Regex.Match(sNewName, "MTable_(\d+)").Groups(1).Value
- Dim nNameIndex As Integer = 0
- If Not String.IsNullOrEmpty(sNameIndex) Then
- Integer.TryParse(sNameIndex, nNameIndex)
- End If
- If nNameIndex > MTableListBoxItem.NewMTableIndex Then
- MTableListBoxItem.NewMTableIndex = nNameIndex
- End If
- End Sub
-
- Private Const MTABLENAME As String = "MTableName"
- Private Const MTNAME As String = "MTName"
-
- Private Sub SetActiveTable()
- Dim ActiveMTableName As String = String.Empty
- GetPrivateProfileString(S_DOORS, K_CURRMTABLE, "", ActiveMTableName)
- 'Dim ActiveMTableFilePath As String = Path.GetDirectoryName(IniFile.m_sTablesRoot) & "\CurrMTable.lua"
- 'If File.Exists(ActiveMTableFilePath) Then
- ' Dim ReadFile As String() = File.ReadAllLines(ActiveMTableFilePath)
- ' For LineIndex As Integer = 0 To ReadFile.Count - 1
- ' If ReadFile(LineIndex).Contains(MTABLENAME) Then
- ' ActiveMTableName = TableUtility.SearchKey(ReadFile(LineIndex), MTNAME)
- ' Exit For
- ' End If
- ' Next
- For Index As Integer = 0 To m_TablesList.Count - 1
- If m_TablesList(Index).TableName = ActiveMTableName Then
- m_TablesList(Index).ActiveTable = True
- Exit For
- End If
- Next
- 'End If
- End Sub
-
- Private Sub SearchText(sText As String, SelectedMTable As MTableListBoxItem)
- Dim bFirst As Boolean = True
- For AssociationIndex = 0 To SelectedMTable.AssociationList.Count - 1
- Dim CurrAssociation As MTableAssociationGridBoxItem = SelectedMTable.AssociationList(AssociationIndex)
- If CurrAssociation.Name.ToLower.Contains(sText) Then
- If bFirst Then
- CurrAssociation.IsSelected = True
- bFirst = False
- End If
- CurrAssociation.IsValidForSearch = True
- Else
- CurrAssociation.IsValidForSearch = False
- End If
- Next
- End Sub
-
- Private Sub SearchInNewlySelectedMTable(SelectedMTable As MTableListBoxItem)
- If Not String.IsNullOrWhiteSpace(m_TextToSearch) Then
- SearchText(m_TextToSearch, SelectedMTable)
- IsEnabledResetSearch = True
- End If
- End Sub
-
-#End Region
-
-#Region "COMMANDS"
-
-#Region "NewTableCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property NewTableCommand As ICommand
- Get
- If m_cmdNewTable Is Nothing Then
- m_cmdNewTable = New RelayCommand(AddressOf NewTable)
- End If
- Return m_cmdNewTable
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub NewTable(param As Object)
- Dim NewMTable As MTableListBoxItem = New MTableListBoxItem("MTable_" & (MTableListBoxItem.NewMTableIndex + 1).ToString, String.Empty)
- m_TablesList.Add(NewMTable)
- MTableListBoxItem.NewMTableIndex += 1
- If Not IsNothing(param) Then
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- SelectedMTable.IsSelected = False
- End If
- NewMTable.IsSelected = True
- End Sub
-
-#End Region ' NewTableCommand
-
-#Region "SaveTableCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property SaveTableCommand As ICommand
- Get
- If m_cmdSaveTable Is Nothing Then
- m_cmdSaveTable = New RelayCommand(AddressOf SaveTable)
- End If
- Return m_cmdSaveTable
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub SaveTable(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If IsNothing(SelectedMTable) Then Return
- If String.IsNullOrEmpty(SelectedMTable.TableNamePath) Then
- SaveTableAs(SelectedMTable)
- Else
- ' verifico di essere collegato alla cartella doors
- If Not VerifyDoorsDir() Then
- CloseWindow()
- Return
- End If
- TableUtility.WriteDoorTable(SelectedMTable, SelectedMTable.TableNamePath)
- SelectedMTable.IsModifiedReset()
- End If
- End Sub
-
-#End Region ' SaveTableCommand
-
-#Region "SaveTableAsCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property SaveTableAsCommand As ICommand
- Get
- If m_cmdSaveTableAs Is Nothing Then
- m_cmdSaveTableAs = New RelayCommand(AddressOf SaveTableAs)
- End If
- Return m_cmdSaveTableAs
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub SaveTableAs(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If IsNothing(SelectedMTable) Then Return
- ' verifico di essere collegato alla cartella doors
- If Not VerifyDoorsDir() Then
- CloseWindow()
- Return
- End If
- Dim sFile As String = String.Empty
- If SaveTableAsDialog(sFile, SelectedMTable.TableName) Then
- SelectedMTable.IsModifiedReset()
- VerifyNewName(Path.GetFileNameWithoutExtension(sFile))
- TableUtility.WriteDoorTable(SelectedMTable, sFile)
- UpdateTables()
- ' seleziono la tabella appena salvata
- For Index As Integer = 0 To m_TablesList.Count - 1
- If m_TablesList(Index).TableNamePath = sFile Then
- m_TablesList(Index).IsSelected = True
- End If
- Next
- End If
- End Sub
-
- Public Function SaveTableAsDialog(ByRef sPath As String, sTableName As String) As Boolean
- ' Direttorio corrente per MTable
- Dim sDir As String = IniFile.m_sTablesRoot
- ' Apertura dialogo di scelta file DDF
- Dim SaveFileDialogView As New EgtWPFLib5.EgtSaveFileDialog
- SaveFileDialogView.Title = EgtMsg(MSG_DOORS + 5)
- SaveFileDialogView.Extension = ".mtl"
- SaveFileDialogView.Directory = sDir
- SaveFileDialogView.FileName = sTableName
- If Not SaveFileDialogView.EgtShowDialog Then
- Return False
- End If
- sPath = SaveFileDialogView.FileName
- Return True
- End Function
-
-#End Region ' SaveTableAsCommand
-
-#Region "RemoveTableCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property RemoveTableCommand As ICommand
- Get
- If m_cmdRemoveTable Is Nothing Then
- m_cmdRemoveTable = New RelayCommand(AddressOf RemoveTable)
- End If
- Return m_cmdRemoveTable
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub RemoveTable(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If IsNothing(SelectedMTable) Then Return
- ' verifico di essere collegato alla cartella doors
- If Not VerifyDoorsDir() Then
- CloseWindow()
- Return
- End If
- ' cancello tutte le tavole nella lista impostate su non visibili (quelle rimaste quando viene creata una nuova tabella e passando ad un altra non la si salva)
- Dim Index As Integer = m_TablesList.Count - 1
- While Index >= 0
- If m_TablesList(Index).Visibility <> Visibility.Visible Then
- m_TablesList.RemoveAt(Index)
- End If
- Index -= 1
- End While
- ' verifico se la tabella selezionata è quella attiva
- If SelectedMTable.ActiveTable Then
- MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 8) & vbCrLf & EgtMsg(MSG_DOORSERRORS + 9), "", MessageBoxButton.OK, MessageBoxImage.Stop)
- Exit Sub
- End If
- ' chiedo conferma prima di cancellare la tabella
- If MessageBox.Show(EgtMsg(MSG_DOORS + 6), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then
- If Not String.IsNullOrEmpty(SelectedMTable.TableNamePath) Then
- File.Delete(SelectedMTable.TableNamePath)
- End If
- Dim SelectedTableIndex As Integer = m_TablesList.IndexOf(SelectedMTable)
- m_TablesList.RemoveAt(SelectedTableIndex)
- If SelectedTableIndex > 0 Then
- TablesList(SelectedTableIndex - 1).IsSelected = True
- End If
- End If
- End Sub
-
-#End Region ' RemoveTableCommand
-
-#Region "SetActiveTableCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property SetActiveTableCommand As ICommand
- Get
- If m_cmdSetActiveTable Is Nothing Then
- m_cmdSetActiveTable = New RelayCommand(AddressOf SetActiveTable)
- End If
- Return m_cmdSetActiveTable
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub SetActiveTable(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If IsNothing(SelectedMTable) Then Return
- If WritePrivateProfileString(S_DOORS, K_CURRMTABLE, SelectedMTable.TableName) Then
- For Index As Integer = 0 To m_TablesList.Count - 1
- If m_TablesList(Index).TableName = SelectedMTable.TableName Then
- m_TablesList(Index).ActiveTable = True
- Else
- m_TablesList(Index).ActiveTable = False
- End If
- Next
- End If
- '' Scrivo il file di configurazione con il nome di questa tavola
- 'Dim FileContent As String() = File.ReadAllLines(Path.GetDirectoryName(IniFile.m_sTablesRoot) & "\" & CURRMTABLE_FILE)
- 'Dim NewTableFileContent As New List(Of String)
- 'For LineIndex As Integer = 0 To FileContent.Count - 1
- ' Dim sCurrLine As String = FileContent(LineIndex)
- ' sCurrLine = sCurrLine.Replace(TableUtility.DATETIME, System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"))
- ' sCurrLine = sCurrLine.Replace(TableUtility.TABLENAME, SelectedMTable.TableName)
- ' NewTableFileContent.Add(sCurrLine)
- 'Next
- 'File.WriteAllLines(Path.ChangeExtension(Path.GetDirectoryName(IniFile.m_sTablesRoot) & "\" & CURRMTABLE_FILE, ".lua"), NewTableFileContent, Text.Encoding.UTF8)
-
- End Sub
-
-#End Region ' SetActiveTableCommand
-
-#Region "ResetSearchCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property ResetSearchCommand As ICommand
- Get
- If m_cmdResetSearch Is Nothing Then
- m_cmdResetSearch = New RelayCommand(AddressOf ResetSearch)
- End If
- Return m_cmdResetSearch
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub ResetSearch()
- TextToSearch = String.Empty
- End Sub
-
- Public Sub ResetSearchedRow()
- For TableIndex = 0 To m_TablesList.Count - 1
- If m_TablesList(TableIndex).IsSelected Then
- For AssociationIndex = 0 To m_TablesList(TableIndex).AssociationList.Count - 1
- Dim CurrAssociation As MTableAssociationGridBoxItem = m_TablesList(TableIndex).AssociationList(AssociationIndex)
- CurrAssociation.IsValidForSearch = False
- Next
- Exit For
- End If
- Next
- End Sub
-
-
-#End Region ' ResetSearchCommand
-
-#Region "SearchPreviousCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property SearchPreviousCommand As ICommand
- Get
- If m_cmdSearchPrevious Is Nothing Then
- m_cmdSearchPrevious = New RelayCommand(AddressOf SearchPrevious)
- End If
- Return m_cmdSearchPrevious
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub SearchPrevious()
- If String.IsNullOrWhiteSpace(m_TextToSearch) Then
- Return
- End If
- Dim bFound As Boolean = False
- Dim LastSearchedRow As MTableAssociationGridBoxItem = Nothing
- For TableIndex = 0 To m_TablesList.Count - 1
- If m_TablesList(TableIndex).IsSelected Then
- For AssociationIndex = 0 To m_TablesList(TableIndex).AssociationList.Count - 1
- Dim CurrAssociation As MTableAssociationGridBoxItem = m_TablesList(TableIndex).AssociationList(AssociationIndex)
- If CurrAssociation.IsSelected Then
- If Not IsNothing(LastSearchedRow) Then
- LastSearchedRow.IsSelected = True
- End If
- Return
- End If
- If CurrAssociation.IsValidForSearch Then
- LastSearchedRow = CurrAssociation
- End If
- Next
- Exit For
- End If
- Next
- End Sub
-
-#End Region ' SearchPreviousCommand
-
-#Region "SearchNextCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property SearchNextCommand As ICommand
- Get
- If m_cmdSearchNext Is Nothing Then
- m_cmdSearchNext = New RelayCommand(AddressOf SearchNext)
- End If
- Return m_cmdSearchNext
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub SearchNext()
- If String.IsNullOrWhiteSpace(m_TextToSearch) Then
- Return
- End If
- Dim bFound As Boolean = False
- For TableIndex = 0 To m_TablesList.Count - 1
- If m_TablesList(TableIndex).IsSelected Then
- For AssociationIndex = 0 To m_TablesList(TableIndex).AssociationList.Count - 1
- Dim CurrAssociation As MTableAssociationGridBoxItem = m_TablesList(TableIndex).AssociationList(AssociationIndex)
- If bFound AndAlso CurrAssociation.IsValidForSearch Then
- CurrAssociation.IsSelected = True
- Return
- End If
- If CurrAssociation.IsSelected Then
- bFound = True
- End If
- Next
- Exit For
- End If
- Next
- End Sub
-
-#End Region ' SearchNextCommand
-
-#Region "FocusSearchCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property FocusSearchCommand As ICommand
- Get
- If m_cmdFocusSearch Is Nothing Then
- m_cmdFocusSearch = New RelayCommand(AddressOf FocusSearch)
- End If
- Return m_cmdFocusSearch
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub FocusSearch()
- FocusSearchTextState = Not m_FocusSearchTextState
- End Sub
-
-#End Region ' FocusSearchCommand
-
-#Region "AddMachCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property AddMachCommand As ICommand
- Get
- If m_cmdAddMach Is Nothing Then
- m_cmdAddMach = New RelayCommand(AddressOf AddMach)
- End If
- Return m_cmdAddMach
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub AddMach(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If IsNothing(SelectedMTable) Then Return
- SelectedMTable.SharedMachIndex += 1
- SelectedMTable.ActiveMachinesList.Add(New MTableMachineListBoxItem(String.Empty, False, False, SelectedMTable.SharedMachIndex))
- SelectedMTable.MachIdList.Add(SelectedMTable.SharedMachIndex)
- End Sub
-
-#End Region ' AddMachCommand
-
-#Region "RemoveMachCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property RemoveMachCommand As ICommand
- Get
- If m_cmdRemoveMach Is Nothing Then
- m_cmdRemoveMach = New RelayCommand(AddressOf RemoveMach)
- End If
- Return m_cmdRemoveMach
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub RemoveMach(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If Not IsNothing(SelectedMTable) AndAlso SelectedMTable.ActiveMachinesList.Count > 1 Then
- ' Chiedo conferma cancellazione associazione macchina
- If MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 12), EgtMsg(MSG_DOORSERRORS + 11), MessageBoxButton.YesNo, MessageBoxImage.Question) <> MessageBoxResult.Yes Then
- Return
- End If
- SelectedMTable.ActiveMachinesList.RemoveAt(SelectedMTable.SharedMachIndex - 1)
- SelectedMTable.MachIdList.RemoveAt(SelectedMTable.SharedMachIndex - 1)
- SelectedMTable.SharedMachIndex -= 1
- End If
- End Sub
-
-#End Region ' RemoveMachCommand
-
-#Region "AddRowCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property AddRowCommand As ICommand
- Get
- If m_cmdAddRow Is Nothing Then
- m_cmdAddRow = New RelayCommand(AddressOf AddRow)
- End If
- Return m_cmdAddRow
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub AddRow(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If Not IsNothing(SelectedMTable) AndAlso Not IsNothing(SelectedMTable.SelectedAssociation) Then
- Dim SelectedIndex As Integer = SelectedMTable.AssociationList.IndexOf(SelectedMTable.SelectedAssociation)
- Dim NewEmptyRow As MTableAssociationGridBoxItem = New MTableAssociationGridBoxItem(False, String.Empty, 1, 0, String.Empty, String.Empty, String.Empty, String.Empty, SelectedMTable.ActiveMachinesList)
- SelectedMTable.AssociationList.Insert(SelectedIndex + 1, NewEmptyRow)
- SelectedMTable.SelectedAssociation = NewEmptyRow
- SelectedMTable.NotifyPropertyChanged("SelectedAssociation")
- End If
- End Sub
-
-#End Region ' AddRowCommand
-
-#Region "RemoveRowCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property RemoveRowCommand As ICommand
- Get
- If m_cmdRemoveRow Is Nothing Then
- m_cmdRemoveRow = New RelayCommand(AddressOf RemoveRow)
- End If
- Return m_cmdRemoveRow
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub RemoveRow(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If Not IsNothing(SelectedMTable) AndAlso SelectedMTable.AssociationList.Count > 1 Then
- ' Chiedo conferma cancellazione riga di associazione
- If MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 10), EgtMsg(MSG_DOORSERRORS + 11), MessageBoxButton.YesNo, MessageBoxImage.Question) <> MessageBoxResult.Yes Then
- Return
- End If
- Dim SelectedIndex As Integer = SelectedMTable.AssociationList.IndexOf(SelectedMTable.SelectedAssociation)
- SelectedMTable.AssociationList.RemoveAt(SelectedIndex)
- If Not SelectedIndex < SelectedMTable.AssociationList.Count Then
- SelectedIndex = SelectedMTable.AssociationList.Count - 1
- End If
- SelectedMTable.SelectedAssociation = SelectedMTable.AssociationList(SelectedIndex)
- SelectedMTable.NotifyPropertyChanged("SelectedAssociation")
- End If
- End Sub
-
-#End Region ' RemoveRowCommand
-
-#Region "MoveRowUpCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property MoveRowUpCommand As ICommand
- Get
- If m_cmdMoveRowUp Is Nothing Then
- m_cmdMoveRowUp = New RelayCommand(AddressOf MoveRowUp)
- End If
- Return m_cmdMoveRowUp
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub MoveRowUp(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If IsNothing(SelectedMTable) Then Return
- Dim SelectedIndex As Integer = SelectedMTable.AssociationList.IndexOf(SelectedMTable.SelectedAssociation)
- If SelectedIndex >= 1 Then
- SelectedMTable.AssociationList.Move(SelectedIndex, SelectedIndex - 1)
- End If
- End Sub
-
-#End Region ' MoveRowUpCommand
-
-#Region "MoveRowDownCommand"
-
- '''
- ''' Returns a command that do Exec.
- '''
- Public ReadOnly Property MoveRowDownCommand As ICommand
- Get
- If m_cmdMoveRowDown Is Nothing Then
- m_cmdMoveRowDown = New RelayCommand(AddressOf MoveRowDown)
- End If
- Return m_cmdMoveRowDown
- End Get
- End Property
-
- '''
- ''' Execute the Exec. This method is invoked by the ExecCommand.
- '''
- Public Sub MoveRowDown(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If IsNothing(SelectedMTable) Then Return
- Dim SelectedIndex As Integer = SelectedMTable.AssociationList.IndexOf(SelectedMTable.SelectedAssociation)
- If SelectedIndex < SelectedMTable.AssociationList.Count - 1 Then
- SelectedMTable.AssociationList.Move(SelectedIndex, SelectedIndex + 1)
- End If
- End Sub
-
-#End Region ' MoveRowDownCommand
-
-#Region "CloseMTableWindowCommand"
-
- '''
- ''' Returns a command that remove the current selected machining.
- '''
- Public ReadOnly Property CloseMTableWindowCommand() As ICommand
- Get
- If m_cmdCloseMTableWindow Is Nothing Then
- m_cmdCloseMTableWindow = New RelayCommand(AddressOf CloseMTableWindow)
- End If
- Return m_cmdCloseMTableWindow
- End Get
- End Property
-
- '''
- ''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
- '''
- Public Sub CloseMTableWindow(param As Object)
- Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
- If Not IsNothing(SelectedMTable) AndAlso (SelectedMTable.IsModified() OrElse String.IsNullOrEmpty(SelectedMTable.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
- SaveTable(SelectedMTable)
- End If
- End If
- CloseWindow()
- End Sub
-
- Public Sub CloseWindow()
- ' ripristino la macchina selezionata all'apertura della finestra
- EgtSetCurrMachine(m_sPreviousActiveMachine)
- ' Chiusura finestra
- MTableListBoxItem.m_delSaveMTable = Nothing
- MTableMachineListBoxItem.m_delCloseMTableWnd = Nothing
- MTableAssociationGridBoxItem.m_delCloseMTableWnd = Nothing
- For Each Window In Application.Current.Windows
- If TypeOf Window Is MTableDbView Then
- Dim MTableDbView As MTableDbView = DirectCast(Window, MTableDbView)
- MTableDbView.DataContext = Nothing
- MTableDbView.Close()
- End If
- Next
-
- End Sub
-
-#End Region ' CloseMTableWindowCommand
-
-#End Region
-
- End Class
-
-End Namespace
\ No newline at end of file
diff --git a/MTableDb/MTableListBox.vb b/MTableDb/MTableListBox.vb
index 6324989..8d1cf83 100644
--- a/MTableDb/MTableListBox.vb
+++ b/MTableDb/MTableListBox.vb
@@ -40,6 +40,7 @@ Public Class MTableListBoxItem
End If
If Not ReadMTableFile() Then Return
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
@@ -109,6 +110,19 @@ Public Class MTableListBoxItem
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
@@ -150,7 +164,7 @@ Public Class MTableListBoxItem
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, String.Empty, String.Empty, String.Empty, ActiveMachinesList))
+ AssociationList.Add(New MTableAssociationGridBoxItem(False, String.Empty, Nothing, 0, String.Empty, Nothing, String.Empty, Nothing, String.Empty, Nothing, String.Empty, ActiveMachinesList, m_AssociationList))
Return True
End If
' resetto indici macchine impostati in tabella
@@ -278,6 +292,16 @@ Public Class MTableMachineListBoxItem
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 Throw New Exception("Exception: Can't find machines dir!")
@@ -309,6 +333,180 @@ Public Class MTableMachineListBoxItem
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
+
+ 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 MTableMachiningGridBoxItem
+ Implements INotifyPropertyChanged
+
+ Private m_refMTableMachine As MTableMachineListBoxItem
+
+ 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) = New ObservableCollection(Of String)({"Layer", "Shuttle", "MinDist"})
+ Public ReadOnly Property PropertyList As ObservableCollection(Of String)
+ Get
+ Return m_PropertyList
+ End Get
+ End Property
+
+ Private m_Property As String
+ 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
+
+ Private m_Join As Boolean
+ Public Property Join As Boolean
+ Get
+ Return m_Join
+ End Get
+ Set(value As Boolean)
+ If value <> m_Join Then
+ m_Join = value
+ NotifyPropertyChanged("Join")
+ End If
+ 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
+
+ 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)
+ Dim bIncrementFollowingGroup As Boolean = False
+ If MachiningList.Count = 1 OrElse MachiningList(ItemIndex).GroupId = 0 Then
+ bIncrementFollowingGroup = False
+ ElseIf ItemIndex = 0 AndAlso MachiningList(ItemIndex + 1).m_GroupId <> Item.m_GroupId Then
+ bIncrementFollowingGroup = True
+ 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
+
+ 'If MachiningList.Count <> 1 AndAlso MachiningList(ItemIndex).GroupId <> 0 AndAlso ((ItemIndex = 0 AndAlso MachiningList(ItemIndex + 1).m_GroupId <> Item.m_GroupId) OrElse
+ ' (ItemIndex = MachiningList.Count - 1 AndAlso MachiningList(ItemIndex - 1).m_GroupId <> Item.m_GroupId) OrElse
+ ' (MachiningList(ItemIndex - 1).m_GroupId <> Item.m_GroupId AndAlso MachiningList(ItemIndex + 1).m_GroupId <> Item.m_GroupId)) Then
+ ' MachiningList.Remove(Item)
+ ' For ListIndex = ItemIndex To MachiningList.Count - 1
+ ' MachiningList(ListIndex).GroupId -= 1
+ ' Next
+ 'Else
+ ' MachiningList.Remove(Item)
+ '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
+
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
@@ -353,6 +551,8 @@ Public Class MTableAssociationGridBoxItem
' 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
@@ -389,6 +589,16 @@ Public Class MTableAssociationGridBoxItem
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
@@ -421,6 +631,7 @@ Public Class MTableAssociationGridBoxItem
Set(value As Integer)
If value <> m_MachId Then
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
@@ -467,30 +678,71 @@ Public Class MTableAssociationGridBoxItem
Return
End If
EgtSetCurrMachine(m_ActiveMachinesList(value - 1).SelectedMachine)
- Dim nMachType As Integer = GDB_ID.NULL
- If Not String.IsNullOrEmpty(m_Mach) Then
- EgtMdbSetCurrMachining(m_Mach)
- If Not EgtMdbSetCurrMachining(m_Mach) Then
- Mach = String.Empty
- NotifyPropertyChanged("Mach")
- End If
- End If
- If Not String.IsNullOrEmpty(m_MachUp) Then
- If Not EgtMdbSetCurrMachining(m_MachUp) Then
- MachUp = String.Empty
- NotifyPropertyChanged("MachUp")
- End If
- End If
- If Not String.IsNullOrEmpty(m_MachDw) Then
- If Not EgtMdbSetCurrMachining(m_MachDw) Then
- MachDw = String.Empty
- NotifyPropertyChanged("MachDw")
- End If
- End If
+ m_RefMachItem = ManageOrderedMachining(Mach, nOldMachId, RefMachItem, "Mach")
+ m_RefMachUpItem = ManageOrderedMachining(MachUp, nOldMachId, RefMachUpItem, "MachUp")
+ m_RefMachDwItem = ManageOrderedMachining(MachDw, nOldMachId, RefMachDwItem, "MachDw")
End If
End Set
End Property
+ Private Function ManageOrderedMachining(ByRef Mach As String, nOldMachId As Integer, ByRef CurrRefMachItem As MTableMachiningGridBoxItem, sProperty As String) 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
+ NotifyPropertyChanged(sProperty)
+ 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
@@ -546,7 +798,7 @@ Public Class MTableAssociationGridBoxItem
Private Sub UpdateMachiningTypeLists()
' se la lista è vuota devo caricarla
- If m_MachinesMachTypeList.Count < m_MachId Then
+ 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
@@ -696,6 +948,13 @@ Public Class MTableAssociationGridBoxItem
End Set
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
@@ -704,9 +963,17 @@ Public Class MTableAssociationGridBoxItem
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
@@ -715,9 +982,17 @@ Public Class MTableAssociationGridBoxItem
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
@@ -726,6 +1001,7 @@ Public Class MTableAssociationGridBoxItem
Set(value As String)
m_IsModified = True
m_MachDw = value
+ RefreshMachItem(m_RefMachDwItem, m_MachDw)
End Set
End Property
@@ -740,7 +1016,10 @@ Public Class MTableAssociationGridBoxItem
Private m_ChiselingList As New List(Of List(Of String))
Private Shared m_MachinesMachTypeList As New List(Of List(Of MachineModel.MachiningsType))
- Sub New(bOn As Boolean, sName As String, nMachId As Integer, nShift As Integer, sOper As String, sMach As String, sMachUp As String, sMachDw As String, ByRef ActiveMachinesList As ObservableCollection(Of MTableMachineListBoxItem))
+ 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
@@ -771,6 +1050,8 @@ Public Class MTableAssociationGridBoxItem
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
@@ -817,13 +1098,58 @@ Public Class MTableAssociationGridBoxItem
NotifyPropertyChanged("SelectedMachType")
If Not IsNothing(m_SelectedMachType) Then
' Imposto i Mach selezionati
- Mach = sMach
- MachUp = sMachUp
- MachDw = sMachDw
+ m_Mach = sMach
+ m_MachUp = sMachUp
+ m_MachDw = sMachDw
+ 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
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
+
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
diff --git a/MTableDb/TableUtility.vb b/MTableDb/TableUtility.vb
index 3089207..1d460c2 100644
--- a/MTableDb/TableUtility.vb
+++ b/MTableDb/TableUtility.vb
@@ -1,4 +1,5 @@
Imports System.Text.RegularExpressions
+Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
@@ -13,22 +14,35 @@ Module TableUtility
Private Const MTABLE As String = ".MTable"
Private Const NAME As String = "Name"
Private Const ONCONST As String = "On"
+ Private Const MACHORD As String = "MachOrd"
+ Private Const MACHJOIN As String = "MachJoin"
Private Const MACH As String = "Mach"
+ Private Const MACHUPORD As String = "MachUpOrd"
+ Private Const MACHUPJOIN As String = "MachUpJoin"
Private Const MACHUP As String = "MachUp"
+ Private Const MACHDWORD As String = "MachDwOrd"
+ Private Const MACHDWJOIN As String = "MachDwJoin"
Private Const MACHDW As String = "MachDw"
Private Const MACHID As String = "MachId"
Private Const SHIFT As String = "Shift"
+ Private Const PROPERTYTABLE As String = "PropertyTable"
Private Const OPER As String = "Oper"
+ Private Const GROUP As String = "Group"
+ Private Const PROPERTYPAR As String = "Property"
Friend Function ReadDoorsTable(Table As MTableListBoxItem) As Boolean
Dim FileContent As String() = File.ReadAllLines(Table.m_TableNamePath)
Dim bMMachineData As Boolean = False
Dim bMTable As Boolean = False
+ Dim bPropertyTable As Boolean = False
+ Dim bOrderedMachining As Boolean = False
For LineIndex As Integer = 0 To FileContent.Count - 1
If FileContent(LineIndex).Contains(MMACHINEDATA) Then
bMMachineData = True
ElseIf FileContent(LineIndex).Contains(MTABLE) Then
bMTable = True
+ ElseIf FileContent(LineIndex).Contains("PropertyTable") Then
+ bPropertyTable = True
End If
Dim Open As Integer = CountCharacter(FileContent(LineIndex), "{"c)
Dim Close As Integer = CountCharacter(FileContent(LineIndex), "}"c)
@@ -37,6 +51,8 @@ Module TableUtility
bMMachineData = False
ElseIf bMTable Then
bMTable = False
+ ElseIf bPropertyTable Then
+ bPropertyTable = False
End If
End If
If bMMachineData Then
@@ -100,12 +116,105 @@ Module TableUtility
If nMachId > Table.m_MachIdList.Count Then
nMachId = 0
End If
- Table.AssociationList.Add(New MTableAssociationGridBoxItem(bOn, sName, nMachId, nShift, sOper, sMach, sMachUp, sMachDw, Table.ActiveMachinesList))
+ ' Creo elementi per lista lavorazioni da ordinare
+ Dim MachItem As MTableMachiningGridBoxItem = Nothing
+ Dim MachUpItem As MTableMachiningGridBoxItem = Nothing
+ Dim MachDwItem As MTableMachiningGridBoxItem = Nothing
+ For MachIndex = 0 To Table.ActiveMachinesList.Count - 1
+ If Table.ActiveMachinesList(MachIndex).MachId = nMachId Then
+ If Not String.IsNullOrWhiteSpace(sMach) Then
+ ' Recupero indice della lavorazione
+ Dim sMachOrd As String = SearchKey(FileContent(LineIndex), MACHORD)
+ Dim sMachJoin As String = SearchKey(FileContent(LineIndex), MACHJOIN)
+ AddOrdMachItem(sMachOrd, MachIndex, sName, sMach, sMachJoin, MachItem, Table)
+ End If
+ If Not String.IsNullOrWhiteSpace(sMachUp) Then
+ If sMachUp <> sMach Then
+ ' Recupero indice della lavorazione
+ Dim sMachOrd As String = SearchKey(FileContent(LineIndex), MACHUPORD)
+ Dim sMachJoin As String = SearchKey(FileContent(LineIndex), MACHUPJOIN)
+ AddOrdMachItem(sMachOrd, MachIndex, sName, sMachUp, sMachJoin, MachUpItem, Table)
+ Else
+ MachUpItem = MachItem
+ End If
+ End If
+ If Not String.IsNullOrWhiteSpace(sMachDw) Then
+ If sMachDw <> sMach And sMachDw <> sMachUp Then
+ ' Recupero indice della lavorazione
+ Dim sMachOrd As String = SearchKey(FileContent(LineIndex), MACHDWORD)
+ Dim sMachJoin As String = SearchKey(FileContent(LineIndex), MACHDWJOIN)
+ AddOrdMachItem(sMachOrd, MachIndex, sName, sMachDw, sMachJoin, MachDwItem, Table)
+ ElseIf sMachDw <> sMach Then
+ MachDwItem = MachItem
+ ElseIf sMachDw <> sMachUp Then
+ MachDwItem = MachUpItem
+ End If
+ End If
+ End If
+ Next
+ Table.AssociationList.Add(New MTableAssociationGridBoxItem(bOn, sName, nMachId, nShift, sOper, MachItem, sMach, MachUpItem, sMachUp, MachDwItem, sMachDw, Table.ActiveMachinesList, Table.AssociationList))
End If
-
+ End If
+ If bPropertyTable Then
+ ' se lavorazioni ancora disordinate
+ If Not bOrderedMachining Then
+ ' Riordino tabelle per ordine lavorazioni
+ For MachIndex = 0 To Table.ActiveMachinesList.Count - 1
+ ' Verifico se c'è almeno una lavorazione ordinata
+ Dim bFound As Boolean = False
+ For MachiningIndex = 0 To Table.ActiveMachinesList(MachIndex).MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = Table.ActiveMachinesList(MachIndex).MachiningList(MachiningIndex)
+ If CurrMachining.RWGroupId <> 0 Then
+ bFound = True
+ Exit For
+ End If
+ Next
+ If Not bFound And Table.ActiveMachinesList(MachIndex).MachiningList.Count > 0 Then
+ Table.ActiveMachinesList(MachIndex).MachiningList(0).GroupId = 1
+ Table.ActiveMachinesList(MachIndex).MachiningList(0).RWGroupId = 100
+ End If
+ Table.ActiveMachinesList(MachIndex).MachiningList = New ObservableCollection(Of MTableMachiningGridBoxItem)(Table.ActiveMachinesList(MachIndex).MachiningList.OrderBy(Function(x) x.RWGroupId))
+ Next
+ bOrderedMachining = True
+ End If
+ ' recupero valori da tabella proprietà
+ Dim sMachId As String = SearchKey(FileContent(LineIndex), MACHID)
+ Dim nMachId As Integer = -1
+ If String.IsNullOrEmpty(sMachId) Then
+ ' il suo valore di default è 1 quindi lo imposto a questo valore
+ nMachId = 1
+ Else
+ Integer.TryParse(sMachId, nMachId)
+ End If
+ Dim sGroup As String = SearchKey(FileContent(LineIndex), GROUP)
+ Dim nGroup As Integer = -1
+ Integer.TryParse(sGroup, nGroup)
+ Dim sProperty As String = SearchKey(FileContent(LineIndex), PROPERTYPAR)
+ For MachIndex = 0 To Table.ActiveMachinesList.Count - 1
+ Dim bFound As Boolean = False
+ If Table.ActiveMachinesList(MachIndex).MachId = nMachId Then
+ For MachiningIndex = 0 To Table.ActiveMachinesList(MachIndex).MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = Table.ActiveMachinesList(MachIndex).MachiningList(MachiningIndex)
+ If CurrMachining.GroupId = nGroup \ 100 Then
+ CurrMachining.PropertyPar = sProperty
+ bFound = True
+ Exit For
+ End If
+ Next
+ End If
+ If bFound Then
+ Exit for
+ End If
+ Next
+ End If
+ Next
+ ' verifico se le liste ordinate contengono un indice diverso da zero
+ For MachIndex = 0 To Table.ActiveMachinesList.Count - 1
+ Dim CurrMachine As MTableMachineListBoxItem = Table.ActiveMachinesList(MachIndex)
+ If CurrMachine.MachiningList.Count > 0 AndAlso CurrMachine.MachiningList(CurrMachine.MachiningList.Count - 1).GroupId = 0 Then
+ CurrMachine.MachiningList(CurrMachine.MachiningList.Count - 1).GroupId = 1
End If
Next
-
' se nessuna macchina, ne aggiungo una vuota
If Table.ActiveMachinesList.Count = 0 Then
Table.SharedMachIndex += 1
@@ -114,11 +223,38 @@ Module TableUtility
End If
' se nessuna lavorazione, ne aggiungo una vuota
If Table.AssociationList.Count = 0 Then
- Table.AssociationList.Add(New MTableAssociationGridBoxItem(False, String.Empty, 0, 0, String.Empty, String.Empty, String.Empty, String.Empty, Table.ActiveMachinesList))
+ Table.AssociationList.Add(New MTableAssociationGridBoxItem(False, String.Empty, 0, 0, String.Empty, Nothing, String.Empty, Nothing, String.Empty, Nothing, String.Empty, Table.ActiveMachinesList, Table.AssociationList))
End If
Return True
End Function
+ Private Sub AddOrdMachItem(sMachOrd As String, MachIndex As Integer, sName As String, sMach As String, sJoin As String, ByRef MachItem As MTableMachiningGridBoxItem, Table As MTableListBoxItem)
+ Dim nMachOrd As Integer = 0
+ Dim bJoin As Boolean = False
+ If Not String.IsNullOrWhiteSpace(sMachOrd) Then
+ Integer.TryParse(sMachOrd, nMachOrd)
+ End If
+ If Not String.IsNullOrEmpty(sJoin) Then
+ Dim nValue As Integer
+ Integer.TryParse(sJoin, nValue)
+ bJoin = nValue <> 0
+ End If
+ ' verifico se esiste già un item della tabella lavorazioni ordinate con gli stessi dati
+ Dim bExist As Boolean = False
+ For OrdMachIndex = 0 To Table.ActiveMachinesList(MachIndex).MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = Table.ActiveMachinesList(MachIndex).MachiningList(OrdMachIndex)
+ If CurrMachining.Geometry = sName AndAlso CurrMachining.Machining = sMach Then
+ bExist = True
+ MachItem = CurrMachining
+ Exit For
+ End If
+ Next
+ If Not bExist Then
+ MachItem = New MTableMachiningGridBoxItem(nMachOrd, sName, sMach, bJoin, Table.ActiveMachinesList(MachIndex))
+ Table.ActiveMachinesList(MachIndex).MachiningList.Add(MachItem)
+ End If
+ End Sub
+
Friend Function SearchKey(sLine As String, sKey As String) As String
Return Regex.Match(sLine, "[,|{|\s]" & sKey & "\s*=\s*['|\""]?(.*?)\s*?[,|}|'|\""]").Groups(1).Value
End Function
@@ -137,6 +273,8 @@ Module TableUtility
Dim NewTableFileContent As New List(Of String)
Dim bMMachineData As Boolean = False
Dim bMTable As Boolean = False
+ Dim bPropertyTable As Boolean = False
+ ReorderMachiningIndex(SelectedTable)
For LineIndex As Integer = 0 To FileContent.Count - 1
Dim sCurrLine As String = FileContent(LineIndex)
sCurrLine = sCurrLine.Replace(DATETIME, System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"))
@@ -150,16 +288,82 @@ Module TableUtility
bMTable = True
NewTableFileContent.Add(sCurrLine)
PrintActiveMachiningList(SelectedTable, NewTableFileContent)
+ ElseIf sCurrLine.Contains(PROPERTYTABLE) Then
+ bPropertyTable = True
+ NewTableFileContent.Add(sCurrLine)
+ PrintPropertyList(SelectedTable, NewTableFileContent)
End If
- If Not bMMachineData AndAlso Not bMTable Then
+ If Not bMMachineData AndAlso Not bMTable AndAlso Not bPropertyTable Then
NewTableFileContent.Add(sCurrLine)
Else
bMMachineData = False
bMTable = False
+ bPropertyTable = False
End If
Next
File.WriteAllLines(sTableNamePath, NewTableFileContent, Text.Encoding.UTF8)
+ ' scrivo tabelle lavorazioni ordinate
+ For MachineIndex = 0 To SelectedTable.ActiveMachinesList.Count - 1
+ WriteMachiningOrderedTable(SelectedTable.ActiveMachinesList(MachineIndex), sTableNamePath)
+ Next
+ End Sub
+
+ Friend Sub WriteMachiningOrderedTable(SelectedMachine As MTableMachineListBoxItem, sTableNamePath As String)
+ Dim FileContent As String() = File.ReadAllLines(IniFile.m_sTablesRoot & "\" & MTABLETEMPLATE_FILE)
+ Dim NewTableFileContent As New List(Of String)
+ Dim bMMachineData As Boolean = False
+ Dim bWaitClosure As Boolean = False
+ Dim bMTable As Boolean = False
+ Dim bPropertyTable As Boolean = False
+ For LineIndex As Integer = 0 To FileContent.Count - 1
+ Dim sCurrLine As String = FileContent(LineIndex)
+ sCurrLine = sCurrLine.Replace(DATETIME, System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"))
+ sCurrLine = sCurrLine.Replace(TABLENAME, Path.GetFileNameWithoutExtension(sTableNamePath))
+
+ If sCurrLine.Contains(MMACHINEDATA) Then
+ bMMachineData = True
+ bWaitClosure = True
+ ElseIf sCurrLine.Contains(MTABLE) Then
+ bMTable = True
+ NewTableFileContent.Add(sCurrLine)
+ PrintOrderedMachiningList(SelectedMachine, NewTableFileContent)
+ ElseIf sCurrLine.Contains(PROPERTYTABLE) Then
+ bPropertyTable = True
+ bWaitClosure = True
+ End If
+
+ If Not bMMachineData AndAlso Not bMTable AndAlso Not bPropertyTable Then
+ NewTableFileContent.Add(sCurrLine)
+ ElseIf bWaitClosure Then
+ bWaitClosure = False
+ Else
+ bMMachineData = False
+ bMTable = False
+ bPropertyTable = False
+ End If
+ Next
+ ' creo nuovo nome
+ Dim sOrderedTableName As String = Path.GetDirectoryName(sTableNamePath) & "\" & Path.GetFileNameWithoutExtension(sTableNamePath) & "_" & SelectedMachine.MachId.ToString & ".otl"
+ File.WriteAllLines(sOrderedTableName, NewTableFileContent, Text.Encoding.UTF8)
+ End Sub
+
+ Private Sub PrintOrderedMachiningList(CurrMachine As MTableMachineListBoxItem, NewTableFileContent As List(Of String))
+ For MachiningIndex = 0 To CurrMachine.MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = CurrMachine.MachiningList(MachiningIndex)
+ Dim sCurrTool As String = String.Empty
+ EgtMdbSetCurrMachining(CurrMachining.Machining)
+ Dim sTUUID As String = String.Empty
+ EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sTUUID)
+ EgtTdbGetToolFromUUID(sTUUID, sCurrTool)
+ Dim CurrentLine As String = " { Group = '" & CurrMachining.GroupId & "', Property = " & CurrMachining.PropertyPar &
+ ", Name = " & CurrMachining.Geometry & "', Mach = " & CurrMachining.Machining & " }"
+ If MachiningIndex < CurrMachine.MachiningList.Count - 1 Then
+ CurrentLine &= " ,"
+ End If
+ CurrentLine &= " -- " & sCurrTool
+ NewTableFileContent.Add(CurrentLine)
+ Next
End Sub
Private Sub PrintActiveMachineList(SelectedTable As MTableListBoxItem, NewTableFileContent As List(Of String))
@@ -173,16 +377,64 @@ Module TableUtility
Next
End Sub
+ Private Sub PrintPropertyList(SelectedTable As MTableListBoxItem, NewTableFileContent As List(Of String))
+ Dim CurrGroupId As Integer = -1
+ Dim LastGroupId As Integer = -1
+ For MachineIndex As Integer = 0 To SelectedTable.ActiveMachinesList.Count - 1
+ If SelectedTable.ActiveMachinesList(MachineIndex).MachiningList.Count > 0 Then
+ LastGroupId = SelectedTable.ActiveMachinesList(MachineIndex).MachiningList(SelectedTable.ActiveMachinesList(MachineIndex).MachiningList.Count - 1).GroupId
+ For MachiningIndex = 0 To SelectedTable.ActiveMachinesList(MachineIndex).MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedTable.ActiveMachinesList(MachineIndex).MachiningList(MachiningIndex)
+ If CurrMachining.GroupId <> CurrGroupId And Not String.IsNullOrWhiteSpace(CurrMachining.PropertyPar) Then
+ Dim CurrentLine As String = " { MachId = '" & SelectedTable.ActiveMachinesList(MachineIndex).MachId & "', Group = " & (CurrMachining.GroupId * 100).ToString &
+ ", Property = " & CurrMachining.PropertyPar & " }"
+ If CurrMachining.GroupId <> LastGroupId Then
+ CurrentLine &= " ,"
+ End If
+ NewTableFileContent.Add(CurrentLine)
+ CurrGroupId = CurrMachining.GroupId
+ ElseIf CurrMachining.GroupId <> CurrGroupId And CurrMachining.GroupId = LastGroupId Then
+ NewTableFileContent(NewTableFileContent.Count - 1) = NewTableFileContent(NewTableFileContent.Count - 1).Trim(","c)
+ End If
+ Next
+ End If
+ Next
+ End Sub
+
+ Private Sub ReorderMachiningIndex(SelectedTable As MTableListBoxItem)
+ For MachineIndex = 0 To SelectedTable.ActiveMachinesList.Count - 1
+ Dim nCurrGroupIndex As Integer = 0
+ Dim nCurrGroupOrd As Integer = 0
+ For MachiningIndex = 0 To SelectedTable.ActiveMachinesList(MachineIndex).MachiningList.Count - 1
+ Dim CurrMachining As MTableMachiningGridBoxItem = SelectedTable.ActiveMachinesList(MachineIndex).MachiningList(MachiningIndex)
+ If CurrMachining.GroupId = 0 Then Continue For
+ If CurrMachining.GroupId <> nCurrGroupIndex Then
+ nCurrGroupOrd = 0
+ nCurrGroupIndex = CurrMachining.GroupId
+ Else
+ nCurrGroupOrd += 1
+ End If
+ CurrMachining.RWGroupId = CurrMachining.GroupId * 100 + nCurrGroupOrd
+ Next
+ Next
+ End Sub
+
Private Sub PrintActiveMachiningList(SelectedTable As MTableListBoxItem, NewTableFileContent As List(Of String))
For Index As Integer = 0 To SelectedTable.AssociationList.Count - 1
If String.IsNullOrEmpty(SelectedTable.AssociationList(Index).Name) Then Continue For
- Dim CurrentLine As String = " { On = " & If(SelectedTable.AssociationList(Index).OnPar, 1, 0) & ", Name = '" & SelectedTable.AssociationList(Index).Name & "'" _
- & If(Not String.IsNullOrEmpty(SelectedTable.AssociationList(Index).Oper), ", Oper = '" & SelectedTable.AssociationList(Index).Oper & "'", String.Empty) _
- & If(Not IsNothing(SelectedTable.AssociationList(Index).MachId) AndAlso SelectedTable.AssociationList(Index).MachId > 1, ", MachId = " & SelectedTable.AssociationList(Index).MachId.ToString, String.Empty) _
- & If(SelectedTable.AssociationList(Index).Shift <> 0, ", Shift = " & SelectedTable.AssociationList(Index).Shift.ToString, String.Empty) _
- & If(Not String.IsNullOrEmpty(SelectedTable.AssociationList(Index).Mach), ", Mach = '" & SelectedTable.AssociationList(Index).Mach & "'", String.Empty) _
- & If(Not String.IsNullOrEmpty(SelectedTable.AssociationList(Index).MachUp), ", MachUp = '" & SelectedTable.AssociationList(Index).MachUp & "'", String.Empty) _
- & If(Not String.IsNullOrEmpty(SelectedTable.AssociationList(Index).MachDw), ", MachDw = '" & SelectedTable.AssociationList(Index).MachDw & "'", String.Empty) & " }"
+ Dim CurrentLine As String = " { On = " & If(SelectedTable.AssociationList(Index).OnPar, 1, 0) & ", Name = '" & SelectedTable.AssociationList(Index).Name & "'" &
+ If(Not String.IsNullOrEmpty(SelectedTable.AssociationList(Index).Oper), ", Oper = '" & SelectedTable.AssociationList(Index).Oper & "'", String.Empty) &
+ If(Not IsNothing(SelectedTable.AssociationList(Index).MachId) AndAlso SelectedTable.AssociationList(Index).MachId > 1, ", MachId = " & SelectedTable.AssociationList(Index).MachId.ToString, String.Empty) &
+ If(SelectedTable.AssociationList(Index).Shift <> 0, ", Shift = " & SelectedTable.AssociationList(Index).Shift.ToString, String.Empty) &
+ If(Not String.IsNullOrEmpty(SelectedTable.AssociationList(Index).Mach), ", MachOrd = '" & SelectedTable.AssociationList(Index).RefMachItem.RWGroupId & "'" &
+ ", MachJoin = '" & If(SelectedTable.AssociationList(Index).RefMachItem.Join, 1, 0) & "'" &
+ ", Mach = '" & SelectedTable.AssociationList(Index).Mach & "'", String.Empty) &
+ If(Not String.IsNullOrEmpty(SelectedTable.AssociationList(Index).MachUp), ", MachUpOrd = '" & SelectedTable.AssociationList(Index).RefMachUpItem.RWGroupId & "'" &
+ ", MachUpJoin = '" & If(SelectedTable.AssociationList(Index).RefMachUpItem.Join, 1, 0) & "'" &
+ ", MachUp = '" & SelectedTable.AssociationList(Index).MachUp & "'", String.Empty) &
+ If(Not String.IsNullOrEmpty(SelectedTable.AssociationList(Index).MachDw), ", MachDwOrd = '" & SelectedTable.AssociationList(Index).RefMachDwItem.RWGroupId & "'" &
+ ", MachDwJoin = '" & If(SelectedTable.AssociationList(Index).RefMachDwItem.Join, 1, 0) & "'" &
+ ", MachDw = '" & SelectedTable.AssociationList(Index).MachDw & "'", String.Empty) & " }"
If Index < SelectedTable.AssociationList.Count - 1 Then
CurrentLine &= " ,"
End If
diff --git a/MachiningsDbWindow/MachiningsDbView.xaml b/MachiningsDbWindow/MachiningsDbView.xaml
index 2761917..938ccb7 100644
--- a/MachiningsDbWindow/MachiningsDbView.xaml
+++ b/MachiningsDbWindow/MachiningsDbView.xaml
@@ -107,13 +107,13 @@
-
-
-
+
+
+
diff --git a/MainWindow/MainWindowViewModel.vb b/MainWindow/MainWindowViewModel.vb
index 2c2e202..2047649 100644
--- a/MainWindow/MainWindowViewModel.vb
+++ b/MainWindow/MainWindowViewModel.vb
@@ -298,6 +298,7 @@ Namespace EgtCAM5
m_sTempDir = m_sDataRoot & "\" & TEMP_DIR
' Impostazione path Ini file
m_sIniFile = m_sConfigDir & "\" & INI_FILE_NAME
+ EgtWPFLib5.IniFile.m_sIniFile = m_sIniFile
' Impostazione path resources dir
m_sResourcesRoot = m_sDataRoot & "\" & RES_DIR
' Impostazione direttorio per le macchine
diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb
index 348eb8f..da14ca5 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/ProjectPage/DoorsPanel/DoorsPanelViewModel.vb b/ProjectPage/DoorsPanel/DoorsPanelViewModel.vb
index 3f3c9f2..c35e2b4 100644
--- a/ProjectPage/DoorsPanel/DoorsPanelViewModel.vb
+++ b/ProjectPage/DoorsPanel/DoorsPanelViewModel.vb
@@ -130,12 +130,16 @@ Namespace EgtCAM5
End If
' verifico
If Not EgtVerifyMachinesDir() Then Return
- Dim MTableDbWindow As New MTableDbView
- MTableDbWindow.Height = 614
- MTableDbWindow.Width = 1024
- MTableDbWindow.DataContext = New MTableDbViewModel
- MTableDbWindow.Owner = Application.Current.MainWindow
- MTableDbWindow.ShowDialog()
+
+ Dim MTableDb As New MTableDbV(Application.Current.MainWindow, New MTableDbVM)
+ MTableDb.ShowDialog()
+
+ 'Dim MTableDbWindow As New MTableDbView
+ 'MTableDbWindow.Height = 614
+ 'MTableDbWindow.Width = 1024
+ 'MTableDbWindow.DataContext = New MTableDbViewModel
+ 'MTableDbWindow.Owner = Application.Current.MainWindow
+ 'MTableDbWindow.ShowDialog()
End Sub
#End Region ' MTableDbCommand
diff --git a/Utility/VMBase.vb b/Utility/VMBase.vb
new file mode 100644
index 0000000..0d9709a
--- /dev/null
+++ b/Utility/VMBase.vb
@@ -0,0 +1,12 @@
+Imports System.ComponentModel
+
+Public Class VMBase
+ Implements INotifyPropertyChanged
+
+ Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
+
+ Public Sub NotifyPropertyChanged(propName As String)
+ RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
+ End Sub
+
+End Class