src/FingersDance.Control.Player/UserControlPlayer.xaml.cs
author ARIAS Santiago
Mon, 26 Oct 2009 08:36:15 +0100
changeset 173 e99fe78cd168
parent 170 91024994f6eb
child 174 45c9e55fcf23
permissions -rw-r--r--
Gesture Control Integration in the Control Player
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
     1
using System;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
     2
using System.IO;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
     3
using System.Net;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
     4
using System.Windows;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
     5
using System.Windows.Controls;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
     6
using System.Windows.Data;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
     7
using System.Windows.Media;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
     8
using System.Windows.Media.Imaging;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
     9
using System.Windows.Media.Animation;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    10
using System.Windows.Navigation;
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    11
using System.ComponentModel;
49
b23aa9d09ac1 debug for video path
cavaliet
parents: 41
diff changeset
    12
using System.Reflection;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
    13
using System.Collections.Generic;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
    14
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
    15
using Microsoft.Surface.Presentation;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
    16
using Microsoft.Surface.Presentation.Controls;
156
e16c8c913c65 Color Factory et application des couleurs au pivot
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 146
diff changeset
    17
using FingersDance.Factory;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
    18
using FingersDance.Actions;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
    19
using FingersDance.Control.TimeLine;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
    20
using FingersDance.Views;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
    21
