|
|
|
@@ -5,6 +5,7 @@ Imports EgtWPFLib
|
|
|
|
|
Imports System.ComponentModel
|
|
|
|
|
Imports System.Threading
|
|
|
|
|
Imports System.Windows.Threading
|
|
|
|
|
Imports System.Windows.Forms
|
|
|
|
|
|
|
|
|
|
Class MainWindow
|
|
|
|
|
|
|
|
|
@@ -54,6 +55,8 @@ Class MainWindow
|
|
|
|
|
Friend m_nTopViewRotStep As Integer = 0
|
|
|
|
|
' Timer per aggiornamento interfaccia
|
|
|
|
|
Private m_IdleTimer As New DispatcherTimer(DispatcherPriority.ApplicationIdle)
|
|
|
|
|
' Timero per reset dei messaggi
|
|
|
|
|
Private m_DelayTimerMsg As New DispatcherTimer(DispatcherPriority.ApplicationIdle)
|
|
|
|
|
' Lista dei pezzi attivi
|
|
|
|
|
Private m_vParts As New List(Of Integer)
|
|
|
|
|
' percorso file template per stampante
|
|
|
|
@@ -192,8 +195,8 @@ Class MainWindow
|
|
|
|
|
' leggo nome file exe (per stampante zebra)
|
|
|
|
|
GetPrivateProfileString(S_PRINTER, K_ZEBRAUTILITIES, System.AppDomain.CurrentDomain.BaseDirectory & "ZebraPrinterUtilitiesR32.exe", m_ZebraUtilitiesExe, m_sIniFile)
|
|
|
|
|
' Recupero opzioni della chiave
|
|
|
|
|
Dim bKey As Boolean = EgtGetKeyLevel(9423, 2310, 1, m_nKeyLevel) And
|
|
|
|
|
EgtGetKeyOptions(9423, 2310, 1, m_nKeyOptions)
|
|
|
|
|
Dim bKey As Boolean = EgtGetKeyLevel(9423, 2602, 1, m_nKeyLevel) And
|
|
|
|
|
EgtGetKeyOptions(9423, 2602, 1, m_nKeyOptions)
|
|
|
|
|
EgtOutLog("KeyOptions : " & bKey.ToString() & " " & m_nKeyOptions.ToString())
|
|
|
|
|
' Imposto dir di default per libreria Lua e lancio libreria di base
|
|
|
|
|
Dim sLuaLibsDir As String = String.Empty
|
|
|
|
@@ -238,7 +241,7 @@ Class MainWindow
|
|
|
|
|
LabelBtn.Content = EgtMsg(91304) 'Stampa Etichetta
|
|
|
|
|
ConfirmBtn.Content = EgtMsg(91305) 'Conferma
|
|
|
|
|
' Abilitazione stampa etichetta
|
|
|
|
|
LabelBtn.IsEnabled = True
|
|
|
|
|
LabelBtn.IsEnabled = GetPrivateProfileInt(S_PRINTER, K_ENABLEPRINTER, 0, m_sIniFile) <> 0
|
|
|
|
|
' Visualizzazione bottoni Prev/Next
|
|
|
|
|
If GetPrivateProfileInt(S_GENERAL, K_PREVNEXTPROJ, 0, m_sIniFile) = 0 Then
|
|
|
|
|
PrevNextGrid.Visibility = Windows.Visibility.Hidden
|
|
|
|
@@ -247,6 +250,8 @@ Class MainWindow
|
|
|
|
|
End If
|
|
|
|
|
' Imposto OnIdle
|
|
|
|
|
AddHandler m_IdleTimer.Tick, AddressOf OnIdle
|
|
|
|
|
' Imposto "Maniglia" per la gestione dell'evento di pulizia dei messaggi
|
|
|
|
|
AddHandler m_DelayTimerMsg.Tick, AddressOf RefreshErrorMsgPrinter
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub ManageSingleIstance()
|
|
|
|
@@ -334,11 +339,11 @@ Class MainWindow
|
|
|
|
|
Dim sText As String = EgtMsg(MSG_MISSINGKEYWD + 2) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 3)
|
|
|
|
|
Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1)
|
|
|
|
|
MissingKeyWnd = New EgtMsgBox(Me, EgtMsg(MSG_MISSINGKEYWD + 1), EgtMsg(MSG_MISSINGKEYWD + 2) & " " & EgtMsg(MSG_MISSINGKEYWD + 3), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL)
|
|
|
|
|
' Altrimenti manca la licenza
|
|
|
|
|
' Altrimenti manca la licenza
|
|
|
|
|
Else
|
|
|
|
|
EgtOutLog("Problems with Licence")
|
|
|
|
|
' Box di avviso licenza con problemi : "Programma senza licenza. \n Caricala e riavvia il programma." "Errore"
|
|
|
|
|
Dim sKeyInfo As String = "" : EgtGetKeyInfo( sKeyInfo)
|
|
|
|
|
Dim sKeyInfo As String = "" : EgtGetKeyInfo(sKeyInfo)
|
|
|
|
|
Dim sText As String = sKeyInfo & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 5) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 6)
|
|
|
|
|
Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1)
|
|
|
|
|
MissingKeyWnd = New EgtMsgBox(Me, sTitle, sText, EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL, 2, 2)
|
|
|
|
@@ -354,9 +359,9 @@ Class MainWindow
|
|
|
|
|
' Recupero il direttorio del file
|
|
|
|
|
Dim sDir As String = System.IO.Path.GetDirectoryName(LicDlg.FileName)
|
|
|
|
|
' Se il file non è già nel direttorio di configurazione lo copio
|
|
|
|
|
If Not String.Equals(System.IO.Path.GetFullPath(sDir), System.IO.Path.GetFullPath( m_sConfigDir), StringComparison.OrdinalIgnoreCase) Then
|
|
|
|
|
If Not String.Equals(System.IO.Path.GetFullPath(sDir), System.IO.Path.GetFullPath(m_sConfigDir), StringComparison.OrdinalIgnoreCase) Then
|
|
|
|
|
Try
|
|
|
|
|
System.IO.File.Copy(LicDlg.FileName, System.IO.Path.Combine( m_sConfigDir, LicDlg.SafeFileName), True)
|
|
|
|
|
System.IO.File.Copy(LicDlg.FileName, System.IO.Path.Combine(m_sConfigDir, LicDlg.SafeFileName), True)
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
End Try
|
|
|
|
|
End If
|
|
|
|
@@ -418,7 +423,7 @@ Class MainWindow
|
|
|
|
|
Private Sub MainWindow_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) Handles Me.PreviewMouseDown
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub MainWindow_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
|
|
|
|
|
Private Sub OnKeyDownHandler(ByVal sender As Object, ByVal e As KeyEventArgs)
|
|
|
|
|
'If (m_NumericKeyboardWD.IsVisible And e.Key = Key.Enter) Then
|
|
|
|
|
' m_NumericKeyboardWD.Visibility = Windows.Visibility.Hidden
|
|
|
|
|
'End If
|
|
|
|
@@ -446,9 +451,11 @@ Class MainWindow
|
|
|
|
|
' Se già selezionato deseleziono
|
|
|
|
|
If nStat = GDB_ST.SEL Then
|
|
|
|
|
EgtDeselectObj(nPartId)
|
|
|
|
|
' Altrimenti seleziono
|
|
|
|
|
' Altrimenti seleziono
|
|
|
|
|
Else
|
|
|
|
|
EgtDeselectAll()
|
|
|
|
|
If Not (Keyboard.Modifiers And ModifierKeys.Control) > 0 Then
|
|
|
|
|
EgtDeselectAll()
|
|
|
|
|
End If
|
|
|
|
|
EgtSelectObj(nPartId)
|
|
|
|
|
End If
|
|
|
|
|
EgtDraw()
|
|
|
|
@@ -518,7 +525,11 @@ Class MainWindow
|
|
|
|
|
|
|
|
|
|
Private Sub PrintBtn_Click(sender As Object, e As RoutedEventArgs) Handles PrintBtn.Click
|
|
|
|
|
|
|
|
|
|
Dim printDlg As New PrintDialog
|
|
|
|
|
Dim printDlg As New System.Windows.Controls.PrintDialog()
|
|
|
|
|
Dim SM_Select As SM = SM.SHADING
|
|
|
|
|
If (Keyboard.Modifiers And ModifierKeys.Control) > 0 Then
|
|
|
|
|
SM_Select = SM.HIDDENLINE
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If printDlg.ShowDialog() Then
|
|
|
|
|
|
|
|
|
@@ -537,7 +548,7 @@ Class MainWindow
|
|
|
|
|
Dim nImgH As Integer = 2400
|
|
|
|
|
Dim sPath As String = m_sTempDir & "\Image.png"
|
|
|
|
|
EgtSetLineAttribs( 3)
|
|
|
|
|
If Not EgtGetImage(SM.HIDDENLINE, colWhite, colWhite, nImgW, nImgH, sPath) Then
|
|
|
|
|
If Not EgtGetImage(SM_Select, colWhite, colWhite, nImgW, nImgH, sPath) Then
|
|
|
|
|
EgtOutLog("Errore creazione immagine di stampa")
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
@@ -579,8 +590,9 @@ Class MainWindow
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
' Funzione per stampa delle etichette
|
|
|
|
|
' Funzione per stampa delle etichette con ZebraPrinter
|
|
|
|
|
Private Sub LabelBtn_Click(sender As Object, e As RoutedEventArgs) Handles LabelBtn.Click
|
|
|
|
|
Dim dTimerSleep As Double = GetPrivateProfileDouble(S_GENERAL, K_PRINTSLEEP, 5000, m_sIniFile)
|
|
|
|
|
Dim FileName As String = DateTime.Now.ToString()
|
|
|
|
|
FileName = FileName.Replace("/"c, "_")
|
|
|
|
|
FileName = FileName.Replace(":"c, "_")
|
|
|
|
@@ -589,6 +601,11 @@ Class MainWindow
|
|
|
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
|
|
|
' recupero il part
|
|
|
|
|
Dim nParentId As Integer = nId
|
|
|
|
|
' se nessun elemento selezionato esco
|
|
|
|
|
If nParentId = GDB_ID.NULL Then
|
|
|
|
|
ReadFileErrorPrinter(False)
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
Dim bArrow As Boolean = False
|
|
|
|
|
While nParentId <> GDB_ID.NULL
|
|
|
|
|
CreateFileData(nParentId, sFileDatIni)
|
|
|
|
@@ -599,9 +616,13 @@ Class MainWindow
|
|
|
|
|
Else
|
|
|
|
|
Process.Start(m_ZebraUtilitiesExe, m_TemplateFilePrinter & " " & sFileDatIni)
|
|
|
|
|
End If
|
|
|
|
|
Thread.Sleep(dTimerSleep)
|
|
|
|
|
' passo al pezzo successivo
|
|
|
|
|
nParentId = EgtGetNextSelectedObj()
|
|
|
|
|
End While
|
|
|
|
|
' attendo che sia generato il file
|
|
|
|
|
Thread.Sleep(10)
|
|
|
|
|
ReadFileErrorPrinter()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
' creazione file ini dei dati pezzo per stampa etichetta
|
|
|
|
@@ -647,6 +668,68 @@ Class MainWindow
|
|
|
|
|
End Try
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub ReadFileErrorPrinter(Optional bReadFileError As Boolean = True)
|
|
|
|
|
' stringa che conterrà il mesasggio da stampare come errore
|
|
|
|
|
Dim sErrorMsg As String = String.Empty
|
|
|
|
|
' se non leggo il messaggio di errore allora
|
|
|
|
|
If Not bReadFileError Then
|
|
|
|
|
sErrorMsg = EgtMsg(4 + 91460)
|
|
|
|
|
|
|
|
|
|
' leggo il messaggio di errore della stampante
|
|
|
|
|
Else
|
|
|
|
|
' percorso del file di errore
|
|
|
|
|
Dim sPathFileError As String = m_sDataRoot & "\Temp\" & "Error.txt"
|
|
|
|
|
' provo a recuperare il mesaggio di errore
|
|
|
|
|
If File.Exists(sPathFileError) Then
|
|
|
|
|
Dim sAllLines As String() = File.ReadAllLines(sPathFileError)
|
|
|
|
|
' verifico che ci sia almeno una riga nel file degli errori
|
|
|
|
|
If sAllLines.Count > 0 Then
|
|
|
|
|
' verifico che la prima riga non sia vuota
|
|
|
|
|
Dim Index As Integer = 0
|
|
|
|
|
While String.IsNullOrEmpty(sAllLines(Index))
|
|
|
|
|
Index += 1
|
|
|
|
|
If Index > sAllLines.Count Then
|
|
|
|
|
EgtOutLog("Il messaggio di errore della stampante non è comprensibile: " & sAllLines(Index))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
End While
|
|
|
|
|
Dim sItems As String() = sAllLines(Index).Split("=")
|
|
|
|
|
'verifico che sia avvenuto lo split
|
|
|
|
|
If sItems.Count > 1 Then
|
|
|
|
|
' verifico che il termine dopo il segno di uguale sia un numero
|
|
|
|
|
Dim nErrorIndex As Integer = -1
|
|
|
|
|
Try
|
|
|
|
|
nErrorIndex = CInt(sItems(1))
|
|
|
|
|
' se nErrorIndex=0 significa che non ci sono errori
|
|
|
|
|
If nErrorIndex < 1 Then
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
EgtOutLog("Il messaggio di errore della stampante non è comprensibile: " & sAllLines(Index))
|
|
|
|
|
Return
|
|
|
|
|
End Try
|
|
|
|
|
sErrorMsg = EgtMsg(nErrorIndex + 91460)
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
' eventualmente stampo il messaggio
|
|
|
|
|
If Not String.IsNullOrEmpty(sErrorMsg) Then
|
|
|
|
|
SetErrorMessage(sErrorMsg)
|
|
|
|
|
End If
|
|
|
|
|
' Lancio timer per aggiornamento interfaccia
|
|
|
|
|
Dim DelayTime As Integer = 4000
|
|
|
|
|
DelayTime = GetPrivateProfileInt(S_PRINTER, K_DELAYTIME, DelayTime, GetIniFile)
|
|
|
|
|
m_DelayTimerMsg.Interval = TimeSpan.FromMilliseconds(DelayTime)
|
|
|
|
|
m_DelayTimerMsg.Start()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
' questa funzione viene eseguita dall'evento associato al m_DelayTimerMsg
|
|
|
|
|
Private Sub RefreshErrorMsgPrinter()
|
|
|
|
|
ClearMessage()
|
|
|
|
|
m_DelayTimerMsg.Stop()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
' cerco se esiste la definizione del "*TOP*" del pezzo
|
|
|
|
|
Private Function GetTopInfoPart(nPartId As Integer) As Boolean
|
|
|
|
|
Dim nRegion As Integer = EgtGetFirstNameInGroup(nPartId, NAME_REGION)
|
|
|
|
|