diff --git a/AttachedBehaviours/ScrollIntoView.vb b/AttachedBehaviours/ScrollIntoView.vb
new file mode 100644
index 0000000..879a2be
--- /dev/null
+++ b/AttachedBehaviours/ScrollIntoView.vb
@@ -0,0 +1,152 @@
+Imports System.Windows.Interactivity
+Imports System.Collections.Specialized
+
+Public Class ScrollIntoViewForListBox
+ Inherits Behavior(Of ListBox)
+
+ Private ItemsSource As INotifyCollectionChanged
+
+ Private ListControl As ListBox
+
+ '''
+ ''' When Beahvior is attached
+ '''
+ Protected Overrides Sub OnAttached()
+ MyBase.OnAttached()
+ ListControl = Me.AssociatedObject
+ AddHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged
+ End Sub
+
+
+ Private Sub AssociatedObject_CollectionChanged(sender As Object, e As System.Collections.Specialized.NotifyCollectionChangedEventArgs)
+ If ListControl.SelectedItem IsNot Nothing Then
+ Dim SelectedItemIndex As Integer = ListControl.Items.IndexOf(ListControl.SelectedItem)
+ ListControl.Dispatcher.BeginInvoke(DirectCast(Sub()
+ ListControl.UpdateLayout()
+ If ListControl.SelectedItem IsNot Nothing Then
+ ListControl.ScrollIntoView(ListControl.SelectedItem)
+ End If
+ End Sub, Action))
+ If SelectedItemIndex > 0 Then
+ ListControl.Dispatcher.BeginInvoke(DirectCast(Sub()
+ ListControl.UpdateLayout()
+ ListControl.ScrollIntoView(ListControl.Items(SelectedItemIndex - 1))
+ End Sub, Action))
+ End If
+ If SelectedItemIndex < ListControl.Items.Count - 2 Then
+ ListControl.Dispatcher.BeginInvoke(DirectCast(Sub()
+ ListControl.UpdateLayout()
+ ListControl.ScrollIntoView(ListControl.Items(SelectedItemIndex + 1))
+ End Sub, Action))
+ End If
+ End If
+ End Sub
+
+ '''
+ ''' On Selection Changed
+ '''
+ '''
+ '''
+ Private Sub AssociatedObject_SelectionChanged(sender As Object, e As SelectionChangedEventArgs)
+ If IsNothing(ItemsSource) Then
+ Dim CurrItemsSource As IEnumerable = Me.AssociatedObject.ItemsSource
+ ItemsSource = TryCast(CurrItemsSource, INotifyCollectionChanged)
+ AddHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged
+ RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged
+
+ ' SE SI CAMBIA ITEMSSOURCE PERDE IL RIFERIMENTO E SMETTE DI FUNZIONARE
+ ' PER RIATTIVARLO USARE IL SEGUENTE CODICE COMMENTATO
+ 'ElseIf ItemsSource IsNot Me.AssociatedObject.ItemsSource Then
+ ' Dim PreviousItemsSourceList As INotifyCollectionChanged = TryCast(ItemsSource, INotifyCollectionChanged)
+ ' RemoveHandler PreviousItemsSourceList.CollectionChanged, AddressOf AssociatedObject_CollectionChanged
+ ' Dim CurrItemsSource As IEnumerable = Me.AssociatedObject.ItemsSource
+ ' ItemsSource = TryCast(CurrItemsSource, INotifyCollectionChanged)
+ ' AddHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged
+ End If
+ End Sub
+
+ '''
+ ''' When behavior is detached
+ '''
+ Protected Overrides Sub OnDetaching()
+ MyBase.OnDetaching()
+ 'RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged
+ RemoveHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged
+ End Sub
+
+End Class
+
+Public Class ScrollIntoViewForDataGrid
+ Inherits Behavior(Of DataGrid)
+
+ Private ItemsSource As INotifyCollectionChanged
+
+ Private ListControl As DataGrid
+
+ '''
+ ''' When Beahvior is attached
+ '''
+ Protected Overrides Sub OnAttached()
+ MyBase.OnAttached()
+ ListControl = Me.AssociatedObject
+ AddHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged
+ End Sub
+
+
+ Private Sub AssociatedObject_CollectionChanged(sender As Object, e As System.Collections.Specialized.NotifyCollectionChangedEventArgs)
+ If ListControl.SelectedItem IsNot Nothing Then
+ Dim SelectedItemIndex As Integer = ListControl.Items.IndexOf(ListControl.SelectedItem)
+ ListControl.Dispatcher.BeginInvoke(DirectCast(Sub()
+ ListControl.UpdateLayout()
+ If ListControl.SelectedItem IsNot Nothing Then
+ ListControl.ScrollIntoView(ListControl.SelectedItem)
+ End If
+ End Sub, Action))
+ If SelectedItemIndex > 0 Then
+ ListControl.Dispatcher.BeginInvoke(DirectCast(Sub()
+ ListControl.UpdateLayout()
+ ListControl.ScrollIntoView(ListControl.Items(SelectedItemIndex - 1))
+ End Sub, Action))
+ End If
+ If SelectedItemIndex < ListControl.Items.Count - 2 Then
+ ListControl.Dispatcher.BeginInvoke(DirectCast(Sub()
+ ListControl.UpdateLayout()
+ ListControl.ScrollIntoView(ListControl.Items(SelectedItemIndex + 1))
+ End Sub, Action))
+ End If
+ End If
+ End Sub
+
+ '''
+ ''' On Selection Changed
+ '''
+ '''
+ '''
+ Private Sub AssociatedObject_SelectionChanged(sender As Object, e As SelectionChangedEventArgs)
+ If IsNothing(ItemsSource) Then
+ Dim CurrItemsSource As IEnumerable = Me.AssociatedObject.ItemsSource
+ ItemsSource = TryCast(CurrItemsSource, INotifyCollectionChanged)
+ AddHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged
+ RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged
+
+ ' SE SI CAMBIA ITEMSSOURCE PERDE IL RIFERIMENTO E SMETTE DI FUNZIONARE
+ ' PER RIATTIVARLO USARE IL SEGUENTE CODICE COMMENTATO
+ 'ElseIf ItemsSource IsNot Me.AssociatedObject.ItemsSource Then
+ ' Dim PreviousItemsSourceList As INotifyCollectionChanged = TryCast(ItemsSource, INotifyCollectionChanged)
+ ' RemoveHandler PreviousItemsSourceList.CollectionChanged, AddressOf AssociatedObject_CollectionChanged
+ ' Dim CurrItemsSource As IEnumerable = Me.AssociatedObject.ItemsSource
+ ' ItemsSource = TryCast(CurrItemsSource, INotifyCollectionChanged)
+ ' AddHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged
+ End If
+ End Sub
+
+ '''
+ ''' When behavior is detached
+ '''
+ Protected Overrides Sub OnDetaching()
+ MyBase.OnDetaching()
+ 'RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged
+ RemoveHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged
+ End Sub
+
+End Class
diff --git a/AttachedBehaviours/ScrollIntoViewForListBox.vb b/AttachedBehaviours/ScrollIntoViewForListBox.vb
deleted file mode 100644
index 7c4f6e4..0000000
--- a/AttachedBehaviours/ScrollIntoViewForListBox.vb
+++ /dev/null
@@ -1,42 +0,0 @@
-Imports System.Windows.Interactivity
-
-Public Class ScrollIntoViewForListBox
- Inherits Behavior(Of ListBox)
-
- '''
- ''' When Beahvior is attached
- '''
- Protected Overrides Sub OnAttached()
- MyBase.OnAttached()
- AddHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged
- End Sub
-
- '''
- ''' On Selection Changed
- '''
- '''
- '''
- Private Sub AssociatedObject_SelectionChanged(sender As Object, e As SelectionChangedEventArgs)
- If TypeOf sender Is ListBox Then
- Dim listBox As ListBox = TryCast(sender, ListBox)
- If listBox.SelectedItem IsNot Nothing Then
- listBox.Dispatcher.BeginInvoke(DirectCast(Sub()
- listBox.UpdateLayout()
- If listBox.SelectedItem IsNot Nothing Then
- listBox.ScrollIntoView(listBox.SelectedItem)
- End If
-
- End Sub, Action))
- End If
- End If
- End Sub
- '''
- ''' When behavior is detached
- '''
- Protected Overrides Sub OnDetaching()
- MyBase.OnDetaching()
- RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged
-
- End Sub
-
-End Class
diff --git a/Constants/ConstDoors.vb b/Constants/ConstDoors.vb
new file mode 100644
index 0000000..71f5562
--- /dev/null
+++ b/Constants/ConstDoors.vb
@@ -0,0 +1,6 @@
+Module ConstDoors
+
+ Public Const S_OPERATIONS As String = "Operations"
+ Public Const S_GEOMETRYNAMES As String = "GeometryNames"
+
+End Module
diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj
index e15ec6c..59904e4 100644
--- a/EgtCAM5.vbproj
+++ b/EgtCAM5.vbproj
@@ -120,22 +120,25 @@
-
+
+
+ MTableDbView.xaml
+ OptionsView.xaml
diff --git a/EgtCAM5Resources.xaml b/EgtCAM5Resources.xaml
index c958cd8..43290c2 100644
--- a/EgtCAM5Resources.xaml
+++ b/EgtCAM5Resources.xaml
@@ -33,6 +33,7 @@
+
-
-
diff --git a/MTableDb/MTableDbView.xaml b/MTableDb/MTableDbView.xaml
index 86d9279..f790d0b 100644
--- a/MTableDb/MTableDbView.xaml
+++ b/MTableDb/MTableDbView.xaml
@@ -1,6 +1,8 @@
-
+
-
-
+
+
+
+
+
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MTableDb/MTableDbViewModel.vb b/MTableDb/MTableDbViewModel.vb
index cbfe6b3..6a39eae 100644
--- a/MTableDb/MTableDbViewModel.vb
+++ b/MTableDb/MTableDbViewModel.vb
@@ -1,29 +1,34 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
+Imports System.Text.RegularExpressions
Namespace EgtCAM5
Public Class MTableDbViewModel
Inherits TabViewModel
- Private m_TablesList As New ObservableCollection(Of String)
- Public Property TablesList As ObservableCollection(Of 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 String))
+ Set(value As ObservableCollection(Of MTableListBoxItem))
m_TablesList = value
End Set
End Property
- Private m_SelectedTable As String
- Public Property SelectedTable As String
+ Private m_SelectedTable As MTableListBoxItem
+ Public Property SelectedTable As MTableListBoxItem
Get
Return m_SelectedTable
End Get
- Set(value As String)
- m_SelectedTable = value
+ Set(value As MTableListBoxItem)
+ If value IsNot m_SelectedTable Then
+ m_SelectedTable = value
+ m_SelectedTable.SelectedAssociation = If(m_SelectedTable.AssociationList.Count > 0, m_SelectedTable.AssociationList(0), Nothing)
+ OnPropertyChanged("SelectedTable")
+ End If
End Set
End Property
@@ -34,23 +39,356 @@ Namespace EgtCAM5
End Get
End Property
+ ' Definizione comandi
+ Private m_cmdNewTable As ICommand
+ Private m_cmdSaveTable As ICommand
+ Private m_cmdSaveTableAs As ICommand
+ Private m_cmdRemoveTable 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
+
+#Region "CONSTRUCTOR"
+
Sub New()
SearchTables()
+ SelectedTable = If(m_TablesList.Count > 0, m_TablesList(0), Nothing)
End Sub
+#End Region
+
+#Region "METHODS"
+
Private Sub SearchTables()
' Leggo dal file ini il direttorio per le Table
- If GetPrivateProfileString(S_TABLE, K_TABLESDIR, "", m_sTablesRoot) = 0 _
- Or Not My.Computer.FileSystem.DirectoryExists(m_sTablesRoot) Then
+ If GetPrivateProfileString(S_TABLE, K_TABLESDIR, "", IniFile.m_sTablesRoot) = 0 _
+ Or Not My.Computer.FileSystem.DirectoryExists(IniFile.m_sTablesRoot) Then
' Se non lo trovo mando messaggio di errore e chiudo la finestra
MessageBox.Show("ERROR IN LOADING TABLES", "Tables dir not found.")
End If
' se trovo la cartella carico la lista di tabelle
- For Each Table In My.Computer.FileSystem.GetFiles(m_sTablesRoot)
- m_TablesList.Add(Path.GetFileNameWithoutExtension(Table))
+ For Each Table In My.Computer.FileSystem.GetFiles(IniFile.m_sTablesRoot)
+ If Path.GetExtension(Table).ToLower = ".lua" Then
+ m_TablesList.Add(New MTableListBoxItem(Path.GetFileNameWithoutExtension(Table), Table))
+ Dim sNameIndex As String = Regex.Match(Path.GetFileNameWithoutExtension(Table), "MTable_(\d+)").Groups(1).Value
+ Dim nNameIndex As Integer = 0
+ If String.IsNullOrEmpty(sNameIndex) Then
+ ' il suo valore di default è 1 quindi lo imposto a questo valore
+ nNameIndex = 0
+ Else
+ Integer.TryParse(sNameIndex, nNameIndex)
+ End If
+ If nNameIndex > MTableListBoxItem.NewMTableIndex Then
+ MTableListBoxItem.NewMTableIndex = nNameIndex
+ End If
+ End If
Next
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(ByVal param As Object)
+ Dim NewMTable As MTableListBoxItem = New MTableListBoxItem("MTable_" & MTableListBoxItem.NewMTableIndex, String.Empty)
+ m_TablesList.Add(NewMTable)
+ MTableListBoxItem.NewMTableIndex += 1
+ SelectedTable = NewMTable
+ 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
+
+ Private Const MMACHINEDATA As String = ".MMachineData"
+ Private Const MTABLE As String = ".MTable"
+ Private Const DATETIME As String = "%DATE_TIME%"
+ Private Const TABLENAME As String = "%TABLE_NAME%"
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub SaveTable()
+ If String.IsNullOrEmpty(SelectedTable.TableNamePath) Then
+ SaveTableAs()
+ Return
+ End If
+ TableUtility.WriteDoorsTable(SelectedTable, SelectedTable.TableNamePath)
+ 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()
+ Dim sFile As String = String.Empty
+ ' Direttorio corrente per MTable
+ Dim sDir As String = IniFile.m_sTablesRoot
+ ' Apertura dialogo di scelta file DDF
+ Dim SaveFileDialog As New System.Windows.Forms.SaveFileDialog
+ SaveFileDialog.Title = "Save MTable file"
+ SaveFileDialog.Filter = "MTable Lua script(*.lua)|*.lua"
+ SaveFileDialog.FilterIndex = 1
+ SaveFileDialog.InitialDirectory = sDir
+ SaveFileDialog.FileName = m_SelectedTable.TableName
+ If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
+ Exit Sub
+ End If
+ sFile = SaveFileDialog.FileName
+ TableUtility.WriteDoorsTable(SelectedTable, sFile)
+ End Sub
+
+#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(ByVal param As Object)
+ If MessageBox.Show("Are you sure you want to delete this MTable?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then
+ File.Delete(SelectedTable.TableNamePath)
+ Dim SelectedTableIndex As Integer = m_TablesList.IndexOf(m_SelectedTable)
+ m_TablesList.RemoveAt(SelectedTableIndex)
+ If SelectedTableIndex > 0 Then
+ SelectedTable = TablesList(SelectedTableIndex - 1)
+ End If
+ End If
+ End Sub
+
+#End Region ' RemoveTableCommand
+
+#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(ByVal param As Object)
+ If Not IsNothing(m_SelectedTable) Then
+ m_SelectedTable.SharedMachIndex += 1
+ m_SelectedTable.ActiveMachinesList.Add(New MTableMachineListBoxItem(String.Empty, False, False, m_SelectedTable.SharedMachIndex))
+ m_SelectedTable.MachIdList.Add(m_SelectedTable.SharedMachIndex)
+ End If
+ 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(ByVal param As Object)
+ If Not IsNothing(m_SelectedTable) And m_SelectedTable.ActiveMachinesList.Count > 1 Then
+ m_SelectedTable.ActiveMachinesList.RemoveAt(m_SelectedTable.SharedMachIndex - 1)
+ m_SelectedTable.MachIdList.RemoveAt(m_SelectedTable.SharedMachIndex - 1)
+ m_SelectedTable.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(ByVal param As Object)
+ If Not IsNothing(m_SelectedTable) And Not IsNothing(m_SelectedTable.SelectedAssociation) Then
+ Dim SelectedIndex As Integer = m_SelectedTable.AssociationList.IndexOf(m_SelectedTable.SelectedAssociation)
+ Dim NewEmptyRow As MTableAssociationGridBoxItem = New MTableAssociationGridBoxItem(False, String.Empty, 1, 0, String.Empty, String.Empty, String.Empty, String.Empty)
+ m_SelectedTable.AssociationList.Insert(SelectedIndex, NewEmptyRow)
+ m_SelectedTable.SelectedAssociation = NewEmptyRow
+ m_SelectedTable.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(ByVal param As Object)
+ If Not IsNothing(m_SelectedTable) And m_SelectedTable.AssociationList.Count > 1 Then
+ Dim SelectedIndex As Integer = m_SelectedTable.AssociationList.IndexOf(m_SelectedTable.SelectedAssociation)
+ m_SelectedTable.AssociationList.RemoveAt(SelectedIndex)
+ If Not SelectedIndex < m_SelectedTable.AssociationList.Count Then
+ SelectedIndex = m_SelectedTable.AssociationList.Count - 1
+ End If
+ m_SelectedTable.SelectedAssociation = m_SelectedTable.AssociationList(SelectedIndex)
+ m_SelectedTable.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(ByVal param As Object)
+ If Not IsNothing(m_SelectedTable) Then
+ Dim SelectedIndex As Integer = m_SelectedTable.AssociationList.IndexOf(m_SelectedTable.SelectedAssociation)
+ If SelectedIndex >= 1 Then
+ m_SelectedTable.AssociationList.Move(SelectedIndex, SelectedIndex - 1)
+ End If
+ 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(ByVal param As Object)
+ If Not IsNothing(m_SelectedTable) Then
+ Dim SelectedIndex As Integer = m_SelectedTable.AssociationList.IndexOf(m_SelectedTable.SelectedAssociation)
+ If SelectedIndex < m_SelectedTable.AssociationList.Count - 1 Then
+ m_SelectedTable.AssociationList.Move(SelectedIndex, SelectedIndex + 1)
+ End If
+ End If
+ End Sub
+
+#End Region ' MoveRowDownCommand
+
+#End Region
+
End Class
End Namespace
\ No newline at end of file
diff --git a/MTableDb/MTableListBox.vb b/MTableDb/MTableListBox.vb
index 04c3ff3..f0d0a0b 100644
--- a/MTableDb/MTableListBox.vb
+++ b/MTableDb/MTableListBox.vb
@@ -1,79 +1,199 @@
Imports System.ComponentModel
Imports System.Collections.ObjectModel
+Imports System.Text.RegularExpressions
+Imports System.IO
Imports EgtUILib
+Imports EgtCAM5.MachineModel
-Public Class MTableListBox
+Public Class MTableListBoxItem
Implements INotifyPropertyChanged
- Private m_Name As String
- Public Property Name As String
+ Friend SharedMachIndex As Integer = 0
+
+ Friend Shared NewMTableIndex As Integer = 1
+
+ Private m_TableNamePath As String
+ Public ReadOnly Property TableNamePath As String
Get
- Return m_Name
+ Return m_TableNamePath
+ End Get
+ End Property
+
+ Private m_TableName As String
+ Public Property TableName As String
+ Get
+ Return m_TableName
End Get
Set(value As String)
- m_Name = value
+ m_TableName = value
End Set
End Property
- Private m_MachineList As ObservableCollection(Of MTableMachineListBox)
- Public Property MachineList As ObservableCollection(Of MTableMachineListBox)
+ Private m_ActiveMachinesList As New ObservableCollection(Of MTableMachineListBoxItem)
+ Public Property ActiveMachinesList As ObservableCollection(Of MTableMachineListBoxItem)
Get
- Return m_MachineList
+ Return m_ActiveMachinesList
End Get
- Set(value As ObservableCollection(Of MTableMachineListBox))
- m_MachineList = Value
+ Set(value As ObservableCollection(Of MTableMachineListBoxItem))
+ m_ActiveMachinesList = value
End Set
End Property
- 'Private m_OnPar As Boolean
- 'Public Property OnPar As Boolean
- ' Get
- ' Return m_OnPar
- ' End Get
- ' Set(value As Boolean)
- ' m_OnPar = value
- ' End Set
- 'End Property
+ Private m_AssociationList As New ObservableCollection(Of MTableAssociationGridBoxItem)
+ Public Property AssociationList As ObservableCollection(Of MTableAssociationGridBoxItem)
+ Get
+ Return m_AssociationList
+ End Get
+ Set(value As ObservableCollection(Of MTableAssociationGridBoxItem))
+ m_AssociationList = value
+ End Set
+ End Property
- 'Private m_Oper As Boolean
- 'Public Property Oper As Boolean
- ' Get
- ' Return m_Oper
- ' End Get
- ' Set(value As Boolean)
- ' m_Oper = value
- ' End Set
- 'End Property
+ Private m_SelectedAssociation As MTableAssociationGridBoxItem
+ Public Property SelectedAssociation As MTableAssociationGridBoxItem
+ Get
+ Return m_SelectedAssociation
+ End Get
+ Set(value As MTableAssociationGridBoxItem)
+ m_SelectedAssociation = value
+ End Set
+ End Property
- 'Private m_Mach As Boolean
- 'Public Property Mach As Boolean
- ' Get
- ' Return m_Mach
- ' End Get
- ' Set(value As Boolean)
- ' m_Mach = value
- ' End Set
- 'End Property
+ ' Lista dei MachId per ComboBox nella DataGrid
+ Private m_MachIdList As New ObservableCollection(Of Integer)
+ Public Property MachIdList As ObservableCollection(Of Integer)
+ Get
+ Return m_MachIdList
+ End Get
+ Set(value As ObservableCollection(Of Integer))
+ m_MachIdList = value
+ End Set
+ End Property
- 'Private m_MachUp As Boolean
- 'Public Property MachUp As Boolean
- ' Get
- ' Return m_MachUp
- ' End Get
- ' Set(value As Boolean)
- ' m_MachUp = value
- ' End Set
- 'End Property
+ Sub New(sTableName As String, sTableNamePath As String)
+ TableName = sTableName
+ m_TableNamePath = sTableNamePath
+ ReadMTableFile()
+ End Sub
- 'Private m_MachDw As Boolean
- 'Public Property MachDw As Boolean
- ' Get
- ' Return m_MachDw
- ' End Get
- ' Set(value As Boolean)
- ' m_MachDw = value
- ' End Set
- 'End Property
+ Private Const MMACHINEDATA As String = ".MMachineData"
+ Private Const MACHNAME As String = "MachName"
+ Private Const NCGENERATE As String = "NcGenerate"
+ Private Const MAKERAW As String = "Makeraw"
+ Private Const MTABLE As String = ".MTable"
+ Private Const NAME As String = "Name"
+ Private Const ONCONST As String = "On"
+ Private Const MACH As String = "Mach"
+ Private Const MACHUP As String = "MachUp"
+ Private Const MACHDW As String = "MachDw"
+ Private Const MACHID As String = "MachId"
+ Private Const SHIFT As String = "Shift"
+ Private Const OPER As String = "Oper"
+
+ Private Sub ReadMTableFile()
+ If String.IsNullOrEmpty(m_TableNamePath) Then
+ SharedMachIndex += 1
+ ActiveMachinesList.Add(New MTableMachineListBoxItem(String.Empty, False, False, SharedMachIndex))
+ m_MachIdList.Add(SharedMachIndex)
+ AssociationList.Add(New MTableAssociationGridBoxItem(False, String.Empty, Nothing, 0, String.Empty, String.Empty, String.Empty, String.Empty))
+ Return
+ End If
+ ' resetto indici macchine impostati in tabella
+ m_MachIdList.Clear()
+ Dim FileContent As IEnumerable(Of String) = File.ReadLines(m_TableNamePath)
+ Dim bMMachineData As Boolean = False
+ Dim bMTable 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
+ End If
+ Dim Open As Integer = CountCharacter(FileContent(LineIndex), "{"c)
+ Dim Close As Integer = CountCharacter(FileContent(LineIndex), "}"c)
+ If Close > Open Then
+ If bMMachineData Then
+ bMMachineData = False
+ ElseIf bMTable Then
+ bMTable = False
+ End If
+ End If
+ If bMMachineData Then
+ Dim sMachName As String = SearchKey(FileContent(LineIndex), MACHNAME)
+ Dim bNcGenerate As Boolean = False
+ Dim bMakeraw As Boolean = False
+ If Not String.IsNullOrEmpty(sMachName) Then
+ Dim sNcGenerate As String = SearchKey(FileContent(LineIndex), NCGENERATE)
+ If Not String.IsNullOrEmpty(sNcGenerate) Then
+ bNcGenerate = Convert.ToBoolean(sNcGenerate)
+ End If
+ Dim sMakeraw As String = SearchKey(FileContent(LineIndex), MAKERAW)
+ If Not String.IsNullOrEmpty(sMakeraw) Then
+ bMakeraw = Convert.ToBoolean(sMakeraw)
+ End If
+ SharedMachIndex += 1
+ ActiveMachinesList.Add(New MTableMachineListBoxItem(sMachName, bNcGenerate, bMakeraw, SharedMachIndex))
+ m_MachIdList.Add(SharedMachIndex)
+ End If
+ End If
+ If bMTable Then
+ Dim sName As String = SearchKey(FileContent(LineIndex), NAME)
+ Dim bOn As Boolean = False
+ Dim sMach As String = String.Empty
+ Dim sMachUp As String = String.Empty
+ Dim sMachDw As String = String.Empty
+ Dim nMachId As Integer = 1
+ Dim nShift As Integer = 0
+ Dim sOper As String = String.Empty
+ If Not String.IsNullOrEmpty(sName) Then
+ Dim sOn As String = SearchKey(FileContent(LineIndex), ONCONST)
+ If Not String.IsNullOrEmpty(sOn) Then
+ Dim nValue As Integer
+ Integer.TryParse(sOn, nValue)
+ bOn = nValue <> 0
+ End If
+ sMach = SearchKey(FileContent(LineIndex), MACH)
+ sMachUp = SearchKey(FileContent(LineIndex), MACHUP)
+ sMachDw = SearchKey(FileContent(LineIndex), MACHDW)
+ Dim sMachId = SearchKey(FileContent(LineIndex), MACHID)
+ 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 sShift = SearchKey(FileContent(LineIndex), SHIFT)
+ If String.IsNullOrEmpty(sShift) Then
+ ' il suo valore di default è 1 quindi lo imposto a questo valore
+ nShift = 0
+ Else
+ Integer.TryParse(sShift, nShift)
+ End If
+ sOper = SearchKey(FileContent(LineIndex), OPER)
+ ' verifico che il MachId letto sia valido
+ If nMachId > m_MachIdList.Count Then
+ nMachId = 0
+ End If
+ AssociationList.Add(New MTableAssociationGridBoxItem(bOn, sName, nMachId, nShift, sOper, sMach, sMachUp, sMachDw))
+ End If
+
+ End If
+ Next
+ End Sub
+
+ Private Function SearchKey(sLine As String, sKey As String) As String
+ Dim x = Regex.Match(sLine, "[,|{|\s]" & sKey & "\s*=\s*['|\""]?(.*?)\s*?[,|}|'|\""]").Groups(1).Value
+ Return Regex.Match(sLine, "[,|{|\s]" & sKey & "\s*=\s*['|\""]?(.*?)\s*?[,|}|'|\""]").Groups(1).Value
+ End Function
+
+ Public Function CountCharacter(ByVal sLine As String, ByVal cValue As Char) As Integer
+ Dim nCount As Integer = 0
+ Dim cArray() As Char = sLine.ToCharArray
+ For Index As Integer = 0 To cArray.Count - 1
+ If cArray(Index) = cValue Then nCount += 1
+ Next
+ Return nCount
+ End Function
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
@@ -83,15 +203,39 @@ Public Class MTableListBox
End Class
-Public Class MTableMachineListBox
+Public Class MTableMachineListBoxItem
+ Implements INotifyPropertyChanged
- Private m_MachName As String
- Public Property MachName As String
+ ' Indice della macchina
+ Private m_MachId As Integer
+ Public Property MachId As Integer
Get
- Return m_MachName
+ Return m_MachId
+ End Get
+ Set(value As Integer)
+ m_MachId = value
+ End Set
+ End Property
+
+ ' Lista di macchine per la ComboBox
+ Private Shared m_MachinesList As New ObservableCollection(Of String)
+ Public Property MachinesList As ObservableCollection(Of String)
+ Get
+ Return m_MachinesList
+ End Get
+ Set(value As ObservableCollection(Of String))
+ m_MachinesList = value
+ End Set
+ End Property
+
+ ' Macchina selezionata
+ Private m_SelectedMachine As String
+ Public Property SelectedMachine As String
+ Get
+ Return m_SelectedMachine
End Get
Set(value As String)
- m_MachName = value
+ m_SelectedMachine = value
End Set
End Property
@@ -115,8 +259,346 @@ Public Class MTableMachineListBox
End Set
End Property
-End Class
+ Sub New(sMachName As String, bNcGenerate As Boolean, bMakeraw As Boolean, nMachId As Integer)
+ If m_MachinesList.Count = 0 Then
+ SearchMachine()
+ End If
+ SelectedMachine = sMachName
+ NcGenerate = bNcGenerate
+ Makeraw = bMakeraw
+ MachId = nMachId
+ End Sub
-Public Class MTableAssociationGridBox
+ ' Funzione che cerca tutte le macchine disponibili per aggiungerle alla lista della ComboBox
+ Private Sub SearchMachine()
+ ' aggiungo elemento stringa vuota per dare la possibilità di non selezionarne nessuna macchina
+ MachinesList.Add(String.Empty)
+ ' aggiungo tutte le macchine
+ Dim TempArray As String() = Directory.GetDirectories(IniFile.m_sMachinesRoot)
+ For i As Integer = 0 To TempArray.Count - 1
+ Dim MachinePathIni As String = TempArray(i) & "\" & Path.GetFileName(TempArray(i)) & ".ini"
+ If File.Exists(MachinePathIni) Then
+ MachinesList.Add(Path.GetFileName(TempArray(i)))
+ End If
+ Next
+ 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 MTableAssociationGridBoxItem
+ Implements INotifyPropertyChanged
+
+ Private m_OnPar As Boolean
+ Public Property OnPar As Boolean
+ Get
+ Return m_OnPar
+ End Get
+ Set(value As Boolean)
+ m_OnPar = value
+ End Set
+ End Property
+
+ Private Shared m_NamesList As ObservableCollection(Of String)
+ Public Property NamesList As ObservableCollection(Of String)
+ Get
+ Return m_NamesList
+ End Get
+ Set(value As ObservableCollection(Of String))
+ If value IsNot m_NamesList Then
+ m_NamesList = value
+ End If
+ End Set
+ End Property
+
+ Private m_Name As String
+ Public Property Name As String
+ Get
+ Return m_Name
+ End Get
+ Set(value As String)
+ If m_NamesList.Contains(value) Then
+ m_Name = value
+ Else
+ m_Name = String.Empty
+ End If
+ End Set
+ End Property
+
+ Private Shared m_OperationsList As ObservableCollection(Of String)
+ Public Property OperationsList As ObservableCollection(Of String)
+ Get
+ Return m_OperationsList
+ End Get
+ Set(value As ObservableCollection(Of String))
+ m_OperationsList = value
+ End Set
+ End Property
+
+ Private m_Oper As String
+ Public Property Oper As String
+ Get
+ Return m_Oper
+ End Get
+ Set(value As String)
+ m_Oper = value
+ End Set
+ End Property
+
+ Private m_MachId As Integer?
+ Public Property MachId As Integer?
+ Get
+ Return m_MachId
+ End Get
+ Set(value As Integer?)
+ m_MachId = value
+ End Set
+ End Property
+
+ Private Shared m_ShiftList As New ObservableCollection(Of Integer)({0, 1})
+ Public ReadOnly Property ShiftList As ObservableCollection(Of Integer)
+ Get
+ Return m_ShiftList
+ End Get
+ End Property
+
+ Private m_Shift As Integer
+ Public Property Shift As Integer
+ Get
+ Return m_Shift
+ End Get
+ Set(value As Integer)
+ m_Shift = value
+ End Set
+ End Property
+
+ Private Shared m_MachTypeList As ObservableCollection(Of MachineModel.MachiningsType)
+ Public Property MachTypeList As ObservableCollection(Of MachineModel.MachiningsType)
+ Get
+ Return m_MachTypeList
+ End Get
+ Set(value As ObservableCollection(Of MachineModel.MachiningsType))
+ m_MachTypeList = value
+ End Set
+ End Property
+
+ Private m_SelectedMachType As MachineModel.MachiningsType
+ Public Property SelectedMachType As MachineModel.MachiningsType
+ Get
+ Return m_SelectedMachType
+ End Get
+ Set(value As MachineModel.MachiningsType)
+ If value IsNot m_SelectedMachType Then
+ m_SelectedMachType = value
+ ' Assegno alla lista delle lavorazioni della riga selezionata la lista di quelle del suo tipo
+ If IsNothing(m_SelectedMachType) Then
+ MachList = Nothing
+ End If
+ Select Case m_SelectedMachType.TypeId
+ Case MCH_MY.DRILLING
+ ' se la lista è vuota devo caricarla
+ If IsNothing(m_DrillingList) Then
+ m_DrillingList = New List(Of String)
+ LoadMachiningListByType(m_DrillingList, MCH_MY.DRILLING)
+ ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione
+ m_DrillingList.Insert(0, String.Empty)
+ End If
+ MachList = New ObservableCollection(Of String)(m_DrillingList)
+ Case MCH_MY.SAWING
+ ' se la lista è vuota devo caricarla
+ If IsNothing(m_SawingList) Then
+ m_SawingList = New List(Of String)
+ LoadMachiningListByType(m_SawingList, MCH_MY.SAWING)
+ ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione
+ m_SawingList.Insert(0, String.Empty)
+ End If
+ MachList = New ObservableCollection(Of String)(m_SawingList)
+ Case MCH_MY.MILLING
+ ' se la lista è vuota devo caricarla
+ If IsNothing(m_MillingList) Then
+ m_MillingList = New List(Of String)
+ LoadMachiningListByType(m_MillingList, MCH_MY.MILLING)
+ ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione
+ m_MillingList.Insert(0, String.Empty)
+ End If
+ MachList = New ObservableCollection(Of String)(m_MillingList)
+ Case MCH_MY.POCKETING
+ ' se la lista è vuota devo caricarla
+ If IsNothing(m_PocketingList) Then
+ m_PocketingList = New List(Of String)
+ LoadMachiningListByType(m_PocketingList, MCH_MY.POCKETING)
+ ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione
+ m_PocketingList.Insert(0, String.Empty)
+ End If
+ MachList = New ObservableCollection(Of String)(m_PocketingList)
+ Case MCH_MY.MORTISING
+ ' se la lista è vuota devo caricarla
+ If IsNothing(m_MortisingList) Then
+ m_MortisingList = New List(Of String)
+ LoadMachiningListByType(m_MortisingList, MCH_MY.MORTISING)
+ ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione
+ m_MortisingList.Insert(0, String.Empty)
+ End If
+ MachList = New ObservableCollection(Of String)(m_MortisingList)
+ Case MCH_MY.SAWROUGHING
+ ' se la lista è vuota devo caricarla
+ If IsNothing(m_SawRoughingList) Then
+ m_SawRoughingList = New List(Of String)
+ LoadMachiningListByType(m_SawRoughingList, MCH_MY.SAWROUGHING)
+ ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione
+ m_SawRoughingList.Insert(0, String.Empty)
+ End If
+ MachList = New ObservableCollection(Of String)(m_SawRoughingList)
+ Case MCH_MY.SAWFINISHING
+ ' se la lista è vuota devo caricarla
+ If IsNothing(m_SawFinishingList) Then
+ m_SawFinishingList = New List(Of String)
+ LoadMachiningListByType(m_SawFinishingList, MCH_MY.SAWFINISHING)
+ ' aggiungo elemento vuoto per poter non impostare alcuna lavorazione
+ m_SawFinishingList.Insert(0, String.Empty)
+ End If
+ MachList = New ObservableCollection(Of String)(m_SawFinishingList)
+ End Select
+ ' Annullo i valori di Mach, MachUp e MachDw
+ Mach = String.Empty
+ NotifyPropertyChanged("Mach")
+ MachUp = String.Empty
+ NotifyPropertyChanged("MachUp")
+ MachDw = String.Empty
+ NotifyPropertyChanged("MachDw")
+ End If
+ End Set
+ End Property
+
+ Private m_MachList As ObservableCollection(Of String)
+ Public Property MachList As ObservableCollection(Of String)
+ Get
+ Return m_MachList
+ End Get
+ Set(value As ObservableCollection(Of String))
+ If value IsNot m_MachList Then
+ m_MachList = value
+ End If
+ End Set
+ End Property
+
+ Private m_Mach As String
+ Public Property Mach As String
+ Get
+ Return m_Mach
+ End Get
+ Set(value As String)
+ m_Mach = value
+ End Set
+ End Property
+
+ Private m_MachUp As String
+ Public Property MachUp As String
+ Get
+ Return m_MachUp
+ End Get
+ Set(value As String)
+ m_MachUp = value
+ End Set
+ End Property
+
+ Private m_MachDw As String
+ Public Property MachDw As String
+ Get
+ Return m_MachDw
+ End Get
+ Set(value As String)
+ m_MachDw = value
+ End Set
+ End Property
+
+ ' Liste per le lavorazioni
+ Private m_DrillingList As List(Of String)
+ Private m_SawingList As List(Of String)
+ Private m_MillingList As List(Of String)
+ Private m_PocketingList As List(Of String)
+ Private m_MortisingList As List(Of String)
+ Private m_SawRoughingList As List(Of String)
+ Private m_SawFinishingList As List(Of String)
+
+ 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)
+ OnPar = bOn
+ ' Inizializzo la lista dei nomi solo la prima volta
+ If IsNothing(m_NamesList) Then
+ Dim NameFilePath As String = IniFile.m_sTablesRoot & "/GeometryNamesList.ini"
+ Dim TempNameList As New List(Of String)
+ Dim Index As Integer = 1
+ Dim sRaedName As String = String.Empty
+ While EgtUILib.GetPrivateProfileString(S_GEOMETRYNAMES, Index.ToString, "", sRaedName, NameFilePath) > 0
+ TempNameList.Add(sRaedName)
+ Index += 1
+ End While
+ NamesList = New ObservableCollection(Of String)(TempNameList)
+ End If
+ Name = sName
+ ' Verifico che il valore di MachId sia valido altrimento lo metto a nothing
+ If nMachId = 0 Then
+ MachId = Nothing
+ Else
+ MachId = nMachId
+ End If
+ If nShift = 1 Then
+ Shift = 1
+ Else
+ Shift = 0
+ End If
+ ' Inizializzo la lista delle operazioni solo la prima volta
+ If IsNothing(m_OperationsList) Then
+ Dim TempOperList As New List(Of String)
+ ' aggiungo elemento stringa vuota per dare la possibilità di non selezionarne nessuna operazione
+ TempOperList.Add(String.Empty)
+ ' aggiungo tutte le altre
+ Dim OperationFilePath As String = IniFile.m_sTablesRoot & "/OperationsList.ini"
+ Dim Index As Integer = 1
+ Dim sRaedOperation As String = String.Empty
+ While EgtUILib.GetPrivateProfileString(S_OPERATIONS, Index.ToString, "", sRaedOperation, OperationFilePath) > 0
+ TempOperList.Add(sRaedOperation)
+ Index += 1
+ End While
+ OperationsList = New ObservableCollection(Of String)(TempOperList)
+ End If
+ Oper = sOper
+ ' Inizializzo la lista di tipi di lavorazione solo la prima volta
+ If IsNothing(m_MachTypeList) Then
+ MachTypeList = New ObservableCollection(Of MachiningsType)(MachineModel.ReadActiveMachiningsFamilies())
+ ' aggiungo elemento stringa vuota(come primo elemento) per dare la possibilità di non selezionarne nessuna operazione
+ MachTypeList.Insert(0, New MachiningsType() With {.TypeId = MCH_MY.NONE, .TypeName = String.Empty})
+ End If
+ ' Imposto MachType selezionato cercando il tipo delle lavorazioni
+ If EgtMdbSetCurrMachining(sMach) OrElse EgtMdbSetCurrMachining(sMachUp) OrElse EgtMdbSetCurrMachining(sMachDw) Then
+ Dim nMachType As Integer = GDB_ID.NULL
+ EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, nMachType)
+ For Each MachTypeIndex In MachTypeList
+ If nMachType = MachTypeIndex.TypeId Then
+ SelectedMachType = MachTypeIndex
+ Exit For
+ End If
+ Next
+ Else
+ SelectedMachType = Nothing
+ End If
+ If Not IsNothing(m_SelectedMachType) Then
+ ' Imposto i Mach selezionati
+ Mach = sMach
+ MachUp = sMachUp
+ MachDw = sMachDw
+ 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
diff --git a/MTableDb/TableUtility.vb b/MTableDb/TableUtility.vb
new file mode 100644
index 0000000..c1304e5
--- /dev/null
+++ b/MTableDb/TableUtility.vb
@@ -0,0 +1,71 @@
+Imports System.IO
+
+Module TableUtility
+
+ Private Const MMACHINEDATA As String = ".MMachineData"
+ Private Const MTABLE As String = ".MTable"
+ Private Const DATETIME As String = "%DATE_TIME%"
+ Private Const TABLENAME As String = "%TABLE_NAME%"
+
+ Friend Sub WriteDoorsTable(SelectedTable As MTableListBoxItem, sTableNamePath As String)
+ Dim FileContent As IEnumerable(Of String) = File.ReadLines(IniFile.m_sTablesRoot & "\DefaultMTable.ini")
+ Dim NewTableFileContent As New List(Of String)
+ Dim bMMachineData As Boolean = False
+ Dim bMTable As Boolean = False
+ For LineIndex As Integer = 0 To FileContent.Count - 1
+ Dim sCurrLine As String = FileContent(LineIndex)
+ If sCurrLine.Contains(DATETIME) Then
+ sCurrLine = sCurrLine.Replace(DATETIME, System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"))
+ ElseIf FileContent(LineIndex).Contains(TABLENAME) Then
+ sCurrLine = sCurrLine.Replace(TABLENAME, Path.GetFileNameWithoutExtension(sTableNamePath))
+ End If
+
+ If sCurrLine.Contains(MMACHINEDATA) Then
+ bMMachineData = True
+ NewTableFileContent.Add(sCurrLine)
+ PrintActiveMachinesList(SelectedTable, NewTableFileContent)
+ ElseIf sCurrLine.Contains(MTABLE) Then
+ bMTable = True
+ NewTableFileContent.Add(sCurrLine)
+ PrintActiveMachiningList(SelectedTable, NewTableFileContent)
+ End If
+
+ If Not bMMachineData AndAlso Not bMTable Then
+ NewTableFileContent.Add(sCurrLine)
+ Else
+ bMMachineData = False
+ bMTable = False
+ End If
+ Next
+ File.WriteAllLines(sTableNamePath, NewTableFileContent, Text.Encoding.UTF8)
+ End Sub
+
+ Private Sub PrintActiveMachinesList(SelectedTable As MTableListBoxItem, NewTableFileContent As List(Of String))
+ For Index As Integer = 0 To SelectedTable.ActiveMachinesList.Count - 1
+ Dim CurrentLine As String = " { MachName = '" & SelectedTable.ActiveMachinesList(Index).SelectedMachine & "', NcGenerate = " & SelectedTable.ActiveMachinesList(Index).NcGenerate.ToString.ToLower _
+ & ", MakeRaw = " & SelectedTable.ActiveMachinesList(Index).Makeraw.ToString.ToLower & " }"
+ If Index < SelectedTable.ActiveMachinesList.Count - 1 Then
+ CurrentLine &= " ,"
+ End If
+ NewTableFileContent.Add(CurrentLine)
+ 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), ", 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) & " }"
+ If Index < SelectedTable.AssociationList.Count - 1 Then
+ CurrentLine &= " ,"
+ End If
+ NewTableFileContent.Add(CurrentLine)
+ Next
+ End Sub
+
+End Module
diff --git a/MachineModel.vb b/MachineModel.vb
new file mode 100644
index 0000000..2d747cd
--- /dev/null
+++ b/MachineModel.vb
@@ -0,0 +1,69 @@
+Imports System.ComponentModel
+Imports EgtUILib
+
+Public Module MachineModel
+
+ '''
+ ''' Method that search the machines in the correct folder and add to the MachinesList those valid.
+ '''
+ Friend Function ReadActiveMachiningsFamilies() As MachiningsType()
+ Dim ActiveMachiningsFamiliesList As New List(Of MachiningsType)
+ If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_DRILLING, 0, m_sCurrMachIniFilePath) <> 0 Then
+ ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.DRILLING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 1)})
+ End If
+ If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWING, 0, m_sCurrMachIniFilePath) <> 0 Then
+ ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 2)})
+ End If
+ If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MILLING, 0, m_sCurrMachIniFilePath) <> 0 Then
+ ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MILLING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 3)})
+ End If
+ If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_POCKETING, 0, m_sCurrMachIniFilePath) <> 0 Then
+ ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.POCKETING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 4)})
+ End If
+ If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MORTISING, 0, m_sCurrMachIniFilePath) <> 0 Then
+ ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MORTISING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 5)})
+ End If
+ If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWROUGHING, 0, m_sCurrMachIniFilePath) <> 0 Then
+ ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWROUGHING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 6)})
+ End If
+ If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWFINISHING, 0, m_sCurrMachIniFilePath) <> 0 Then
+ ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWFINISHING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 7)})
+ End If
+ Return ActiveMachiningsFamiliesList.ToArray
+ End Function
+
+ Friend Sub LoadMachiningListByType(MachiningList As List(Of String), nType As MCH_MY)
+ Dim MachiningName As String = String.Empty
+ EgtMdbGetFirstMachining(nType, MachiningName)
+ While Not String.IsNullOrWhiteSpace(MachiningName)
+ MachiningList.Add(MachiningName)
+ EgtMdbGetNextMachining(nType, MachiningName)
+ End While
+ End Sub
+
+ '''
+ ''' Structure that represent a tool's family, containing family type and family name
+ '''
+ Public Class MachiningsType
+ Implements INotifyPropertyChanged
+
+ Friend TypeId As MCH_MY
+ Private m_TypeName As String
+ Public Property TypeName As String
+ Get
+ Return m_TypeName
+ End Get
+ Set(value As String)
+ m_TypeName = value
+ End Set
+ End Property
+
+ Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
+
+ Public Sub NotifyPropertyChanged(propName As String)
+ RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
+ End Sub
+
+ End Class
+
+End Module
diff --git a/MachiningsDbWindow/MachiningsDbViewModel.vb b/MachiningsDbWindow/MachiningsDbViewModel.vb
index 2c61c19..eb8fec5 100644
--- a/MachiningsDbWindow/MachiningsDbViewModel.vb
+++ b/MachiningsDbWindow/MachiningsDbViewModel.vb
@@ -388,7 +388,7 @@ Namespace EgtCAM5
'''
Private Sub LoadSelectedMachineMachinings()
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
- Dim ActiveMachiningsTypes() As MachiningsType = ReadActiveMachiningsFamilies()
+ Dim ActiveMachiningsTypes() As MachiningsType = MachineModel.ReadActiveMachiningsFamilies()
For Each MachiningsType In ActiveMachiningsTypes
Dim FamilyTreeView As New FamilyMachiningTreeViewItem(MachiningsType.TypeName, MachiningsType.TypeId)
MachiningsList.Add(FamilyTreeView)
@@ -406,44 +406,6 @@ Namespace EgtCAM5
End If
End Sub
- '''
- ''' Method that search the machines in the correct folder and add to the MachinesList those valid.
- '''
- Private Function ReadActiveMachiningsFamilies() As MachiningsType()
- Dim ActiveMachiningsFamiliesList As New List(Of MachiningsType)
- If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_DRILLING, 0, m_sCurrMachIniFilePath) <> 0 Then
- ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.DRILLING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 1)})
- End If
- If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWING, 0, m_sCurrMachIniFilePath) <> 0 Then
- ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 2)})
- End If
- If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MILLING, 0, m_sCurrMachIniFilePath) <> 0 Then
- ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MILLING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 3)})
- End If
- If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_POCKETING, 0, m_sCurrMachIniFilePath) <> 0 Then
- ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.POCKETING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 4)})
- End If
- If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MORTISING, 0, m_sCurrMachIniFilePath) <> 0 Then
- ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MORTISING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 5)})
- End If
- If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWROUGHING, 0, m_sCurrMachIniFilePath) <> 0 Then
- ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWROUGHING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 6)})
- End If
- If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWFINISHING, 0, m_sCurrMachIniFilePath) <> 0 Then
- ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWFINISHING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 7)})
- End If
- Return ActiveMachiningsFamiliesList.ToArray
- End Function
-
- '''
- ''' Structure that represent a tool's family, containing family type and family name
- '''
- Structure MachiningsType
-
- Friend TypeId As MCH_MY
- Friend TypeName As String
-
- End Structure
#Region "NewCommand"
diff --git a/ProjectPage/DoorsPanel/DoorsPanelView.xaml b/ProjectPage/DoorsPanel/DoorsPanelView.xaml
index 81f8765..d9b4c47 100644
--- a/ProjectPage/DoorsPanel/DoorsPanelView.xaml
+++ b/ProjectPage/DoorsPanel/DoorsPanelView.xaml
@@ -14,7 +14,7 @@
+ Style="{StaticResource GridViewPanelButton}" Width="65" Content="MTABLE"/>
diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml
index b73a1f0..06098a0 100644
--- a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml
+++ b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml
@@ -44,7 +44,7 @@
-
+
diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml.vb
index 2c92509..90fbf17 100644
--- a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml.vb
+++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml.vb
@@ -1,5 +1,6 @@
Imports EgtWPFLib5
Imports EgtWPFLib5.EgtFloating
+
Public Class OperationExpanderView
Private EgtFloatingTray As EgtFloatingTray