34
|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Windows; |
|
6 |
using System.Windows.Controls; |
|
7 |
using System.Windows.Data; |
|
8 |
using System.Windows.Documents; |
|
9 |
using System.Windows.Input; |
|
10 |
using System.Windows.Media; |
|
11 |
using System.Windows.Media.Imaging; |
|
12 |
using System.Windows.Shapes; |
|
13 |
using System.Windows.Threading; |
|
14 |
using Microsoft.Surface; |
|
15 |
using Microsoft.Surface.Presentation; |
|
16 |
using Microsoft.Surface.Presentation.Controls; |
|
17 |
|
|
18 |
namespace FingersDance.Control.UserPanel |
|
19 |
{ |
|
20 |
/// <summary> |
|
21 |
/// Interaction logic for SurfaceWindow1.xaml |
|
22 |
/// </summary> |
|
23 |
public partial class SurfaceWindow1 : SurfaceWindow |
|
24 |
{ |
|
25 |
/// <summary> |
|
26 |
/// Default constructor. |
|
27 |
/// </summary> |
|
28 |
public SurfaceWindow1() |
|
29 |
{ |
|
30 |
InitializeComponent(); |
|
31 |
|
|
32 |
// Add handlers for Application activation events |
|
33 |
AddActivationHandlers(); |
|
34 |
} |
|
35 |
|
|
36 |
|
|
37 |
/// <summary> |
|
38 |
/// Occurs when the window is about to close. |
|
39 |
/// </summary> |
|
40 |
/// <param name="e"></param> |
|
41 |
protected override void OnClosed(EventArgs e) |
|
42 |
{ |
|
43 |
base.OnClosed(e); |
|
44 |
|
|
45 |
// Remove handlers for Application activation events |
|
46 |
RemoveActivationHandlers(); |
|
47 |
} |
|
48 |
|
|
49 |
/// <summary> |
|
50 |
/// Adds handlers for Application activation events. |
|
51 |
/// </summary> |
|
52 |
private void AddActivationHandlers() |
|
53 |
{ |
|
54 |
// Subscribe to surface application activation events |
|
55 |
ApplicationLauncher.ApplicationActivated += OnApplicationActivated; |
|
56 |
ApplicationLauncher.ApplicationPreviewed += OnApplicationPreviewed; |
|
57 |
ApplicationLauncher.ApplicationDeactivated += OnApplicationDeactivated; |
|
58 |
} |
|
59 |
|
|
60 |
/// <summary> |
|
61 |
/// Removes handlers for Application activation events. |
|
62 |
/// </summary> |
|
63 |
private void RemoveActivationHandlers() |
|
64 |
{ |
|
65 |
// Unsubscribe from surface application activation events |
|
66 |
ApplicationLauncher.ApplicationActivated -= OnApplicationActivated; |
|
67 |
ApplicationLauncher.ApplicationPreviewed -= OnApplicationPreviewed; |
|
68 |
ApplicationLauncher.ApplicationDeactivated -= OnApplicationDeactivated; |
|
69 |
} |
|
70 |
|
|
71 |
/// <summary> |
|
72 |
/// This is called when application has been activated. |
|
73 |
/// </summary> |
|
74 |
/// <param name="sender"></param> |
|
75 |
/// <param name="e"></param> |
|
76 |
private void OnApplicationActivated(object sender, EventArgs e) |
|
77 |
{ |
|
78 |
//TODO: enable audio, animations here |
|
79 |
} |
|
80 |
|
|
81 |
/// <summary> |
|
82 |
/// This is called when application is in preview mode. |
|
83 |
/// </summary> |
|
84 |
/// <param name="sender"></param> |
|
85 |
/// <param name="e"></param> |
|
86 |
private void OnApplicationPreviewed(object sender, EventArgs e) |
|
87 |
{ |
|
88 |
//TODO: Disable audio here if it is enabled |
|
89 |
|
|
90 |
//TODO: optionally enable animations here |
|
91 |
} |
|
92 |
|
|
93 |
/// <summary> |
|
94 |
/// This is called when application has been deactivated. |
|
95 |
/// </summary> |
|
96 |
/// <param name="sender"></param> |
|
97 |
/// <param name="e"></param> |
|
98 |
private void OnApplicationDeactivated(object sender, EventArgs e) |
|
99 |
{ |
|
100 |
//TODO: disable audio, animations here |
|
101 |
} |
|
102 |
|
|
103 |
private void UserControlPlayer_PlayerOpened(object sender, EventArgs e) |
|
104 |
{ |
|
105 |
//Initialisation du slider |
|
106 |
UserControlTimeLine.initslider(UserControlPlayer.TotalMilliseconds); |
|
107 |
//Demarrage du Timer |
|
108 |
UserControlTimeLine.timerStart(); |
|
109 |
|
|
110 |
} |
|
111 |
|
|
112 |
private void SurfaceWindow_Activated(object sender, EventArgs e) |
|
113 |
{ |
|
114 |
//initialisation du Timer |
|
115 |
UserControlTimeLine.initTimer(); |
|
116 |
} |
|
117 |
|
|
118 |
private void UserControlTimeLine_DragStarted(object sender, EventArgs e) |
|
119 |
{ |
|
120 |
UserControlPlayer.playerPause(); |
|
121 |
} |
|
122 |
|
|
123 |
private void UserControlTimeLine_DragCompleted(object sender, EventArgs e) |
|
124 |
{ |
|
125 |
} |
|
126 |
|
|
127 |
private void UserControlTimeLine_TimerTick(object sender, EventArgs e) |
|
128 |
{ |
|
129 |
if (!UserControlTimeLine.IsDragging) |
|
130 |
{ |
|
131 |
UserControlTimeLine.Slider.Value = UserControlPlayer.Player.Position.TotalMilliseconds; |
|
132 |
} |
|
133 |
if (UserControlTimeLine.FinishedDragging) |
|
134 |
{ |
|
135 |
int SliderValue = (int)UserControlTimeLine.Slider.Value; |
|
136 |
TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue); |
|
137 |
|
|
138 |
UserControlPlayer.Player.Position = ts; |
|
139 |
UserControlPlayer.playerPlay(); |
|
140 |
|
|
141 |
UserControlTimeLine.IsDragging = false; |
|
142 |
UserControlTimeLine.FinishedDragging = false; |
|
143 |
} |
|
144 |
} |
|
145 |
} |
|
146 |
} |