src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs
author PAMPHILE Jonathan <pamphile@efrei.fr>
Tue, 17 Nov 2009 13:25:05 +0100
changeset 206 89813df17ec2
parent 205 468f3757f1f8
parent 203 2948b34324bb
child 216 45d2dff788f2
permissions -rw-r--r--
merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     1
using System;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     2
using System.IO;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     3
using System.Net;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     4
using System.Windows;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     5
using System.Windows.Controls;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     6
using System.Windows.Data;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     7
using System.Windows.Media;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     8
using System.Windows.Media.Animation;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     9
using System.Windows.Navigation;
39
0efa1d506f28 Correct compilation + lib
ymh
parents: 35
diff changeset
    10
using FingersDance.Control.TimeLine;
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 188
diff changeset
    11
using FingersDance.Data;
195
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    12
using FingersDance.Factory;
203
2948b34324bb first step of adding annotation from a recognised gesture.
cavaliet
parents: 195
diff changeset
    13
using GestureControl;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    14
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    15
namespace FingersDance.Control.SyncSource
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    16
{
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    17
	public partial class UserControlSyncSource
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    18
	{
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    19
        #region Variables   
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    20
            public event EventHandler OnSuccessAnnotation;
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    21
        #endregion
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    22
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    23
		public UserControlSyncSource()
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    24
		{
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    25
			this.InitializeComponent();
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    26
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    27
			// Insert code required on object creation below this point.
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    28
		}
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    29
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 188
diff changeset
    30
        public void Load(string path, Color col, Cutting cut)
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 75
diff changeset
    31
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 75
diff changeset
    32
            this.UserControlPlayer.initPlayer(path);
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 143
diff changeset
    33
            //Initialisation du Timer
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 188
diff changeset
    34
            UCTimeLine.initTimer(col, cut);
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    35
            this.UserControlPlayer.playerPlay();
195
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    36
            this.userControlTimeLine.OnSuccessAnnotation += new EventHandler(userControlTimeLine_OnSuccessAnnotation);
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    37
            this.userControlTimeLine.AnnotationAdded += new EventHandler(userControlTimeLine_AnnotationAdded);
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    38
            this.userControlTimeLine.AnnotationRemoved += new EventHandler(userControlTimeLine_AnnotationRemoved);
203
2948b34324bb first step of adding annotation from a recognised gesture.
cavaliet
parents: 195
diff changeset
    39
            this.UserControlPlayer.PlayerStopOrPause += new EventHandler(UserControlPlayer_PlayerStopOrPause);
2948b34324bb first step of adding annotation from a recognised gesture.
cavaliet
parents: 195
diff changeset
    40
            UserControlPlayer.NewGestureRegognized += new EventHandler(UCTimeLine.UserControlPlayer_NewGestureRegognized);
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 75
diff changeset
    41
        }
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    42
195
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    43
        void userControlTimeLine_AnnotationRemoved(object sender, EventArgs e)
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    44
        {
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    45
            try
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    46
            {
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    47
                DataDictionary Data = (new DataFactory()).Data;
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    48
                Data.RemoveAnnotation((Annotation)sender);
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    49
            }
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    50
            catch { }
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    51
        }
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    52
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    53
        //  Ajout Annotation
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    54
        void userControlTimeLine_AnnotationAdded(object sender, EventArgs e)
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    55
        {
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    56
            try
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    57
            {
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    58
                DataDictionary Data = (new DataFactory()).Data;
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    59
                Data.AddAnnotation((Annotation)sender);
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    60
            }
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    61
            catch { }
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    62
        }
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    63
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    64
        #region player
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    65
        private void UserControlPlayer_PlayerOpened(object sender, EventArgs e)
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    66
        {
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    67
            //Initialisation du slider
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
    68
            UCTimeLine.initslider(UserControlPlayer.TotalMilliseconds);
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    69
            //Demarrage du Timer
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
    70
            UCTimeLine.timerStart();
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    71
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    72
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    73
165
e78e40b9d761 Pivot Improved and methods for timeline
riley
parents: 162
diff changeset
    74
        public void UserControlPlayer_PlayerStopOrPause(object sender, EventArgs e)
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    75
        {
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    76
            try
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    77
            {
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    78
                userControlTimeLine.thumbRotation((bool)sender);
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    79
            }catch(Exception ){}
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    80
        }
188
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    81
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    82
        public void setUserPlayerVolume(double val)
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    83
        {
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    84
            try
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    85
            {
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    86
                UserControlPlayer.setSound(val);
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    87
            }
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    88
            catch (Exception) { }
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    89
        }
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    90
        public void setUserPlayerMute(bool b)
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    91
        {
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    92
            try
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    93
            {
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    94
                UserControlPlayer.setMute(b);
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    95
            }
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    96
            catch (Exception) { }
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    97
        }
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    98
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    99
        #endregion
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   100
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   101
        #region TimeLine
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   102
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   103
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   104
        private void UserControlTimeLine_DragStarted(object sender, EventArgs e)
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   105
        {
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   106
            UserControlPlayer.playerPause();
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   107
        }
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   108
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   109
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   110
        private void UserControlTimeLine_DragCompleted(object sender, EventArgs e)
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   111
        {
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   112
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   113
        private void userControlTimeLine_OnSuccessAnnotation(object sender, EventArgs e)
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   114
        {
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   115
            OnSuccessAnnotation(this, new EventArgs());
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   116
        }
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   117
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   118
        #endregion
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   119
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   120
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   121
        #region SynSource pour chaque X milliseconds
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   122
        private void UserControlTimeLine_TimerTick(object sender, EventArgs e)
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   123
        {
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   124
            if (!UCTimeLine.IsDragging)
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   125
            {
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   126
                UCTimeLine.Slider.Value = UserControlPlayer.Player.Position.TotalMilliseconds;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   127
            }
195
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
   128
            int SliderValue = (int)UCTimeLine.Slider.Value;
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   129
            if (UCTimeLine.FinishedDragging)
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   130
            {
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   131
                TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue);
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   132
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   133
                UserControlPlayer.Player.Position = ts;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   134
                UserControlPlayer.playerPlay();
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   135
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   136
                UCTimeLine.IsDragging = false;
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   137
                UCTimeLine.FinishedDragging = false;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   138
            }
205
468f3757f1f8 Correction probleme tc annotation
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 195
diff changeset
   139
            UserControlPlayer.Time = (float)SliderValue / 1000;
195
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
   140
            DataDictionary Data = (new DataFactory()).Data;
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
   141
            UserControlPlayer.ApplyColor(Data.GetColors((int)((float)SliderValue / 1000)));
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   142
        }
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   143
        #endregion
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   144
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   145
        public UserControlTimeLine userControlTimeLine
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   146
        {
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   147
            get { return this.UCTimeLine; }
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   148
        }
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   149
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   150
        public void PlayerPause()
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   151
        {
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   152
            UserControlPlayer.playerPause();
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   153
        }
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   154
    }
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   155
}