-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathShellViewModel_UIBehaviours.cs
More file actions
392 lines (326 loc) · 12.3 KB
/
ShellViewModel_UIBehaviours.cs
File metadata and controls
392 lines (326 loc) · 12.3 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
using Caliburn.Micro;
using Bivrost.Bivrost360Player.WPF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Animation;
using LoggerManager = Bivrost.Log.LoggerManager;
namespace Bivrost.Bivrost360Player
{
public partial class ShellViewModel
{
public void HideUI()
{
var shell = playerWindow as ShellView;
shell.topMenuPanel.Visibility = Visibility.Collapsed;
//shell.controlBar.Visibility = Visibility.Collapsed;
//shell.logoImage.Visibility = Visibility.Collapsed;
shell.menuRow.Height = new GridLength(0);
//shell.SelectedFileNameLabel.Visibility = Visibility.Collapsed;
//shell.mainGrid.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black);
shell.OpenSettings.Visibility = Visibility.Collapsed;
NotifyOfPropertyChange(null);
}
public void ShowUI()
{
var shell = playerWindow as ShellView;
shell.topMenuPanel.Visibility = Visibility.Visible;
//shell.controlBar.Visibility = Visibility.Visible;
//shell.logoImage.Visibility = Visibility.Visible;
shell.menuRow.Height = new GridLength(22);
//shell.SelectedFileNameLabel.Visibility = Visibility.Visible;
//shell.mainGrid.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black);
shell.OpenSettings.Visibility = Visibility.Visible;
NotifyOfPropertyChange(null);
}
private void HideBars()
{
//Task.Factory.StartNew(() => Execute.OnUIThread(() => {
Execute.OnUIThreadAsync(() =>
{
Storyboard storyboard = new Storyboard();
double animTime = 0.8;
GridLengthAnimation heightAnimation = new GridLengthAnimation() { From = shellView.bottomBarRow.Height, To = new GridLength(0), Duration = TimeSpan.FromSeconds(animTime) };
heightAnimation.EasingFunction = new QuadraticEase() { EasingMode = EasingMode.EaseInOut };
Storyboard.SetTarget(heightAnimation, shellView.bottomBarRow);
Storyboard.SetTargetProperty(heightAnimation, new PropertyPath("Height"));
storyboard.Children.Add(heightAnimation);
DoubleAnimation topHeightAnimation = new DoubleAnimation() { From = shellView.TopBar.Height, To = 0, Duration = TimeSpan.FromSeconds(animTime) };
topHeightAnimation.EasingFunction = new QuadraticEase() { EasingMode = EasingMode.EaseInOut };
Storyboard.SetTarget(topHeightAnimation, shellView.TopBar);
Storyboard.SetTargetProperty(topHeightAnimation, new PropertyPath("Height"));
storyboard.Children.Add(topHeightAnimation);
DoubleAnimation opacityAnimatiion = new DoubleAnimation() { From = shellView.SelectedFileNameLabel.Opacity, To = 0, Duration = TimeSpan.FromSeconds(animTime / 2) };
Storyboard.SetTarget(opacityAnimatiion, shellView.SelectedFileNameLabel);
Storyboard.SetTargetProperty(opacityAnimatiion, new PropertyPath("Opacity"));
storyboard.Children.Add(opacityAnimatiion);
DoubleAnimation opacityProgressAnimation = new DoubleAnimation() { From = shellView.SelectedFileNameLabel.Opacity, To = 0, Duration = TimeSpan.FromSeconds(animTime) };
Storyboard.SetTarget(opacityProgressAnimation, shellView.VideoProgressBar);
Storyboard.SetTargetProperty(opacityProgressAnimation, new PropertyPath("Opacity"));
storyboard.Children.Add(opacityProgressAnimation);
storyboard.Begin();
});
//}));
}
private void ShowBars()
{
//Task.Factory.StartNew(() => Execute.OnUIThread(() => {
Execute.OnUIThreadAsync(() =>
{
Storyboard storyboard = new Storyboard();
double animTime = 0.4;
GridLengthAnimation heightAnimation = new GridLengthAnimation() { From = shellView.bottomBarRow.Height, To = new GridLength(68), Duration = TimeSpan.FromSeconds(animTime) };
heightAnimation.EasingFunction = new QuadraticEase() { EasingMode = EasingMode.EaseInOut };
Storyboard.SetTarget(heightAnimation, shellView.bottomBarRow);
Storyboard.SetTargetProperty(heightAnimation, new PropertyPath("Height"));
storyboard.Children.Add(heightAnimation);
DoubleAnimation topHeightAnimation = new DoubleAnimation() { From = shellView.TopBar.Height, To = 32, Duration = TimeSpan.FromSeconds(animTime) };
topHeightAnimation.EasingFunction = new QuadraticEase() { EasingMode = EasingMode.EaseInOut };
Storyboard.SetTarget(topHeightAnimation, shellView.TopBar);
Storyboard.SetTargetProperty(topHeightAnimation, new PropertyPath("Height"));
storyboard.Children.Add(topHeightAnimation);
DoubleAnimation opacityAnimatiion = new DoubleAnimation() { From = shellView.SelectedFileNameLabel.Opacity, To = 1, Duration = TimeSpan.FromSeconds(animTime * 2) };
Storyboard.SetTarget(opacityAnimatiion, shellView.SelectedFileNameLabel);
Storyboard.SetTargetProperty(opacityAnimatiion, new PropertyPath("Opacity"));
storyboard.Children.Add(opacityAnimatiion);
DoubleAnimation opacityProgressAnimation = new DoubleAnimation() { From = shellView.SelectedFileNameLabel.Opacity, To = 1, Duration = TimeSpan.FromSeconds(animTime) };
Storyboard.SetTarget(opacityProgressAnimation, shellView.VideoProgressBar);
Storyboard.SetTargetProperty(opacityProgressAnimation, new PropertyPath("Opacity"));
storyboard.Children.Add(opacityProgressAnimation);
storyboard.Begin();
});
//}));
}
private void AnimateIndicator(UIElement uiControl)
{
Task.Factory.StartNew(() =>
{
Thread.Sleep(100);
Execute.OnUIThreadAsync(() =>
{
Storyboard storyboard = new Storyboard();
double animTime = 0.8;
DoubleAnimation opacityAnimation = new DoubleAnimation { From = 0.8, To = 0.0, Duration = TimeSpan.FromSeconds(animTime) };
Storyboard.SetTarget(opacityAnimation, uiControl);
Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
storyboard.Children.Add(opacityAnimation);
DoubleAnimation scaleAnimationX = new DoubleAnimation { From = 0.5, To = 1.5, Duration = TimeSpan.FromSeconds(animTime) };
Storyboard.SetTarget(scaleAnimationX, uiControl);
Storyboard.SetTargetProperty(scaleAnimationX, new PropertyPath("RenderTransform.ScaleX"));
storyboard.Children.Add(scaleAnimationX);
DoubleAnimation scaleAnimationY = new DoubleAnimation { From = 0.5, To = 1.5, Duration = TimeSpan.FromSeconds(animTime) };
Storyboard.SetTarget(scaleAnimationY, uiControl);
Storyboard.SetTargetProperty(scaleAnimationY, new PropertyPath("RenderTransform.ScaleY"));
storyboard.Children.Add(scaleAnimationY);
storyboard.Begin();
});
});
}
public void ShowPlaybackUI()
{
ShowStartupPanel(false);
ShowDropFilesPanel(false);
//shellView.VideoTime.Visibility = Visibility.Visible;
}
private Storyboard dropFilesPanelDashAnimation;
public void ShowDropFilesPanel(bool visibility)
{
shellView.DropFilesPanel.Visibility = visibility ? Visibility.Visible : Visibility.Collapsed;
if (visibility)
{
if (dropFilesPanelDashAnimation == null)
{
dropFilesPanelDashAnimation = new Storyboard();
double animTime = 5;
DoubleAnimation offsetAnimation = new DoubleAnimation { From = 0, To = 50, Duration = TimeSpan.FromSeconds(animTime) };
Storyboard.SetTarget(offsetAnimation, shellView.DropFilesRect);
Storyboard.SetTargetProperty(offsetAnimation, new PropertyPath("StrokeDashOffset"));
dropFilesPanelDashAnimation.Children.Add(offsetAnimation);
dropFilesPanelDashAnimation.RepeatBehavior = RepeatBehavior.Forever;
dropFilesPanelDashAnimation.Begin(shellView.DropFilesRect, true);
LoggerManager.Info("Begin storyboard");
}
else
{
if (dropFilesPanelDashAnimation.GetCurrentState(shellView.DropFilesRect) == ClockState.Stopped)
{
LoggerManager.Info("Begin storyboard again");
dropFilesPanelDashAnimation.Begin(shellView.DropFilesRect, true);
}
}
}
else
{
if (dropFilesPanelDashAnimation != null)
{
dropFilesPanelDashAnimation.Stop(shellView.DropFilesRect);
LoggerManager.Info("Stop storyboard");
}
}
}
void PlaybackControlUIHitTestVisible(bool hitTestVisible)
{
shellView.controlBar.IsHitTestVisible = hitTestVisible;
}
public void ShowStartupPanel(bool visibility)
{
shellView.StartupPanel.Visibility = visibility ? Visibility.Visible : Visibility.Collapsed;
}
public void ShowStartupUI()
{
Execute.OnUIThreadAsync(() =>
{
shellView.TopBar.Visibility = Visibility.Hidden;
this.DXCanvas.Visibility = Visibility.Hidden;
ShowStartupPanel(true);
ShowDropFilesPanel(false);
//shellView.VideoTime.Visibility = Visibility.Hidden;
});
}
public void OpenEULA()
{
}
public void OpenHomePage()
{
if (Fullscreen) ToggleFullscreen(true);
System.Diagnostics.Process.Start("https://tools.bivrost360.com/landing-pages/360PlayerWindows");
}
public void OpenSupportPage()
{
if (Fullscreen) ToggleFullscreen(true);
System.Diagnostics.Process.Start("https://tools.bivrost360.com/landing-pages/360PlayerWindows/support");
}
public void OpenBuyPage()
{
var confirm = Application.Current.Dispatcher.Invoke(() =>
{
var decision = MessageBox.Show(
Application.Current.MainWindow,
"To gain full access to the 360Player's features and get a commercial license, " +
"join the BIVROST R&D Program at http://bivrost360.com." +
"\n\nIf you have bought a copy of 360Player before and your license is still " +
"valid, please contact support: support@bivrost360.com.",
"360Player for Windows licensing",
MessageBoxButton.OK,
MessageBoxImage.Asterisk,
MessageBoxResult.OK
);
return decision == MessageBoxResult.OK;
});
}
public void OpenLicenseManagement()
{
#if FEATURE_LICENSE_NINJA
licensingConnector.OpenLicenseManagement();
#else
OpenBuyPage();
#endif
}
public void DisableTabPress(object sender, object e)
{
LoggerManager.Info("tabstop");
}
public void ChangeFov(System.Windows.Input.MouseWheelEventArgs wheelEventArgs)
{
ChangeFovDeg(Math.Sign(wheelEventArgs.Delta) * -5f);
}
// Caliburn/WPF bindings don't support function overload?
public void ChangeFovDeg(float deg)
{
if (IsPlaying)
{
if (this.DXCanvas.Scene != null)
{
Scene scene = ((Scene)this.DXCanvas.Scene);
scene.ChangeFov(deg);
}
}
}
// Using arguments changed -10 to 0?
public void ZoomIn() { ChangeFovDeg(-10); }
public void ZoomOut() { ChangeFovDeg(10); }
public void ResetFov()
{
if (IsPlaying)
{
if (this.DXCanvas.Scene != null)
{
Scene scene = ((Scene)this.DXCanvas.Scene);
scene.ResetFov();
}
}
}
public void ChangeFovZoomIn()
{
ChangeFov(new System.Windows.Input.MouseWheelEventArgs(null, 0, 120));
}
public void ChangeFovZoomOut()
{
ChangeFov(new System.Windows.Input.MouseWheelEventArgs(null, 0, -120));
}
public void Dummy(RoutedEventArgs e)
{
e.Handled = true;
}
public Visibility DebugVisible { get; set; } = Visibility.Collapsed;
public void ShowDebug()
{
Execute.OnUIThreadAsync(() =>
{
DebugVisible = Visibility.Visible;
NotifyOfPropertyChange(() => DebugVisible);
});
}
public void HideDebug()
{
Execute.OnUIThreadAsync(() =>
{
DebugVisible = Visibility.Collapsed;
NotifyOfPropertyChange(() => DebugVisible);
});
}
#region debug text
public string DebugText { get; set; } = "";
public void AppendDebugText(string line)
{
DebugText += line + "\n";
}
public void ClearDebugText()
{
DebugText = "";
}
public void UpdateDebugText()
{
Execute.OnUIThreadAsync(() => NotifyOfPropertyChange(() => DebugText));
}
#endregion
public void NormalProjection()
{
if (this.DXCanvas.Scene != null)
{
((Scene)this.DXCanvas.Scene).RectlinearProjection();
}
}
public void LittlePlanetProjection()
{
if(this.DXCanvas.Scene != null)
{
((Scene)this.DXCanvas.Scene).StereographicProjection();
}
}
public void SeekRelative(int v)
{
if(_mediaDecoder != null)
{
if(_mediaDecoder.Initialized && _mediaDecoder.Ready)
{
_mediaDecoder.Seek(_mediaDecoder.CurrentPosition + v);
}
}
}
}
}