diff --git a/Machine/ImportExportToolWD.xaml b/Machine/ImportExportToolWD.xaml
new file mode 100644
index 0000000..881c24c
--- /dev/null
+++ b/Machine/ImportExportToolWD.xaml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Machine/ImportExportToolWD.xaml.vb b/Machine/ImportExportToolWD.xaml.vb
new file mode 100644
index 0000000..7596f3d
--- /dev/null
+++ b/Machine/ImportExportToolWD.xaml.vb
@@ -0,0 +1,3 @@
+Public Class ImportExportToolWD
+
+End Class
\ No newline at end of file
diff --git a/Machine/ToolsDbPageUC.xaml b/Machine/ToolsDbPageUC.xaml
index 61251e7..9aeee72 100644
--- a/Machine/ToolsDbPageUC.xaml
+++ b/Machine/ToolsDbPageUC.xaml
@@ -434,13 +434,17 @@
-
+
+
+
+
+
diff --git a/Machine/ToolsDbPageUC.xaml.vb b/Machine/ToolsDbPageUC.xaml.vb
index c23ada2..61190c6 100644
--- a/Machine/ToolsDbPageUC.xaml.vb
+++ b/Machine/ToolsDbPageUC.xaml.vb
@@ -3,6 +3,7 @@ Imports OmagCUT.TreeViewItem
Imports System.ComponentModel
Imports EgtUILib
Imports EgtWPFLib
+Imports EgtWPFLib5
Public Class ToolsDbPageUC
@@ -53,6 +54,8 @@ Public Class ToolsDbPageUC
NewBtn.Content = EgtMsg(MSG_MACHINEPAGEUC + 15)
SaveBtn.Content = EgtMsg(MSG_MACHINEPAGEUC + 17)
RemoveBtn.Content = EgtMsg(MSG_MACHINEPAGEUC + 18)
+ ExportBtn.Content = "Export"
+ ImportBtn.Content = "Import"
NameTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 1)
TCPosTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 2)
@@ -239,17 +242,17 @@ Public Class ToolsDbPageUC
Next
' Determino il tipo di utensile
Dim nType As Integer
- EgtTdbGetCurrToolParam( MCH_TP.TYPE, nType)
+ EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType)
' Imposto testa e uscita
' Sempre lame su H1.1 e utensili foretto, fresa e mola da scasso su H1.2
- If ( nType And MCH_TF.WATERJET) = 0 then
+ If (nType And MCH_TF.WATERJET) = 0 Then
Dim bSaw As Boolean = ((nType And MCH_TF.SAWBLADE) <> 0)
- EgtTdbSetCurrToolParam( MCH_TP.HEAD, "H1")
- EgtTdbSetCurrToolParam( MCH_TP.EXIT_, If(bSaw, 1, 2))
- ' Waterjet sempre su H2.1
+ EgtTdbSetCurrToolParam(MCH_TP.HEAD, "H1")
+ EgtTdbSetCurrToolParam(MCH_TP.EXIT_, If(bSaw, 1, 2))
+ ' Waterjet sempre su H2.1
Else
- EgtTdbSetCurrToolParam( MCH_TP.HEAD, "H2")
- EgtTdbSetCurrToolParam( MCH_TP.EXIT_, 1)
+ EgtTdbSetCurrToolParam(MCH_TP.HEAD, "H2")
+ EgtTdbSetCurrToolParam(MCH_TP.EXIT_, 1)
End If
' Per macchine senza ToolChanger, resetto la posizione su questo
If m_CurrMachine.ShowToolChanger = 0 Then
@@ -317,8 +320,8 @@ Public Class ToolsDbPageUC
EgtTdbGetCurrToolParam(MCH_TP.TYPE, CurrType)
For Each ToolFamily As CathegoryItem In ToolsList
If ToolFamily.nTType = CurrType Then
- Dim NewToolItem As New CustomItem( NewName, CurrType)
- ToolFamily.Items.Add( NewToolItem)
+ Dim NewToolItem As New CustomItem(NewName, CurrType)
+ ToolFamily.Items.Add(NewToolItem)
NewToolItem.IsSelected = True
GetToolParams()
m_OldItem = ToolTreeView.SelectedItem
@@ -354,15 +357,15 @@ Public Class ToolsDbPageUC
Dim sItems() As String = sUserNotes.Split(";".ToCharArray)
For i As Integer = 0 To sItems.Count() - 1
If sItems(i).Contains("CODE=") Then
- CodeTxBx.Text = sItems(i).Substring( 5)
+ CodeTxBx.Text = sItems(i).Substring(5)
ElseIf sItems(i).Contains("SUPPL=") Then
- SupplierTxBx.Text = sItems(i).Substring( 6)
+ SupplierTxBx.Text = sItems(i).Substring(6)
ElseIf sItems(i).Contains("S/N=") Then
- SerNbrTxBx.Text = sItems(i).Substring( 4)
+ SerNbrTxBx.Text = sItems(i).Substring(4)
ElseIf sItems(i).Contains("END=") Then
EndLifeChBx.IsChecked = True
- m_sEndLife = sItems(i).Substring( 4)
- ElseIf Not String.IsNullOrWhiteSpace(sItems(i))
+ m_sEndLife = sItems(i).Substring(4)
+ ElseIf Not String.IsNullOrWhiteSpace(sItems(i)) Then
sToShow &= sItems(i) & ";"
End If
Next
@@ -383,7 +386,7 @@ Public Class ToolsDbPageUC
sUserNotes &= "SUPPL=" & SupplierTxBx.Text & ";"
sUserNotes &= "S/N=" & SerNbrTxBx.Text & ";"
If EndLifeChBx.IsChecked Then
- If String.IsNullOrWhiteSpace( m_sEndLife) Then
+ If String.IsNullOrWhiteSpace(m_sEndLife) Then
m_sEndLife = My.Computer.Clock.LocalTime.ToString("dd.MM.yyyy HH:mm:ss")
End If
sUserNotes &= "END=" & m_sEndLife & ";"
@@ -479,18 +482,169 @@ Public Class ToolsDbPageUC
End If
End Sub
+ Private Sub ExportBtn_Click(Sender As Object, e As RoutedEventArgs) Handles ExportBtn.Click
+ ' contesto corrente
+ EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
+
+ ' creo lista utensili per esportazione
+ Dim ToolToExportList = New ObservableCollection(Of ImpExpFamily)
+ Dim Family As CathegoryItem
+ Dim Tool As CustomItem
+ For Each Family In ToolsList
+ Dim ImpExpFamily As New ImpExpFamily(Family.Name, Family.nTType)
+ ImpExpFamily.PictureString = "/Resources/ToolsTreeviewImages/Folder.png"
+ For Each Tool In Family.Items
+ Dim CurrTool = New ImpExpItem(Tool.Name, False)
+ ImpExpFamily.ToolList.Add(CurrTool)
+ Next
+ ToolToExportList.Add(ImpExpFamily)
+ Next
+
+ Dim ExportWndVM As New ImportExportToolWindowVM(ToolToExportList)
+ Dim ExportWnd As New ImportExportToolWindowV(Application.Current.MainWindow, ExportWndVM)
+
+ ExportWnd.ShowDialog()
+ End Sub
+
+ Private Sub ImportBtn_Click(Sender As Object, e As RoutedEventArgs) Handles ImportBtn.Click
+ ' contesto corrente
+ EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
+ ' apro dialogo di scelta file
+ Dim ImportFileDlg As New Microsoft.Win32.OpenFileDialog() With {
+ .Title = EgtMsg(31161) & " " & EgtMsg(31163),
+ .DefaultExt = ".data",
+ .Filter = "Tools (.data)|*.data",
+ .CheckFileExists = True,
+ .ValidateNames = True
+ }
+ If ImportFileDlg.ShowDialog() <> True Then Return
+ Dim ImportFilePath As String = ImportFileDlg.FileName
+ ' recupero liste utensili da importare
+ Dim ImportFileToolNameList As String() = Nothing
+ Dim ImportFileToolFamilyList As Integer() = Nothing
+ EgtTdbToBeImported(ImportFilePath, ImportFileToolNameList, ImportFileToolFamilyList)
+ ' li inserisco in lista per finestra di scelta
+ Dim ToolToImportList As New ObservableCollection(Of ImpExpFamily)
+ ' creo famiglie di utensili in base a quelle trovate in lista importata
+ For ToolIndex As Integer = 0 To ImportFileToolNameList.Count - 1
+ Dim ToolName As String = ImportFileToolNameList(ToolIndex)
+ Dim ToolFamily As Integer = ImportFileToolFamilyList(ToolIndex)
+ ToolFamily = ToolFamily And
+ (MCH_TF.DRILLBIT Or
+ MCH_TF.SAWBLADE Or
+ MCH_TF.MILL Or
+ MCH_TF.MORTISE Or
+ MCH_TF.CHISEL Or
+ MCH_TF.WATERJET Or
+ MCH_TF.COMPO)
+ Dim bFounded As Boolean = False
+ Dim ToolToImportFamily As ImpExpFamily
+ For Each ToolToImportFamily In ToolToImportList
+ If (ToolFamily = ToolToImportFamily.FamilyType) Then
+ ToolToImportFamily.ToolList.Add(New ImpExpItem(ToolName, AlreadyExist(ToolName)))
+ bFounded = True
+ Exit For
+ End If
+ Next
+ If Not bFounded Then
+ Dim NewFamily As New ImpExpFamily(GetToolFamilyName(ToolFamily), ToolFamily)
+ NewFamily.ToolList.Add(New ImpExpItem(ToolName, AlreadyExist(ToolName)))
+ ToolToImportList.Add(NewFamily)
+ End If
+ Next
+ Dim ImportWndVM As New ImportExportToolWindowVM(ToolToImportList, ImportFilePath, ImportFileToolNameList)
+ Dim ImportWnd As New ImportExportToolWindowV(Application.Current.MainWindow, ImportWndVM)
+
+ If ImportWnd.ShowDialog() Then
+ ' Aggiungo all'albero visualizzato gli utensili appena importati
+ LoadImportedMachineTools(ImportWndVM.vsImported)
+ End If
+ End Sub
+
+ Private Function AlreadyExist(ToolName As String) As Boolean
+ Dim ToolFamily As CathegoryItem
+ For Each ToolFamily In ToolsList
+ Dim ToolItem As CustomItem
+ For Each ToolItem In ToolFamily.Items
+ If ToolName = ToolItem.Name Then
+ Return True
+ End If
+ Next
+ Next
+ Return False
+ End Function
+
+ Private Function GetToolFamilyName(NewToolFamily As Integer) As String
+ Dim ToolFamily As CathegoryItem
+ For Each ToolFamily In ToolsList
+ If NewToolFamily = ToolFamily.nTType Then
+ Return ToolFamily.Name
+ End If
+ Next
+ Return ""
+ End Function
+
+ Private Sub LoadImportedMachineTools(vsImportedTools As String())
+ ' Leggo tutti gli utensili presenti nella Macchina (quindi anche quelli appena importati).
+ Dim ActiveToolsFamilies() As ToolsFamily = MachineUtility.ReadToolFamilies(m_CurrMachine.sMachIniFile)
+ Dim ToolsFamilyIndex As Integer = 0
+ Dim ToolsFamilyItem As ToolsFamily
+ For Each ToolsFamilyItem In ActiveToolsFamilies
+ Dim FamilyTreeView As New CathegoryItem(ToolsFamilyItem.Name, ToolsFamilyItem.Id)
+ Dim ToolFamilyItem = ToolsList.FirstOrDefault(Function(ToolFamily) ToolsFamilyItem.Id = FamilyTreeView.nTType)
+ If IsNothing(ToolFamilyItem) Then
+ ToolsList.Insert(ToolsFamilyIndex, FamilyTreeView)
+ End If
+ Dim nType As Integer = 0
+ Dim ToolName As String = String.Empty
+ Dim ToolIndex As Integer = 0
+ EgtSetCurrentContext(ToolScene.GetCtx())
+ If EgtTdbGetFirstTool(ToolsFamilyItem.Id, ToolName, nType) Then
+ Dim ToolItem = ToolsList(ToolsFamilyIndex).Items.FirstOrDefault(Function(Tool) Tool.Name = ToolName)
+ If IsNothing(ToolItem) Then
+ ' Se leggo un utensile non presente nella ToolsList visualizzata lo aggiungo ad essa.
+ Dim NewToolName As New CustomItem(ToolName, nType)
+ ToolsList(ToolsFamilyIndex).Items.Insert(ToolIndex, NewToolName)
+ ElseIf vsImportedTools.Contains(ToolName) Then
+ ' Se un utensile è presente nella ToolsList visualizzata ma nel contempo è nell'array vsImported
+ ' vuol dire che è stato sovrascritto perciò lo rimuovo e lo riaggiungo alla ToolsList.
+ ToolsList(ToolsFamilyIndex).Items.Remove(ToolsList(ToolsFamilyIndex).Items.FirstOrDefault(Function(Tool) Tool.Name = ToolName))
+ Dim NewToolName As New CustomItem(ToolName, nType)
+ ToolsList(ToolsFamilyIndex).Items.Insert(ToolIndex, NewToolName)
+ End If
+ ToolIndex += 1
+ While EgtTdbGetNextTool(ToolsFamilyItem.Id, ToolName, nType)
+ ToolItem = ToolsList(ToolsFamilyIndex).Items.FirstOrDefault(Function(Tool) Tool.Name = ToolName)
+ If IsNothing(ToolItem) Then
+ ' Se leggo un utensile non presente nella ToolsList visualizzata lo aggiungo ad essa.
+ Dim NewToolName As New CustomItem(ToolName, nType)
+ ToolsList(ToolsFamilyIndex).Items.Insert(ToolIndex, NewToolName)
+ ElseIf vsImportedTools.Contains(ToolName) Then
+ ' Se un utensile è presente nella ToolsList visualizzata ma nel contempo è nell'array vsImported
+ ' vuol dire che è stato sovrascritto perciò lo rimuovo e lo riaggiungo alla ToolsList.
+ ToolsList(ToolsFamilyIndex).Items.Remove(ToolsList(ToolsFamilyIndex).Items.FirstOrDefault(Function(Tool) Tool.Name = ToolName))
+ Dim NewToolName As New CustomItem(ToolName, nType)
+ ToolsList(ToolsFamilyIndex).Items.Insert(ToolIndex, NewToolName)
+ End If
+ ToolIndex += 1
+ End While
+ End If
+ ToolsFamilyIndex += 1
+ Next
+ End Sub
+
Friend Sub InitializeToolGroup(bEnabled As Boolean, nTType As Integer, sFName As String)
If Not bEnabled Then Return
' Inserisco categoria ed eventuali elementi
- Dim ToolCathegory As New CathegoryItem( sFName, nTType)
+ Dim ToolCathegory As New CathegoryItem(sFName, nTType)
Dim nType As Integer = 0
Dim ToolName As String = String.Empty
- Dim bFound As Boolean = EgtTdbGetFirstTool( nTType, ToolName, nType)
+ Dim bFound As Boolean = EgtTdbGetFirstTool(nTType, ToolName, nType)
While bFound
- If nType = nTType Then ToolCathegory.Items.Add( New CustomItem( ToolName, nType))
- bFound = EgtTdbGetNextTool( nTType, ToolName, nType)
+ If nType = nTType Then ToolCathegory.Items.Add(New CustomItem(ToolName, nType))
+ bFound = EgtTdbGetNextTool(nTType, ToolName, nType)
End While
- ToolsList.Add( ToolCathegory)
+ ToolsList.Add(ToolCathegory)
End Sub
Private Sub GetToolParams()
@@ -545,7 +699,7 @@ Public Class ToolsDbPageUC
HeadTxBx.Text = ToolString
EgtTdbGetCurrToolParam(MCH_TP.EXIT_, ToolInt)
ExitTxBx.Text = ToolInt.ToString()
- if Not GetSpecials() Then
+ If Not GetSpecials() Then
EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, ToolString)
UserNotesTxBx.Text = ToolString
End If
@@ -601,7 +755,7 @@ Public Class ToolsDbPageUC
EgtTdbSetCurrToolParam(MCH_TP.HEAD, HeadTxBx.Text)
Int32.TryParse(ExitTxBx.Text, nTemp)
EgtTdbSetCurrToolParam(MCH_TP.EXIT_, nTemp)
- if Not SetSpecials() Then
+ If Not SetSpecials() Then
EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, UserNotesTxBx.Text)
End If
End Sub
@@ -637,7 +791,7 @@ Public Class ToolsDbPageUC
Dim bShowUserNotes As Boolean = ((m_nToolType = MCH_TY.SAW_STD And m_CurrMachine.ShowUserNotes <> 0) Or m_CurrMachine.ShowUserNotes = 1)
UserNotesTxBl.Visibility = If(bShowUserNotes, Windows.Visibility.Visible, Windows.Visibility.Hidden)
UserNotesTxBx.Visibility = If(bShowUserNotes, Windows.Visibility.Visible, Windows.Visibility.Hidden)
- Dim bShowSpecials As Boolean = ((m_nToolType = MCH_TY.SAW_STD And m_CurrMachine.ShowSpecials <> 0) Or m_CurrMachine.ShowSpecials = 1)
+ Dim bShowSpecials As Boolean = ((m_nToolType = MCH_TY.SAW_STD And m_CurrMachine.ShowSpecials <> 0) Or m_CurrMachine.ShowSpecials = 1)
SerNbrTxBl.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden)
SerNbrTxBx.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden)
CodeTxBl.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden)
@@ -776,7 +930,7 @@ Public Class ToolsDbPageUC
Private Sub RecreateToolDraw(ByVal dVal As Double)
' Salvo il vecchio valore
Dim dOldVal As Double
- GetVariableValue( dOldVal)
+ GetVariableValue(dOldVal)
' Aggiorno dati utensile
SetVariableValue(dVal)
' Creo utensile
@@ -1004,7 +1158,7 @@ Public Class ToolsDbPageUC
End Function
Private Function CreateToolDraw() As Boolean
- Dim nErr As Integer = EgtTdbCurrToolDraw( m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx(), ToolScene.GetCtx())
+ Dim nErr As Integer = EgtTdbCurrToolDraw(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx(), ToolScene.GetCtx())
EgtSetCurrentContext(ToolScene.GetCtx())
Return (nErr = 0)
End Function
@@ -1057,4 +1211,4 @@ Public Class ToolsDbPageUC
End If
End Sub
-End Class
+End Class
\ No newline at end of file
diff --git a/OmagCUT.vbproj b/OmagCUT.vbproj
index e386058..e6a7541 100644
--- a/OmagCUT.vbproj
+++ b/OmagCUT.vbproj
@@ -196,6 +196,9 @@
CadCutPageUC.xaml
+
+ ImportExportToolWD.xaml
+ StartLauncheWD.xaml
@@ -431,6 +434,9 @@
DesignerMSBuild:Compile
+
+ Designer
+