using FingersDance.ViewModels;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    22
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    23
namespace FingersDance.Control.Player
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    24
{
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    25
	public partial class UserControlPlayer
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    26
	{
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    27
        #region Variables
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    28
        private bool isPlaying = false;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    29
        #endregion
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    30
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    31
        public event EventHandler PlayerOpened;
165
e78e40b9d761 Pivot Improved and methods for timeline
riley
parents: 163
diff changeset
    32
        public event EventHandler PlayerStopOrPause;
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    33
170
91024994f6eb UserControl InfoUser V1
ARIAS Santiago
parents: 168
diff changeset
    34
        #region constructors
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    35
        public UserControlPlayer()
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    36
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    37
            this.InitializeComponent();
121
32611257e99f Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 119
diff changeset
    38
            MediaElementVideo.LoadedBehavior = MediaState.Manual;
32611257e99f Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 119
diff changeset
    39
            MediaElementVideo.UnloadedBehavior = MediaState.Manual;
173
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
    40
            //SAR
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
    41
            //Control User Info
170
91024994f6eb UserControl InfoUser V1
ARIAS Santiago
parents: 168
diff changeset
    42
            usercontrolInfoUser.LabelSession.Content = "Seance Test";
91024994f6eb UserControl InfoUser V1
ARIAS Santiago
parents: 168
diff changeset
    43
            usercontrolInfoUser.LabelUser.Content = "User Test";
173
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
    44
            //Gesture Control
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
    45
            gestureControl.GestureEvent+= new GestureControl.GestureControl.GestureRoutedEventHandler(GestureDetected);
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    46
        }
170
91024994f6eb UserControl InfoUser V1
ARIAS Santiago
parents: 168
diff changeset
    47
        #endregion
91024994f6eb UserControl InfoUser V1
ARIAS Santiago
parents: 168
diff changeset
    48
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    49
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    50
        #region Properties
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    51
        public double TotalMilliseconds
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    52
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    53
            get
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    54
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    55
                return MediaElementVideo.NaturalDuration.TimeSpan.TotalMilliseconds;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    56
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    57
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    58
        public MediaElement Player
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    59
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    60
            get
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    61
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    62
                return MediaElementVideo;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    63
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    64
            set
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    65
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    66
                MediaElementVideo= value;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    67
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    68
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    69
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    70
        #endregion
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    71
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    72
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    73
        #region Methodes
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    74
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    75
        public void initPlayer(string path)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    76
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    77
            //init player
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    78
            isPlaying = false;
121
32611257e99f Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 119
diff changeset
    79
            MediaElementVideo.Source = new Uri(path);
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    80
            MediaElementVideo.ScrubbingEnabled = true;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    81
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    82
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    83
        public void playerPause()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    84
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    85
            MediaElementVideo.Pause();
165
e78e40b9d761 Pivot Improved and methods for timeline
riley
parents: 163
diff changeset
    86
            if (PlayerStopOrPause != null)
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    87
                PlayerStopOrPause(false, new EventArgs());
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    88
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    89
        public void playerPlay()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    90
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    91
            MediaElementVideo.Play();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    92
            if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    93
                PlayerStopOrPause(true, new EventArgs());
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    94
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    95
        public void playerStop()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    96
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    97
            MediaElementVideo.Stop();
165
e78e40b9d761 Pivot Improved and methods for timeline
riley
parents: 163
diff changeset
    98
            if (PlayerStopOrPause != null)
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    99
                PlayerStopOrPause(false, new EventArgs());
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   100
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   101
        
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   102
        #endregion
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   103
173
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   104
        #region GestureEvents
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   105
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   106
        public void GestureDetected(object sender, GestureControl.GestureRoutedEventArgs e)
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   107
        {
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   108
            Console.WriteLine("gesture detected: " + e.Gesture);
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   109
            switch (e.Gesture)
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   110
            {
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   111
                case "UP":
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   112
                    //
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   113
                    usercontrolInfoUser.LabelSession.Content = "UP!";
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   114
                    break;
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   115
                case "LEFT":
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   116
                    usercontrolInfoUser.LabelSession.Content = "LEFT!";
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   117
                    break;
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   118
                case "RIGHT":
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   119
                    usercontrolInfoUser.LabelSession.Content = "RIGHT!";
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   120
                    break;
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   121
                case "DOWN":
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   122
                    usercontrolInfoUser.LabelSession.Content = "DOWN!";
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   123
                    break;
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   124
                default:
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   125
                    //this.TxtGesture.Text = e.Gesture;
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   126
                    break;
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   127
            }
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   128
        }
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   129
        #endregion
e99fe78cd168 Gesture Control Integration in the Control Player
ARIAS Santiago
parents: 170
diff changeset
   130
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   131
        #region Button Simple Player Actions
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   132
        private void ButtonPlayPause_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   133
        {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   134
            if (!isPlaying)//Play
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   135
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   136
                isPlaying = true;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   137
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   138
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   139
                    MediaElementVideo.Play();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   140
                    if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   141
                        PlayerStopOrPause(true, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   142
                }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   143
                catch (Exception ex) { }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   144
            }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   145
            else//Pause
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   146
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   147
                isPlaying = false;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   148
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   149
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   150
                    MediaElementVideo.Pause();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   151
                    if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   152
                        PlayerStopOrPause(false, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   153
                }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   154
                catch (Exception exx) { }
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   155
            }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   156
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   157
        }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   158
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   159
        private void ButtonPlayPause_Click(object sender, RoutedEventArgs e)
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   160
        {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   161
            if (!isPlaying)//Play
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   162
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   163
                isPlaying = true;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   164
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   165
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   166
                    MediaElementVideo.Play();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   167
                    if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   168
                        PlayerStopOrPause(true, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   169
                }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   170
                catch (Exception ex) { }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   171
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   172
            }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   173
            else//Pause
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   174
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   175
                isPlaying = false;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   176
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   177
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   178
                    MediaElementVideo.Pause();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   179
                    if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   180
                        PlayerStopOrPause(false, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   181
                }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   182
                catch (Exception exx) { }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   183
                //ButtonPlayPause.Background = FindResource("[Skin_1]_Play_button_xaml") as Brush;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   184
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   185
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   186
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   187
        private void ButtonFastForward_Click(object sender, RoutedEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   188
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   189
            if (MediaElementVideo.SpeedRatio <= 3)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   190
                MediaElementVideo.SpeedRatio += 1;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   191
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   192
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   193
        private void ButtonFastForward_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   194
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   195
            if (MediaElementVideo.SpeedRatio <= 3)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   196
                MediaElementVideo.SpeedRatio += 1;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   197
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   198
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   199
        private void ButtonRewind_Click(object sender, RoutedEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   200
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   201
            //TimeSpan ts = new TimeSpan(0, 0, 0, 0);
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   202
            if (MediaElementVideo.SpeedRatio > 1)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   203
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   204
                MediaElementVideo.SpeedRatio -= 1;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   205
            }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   206
            else
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   207
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   208
                MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5));
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   209
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   210
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   211
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   212
        private void ButtonRewind_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   213
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   214
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   215
            //TimeSpan ts = new TimeSpan(0, 0, 0,0);
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   216
            if (MediaElementVideo.SpeedRatio > 1)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   217
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   218
                MediaElementVideo.SpeedRatio -= 1;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   219
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   220
            else
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   221
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   222
                MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5));
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   223
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   224
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   225
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   226
        #endregion
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   227
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   228
        private void MediaElementVideo_MediaOpened(object sender, RoutedEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   229
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   230
            OnPlayerOpened();
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   231
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   232
        protected virtual void OnPlayerOpened()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   233
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   234
            if(PlayerOpened!=null)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   235
                PlayerOpened(this, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   236
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   237
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   238
        private void Play_Pause_area_DragEnter(object sender, SurfaceDragDropEventArgs e)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   239
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   240
            //Console.WriteLine("Enter");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   241
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   242
            // If the TimelineAnnotationView comes from a user control different from the current one, 
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   243
            // it means that we want to add the annotation to the current list.
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   244
            // So we check if the dragged annotation can be dragged or if it will recover any existant annotation (in this case it will not be accepted)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   245
            // e.Cursor.DragSource is the SurfaceListBox where the drag started from
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   246
            SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   247
            // We get the instance of the UserControlSyncSource
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   248
            UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   249
            // and its UserControlTimeline
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   250
            UserControlTimeLine tl = (UserControlTimeLine)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0];
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   251
            if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   252
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   253
                // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   254
                AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   255
                Play_Pause_area.Background = tl.isAnnotationAccepted(annotationDataVM) ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   256
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   257
            else
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   258
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   259
                Play_Pause_area.Background = new SolidColorBrush(Colors.White);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   260
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   261
            Play_Pause_area.Opacity = 0.3;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   262
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   263
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   264
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   265
        private void Play_Pause_area_DragLeave(object sender, SurfaceDragDropEventArgs e)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   266
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   267
            //Console.WriteLine("Leave");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   268
            Play_Pause_area.Opacity = 0;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   269
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   270
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   271
        private void Play_Pause_area_DragOver(object sender, SurfaceDragDropEventArgs e)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   272
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   273
            //Console.WriteLine("Over");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   274
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   275
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   276
        private void Play_Pause_area_Drop(object sender, SurfaceDragDropEventArgs e)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   277
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   278
            //Console.WriteLine("Drop");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   279
            Play_Pause_area.Opacity = 0;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   280
            // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   281
            AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   282
            int nbSeconds = (int)annotationDataVM.TcBegin;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   283
            int nbMilliSec = (int)((annotationDataVM.TcBegin * 1000)%1000);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   284
            MediaElementVideo.Position = new TimeSpan(0, 0, 0, nbSeconds, nbMilliSec);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   285
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   286
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   287
            // If the TimelineAnnotationView comes from a user control different from the current one, 
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   288
            // it means that we want to add the annotation to the current list.
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   289
            // So we generate the ActionAddAnnotation
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   290
            // e.Cursor.DragSource is the SurfaceListBox where the drag started from
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   291
            SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   292
            // We get the instance of the UserControlSyncSource
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   293
            UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   294
            // and its UserControlTimeline
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   295
            UserControl tl = (UserControl)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0];
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   296
            if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   297
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   298
                // Now we build the action arguments : a list holding the timeline and the annotation view models
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   299
                List<Object> actionsArgs = new List<Object>();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   300
                actionsArgs.Add(tl);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   301
                actionsArgs.Add(annotationDataVM);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   302
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   303
                ActionGenerator ag = new ActionGenerator();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   304
                ActionBase ab = ag.GetAction("ActionAddAnnotation", actionsArgs);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   305
                if (ab != null)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   306
                    ab.Execute();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   307
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   308
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   309
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   310
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   311
        //This function Sets a brush in a specific rectangle of the StackPanelAnnotation
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   312
        public void displayStackPanelAnnotations(int id, Brush brushAnnotation)
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   313
        {
163
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   314
            Object o = null;
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   315
            switch (id)
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   316
            {
163
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   317
                case 1: 
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   318
                    rect1.Fill = brushAnnotation;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   319
                    o = rect1.FindResource("Rect1Annotation");
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   320
                    rect1.BeginStoryboard((Storyboard)o);
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   321
                    break;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   322
                case 2: rect2.Fill = brushAnnotation;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   323
                    o = rect2.FindResource("Rect2Annotation");
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   324
                    rect2.BeginStoryboard((Storyboard)o);
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   325
                    break;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   326
                case 3: rect3.Fill = brushAnnotation;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   327
                    o = rect3.FindResource("Rect3Annotation");
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   328
                    rect3.BeginStoryboard((Storyboard)o);
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   329
                    break;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   330
                case 4: rect4.Fill = brushAnnotation;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   331
                    o = rect4.FindResource("Rect4Annotation");
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   332
                    rect4.BeginStoryboard((Storyboard)o);
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   333
                    break;
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   334
                default: break;
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   335
            }
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   336
        }
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   337
	}
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   338
}