src/FingersDance.Control.Player/UserControlPlayer.xaml.cs
author cavaliet
Wed, 07 Oct 2009 17:16:46 +0200
changeset 135 84b3bf5ee3d2
parent 134 f5108a598aa7
child 136 8b513df1b446
permissions -rw-r--r--
First step of drag and drop annotation from a timeline to an other 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;
135
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
    13
using System.Collections.Generic;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    14
134
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
    15
using Microsoft.Surface.Presentation;
135
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
    16
using Microsoft.Surface.Presentation.Controls;
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
    17
using FingersDance.ActionFactory;
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
    18
using FingersDance.Actions;
134
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
    19
using FingersDance.Views;
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
    20
using FingersDance.ViewModels;
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
    21
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    22
namespace FingersDance.Control.Player
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    23
{
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    24
	public partial class UserControlPlayer
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    25
	{
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    26
        #region Variables
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    27
        private bool isPlaying = false;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    28
        #endregion
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    29
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    30
        public event EventHandler PlayerOpened;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    31
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    32
        public UserControlPlayer()
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    33
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    34
            this.InitializeComponent();
121
32611257e99f Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 119
diff changeset
    35
            MediaElementVideo.LoadedBehavior = MediaState.Manual;
32611257e99f Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 119
diff changeset
    36
            MediaElementVideo.UnloadedBehavior = MediaState.Manual;
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    37
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    38
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    39
        #region Properties
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    40
        public double TotalMilliseconds
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    41
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    42
            get
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    43
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    44
                return MediaElementVideo.NaturalDuration.TimeSpan.TotalMilliseconds;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    45
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    46
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    47
        public MediaElement Player
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;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    52
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    53
            set
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    54
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    55
                MediaElementVideo= value;
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
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    59
        #endregion
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    60
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    61
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    62
        #region Methodes
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    63
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    64
        public void initPlayer(string path)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    65
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    66
            //init player
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    67
            isPlaying = false;
121
32611257e99f Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 119
diff changeset
    68
            MediaElementVideo.Source = new Uri(path);
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    69
            MediaElementVideo.ScrubbingEnabled = true;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    70
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 77
diff changeset
    71
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    72
        public void playerPause()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    73
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    74
            MediaElementVideo.Pause();
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    75
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    76
        public void playerPlay()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    77
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    78
            MediaElementVideo.Play();
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    79
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    80
        public void playerStop()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    81
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    82
            MediaElementVideo.Stop();
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    83
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    84
        
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    85
        #endregion
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    86
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    87
        private void ButtonPlayPause_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    88
        {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    89
            if (!isPlaying)//Play
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    90
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
    91
                isPlaying = true;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    92
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    93
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    94
                    MediaElementVideo.Play();
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    95
                }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    96
                catch (Exception ex) { }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    97
            }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    98
            else//Pause
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
    99
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   100
                isPlaying = false;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   101
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   102
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   103
                    MediaElementVideo.Pause();
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   104
                }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   105
                catch (Exception exx) { }
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   106
            }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   107
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   108
        }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   109
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   110
        private void ButtonPlayPause_Click(object sender, RoutedEventArgs e)
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   111
        {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   112
            if (!isPlaying)//Play
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   113
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   114
                isPlaying = true;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   115
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   116
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   117
                    MediaElementVideo.Play();
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   118
                }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   119
                catch (Exception ex) { }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   120
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   121
            }
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   122
            else//Pause
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   123
            {
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   124
                isPlaying = false;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   125
                try
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   126
                {
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   127
                    MediaElementVideo.Pause();
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   128
                }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   129
                catch (Exception exx) { }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   130
                //ButtonPlayPause.Background = FindResource("[Skin_1]_Play_button_xaml") as Brush;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   131
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   132
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   133
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   134
        private void ButtonFastForward_Click(object sender, RoutedEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   135
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   136
            if (MediaElementVideo.SpeedRatio <= 3)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   137
                MediaElementVideo.SpeedRatio += 1;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   138
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   139
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   140
        private void ButtonFastForward_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   141
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   142
            if (MediaElementVideo.SpeedRatio <= 3)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   143
                MediaElementVideo.SpeedRatio += 1;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   144
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   145
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   146
        private void ButtonRewind_Click(object sender, RoutedEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   147
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   148
            //TimeSpan ts = new TimeSpan(0, 0, 0, 0);
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   149
            if (MediaElementVideo.SpeedRatio > 1)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   150
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   151
                MediaElementVideo.SpeedRatio -= 1;
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   152
            }
34
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   153
            else
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   154
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   155
                MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5));
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   156
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   157
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   158
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   159
        private void ButtonRewind_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   160
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   161
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   162
            //TimeSpan ts = new TimeSpan(0, 0, 0,0);
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   163
            if (MediaElementVideo.SpeedRatio > 1)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   164
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   165
                MediaElementVideo.SpeedRatio -= 1;
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   166
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   167
            else
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   168
            {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   169
                MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5));
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   170
            }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   171
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   172
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   173
        private void MediaElementVideo_MediaOpened(object sender, RoutedEventArgs e)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   174
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   175
            OnPlayerOpened();
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   176
        }
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   177
        protected virtual void OnPlayerOpened()
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   178
        {
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   179
            if(PlayerOpened!=null)
9e222810f5b5 User Control Player
sarias
parents: 10
diff changeset
   180
                PlayerOpened(this, new EventArgs());
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   181
        }
