src/FingersDance.Control.Player/UserControlPlayer.xaml.cs
author ARIAS Santiago
Sun, 25 Oct 2009 19:26:16 +0100
changeset 170 91024994f6eb
parent 168 d70ee2002f75
child 173 e99fe78cd168
permissions -rw-r--r--
UserControl InfoUser V1 + background MainSurfaceWindows change
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;
170
91024994f6eb UserControl InfoUser V1
ARIAS Santiago
parents: 168
diff changeset
    40
            usercontrolInfoUser.LabelSession.Content = "Seance Test";
91024994f6eb UserControl InfoUser V1
ARIAS Santiago
parents: 168
diff changeset
    41
            usercontrolInfoUser.LabelUser.Content = "User Test";
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    42
        }
170
91024994f6eb UserControl InfoUser V1
ARIAS Santiago
parents: 168
diff changeset
    43
        #endregion
91024994f6eb UserControl InfoUser V1
ARIAS Santiago
parents: 168
diff changeset
    44
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    45
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    46
        #region Properties
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    47
        public double TotalMilliseconds
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    48
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    49
            get
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    50
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    51
                return MediaElementVideo.NaturalDuration.TimeSpan.TotalMilliseconds;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    52
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    53
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    54
        public MediaElement Player
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    55
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    56
            get
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    57
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    58
                return MediaElementVideo;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    59
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    60
            set
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    61
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    62
                MediaElementVideo= value;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    63
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    64
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    65
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    66
        #endregion
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
        #region Methodes
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    70
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    71
        public void initPlayer(string path)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    72
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    73
            //init player
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    74
            isPlaying = false;
121
32611257e99f Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 119
diff changeset
    75
            MediaElementVideo.Source = new Uri(path);
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    76
            MediaElementVideo.ScrubbingEnabled = true;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    77
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    78
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    79
        public void playerPause()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    80
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    81
            MediaElementVideo.Pause();
165
e78e40b9d761 Pivot Improved and methods for timeline
riley
parents: 163
diff changeset
    82
            if (PlayerStopOrPause != null)
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    83
                PlayerStopOrPause(false, new EventArgs());
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    84
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    85
        public void playerPlay()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    86
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    87
            MediaElementVideo.Play();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    88
            if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    89
                PlayerStopOrPause(true, new EventArgs());
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    90
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    91
        public void playerStop()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    92
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    93
            MediaElementVideo.Stop();
