diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index dc4b97d..03c7b23 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -40,6 +40,7 @@ Module ConstIni Public Const K_INVERTBEVEL As String = "DisableInvertBevel" Public Const K_ASKMEAGAINCONFIRM As String = "AskMeAgainConfirm" Public Const K_EGTCAMEXE As String = "EgtCam5Exe" + Public Const K_REFRESHTIME As String = "RefreshTime" Public Const S_LANGUAGES As String = "Languages" Public Const K_LANGUAGE As String = "Language" diff --git a/StatusBar/StatusBarVM.vb b/StatusBar/StatusBarVM.vb index 7bc24a1..0e3ad91 100644 --- a/StatusBar/StatusBarVM.vb +++ b/StatusBar/StatusBarVM.vb @@ -3,16 +3,21 @@ Imports System.Runtime.InteropServices Imports System.IO Imports EgtUILib Imports System.Threading +Imports System.Windows.Threading Imports System.ComponentModel +Imports EgtWPFLib5 Public Class StatusBarVM - Implements INotifyPropertyChanged + Inherits EgtWPFLib5.StatusBarVM #Region "FIELDS & PROPERTIES" - ' Funzioni di callback per output in interfaccia da LUA + ' Funzioni di callback per output In interfaccia da LUA 'Private m_ProcEventsCallback As New ProcessEventsCallback(AddressOf ProcessEvents) - 'Private m_OutTextCallback As New OutTextCallback(AddressOf OutText) + Private m_OutTextCallback As New OutTextCallback(AddressOf OutText) + Private m_RefreshTimer As New DispatcherTimer + ' tempo di cancellazione messaggio + Private m_nRefreshTime As Integer = 5000 ' GRAPHICAL ELEMENTS Private m_StatusOutput As String @@ -69,14 +74,31 @@ Public Class StatusBarVM Sub New() Map.SetRefStatusBarVM(Me) + '' Installo funzione gestione eventi per lua + 'EgtSetProcessEvents(m_ProcEventsCallback) + ' Installo funzione output testo su status per lua + EgtSetOutText(m_OutTextCallback) + m_nRefreshTime = GetMainPrivateProfileInt(S_GENERAL, K_REFRESHTIME, 5000) End Sub #End Region ' Constructor - Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged + ' riceve le stringhe dei messaggi lua EgtOutText + Public Function OutText(ByRef psText As IntPtr) As Boolean + ' Assegno stringa + OutputMessage = (Marshal.PtrToStringUni(psText)) + m_StatusOutput = OutputMessage + NotifyPropertyChanged("StatusOutput") + AddHandler m_RefreshTimer.Tick, AddressOf RefreshTimer_tick + m_RefreshTimer.Interval = TimeSpan.FromMilliseconds(m_nRefreshTime) + m_RefreshTimer.Start() + Return True + End Function - Public Sub NotifyPropertyChanged(propName As String) - RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) + ' dopo m_nRefreshTime pulisco il messaggio + Private Sub RefreshTimer_tick() + m_StatusOutput = String.Empty + NotifyPropertyChanged("StatusOutput") End Sub End Class @@ -100,4 +122,5 @@ Public Class SPItem m_SPMessage = Message End Sub -End Class \ No newline at end of file +End Class +