EgtCAM5 :

- Aggiunta selezione MTable correntemente attiva.
This commit is contained in:
Emmanuele Sassi
2016-10-24 09:52:38 +00:00
parent e3f863a16d
commit e3a00c0933
9 changed files with 136 additions and 8 deletions
+79 -3
View File
@@ -21,9 +21,8 @@ Namespace EgtCAM5
End Set
End Property
#Region "Fields & Properties for graphical elements"
#Region "Messages"
Private m_Title As String
Public ReadOnly Property Title As String
Get
Return EgtMsg(MSG_MAINWINDOW + 20)
@@ -132,7 +131,13 @@ Namespace EgtCAM5
End Get
End Property
#End Region
Public ReadOnly Property CurrMsg As String
Get
Return EgtMsg(MSG_DOORS + 25)
End Get
End Property
#End Region ' Messages
#Region "ToolTip"
@@ -157,6 +162,11 @@ Namespace EgtCAM5
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
@@ -165,6 +175,7 @@ Namespace EgtCAM5
Private m_cmdSaveTable As ICommand
Private m_cmdSaveTableAs As ICommand
Private m_cmdRemoveTable As ICommand
Private m_cmdSetActiveTable As ICommand
Private m_cmdAddMach As ICommand
Private m_cmdRemoveMach As ICommand
Private m_cmdAddRow As ICommand
@@ -178,6 +189,7 @@ Namespace EgtCAM5
Sub New()
EgtGetCurrMachineName(m_sPreviousActiveMachine)
UpdateTables()
SetActiveTable()
If m_TablesList.Count > 0 Then
m_TablesList(0).IsSelected = True
End If
@@ -216,6 +228,28 @@ Namespace EgtCAM5
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
Dim ActiveMTableFilePath As String = Path.GetDirectoryName(IniFile.m_sTablesRoot) & "\CurrMTable.lua"
If File.Exists(ActiveMTableFilePath) Then
Dim ReadFile As IEnumerable(Of String) = File.ReadLines(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
End If
Next
End If
End Sub
#End Region
#Region "COMMANDS"
@@ -371,6 +405,48 @@ Namespace EgtCAM5
#End Region ' RemoveTableCommand
#Region "SetActiveTableCommand"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
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
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub SetActiveTable(param As Object)
Dim SelectedMTable As MTableListBoxItem = DirectCast(param, MTableListBoxItem)
If IsNothing(SelectedMTable) Then Return
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
' Scrivo il file di configurazione con il nome di questa tavola
Dim FileContent As IEnumerable(Of String) = File.ReadLines(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 "AddMachCommand"
''' <summary>