/
ChildViewModel.vb
69 lines (67 loc) · 1.9 KB
/
ChildViewModel.vb
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
69
Imports System
Imports System.Windows
Imports System.Windows.Input
Imports System.Windows.Threading
Imports DevExpress.Mvvm
Namespace DXSample.ViewModels
Public Class ChildViewModel
Inherits ViewModelBase
Protected ReadOnly Property CurrentWindowService() As ICurrentWindowService
Get
Return Me.GetService(Of ICurrentWindowService)()
End Get
End Property
Private privateCloseWindowCommand As ICommand
Public Property CloseWindowCommand() As ICommand
Get
Return privateCloseWindowCommand
End Get
Private Set(ByVal value As ICommand)
privateCloseWindowCommand = value
End Set
End Property
Private privateTemporarilyHideWindowCommand As ICommand
Public Property TemporarilyHideWindowCommand() As ICommand
Get
Return privateTemporarilyHideWindowCommand
End Get
Private Set(ByVal value As ICommand)
privateTemporarilyHideWindowCommand = value
End Set
End Property
Public Property Caption() As String
Get
Return GetValue(Of String)()
End Get
Set(ByVal value As String)
SetValue(value)
End Set
End Property
Public Property WindowState() As WindowState
Get
Return GetValue(Of WindowState)()
End Get
Set(ByVal value As WindowState)
SetValue(value)
End Set
End Property
Public Sub New()
CloseWindowCommand = New DelegateCommand(AddressOf CloseWindow)
TemporarilyHideWindowCommand = New DelegateCommand(AddressOf TemporarilyHideWindow)
End Sub
Private Sub CloseWindow()
Me.CurrentWindowService.Close()
End Sub
Private Sub TemporarilyHideWindow()
Me.CurrentWindowService.Hide()
Dim timer = New DispatcherTimer() With {.Interval = TimeSpan.FromSeconds(3)}
AddHandler timer.Tick, Sub(o, e)
Me.CurrentWindowService.SetWindowState(WindowState.Maximized)
Me.CurrentWindowService.Show()
Me.CurrentWindowService.Activate()
timer.Stop()
End Sub
timer.Start()
End Sub
End Class
End Namespace