EgtDOORCreator 2.2k1:

-> aggiunto bottone per aprire la porta corrente con il programma Cam5.
This commit is contained in:
Nicola Pievani
2020-11-17 17:57:32 +00:00
parent ed24c7fe25
commit a2aaa829fc
8 changed files with 146 additions and 4 deletions
+128
View File
@@ -65,6 +65,20 @@ Public Class ProjectManagerVM
End Get
End Property
Public ReadOnly Property VisibilityEgtCAM As Visibility
Get
If String.IsNullOrEmpty(IniFile.m_sEgtCameEXEPath) Then
Return Visibility.Collapsed
ElseIf Not File.Exists(IniFile.m_sEgtCameEXEPath) Then
Return Visibility.Collapsed
ElseIf File.Exists(IniFile.m_sEgtCameEXEPath) Then
Return Visibility.Visible
Else
Return Visibility.Collapsed
End If
End Get
End Property
Private m_IsModifiedImage As String = "/Resources/TopCommandBar/Save.png"
Public Property IsModifiedImage As String
Get
@@ -130,6 +144,7 @@ Public Class ProjectManagerVM
Private m_cmdHardware As ICommand
Private m_cmdRefreshDir As ICommand
Private m_cmdCreateAssembly As ICommand
Private m_CmdOpenCam As ICommand
#Region "ToolTip"
@@ -211,6 +226,12 @@ Public Class ProjectManagerVM
End Get
End Property
Public ReadOnly Property OpenCamToolTip As String
Get
Return "EgtCam5"
End Get
End Property
Public ReadOnly Property DuplicaToolTip As String
Get
' Save As
@@ -1271,6 +1292,59 @@ Public Class ProjectManagerVM
#End Region ' Copy
#Region "OpenCam5"
Public ReadOnly Property OpenCamCommand As ICommand
Get
If m_CmdOpenCam Is Nothing Then
m_CmdOpenCam = New Command(AddressOf OpenCam)
End If
Return m_CmdOpenCam
End Get
End Property
Public Sub OpenCam()
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
' 50192 = Impossible to export to machine a door if there is not a door!
MessageBox.Show(EgtMsg(50192), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
Return
End If
'Verifico che tutto sia salvato, altrimenti esco con messaggio
If Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified() Then
' Project must be saved before copying
MessageBox.Show(EgtMsg(50186), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
Return
End If
' Dim CurrFile As String = IniFile.m_sTempDir & "\CurrPart" & DDF_EXTENSION
Dim CurrFile As String = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name
Try
Dim Proc As New Process
Proc.StartInfo.FileName = IniFile.m_sEgtCameEXEPath
' 0: creata una porta come descritta nel file riferito
' 1 viene creata la porta e il suo programma di lavorazione sul centro di lavoro preconfigurato
Proc.StartInfo.Arguments = """" & CurrFile & """ " & If((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift, """1""", """0""")
If Not Proc.Start() Then
' Error in starting EgtCam5.exe
MessageBox.Show(EgtMsg(50567), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
End If
Catch ex As Exception
' Error in starting EgtCam5.exe
MessageBox.Show(EgtMsg(50567), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
End Try
Dim sError As String = String.Empty
Dim nType As Integer = 0
ShowGraphicError(sError, nType)
If Not String.IsNullOrEmpty(sError) And nType > 0 Then
MessageBox.Show(sError, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
ElseIf Not String.IsNullOrEmpty(sError) And nType < 0 Then
MessageBox.Show(sError, EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
End If
End Sub
#End Region ' Copy
#Region "Duplica"
Public ReadOnly Property DuplicaCommand As ICommand
@@ -1574,6 +1648,60 @@ Public Class ProjectManagerVM
#End Region ' CreateAssemblyCommand
#Region "METHODS"
#End Region ' Methos
'questo metodo restituisce l'errore letto nel file CurrDoor.txt
Public Sub ShowGraphicError(ByRef ErrorMessages As String, ByRef Type As Integer)
' se non c'è nessuna porta aperta allora esco
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse
IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then
Return
End If
Dim FileLog As String = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name
FileLog = FileLog.Replace(DDF_EXTENSION, ".txt")
Dim FileContent() As String
' controllo se esite il file CurrDoor.txt
If Not File.Exists(FileLog) Then Return
FileContent = File.ReadAllLines(FileLog)
' se il file esiste ma è vuoto
If FileContent.Count = 0 Then
MessageBox.Show(EgtMsg(50107), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
End If
Dim IndexLine As Integer = 0
Dim nMsgErr As Integer = 0
' leggo il valore numerico (se il valore non è numerico è passato di default il valore 0)
nMsgErr = RegexFunction.ErrDraw(FileContent(IndexLine))
Type = nMsgErr
' passo alla riga succesiva
IndexLine += 1
' se il valore è maggiore di zero allora è un errore
If nMsgErr > 0 Then
' salto tutte le righe vuote
While String.IsNullOrEmpty(FileContent(IndexLine)) AndAlso IndexLine < FileContent.Count
IndexLine += 1
End While
ErrorMessages = FileContent(IndexLine)
IndexLine += 1
While IndexLine < FileContent.Count
ErrorMessages &= vbNewLine & FileContent(IndexLine)
IndexLine += 1
End While
' altrimenti un avvertimento
ElseIf nMsgErr < 0 Then
While String.IsNullOrEmpty(FileContent(IndexLine)) AndAlso IndexLine < FileContent.Count
IndexLine += 1
End While
ErrorMessages = FileContent(IndexLine)
IndexLine += 1
While IndexLine < FileContent.Count
ErrorMessages &= vbNewLine & FileContent(IndexLine)
IndexLine += 1
End While
Else
ErrorMessages = String.Empty
End If
End Sub
#End Region ' Commands
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged