diff --git a/BeamMachiningsWindow/BeamMachiningsWindowV.xaml b/BeamMachiningsWindow/BeamMachiningsWindowV.xaml
new file mode 100644
index 0000000..26a8366
--- /dev/null
+++ b/BeamMachiningsWindow/BeamMachiningsWindowV.xaml
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BeamMachiningsWindow/BeamMachiningsWindowV.xaml.vb b/BeamMachiningsWindow/BeamMachiningsWindowV.xaml.vb
new file mode 100644
index 0000000..5838f6e
--- /dev/null
+++ b/BeamMachiningsWindow/BeamMachiningsWindowV.xaml.vb
@@ -0,0 +1,18 @@
+Public Class BeamMachiningsWindowV
+
+ Private WithEvents m_BeamMachiningsWindowVM As BeamMachiningsWindowVM
+
+ Sub New(Owner As Window, BeamMachiningsWindowVM As BeamMachiningsWindowVM)
+ MyBase.New(Owner)
+ ' This call is required by the designer.
+ InitializeComponent()
+ Me.DataContext = BeamMachiningsWindowVM
+ ' Assegno al riferimento locale al VM il VM preso dal DataContext
+ m_BeamMachiningsWindowVM = BeamMachiningsWindowVM
+ End Sub
+
+ Private Sub CloseWindow(bDialogResult As Boolean) Handles m_BeamMachiningsWindowVM.m_CloseWindow
+ Me.DialogResult = bDialogResult
+ End Sub
+
+End Class
diff --git a/BeamMachiningsWindow/BeamMachiningsWindowVM.vb b/BeamMachiningsWindow/BeamMachiningsWindowVM.vb
new file mode 100644
index 0000000..28764a3
--- /dev/null
+++ b/BeamMachiningsWindow/BeamMachiningsWindowVM.vb
@@ -0,0 +1,513 @@
+Imports System.IO
+Imports System.Collections.ObjectModel
+Imports EgtUILib
+
+Public Class BeamMachiningsWindowVM
+ Inherits VMBase
+
+#Region "FIELDS & PROPERTIES"
+
+ Private Const ONCONST As String = "On"
+ Private Const NAME As String = "Name"
+ Private Const TYPE As String = "Type"
+ Friend Const DATETIME As String = "%DATE_TIME%"
+ Friend Const TABLENAME As String = "%TABLE_NAME%"
+ Private Const BEAMTABLETEMPLATE_FILE As String = "BeamTableTemplate.ini"
+
+ Friend Event m_CloseWindow(bDialogResult As Boolean)
+
+ Private m_MachiningList As New ObservableCollection(Of String)({"Cut", "Drill", "Milling", "Pocketing", "Sawing"})
+ Public ReadOnly Property MachiningList As ObservableCollection(Of String)
+ Get
+ Return m_MachiningList
+ End Get
+ End Property
+
+ Private m_SelMachining As String
+ Public Property SelMachining As String
+ Get
+ Return m_SelMachining
+ End Get
+ Set(value As String)
+ ' verifico se pagina precedente modificata
+ Dim TableModified As Boolean = False
+ For Each Line In m_TableRowList
+ If Line.IsModified Then
+ TableModified = True
+ Exit For
+ End If
+ Next
+ ' se modificata, chiedo se salvare
+ If TableModified Then
+ Select Case MessageBox.Show(EgtMsg(9007), EgtMsg(9006), MessageBoxButton.YesNoCancel, MessageBoxImage.Question)
+ Case MessageBoxResult.Yes
+ Save()
+ Case MessageBoxResult.No
+ ' non devo fare nulla
+ End Select
+ End If
+ m_SelMachining = value
+ LoadMachiningList()
+ LoadTypeList()
+ ReadTableFile()
+ NotifyPropertyChanged("SelMachining")
+ End Set
+ End Property
+ Private Sub SetSelMachining(value As String)
+ m_SelMachining = value
+ LoadMachiningList()
+ LoadTypeList()
+ ReadTableFile()
+ NotifyPropertyChanged("SelMachining")
+ End Sub
+
+ Private m_TableRowList As ObservableCollection(Of GridLine)
+ Public Property TableRowList As ObservableCollection(Of GridLine)
+ Get
+ Return m_TableRowList
+ End Get
+ Set(value As ObservableCollection(Of GridLine))
+ m_TableRowList = value
+ End Set
+ End Property
+
+ Private m_SelRowIndex As Integer = 0
+ Public Property SelRowIndex As Integer
+ Get
+ Return m_SelRowIndex
+ End Get
+ Set(value As Integer)
+ m_SelRowIndex = value
+ End Set
+ End Property
+
+#Region "Messages"
+
+ Public ReadOnly Property Title As String
+ Get
+ Return EgtMsg(9000)
+ End Get
+ End Property
+
+ Public ReadOnly Property OnHdr As String
+ Get
+ Return EgtMsg(9001)
+ End Get
+ End Property
+
+ Public ReadOnly Property NameHdr As String
+ Get
+ Return EgtMsg(9002)
+ End Get
+ End Property
+
+ Public ReadOnly Property TypeHdr As String
+ Get
+ Return EgtMsg(9003)
+ End Get
+ End Property
+
+ Public ReadOnly Property AddRowMsg As String
+ Get
+ Return EgtMsg(9004)
+ End Get
+ End Property
+
+ Public ReadOnly Property DeleteRowMsg As String
+ Get
+ Return EgtMsg(9005)
+ End Get
+ End Property
+
+ Public ReadOnly Property SaveMsg As String
+ Get
+ Return EgtMsg(9006)
+ End Get
+ End Property
+
+#End Region ' Messages
+
+ ' Definizione comandi
+ Private m_cmdMoveRowUp As ICommand
+ Private m_cmdMoveRowDown As ICommand
+ Private m_cmdAddRow As ICommand
+ Private m_cmdDeleteRow As ICommand
+ Private m_cmdSave As ICommand
+ Private m_cmdClose As ICommand
+
+#End Region ' FIELDS & PROPERTIES
+
+#Region "CONSTRUCTOR"
+
+ Sub New()
+ ' Carico file delle lavorazioni
+
+ ' Seleziono il primo
+ If m_MachiningList.Count > 0 Then
+ SetSelMachining(m_MachiningList(0))
+ End If
+ NotifyPropertyChanged("MachiningList")
+ End Sub
+
+#End Region ' CONSTRUCTOR
+
+#Region "METHODS"
+
+ Private Function LoadMachiningList() As Boolean
+ Dim MachiningType As MCH_MY = MCH_MY.NONE
+ Select Case SelMachining
+ Case "Cut"
+ MachiningType = MCH_MY.MILLING
+ Case "Drill"
+ MachiningType = MCH_MY.DRILLING
+ Case "Milling"
+ MachiningType = MCH_MY.MILLING
+ Case "Pocketing"
+ MachiningType = MCH_MY.POCKETING
+ Case "Sawing"
+ MachiningType = MCH_MY.MORTISING
+ End Select
+ Dim MachiningList As New List(Of String)
+ LoadMachiningListByType(MachiningList, MachiningType)
+ GridLine.SetNamesList(New ObservableCollection(Of String)(MachiningList))
+ Return True
+ End Function
+
+ Private Function LoadTypeList() As Boolean
+ Dim FilePath As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\" & "Beam" & "\MachiningTypes.ini"
+ Dim TypeList As New List(Of String)
+ Dim Index As Integer = 1
+ Dim Type As String = ""
+ While EgtUILib.GetPrivateProfileString(SelMachining, Index.ToString, "", Type, FilePath) > 0
+ TypeList.Add(Type)
+ Index += 1
+ End While
+ GridLine.SetTypeList(New ObservableCollection(Of String)(TypeList))
+ Return True
+ End Function
+
+ Private Function ReadTableFile() As Boolean
+ ' svuoto la lista
+ m_TableRowList = New ObservableCollection(Of GridLine)
+ Dim FilePath As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\" & "Beam" & "\" & SelMachining & "Data.lua"
+ If Not File.Exists(FilePath) Then Return False
+ Dim FileContent As String() = File.ReadAllLines(FilePath)
+ Dim FoundTableName As Boolean = False
+ For LineIndex As Integer = 0 To FileContent.Count - 1
+ If FileContent(LineIndex).Contains(SelMachining & "Data") Then
+ FoundTableName = True
+ End If
+ Dim Open As Integer = CountCharacter(FileContent(LineIndex), "{"c)
+ Dim Close As Integer = CountCharacter(FileContent(LineIndex), "}"c)
+ If Close > Open Then
+ If FoundTableName Then
+ FoundTableName = False
+ End If
+ End If
+ If FoundTableName Then
+ Dim sOn As String = SearchKey(FileContent(LineIndex), ONCONST)
+ Dim sName As String = SearchKey(FileContent(LineIndex), NAME)
+ Dim sType As String = SearchKey(FileContent(LineIndex), TYPE)
+ If Not String.IsNullOrWhiteSpace(sOn) AndAlso Not String.IsNullOrWhiteSpace(sName) AndAlso Not String.IsNullOrWhiteSpace(sType) Then
+ If String.Compare(sOn, "true", True) = 0 Then
+ TableRowList.Add(New GridLine(True, sName, sType))
+ ElseIf String.Compare(sOn, "false", True) = 0 Then
+ TableRowList.Add(New GridLine(False, sName, sType))
+ Else
+ Continue For
+ End If
+ End If
+ End If
+ Next
+ NotifyPropertyChanged("TableRowList")
+ Return True
+ End Function
+
+ Private Function WriteTableFile() As Boolean
+ ' inizio routine di scrittura
+ Dim FileContent As String() = File.ReadAllLines(IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\" & "Beam" & "\" & BEAMTABLETEMPLATE_FILE)
+ Dim NewTableFileContent As New List(Of String)
+ Dim bBeamTable 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, SelMachining & "Data")
+
+ If sCurrLine.Contains(SelMachining & "Data") AndAlso sCurrLine.Contains("=") Then
+ bBeamTable = True
+ NewTableFileContent.Add(sCurrLine)
+ PrintActiveMachiningList(NewTableFileContent)
+ End If
+
+ If Not bBeamTable Then
+ NewTableFileContent.Add(sCurrLine)
+ Else
+ bBeamTable = False
+ End If
+ Next
+ Dim FilePath As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\" & "Beam" & "\" & SelMachining & "Data.lua"
+ File.WriteAllLines(FilePath, NewTableFileContent, Text.Encoding.UTF8)
+ Return True
+ End Function
+
+ Private Sub PrintActiveMachiningList(NewTableFileContent As List(Of String))
+ For Index As Integer = 0 To m_TableRowList.Count - 1
+ If String.IsNullOrEmpty(m_TableRowList(Index).Name) Then Continue For
+ Dim CurrentLine As String = " { On = " & If(m_TableRowList(Index).OnPar, "true", "false") & ", Name = '" & m_TableRowList(Index).Name & "', Type = '" & m_TableRowList(Index).Type & "'}"
+ If Index < m_TableRowList.Count - 1 Then
+ CurrentLine &= ","
+ End If
+ NewTableFileContent.Add(CurrentLine)
+ Next
+ End Sub
+
+
+#End Region ' METHODS
+
+#Region "COMMANDS"
+
+#Region "MoveRowUp"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property MoveRowUp_Command 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()
+ If SelRowIndex > 0 Then
+ m_TableRowList.Move(SelRowIndex, SelRowIndex - 1)
+ End If
+ End Sub
+
+#End Region ' MoveRowUp
+
+#Region "MoveRowDown"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property MoveRowDown_Command 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()
+ If SelRowIndex < m_TableRowList.Count - 1 Then
+ m_TableRowList.Move(SelRowIndex, SelRowIndex + 1)
+ End If
+ End Sub
+
+#End Region ' MoveRowDown
+
+#Region "AddRow"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property AddRow_Command 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()
+ m_TableRowList.Insert(SelRowIndex + 1, New GridLine(False, "", ""))
+ End Sub
+
+#End Region ' AddRow
+
+#Region "DeleteRow"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property DeleteRow_Command As ICommand
+ Get
+ If m_cmdDeleteRow Is Nothing Then
+ m_cmdDeleteRow = New Command(AddressOf DeleteRow)
+ End If
+ Return m_cmdDeleteRow
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub DeleteRow()
+ m_TableRowList.RemoveAt(SelRowIndex)
+ End Sub
+
+#End Region ' DeleteRow
+
+#Region "Save"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property Save_Command As ICommand
+ Get
+ If m_cmdSave Is Nothing Then
+ m_cmdSave = New Command(AddressOf Save)
+ End If
+ Return m_cmdSave
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub Save()
+ ' scrivo il file
+ WriteTableFile()
+ ' resetto le modifiche
+ For Each Line In m_TableRowList
+ Line.ResetIsModified()
+ Next
+ End Sub
+
+#End Region ' Save
+
+#Region "Close"
+
+ '''
+ ''' Returns a command that do Exec.
+ '''
+ Public ReadOnly Property Close_Command As ICommand
+ Get
+ If m_cmdClose Is Nothing Then
+ m_cmdClose = New Command(AddressOf Close)
+ End If
+ Return m_cmdClose
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Exec. This method is invoked by the ExecCommand.
+ '''
+ Public Sub Close()
+ ' verifico se pagina precedente modificata
+ Dim TableModified As Boolean = False
+ For Each Line In m_TableRowList
+ If Line.IsModified Then
+ TableModified = True
+ Exit For
+ End If
+ Next
+ ' se modificata, chiedo se salvare
+ If TableModified Then
+ Select Case MessageBox.Show(EgtMsg(9007), EgtMsg(9006), MessageBoxButton.YesNo, MessageBoxImage.Question)
+ Case MessageBoxResult.Yes
+ Save()
+ Case MessageBoxResult.No
+ ' non devo fare nulla
+ End Select
+ End If
+ RaiseEvent m_CloseWindow(True)
+ End Sub
+
+#End Region ' Close
+
+#End Region ' COMMANDS
+
+End Class
+
+Public Class GridLine
+ Inherits VMBase
+
+ Friend ReadOnly Property IsModified As Boolean
+ Get
+ Return m_IsOnModified Or m_IsNameModified Or m_IsTypeModified
+ End Get
+ End Property
+ Friend Sub ResetIsModified()
+ m_IsOnModified = False
+ m_IsNameModified = False
+ m_IsTypeModified = False
+ End Sub
+
+ Private m_IsOnModified As Boolean = False
+ Private m_On As Boolean
+ Public Property OnPar As Boolean
+ Get
+ Return m_On
+ End Get
+ Set(value As Boolean)
+ m_On = value
+ m_IsOnModified = True
+ End Set
+ End Property
+
+ Private Shared m_NamesList As ObservableCollection(Of String)
+ Public ReadOnly Property NamesList As ObservableCollection(Of String)
+ Get
+ Return m_NamesList
+ End Get
+ End Property
+ Friend Shared Sub SetNamesList(NamesList As ObservableCollection(Of String))
+ m_NamesList = NamesList
+ End Sub
+
+ Private m_IsNameModified As Boolean = False
+ Private m_Name As String
+ Public Property Name As String
+ Get
+ Return m_Name
+ End Get
+ Set(value As String)
+ m_Name = value
+ m_IsNameModified = True
+ End Set
+ End Property
+
+ Private Shared m_TypeList As ObservableCollection(Of String)
+ Public ReadOnly Property TypeList As ObservableCollection(Of String)
+ Get
+ Return m_TypeList
+ End Get
+ End Property
+ Friend Shared Sub SetTypeList(TypeList As ObservableCollection(Of String))
+ m_TypeList = TypeList
+ End Sub
+
+ Private m_IsTypeModified As Boolean = False
+ Private m_Type As String
+ Public Property Type As String
+ Get
+ Return m_Type
+ End Get
+ Set(value As String)
+ m_Type = value
+ m_IsTypeModified = True
+ End Set
+ End Property
+
+ Sub New(bOnPar As Boolean, sName As String, sType As String)
+ m_On = bOnPar
+ m_Name = sName
+ m_Type = sType
+ End Sub
+
+End Class
\ No newline at end of file
diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj
index bc90b1c..329bc47 100644
--- a/EgtCAM5.vbproj
+++ b/EgtCAM5.vbproj
@@ -147,6 +147,10 @@
+
+ BeamMachiningsWindowV.xaml
+
+
@@ -338,6 +342,10 @@
DesignerMSBuild:Compile
+
+ MSBuild:Compile
+ Designer
+ DesignerMSBuild:Compile
diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb
index dc2a1ec..7e80d37 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/Special-Beam/BeamPanelVM.vb b/Special-Beam/BeamPanelVM.vb
index 9e82dc4..963e012 100644
--- a/Special-Beam/BeamPanelVM.vb
+++ b/Special-Beam/BeamPanelVM.vb
@@ -3,6 +3,8 @@ Imports EgtUILib
Public Class BeamPanelVM
+ Friend Const BEAM_MACHININGS As String = "BeamMachinings"
+
Private m_ButtonList As New List(Of ButtonItem)
Public ReadOnly Property ButtonList As List(Of ButtonItem)
Get
diff --git a/SpecialPanel/SpecialPanelVM.vb b/SpecialPanel/SpecialPanelVM.vb
index 6845071..65d660c 100644
--- a/SpecialPanel/SpecialPanelVM.vb
+++ b/SpecialPanel/SpecialPanelVM.vb
@@ -74,6 +74,13 @@ Public Class ButtonItem
'''
Public Sub LuaExec(ByVal param As Object)
If String.IsNullOrWhiteSpace(m_sLuaCmdPath) Then Return
+ ' se trovo costante di apertura file lavorazioni travi
+ If m_sLuaCmdPath = BeamPanelVM.BEAM_MACHININGS Then
+ ' apro finestra di gestione lavorazioni travi
+ Dim BeamMachiningsWindowV As New BeamMachiningsWindowV(Application.Current.MainWindow, New BeamMachiningsWindowVM)
+ BeamMachiningsWindowV.ShowDialog()
+ Return
+ End If
If Not File.Exists(m_sLuaCmdPath) Then Return
If Not Path.GetExtension(m_sLuaCmdPath).ToLower = ".lua" Then Return
' eseguo file Lua
diff --git a/Utility/Dictionary.xaml b/Utility/Dictionary.xaml
index e83ff46..245b2ce 100644
--- a/Utility/Dictionary.xaml
+++ b/Utility/Dictionary.xaml
@@ -1015,5 +1015,39 @@
+
+
+
+
+
+
diff --git a/Utility/IniFile.vb b/Utility/IniFile.vb
index 9000a8d..d64f939 100644
--- a/Utility/IniFile.vb
+++ b/Utility/IniFile.vb
@@ -209,7 +209,11 @@ Public Module IniFile
Dim sImagePath As String = If(sItems.Count() >= 2, sItems(1), "")
Dim sToolTip As String = If(sItems.Count() >= 3, sItems(2), "")
If Not String.IsNullOrWhiteSpace(sBaseDir) Then
- If Not String.IsNullOrWhiteSpace(sLuaPath) Then sLuaPath = IniFile.m_sBeamDirPath & "\" & sLuaPath
+ If Not String.IsNullOrWhiteSpace(sLuaPath) Then
+ If sLuaPath.Contains(".lua") Then
+ sLuaPath = IniFile.m_sBeamDirPath & "\" & sLuaPath
+ End If
+ End If
If Not String.IsNullOrWhiteSpace(sImagePath) Then sImagePath = IniFile.m_sBeamDirPath & "\" & sImagePath
End If
ReadedButtonItem = New ButtonItem(sLuaPath, sImagePath, sToolTip)