-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnimatedVisualPlayerProposed.cs
91 lines (75 loc) · 3.62 KB
/
AnimatedVisualPlayerProposed.cs
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
using Microsoft.UI.Xaml.Controls;
using System;
using Windows.UI.Xaml;
namespace ProgressUIPrototype
{
public class AnimatedVisualPlayerProposed : AnimatedVisualPlayer
{
public AnimatedVisualPlayerProposed()
{
// some issue setting this in markup.. so hacking this for now.
AutoPlay = false;
}
public bool IsLooping
{
get { return (bool)GetValue(IsLoopingProperty); }
set { SetValue(IsLoopingProperty, value); }
}
public static readonly DependencyProperty IsLoopingProperty =
DependencyProperty.Register("IsLooping", typeof(bool), typeof(AnimatedVisualPlayerProposed), new PropertyMetadata(false));
public double StartPosition
{
get { return (double)GetValue(StartPositionProperty); }
set { SetValue(StartPositionProperty, value); }
}
public static readonly DependencyProperty StartPositionProperty =
DependencyProperty.Register("StartPosition", typeof(double), typeof(AnimatedVisualPlayerProposed), new PropertyMetadata(0.0));
public double StopPosition
{
get { return (double)GetValue(StopPositionProperty); }
set { SetValue(StopPositionProperty, value); }
}
public static readonly DependencyProperty StopPositionProperty =
DependencyProperty.Register("StopPosition", typeof(double), typeof(AnimatedVisualPlayerProposed), new PropertyMetadata(1.0));
public new bool IsPlaying
{
get { return (bool)GetValue(IsPlayingProperty); }
set { SetValue(IsPlayingProperty, value); }
}
public static readonly new DependencyProperty IsPlayingProperty =
DependencyProperty.Register("IsPlaying", typeof(bool), typeof(AnimatedVisualPlayerProposed), new PropertyMetadata(false, new PropertyChangedCallback(OnIsPlayingChanged)));
private static void OnIsPlayingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if ((bool)e.NewValue)
{
var player = d as AnimatedVisualPlayerProposed;
_ = player.PlayAsync(player.StartPosition, player.StopPosition, player.IsLooping);
}
}
public double Position
{
get { return (double)GetValue(PositionProperty); }
set { SetValue(PositionProperty, value); }
}
public static readonly DependencyProperty PositionProperty =
DependencyProperty.Register("Position", typeof(double), typeof(AnimatedVisualPlayerProposed), new PropertyMetadata(0, new PropertyChangedCallback(OnPositionChanged)));
private static void OnPositionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var player = d as AnimatedVisualPlayerProposed;
var value = (double)e.NewValue;
player.SetProgress(value);
}
public new IAnimatedVisualSource Source
{
get { return (IAnimatedVisualSource)GetValue(SourceProperty); }
set { SetValue(SourceProperty, value); }
}
public static readonly new DependencyProperty SourceProperty =
DependencyProperty.Register("Source", typeof(IAnimatedVisualSource), typeof(AnimatedVisualPlayerProposed), new PropertyMetadata(null, new PropertyChangedCallback(OnSourceChanged)));
private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var player = d as AnimatedVisualPlayer;
player.Source = e.NewValue as IAnimatedVisualSource;
}
}
}