forked from changbowen/Ken-Burns-Slideshow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControlWindow.xaml.vb
125 lines (116 loc) · 5.84 KB
/
ControlWindow.xaml.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
Public Class ControlWindow
Sub New()
' This call is required by the designer.
InitializeComponent()
Owner = Application.Current.MainWindow
End Sub
Private Sub Window_Closing(sender As Object, e As ComponentModel.CancelEventArgs)
If Not MainWindow.nextcloseaction = MainWindow.CloseAction.DirectQuit Then
e.Cancel = True
Hide() 'if close, next F1 will throw exception
End If
End Sub
Friend Sub Btn_SwitchImage_Click(sender As Object, e As RoutedEventArgs) Handles Btn_SwitchImage.Click
Task.Run(Sub()
Dispatcher.Invoke(Sub()
Btn_SwitchImage.IsEnabled = False
Btn_Restart.IsEnabled = False
End Sub)
Threading.Thread.Sleep(3000)
Dispatcher.Invoke(Sub()
Btn_SwitchImage.IsEnabled = True
Btn_Restart.IsEnabled = True
End Sub)
End Sub)
DirectCast(Owner, MainWindow).SwitchImage()
End Sub
Friend Sub Btn_SwitchAudio_Click(sender As Object, e As RoutedEventArgs) Handles Btn_SwitchAudio.Click
Task.Run(Sub()
Dispatcher.Invoke(Sub()
Btn_SwitchAudio.IsEnabled = False
Btn_Restart.IsEnabled = False
Btn_NextSong.IsEnabled = False
End Sub)
Threading.Thread.Sleep(3000)
Dispatcher.Invoke(Sub()
Btn_SwitchAudio.IsEnabled = True
Btn_Restart.IsEnabled = True
Btn_NextSong.IsEnabled = True
End Sub)
End Sub)
DirectCast(Owner, MainWindow).SwitchAudio()
End Sub
Friend Sub Btn_Restart_Click(sender As Object, e As RoutedEventArgs) Handles Btn_Restart.Click
Task.Run(Sub()
Dispatcher.Invoke(Sub()
Btn_SwitchImage.IsEnabled = False
Btn_SwitchAudio.IsEnabled = False
Btn_Restart.IsEnabled = False
Btn_NextSong.IsEnabled = False
End Sub)
Threading.Thread.Sleep(3000)
Dispatcher.Invoke(Sub()
Btn_SwitchImage.IsEnabled = True
Btn_SwitchAudio.IsEnabled = True
Btn_Restart.IsEnabled = True
Btn_NextSong.IsEnabled = True
End Sub)
End Sub)
DirectCast(Owner, MainWindow).RestartAll()
End Sub
Friend Sub Btn_NextSong_Click(sender As Object, e As RoutedEventArgs) Handles Btn_NextSong.Click
Task.Run(Sub()
Dispatcher.Invoke(Sub()
Btn_SwitchAudio.IsEnabled = False
Btn_Restart.IsEnabled = False
Btn_NextSong.IsEnabled = False
End Sub)
Threading.Thread.Sleep(3000)
Dispatcher.Invoke(Sub()
Btn_SwitchAudio.IsEnabled = True
Btn_Restart.IsEnabled = True
Btn_NextSong.IsEnabled = True
End Sub)
End Sub)
DirectCast(Owner, MainWindow).NextSong()
End Sub
Private Sub Btn_Options_Click(sender As Object, e As RoutedEventArgs) Handles Btn_Options.Click
Dim optwin As New OptWindow
optwin.ShowDialog()
optwin.Close()
End Sub
Private Sub Btn_EditSlide_Click(sender As Object, e As RoutedEventArgs) Handles Btn_EditSlide.Click
Dim editwin As New EditWindow
editwin.ShowDialog()
editwin.Close()
End Sub
Private Sub Btn_Exit_Click(sender As Object, e As RoutedEventArgs) Handles Btn_Exit.Click
DirectCast(Owner, MainWindow).Close()
End Sub
Private Sub Window_PreviewKeyDown(sender As Object, e As KeyEventArgs)
If e.Key = Key.Escape Then
Hide()
ElseIf e.Key = Key.P Then
If Keyboard.Modifiers = ModifierKeys.Control AndAlso Btn_SwitchImage.IsEnabled Then 'pause image
Btn_SwitchImage_Click(Nothing, Nothing)
ElseIf Keyboard.Modifiers = ModifierKeys.Shift AndAlso Btn_SwitchAudio.IsEnabled Then 'fadeout audio only
Btn_SwitchAudio_Click(Nothing, Nothing)
End If
ElseIf e.Key = Key.R AndAlso Keyboard.Modifiers = ModifierKeys.Control AndAlso Btn_Restart.IsEnabled Then
Btn_Restart_Click(Nothing, Nothing)
ElseIf e.Key = Key.F12 Then
Dim optwin As New OptWindow
optwin.ShowDialog()
optwin.Close()
ElseIf e.Key = Key.F11 Then
Dim editwin As New EditWindow
editwin.ShowDialog()
editwin.Close()
ElseIf e.Key = Key.Q AndAlso Keyboard.Modifiers = ModifierKeys.Control Then 'immediately quit
MainWindow.nextcloseaction = MainWindow.CloseAction.FadeToDesktop
DirectCast(Owner, MainWindow).Close()
ElseIf e.Key = Key.N AndAlso Keyboard.Modifiers = ModifierKeys.Control Then
Btn_NextSong_Click(Nothing, Nothing)
End If
End Sub
End Class