1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
Public Class ClsViewModele
Implements INotifyPropertyChanged
Public Timer1 As DispatcherTimer
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Protected Overridable Sub OnPropertyChanged(ByVal propertyName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End Sub
Private monModèle As ClsModele
Public Sub New()
monModèle = New ClsModele
_MonImage= monModèle.MonImage
ModificationModèle = False
Timer1 = New DispatcherTimer
AddHandler Timer1.Tick, AddressOf Timer1_Tick
Timer1.Interval = New TimeSpan(0, 0, 1)
Timer1.Start()
End Sub
Public Property MonImage As Uri
Get
Return Me._MonImage
End Get
Set(value As Uri)
Me._MonImage = value
OnPropertyChanged("MonImage")
If ModificationModèle = True Then
monModèle.MonImage = _MonImage
End If
End Set
End Property
'(Commandé par un checkbox)
Private _modificationModèle As Boolean
Public Property ModificationModèle As Boolean
Get
Return Me._modificationModèle
End Get
Set(ByVal value As Boolean)
Me._modificationModèle = value
OnPropertyChanged("ModificationModèle")
End Set
End Property
'Affectation de nouvelle image par le timer (pour essaie bien-sur)
Private alterne As Boolean
Private Sub Timer1_Tick(sender As Object, e As EventArgs)
Dim myPath As String
If alterne Then
myPath = System.AppDomain.CurrentDomain.BaseDirectory & "Lampe\Lampe_Eteinte.jpg"
If System.IO.File.Exists(myPath) Then
MonImage = New Uri(myPath, UriKind.RelativeOrAbsolute)
End If
Else
myPath = System.AppDomain.CurrentDomain.BaseDirectory & "Lampe\Lampe_Vert.jpg"
MonImage = New Uri(myPath, UriKind.RelativeOrAbsolute)
End If
alterne = Not alterne
End Sub |
Partager