EgtWPFLib5 :

- correzione a verifica unicità nome disegno custom per utensile.
This commit is contained in:
Dario Sassi
2026-04-02 10:36:22 +02:00
parent 635f406fad
commit 3ceafa752c
+25 -9
View File
@@ -3733,6 +3733,7 @@ Public Class ToolTreeViewItem
''' Creata the new tool. This method is invoked by the NewCommand.
''' </summary>
Public Sub OpenDrawFile(ByVal param As Object)
' Scelta del file
Dim OpenFileDialog As New Microsoft.Win32.OpenFileDialog With {
.Title = "Open draw file",
.DefaultExt = ".nge",
@@ -3741,19 +3742,34 @@ Public Class ToolTreeViewItem
.FileName = m_Draw
}
If OpenFileDialog.ShowDialog <> True Then Return
'Dim OpenFileDialog As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
' .Title = "Open draw file",
' .InitialDirectory = ToolDbWindowVM.m_sToolDirPath,
' .Filter = "File Nge (.nge)|*.nge",
' .FileName = m_Draw
'}
'If OpenFileDialog.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return
m_Draw = Path.GetFileName(OpenFileDialog.FileName)
Dim sFileName As String = Path.GetFileName(OpenFileDialog.FileName)
' Verifico che lo stesso file non sia già riferito da un altro utensile
Dim NameList As New List(Of String)
For Each ItemsTool As FamilyToolTreeViewItem In LibMap.refToolDbWindowVM.ToolsList
For Each ItemTool As ToolTreeViewItem In ItemsTool.Items
If String.IsNullOrEmpty(ItemTool.Draw) Then
EgtTdbSetCurrTool(ItemTool.Name)
EgtTdbGetCurrToolParam(MCH_TP.DRAW, ItemTool.Draw)
End If
If Not String.IsNullOrWhiteSpace(ItemTool.Draw) AndAlso Not ItemTool.IsSelected AndAlso sFileName.Equals(ItemTool.Draw) Then
NameList.Add(ItemTool.Name)
End If
Next
Next
EgtTdbSetCurrTool(LibMap.refToolDbWindowVM.SelTool.Name)
If NameList.Count > 0 Then
Dim sTools As String = String.Join(Environment.NewLine, NameList)
' Disegno già utilizzato in: XXXX selezionarne un altro
MessageBox.Show(EgtMsg(6082) & Environment.NewLine & sTools & Environment.NewLine & EgtMsg(6083), EgtMsg(15003),
MessageBoxButton.OK, MessageBoxImage.Information)
Return
End If
' Se il file è preso da una cartella diversa da quella degli utensili viene copiato nella cartella degli utensili
Dim sFilePath As String = Path.GetDirectoryName(OpenFileDialog.FileName)
If sFilePath <> ToolDbWindowVM.m_sToolDirPath Then
File.Copy(OpenFileDialog.FileName, Path.Combine(ToolDbWindowVM.m_sToolDirPath, m_Draw))
File.Copy(OpenFileDialog.FileName, Path.Combine(ToolDbWindowVM.m_sToolDirPath, sFileName))
End If
m_Draw = sFileName
UpdateSceneToolDraw()
End Sub