Gestione salvataggio immagine originale

This commit is contained in:
Nicola Pievani
2025-02-18 10:43:12 +01:00
parent f45d482e1b
commit 925ac18a45
5 changed files with 73 additions and 13 deletions
+3
View File
@@ -30,6 +30,7 @@ Module ConstIniSlab
Public Const K_LASTPROJ As String = "LastProj"
Public Const K_AUTOLOADLASTPROJ As String = "AutoLoadLastProj"
Public Const K_IMAGEDIR As String = "ImageDir"
Public Const K_ORIGIMAGEDIR As String = "OrigImageDir"
Public Const K_EXPORTDIR As String = "ExportDir"
Public Const K_CONTOURFROMCAMERA As String = "ContourFromCamera"
Public Const K_SUPPORT As String = "Support"
@@ -87,11 +88,13 @@ Module ConstIniSlab
Public Const K_CAM_INFO As String = "Info"
Public Const K_CAM_RESULT As String = "Result"
Public Const K_CAM_CONTOUR As String = "Contour"
Public Const K_CAM_ORIGIMAGE As String = "OrigImage"
Public Const K_CAM_EXEPATH2 As String = "ExePath2"
Public Const K_CAM_IMAGE2 As String = "Image2"
Public Const K_CAM_INFO2 As String = "Info2"
Public Const K_CAM_RESULT2 As String = "Result2"
Public Const K_CAM_CONTOUR2 As String = "Contour2"
Public Const K_CAM_ORIGIMAGE2 As String = "OrigImage2"
Public Const K_CAM_THRESHOLD As String = "Threshold"
Public Const K_CAM_TOLERANCE As String = "Tolerance"
Public Const K_CAM_TIMEOUT As String = "Timeout"
+2 -2
View File
@@ -58,5 +58,5 @@ Imports System.Windows
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.6.10.1")>
<Assembly: AssemblyFileVersion("2.6.10.1")>
<Assembly: AssemblyVersion("2.7.2.1")>
<Assembly: AssemblyFileVersion("2.7.2.1")>
+9 -9
View File
@@ -16,15 +16,15 @@
<Setter Property="Height" Value="30"/>
<Setter Property="Width" Value="30"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter x:Name="MyContentPresenter"
Content="{TemplateBinding Content}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter x:Name="MyContentPresenter"
Content="{TemplateBinding Content}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
+31
View File
@@ -544,6 +544,21 @@ Public Class OptionPanelSlabVM
Catch ex As Exception
Return String.Empty
End Try
' Aggiorno il nome del file origine
Dim sOrigImageDir As String = String.Empty
GetMainPrivateProfileString(S_GENERAL, K_ORIGIMAGEDIR, "", sOrigImageDir)
If Not String.IsNullOrEmpty(sOrigImageDir) Then
Dim sOrigFileImg As String = sOrigImageDir & "\" & "OrigFinaleImage.jpg"
If File.Exists(sOrigFileImg) Then
Try
File.Copy(sOrigFileImg, sOrigImageDir & "\" & Path.GetFileNameWithoutExtension(NewImgPath) & ".jpg", True)
File.Delete(sOrigFileImg)
Catch ex As Exception
EgtOutLog("Error in coping orig file: " & ex.ToString)
End Try
End If
End If
Return Path.GetFileName(NewImgPath)
End Function
@@ -759,6 +774,22 @@ Public Class OptionPanelSlabVM
' non è un problema
End Try
End If
' Elimino il file origine
Dim sOrigImageDir As String = String.Empty
GetMainPrivateProfileString(S_GENERAL, K_ORIGIMAGEDIR, "", sOrigImageDir)
If Not String.IsNullOrEmpty(sOrigImageDir) Then
Dim sOrigFileImg As String = sOrigImageDir & "\" & Path.GetFileNameWithoutExtension(sImagePath) & ".jpg"
If File.Exists(sOrigFileImg) Then
Try
File.Delete(sOrigFileImg)
Catch ex As FileNotFoundException
' non è un problema
Catch ex As Exception
' non è un problema
End Try
End If
End If
End Sub
#End Region ' Remove
+28 -2
View File
@@ -20,6 +20,8 @@ Public Class Camera
Friend Const FINAL_IMAGE As String = "FinalImage.jpg"
Public Shared bFirstWarning As Boolean = True
' Dati
Private m_bCameraLink As Boolean = False
Private m_bCalcContour As Boolean = False
@@ -41,6 +43,10 @@ Public Class Camera
Private m_nTimeout As Integer = 30
Private m_sImageDir As String = String.Empty
Private m_sOrigImage As String = String.Empty
Private m_sOrigImage2 As String = String.Empty
Private m_sOrigImageDir As String = String.Empty
' Flag per foto in esecuzione
Friend m_bBusy As Boolean = False
@@ -53,10 +59,12 @@ Public Class Camera
GetMainPrivateProfileString(S_CAMERA, K_CAM_INFO, "", m_sInfo)
GetMainPrivateProfileString(S_CAMERA, K_CAM_RESULT, "", m_sResult)
GetMainPrivateProfileString(S_CAMERA, K_CAM_CONTOUR, "", m_sContour)
GetMainPrivateProfileString(S_CAMERA, K_CAM_ORIGIMAGE, "", m_sOrigImage)
m_nThreshold = GetMainPrivateProfileInt(S_CAMERA, K_CAM_THRESHOLD, 60)
m_dTolerance = GetMainPrivateProfileDouble(S_CAMERA, K_CAM_TOLERANCE, 5)
m_nTimeout = GetMainPrivateProfileInt(S_CAMERA, K_CAM_TIMEOUT, 30)
GetMainPrivateProfileString(S_GENERAL, K_IMAGEDIR, "", m_sImageDir)
GetMainPrivateProfileString(S_GENERAL, K_ORIGIMAGEDIR, "", m_sOrigImageDir)
' Verifico abilitazione riconoscimento contorno automatico del grezzo
m_bCalcContour = MainData.GetKeyOption(KEY_OPT.AUTO_PHOTO) AndAlso
(GetMainPrivateProfileInt(S_GENERAL, K_CONTOURFROMCAMERA, 0) <> 0)
@@ -347,8 +355,26 @@ Public Class Camera
Dim sInfoDest As String = Path.ChangeExtension(sImageDest, "txt")
File.Copy(If(nInd <> 2, m_sImage, m_sImage2), sImageDest, True)
File.Copy(If(nInd <> 2, m_sInfo, m_sInfo2), sInfoDest, True)
' Se richiesto il riconoscimento del contorno
Dim sContourDest As String = String.Empty
'--------------------------------------------------------------
If Not String.IsNullOrEmpty(m_sOrigImageDir) Then
Try
Dim sOrig As String = "OrigFinaleImage.jpg"
Dim sOrigImageDest As String = m_sOrigImageDir & "\" & Path.GetFileName(If(nInd <> 2, sOrig, m_sOrigImage2))
File.Copy(If(nInd <> 2, m_sOrigImage, m_sOrigImage2), sOrigImageDest, True)
File.Delete(m_sOrigImage)
Catch e As Exception
EgtOutLog("Error in copy and delete orig image: " & e.ToString)
End Try
Else
' Solo al primo scatto comunico questo messaggio
If bFirstWarning Then
EgtOutLog(" INFORMATION: Program is not configurated to save original imege file.")
bFirstWarning = False
End If
End If
'--------------------------------------------------------------
' Se richiesto il riconoscimento del contorno
Dim sContourDest As String = String.Empty
If m_bCalcContour Then
sContourDest = Path.ChangeExtension(sImageDest, "dxf")
File.Copy(If(nInd <> 2, m_sContour, m_sContour2), sContourDest, True)