165
e78e40b9d761 Pivot Improved and methods for timeline
riley
parents: 163
diff changeset
    94
            if (PlayerStopOrPause != null)
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    95
                PlayerStopOrPause(false, new EventArgs());
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    96
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    97
        
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    98
        #endregion
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    99
165
e78e40b9d761 Pivot Improved and methods for timeline
riley
parents: 163
diff changeset
   100
        
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   101
        #region Button Simple Player Actions
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   102
        private void ButtonPlayPause_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   103
        {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   104
            if (!isPlaying)//Play
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   105
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   106
                isPlaying = true;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   107
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   108
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   109
                    MediaElementVideo.Play();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   110
                    if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   111
                        PlayerStopOrPause(true, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   112
                }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   113
                catch (Exception ex) { }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   114
            }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   115
            else//Pause
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   116
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   117
                isPlaying = false;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   118
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   119
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   120
                    MediaElementVideo.Pause();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   121
                    if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   122
                        PlayerStopOrPause(false, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   123
                }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   124
                catch (Exception exx) { }
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   125
            }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   126
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   127
        }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   128
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   129
        private void ButtonPlayPause_Click(object sender, RoutedEventArgs e)
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   130
        {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   131
            if (!isPlaying)//Play
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   132
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   133
                isPlaying = true;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   134
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   135
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   136
                    MediaElementVideo.Play();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   137
                    if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   138
                        PlayerStopOrPause(true, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   139
                }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   140
                catch (Exception ex) { }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   141
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   142
            }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   143
            else//Pause
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   144
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   145
                isPlaying = false;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   146
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   147
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   148
                    MediaElementVideo.Pause();
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   149
                    if (PlayerStopOrPause != null)
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   150
                        PlayerStopOrPause(false, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   151
                }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   152
                catch (Exception exx) { }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   153
                //ButtonPlayPause.Background = FindResource("[Skin_1]_Play_button_xaml") as Brush;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   154
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   155
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   156
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   157
        private void ButtonFastForward_Click(object sender, RoutedEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   158
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   159
            if (MediaElementVideo.SpeedRatio <= 3)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   160
                MediaElementVideo.SpeedRatio += 1;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   161
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   162
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   163
        private void ButtonFastForward_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   164
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   165
            if (MediaElementVideo.SpeedRatio <= 3)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   166
                MediaElementVideo.SpeedRatio += 1;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   167
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   168
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   169
        private void ButtonRewind_Click(object sender, RoutedEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   170
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   171
            //TimeSpan ts = new TimeSpan(0, 0, 0, 0);
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   172
            if (MediaElementVideo.SpeedRatio > 1)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   173
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   174
                MediaElementVideo.SpeedRatio -= 1;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   175
            }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   176
            else
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   177
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   178
                MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5));
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   179
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   180
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   181
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   182
        private void ButtonRewind_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   183
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   184
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   185
            //TimeSpan ts = new TimeSpan(0, 0, 0,0);
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   186
            if (MediaElementVideo.SpeedRatio > 1)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   187
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   188
                MediaElementVideo.SpeedRatio -= 1;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   189
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   190
            else
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   191
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   192
                MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5));
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   193
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   194
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   195
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   196
        #endregion
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   197
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   198
        private void MediaElementVideo_MediaOpened(object sender, RoutedEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   199
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   200
            OnPlayerOpened();
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   201
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   202
        protected virtual void OnPlayerOpened()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   203
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   204
            if(PlayerOpened!=null)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   205
                PlayerOpened(this, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   206
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   207
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   208
        private void Play_Pause_area_DragEnter(object sender, SurfaceDragDropEventArgs e)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   209
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   210
            //Console.WriteLine("Enter");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   211
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   212
            // If the TimelineAnnotationView comes from a user control different from the current one, 
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   213
            // it means that we want to add the annotation to the current list.
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   214
            // 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
   215
            // e.Cursor.DragSource is the SurfaceListBox where the drag started from
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   216
            SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   217
            // We get the instance of the UserControlSyncSource
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   218
            UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   219
            // and its UserControlTimeline
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   220
            UserControlTimeLine tl = (UserControlTimeLine)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0];
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   221
            if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   222
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   223
                // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   224
                AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   225
                Play_Pause_area.Background = tl.isAnnotationAccepted(annotationDataVM) ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   226
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   227
            else
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   228
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   229
                Play_Pause_area.Background = new SolidColorBrush(Colors.White);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   230
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   231
            Play_Pause_area.Opacity = 0.3;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   232
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   233
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   234
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   235
        private void Play_Pause_area_DragLeave(object sender, SurfaceDragDropEventArgs e)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   236
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   237
            //Console.WriteLine("Leave");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   238
            Play_Pause_area.Opacity = 0;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   239
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   240
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   241
        private void Play_Pause_area_DragOver(object sender, SurfaceDragDropEventArgs e)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   242
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   243
            //Console.WriteLine("Over");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   244
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   245
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   246
        private void Play_Pause_area_Drop(object sender, SurfaceDragDropEventArgs e)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   247
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   248
            //Console.WriteLine("Drop");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   249
            Play_Pause_area.Opacity = 0;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   250
            // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   251
            AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   252
            int nbSeconds = (int)annotationDataVM.TcBegin;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   253
            int nbMilliSec = (int)((annotationDataVM.TcBegin * 1000)%1000);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   254
            MediaElementVideo.Position = new TimeSpan(0, 0, 0, nbSeconds, nbMilliSec);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   255
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   256
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   257
            // If the TimelineAnnotationView comes from a user control different from the current one, 
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   258
            // it means that we want to add the annotation to the current list.
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   259
            // So we generate the ActionAddAnnotation
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   260
            // e.Cursor.DragSource is the SurfaceListBox where the drag started from
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   261
            SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   262
            // We get the instance of the UserControlSyncSource
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   263
            UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   264
            // and its UserControlTimeline
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   265
            UserControl tl = (UserControl)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0];
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   266
            if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   267
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   268
                // 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
   269
                List<Object> actionsArgs = new List<Object>();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   270
                actionsArgs.Add(tl);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   271
                actionsArgs.Add(annotationDataVM);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   272
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   273
                ActionGenerator ag = new ActionGenerator();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   274
                ActionBase ab = ag.GetAction("ActionAddAnnotation", actionsArgs);
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   275
                if (ab != null)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   276
                    ab.Execute();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   277
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   278
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 122
diff changeset
   279
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   280
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   281
        //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
   282
        public void displayStackPanelAnnotations(int id, Brush brushAnnotation)
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   283
        {
163
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   284
            Object o = null;
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   285
            switch (id)
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   286
            {
163
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   287
                case 1: 
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   288
                    rect1.Fill = brushAnnotation;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   289
                    o = rect1.FindResource("Rect1Annotation");
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   290
                    rect1.BeginStoryboard((Storyboard)o);
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   291
                    break;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   292
                case 2: rect2.Fill = brushAnnotation;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   293
                    o = rect2.FindResource("Rect2Annotation");
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   294
                    rect2.BeginStoryboard((Storyboard)o);
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   295
                    break;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   296
                case 3: rect3.Fill = brushAnnotation;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   297
                    o = rect3.FindResource("Rect3Annotation");
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   298
                    rect3.BeginStoryboard((Storyboard)o);
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   299
                    break;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   300
                case 4: rect4.Fill = brushAnnotation;
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   301
                    o = rect4.FindResource("Rect4Annotation");
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   302
                    rect4.BeginStoryboard((Storyboard)o);
d5148710e229 Display Annotations with storyboard effect
sarias
parents: 162
diff changeset
   303
                    break;
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   304
                default: break;
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   305
            }
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 156
diff changeset
   306
        }
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   307
	}
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   308
}