134
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   182
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   183
        private void Play_Pause_area_DragEnter(object sender, SurfaceDragDropEventArgs e)
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   184
        {
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   185
            //Console.WriteLine("Enter");
135
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   186
            Play_Pause_area.Opacity = 0.5;
134
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   187
        }
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   188
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   189
        private void Play_Pause_area_DragLeave(object sender, SurfaceDragDropEventArgs e)
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   190
        {
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   191
            //Console.WriteLine("Leave");
135
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   192
            Play_Pause_area.Opacity = 0;
134
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   193
        }
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   194
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   195
        private void Play_Pause_area_DragOver(object sender, SurfaceDragDropEventArgs e)
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   196
        {
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   197
            //Console.WriteLine("Over");
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   198
        }
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   199
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   200
        private void Play_Pause_area_Drop(object sender, SurfaceDragDropEventArgs e)
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   201
        {
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   202
            //Console.WriteLine("Drop");
135
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   203
            Play_Pause_area.Opacity = 0;
134
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   204
            // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   205
            AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   206
            int nbSeconds = (int)annotationDataVM.TcBegin;
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   207
            int nbMilliSec = (int)((annotationDataVM.TcBegin * 1000)%1000);
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   208
            MediaElementVideo.Position = new TimeSpan(0, 0, 0, nbSeconds, nbMilliSec);
135
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   209
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   210
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   211
            // If the TimelineAnnotationView comes from a user control different from the current one, 
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   212
            // it means that we want to add the annotation to the current list.
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   213
            // So we generate the ActionAddAnnotation
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   214
            // e.Cursor.DragSource is the SurfaceListBox where the drag started from
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   215
            SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource;
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   216
            // We get the instance of the UserControlSyncSource
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   217
            UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent;
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   218
            // and its UserControlTimeline
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   219
            UserControl tl = (UserControl)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0];
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   220
            if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl)
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   221
            {
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   222
                // Now we build the action arguments : a list holding the timeline and the annotation view models
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   223
                List<Object> actionsArgs = new List<Object>();
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   224
                actionsArgs.Add(tl);
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   225
                actionsArgs.Add(annotationDataVM);
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   226
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   227
                ActionGenerator ag = new ActionGenerator();
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   228
                ActionBase ab = ag.GetAction("ActionAddAnnotation", actionsArgs);
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   229
                if (ab != null)
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   230
                    ab.Execute();
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   231
            }
84b3bf5ee3d2 First step of drag and drop annotation from a timeline to an other player
cavaliet
parents: 134
diff changeset
   232
134
f5108a598aa7 drag and drop places the video at the good timecode.
cavaliet
parents: 122
diff changeset
   233
        }
3
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   234
	}
4f1ea403073d Projet Menu avec profondeur complete.
sarias
parents:
diff changeset
   235
}