-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainViewModel.vb
More file actions
56 lines (47 loc) · 2.37 KB
/
MainViewModel.vb
File metadata and controls
56 lines (47 loc) · 2.37 KB
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
Imports System
Imports System.Threading.Tasks
Imports DevExpress.Mvvm
Namespace InteractiveNotifications
Public Class MainViewModel
Protected Overridable ReadOnly Property NotificationService As INotificationService
Get
Return Nothing
End Get
End Property
Public Property PredefinedNotificationId As Integer
Protected Sub New()
PredefinedNotificationId = 100
End Sub
Public Sub ShowNotification()
Dim text1 As String = "Lorem ipsum dolor sit amet integer fringilla, dui eget ultrices cursus, justo tellus."
Dim text2 As String = "In ornare ante magna, eget volutpat mi bibendum a. Nam ut ullamcorper libero. Pellentesque habitant."
Dim text3 As String = "Quisque sapien odio, mollis tincidunt est id, fringilla euismod neque. Aenean adipiscing lorem dui, nec. "
Dim notification As INotification = NotificationService.CreatePredefinedNotification(text1, text2, text3, Nothing, PredefinedNotificationId.ToString())
PredefinedNotificationId += 1
Show(notification)
End Sub
Private Sub Show(ByVal notification As INotification)
CreateLogLine("Showing...")
notification.ShowAsync().ContinueWith(New Action(Of Task(Of NotificationResult))(AddressOf OnNotificationShown), TaskScheduler.FromCurrentSynchronizationContext())
End Sub
Private Sub OnNotificationShown(ByVal task As Task(Of NotificationResult))
Try
Select Case task.Result
Case NotificationResult.Activated
CreateLogLine("Activated")
Case NotificationResult.TimedOut
CreateLogLine("Timed out")
Case NotificationResult.UserCanceled
CreateLogLine("Canceled by user")
Case NotificationResult.Dropped
CreateLogLine("Dropped (the queue is full)")
End Select
Catch e As AggregateException
CreateLogLine("Error: " & e.InnerException.Message)
End Try
End Sub
Private Sub CreateLogLine(ByVal text As String)
System.Diagnostics.Debug.WriteLine(text)
End Sub
End Class
End Namespace