src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs
author PAMPHILE Jonathan <pamphile@efrei.fr>
Tue, 17 Nov 2009 13:22:14 +0100
changeset 205 468f3757f1f8
parent 195 48b3139bb182
child 206 89813df17ec2
permissions -rw-r--r--
Correction probleme tc annotation
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;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    13
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    14
namespace FingersDance.Control.SyncSource
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    15
{
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    16
	public partial class UserControlSyncSource
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    17
	{
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    18
        #region Variables   
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    19
            public event EventHandler OnSuccessAnnotation;
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    20
        #endregion
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    21
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    22
		public UserControlSyncSource()
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    23
		{
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    24
			this.InitializeComponent();
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    25
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    26
			// Insert code required on object creation below this point.
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    27
		}
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    28
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
    29
        public void Load(string path, Color col, Cutting cut)
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 75
diff changeset
    30
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 75
diff changeset
    31
            this.UserControlPlayer.initPlayer(path);
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 143
diff changeset
    32
            //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
    33
            UCTimeLine.initTimer(col, cut);
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    34
            this.UserControlPlayer.playerPlay();
195
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    35
            this.userControlTimeLine.OnSuccessAnnotation += new EventHandler(userControlTimeLine_OnSuccessAnnotation);
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    36
            this.userControlTimeLine.AnnotationAdded += new EventHandler(userControlTimeLine_AnnotationAdded);
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    37
            this.userControlTimeLine.AnnotationRemoved += new EventHandler(userControlTimeLine_AnnotationRemoved);
165
e78e40b9d761 Pivot Improved and methods for timeline
riley
parents: 162
diff changeset
    38
            this.UserControlPlayer.PlayerStopOrPause +=new EventHandler(UserControlPlayer_PlayerStopOrPause);
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 75
diff changeset
    39
        }
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    40
195
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    41
        void userControlTimeLine_AnnotationRemoved(object sender, EventArgs e)
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    42
        {
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    43
            try
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
                DataDictionary Data = (new DataFactory()).Data;
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    46
                Data.RemoveAnnotation((Annotation)sender);
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    47
            }
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    48
            catch { }
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
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    51
        //  Ajout Annotation
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    52
        void userControlTimeLine_AnnotationAdded(object sender, EventArgs e)
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    53
        {
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    54
            try
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
                DataDictionary Data = (new DataFactory()).Data;
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    57
                Data.AddAnnotation((Annotation)sender);
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    58
            }
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
    59
            catch { }
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
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    62
        #region player
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    63
        private void UserControlPlayer_PlayerOpened(object sender, EventArgs e)
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    64
        {
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    65
            //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
    66
            UCTimeLine.initslider(UserControlPlayer.TotalMilliseconds);
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    67
            //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
    68
            UCTimeLine.timerStart();
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    69
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    70
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    71
165
e78e40b9d761 Pivot Improved and methods for timeline
riley
parents: 162
diff changeset
    72
        public void UserControlPlayer_PlayerStopOrPause(object sender, EventArgs e)
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    73
        {
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    74
            try
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
                userControlTimeLine.thumbRotation((bool)sender);
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
    77
            }catch(Exception ){}
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    78
        }
188
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    79
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    80
        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
    81
        {
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    82
            try
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
                UserControlPlayer.setSound(val);
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
            catch (Exception) { }
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
        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
    89
        {
e642ad0c366b Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents: 186
diff changeset
    90
            try
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
                UserControlPlayer.setMute(b);
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
            catch (Exception) { }
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
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    97
        #endregion
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    98
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    99
        #region TimeLine
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   100
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   101
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   102
        private void UserControlTimeLine_DragStarted(object sender, EventArgs e)
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   103
        {
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   104
            UserControlPlayer.playerPause();
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   105
        }
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   106
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   107
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   108
        private void UserControlTimeLine_DragCompleted(object sender, EventArgs e)
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   109
        {
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   110
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   111
        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
   112
        {
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   113
            OnSuccessAnnotation(this, new EventArgs());
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   114
        }
168
d70ee2002f75 Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents: 165
diff changeset
   115
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   116
        #endregion
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   117
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   118
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   119
        #region SynSource pour chaque X milliseconds
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   120
        private void UserControlTimeLine_TimerTick(object sender, EventArgs e)
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   121
        {
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   122
            if (!UCTimeLine.IsDragging)
35
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
                UCTimeLine.Slider.Value = UserControlPlayer.Player.Position.TotalMilliseconds;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   125
            }
195
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
   126
            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
   127
            if (UCTimeLine.FinishedDragging)
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   128
            {
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   129
                TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue);
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   130
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   131
                UserControlPlayer.Player.Position = ts;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   132
                UserControlPlayer.playerPlay();
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   133
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   134
                UCTimeLine.IsDragging = false;
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   135
                UCTimeLine.FinishedDragging = false;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   136
            }
205
468f3757f1f8 Correction probleme tc annotation
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 195
diff changeset
   137
            UserControlPlayer.Time = (float)SliderValue / 1000;
195
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
   138
            DataDictionary Data = (new DataFactory()).Data;
48b3139bb182 Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 193
diff changeset
   139
            UserControlPlayer.ApplyColor(Data.GetColors((int)((float)SliderValue / 1000)));
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   140
        }
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   141
        #endregion
75
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   142
99d003723474 data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents: 39
diff changeset
   143
        public UserControlTimeLine userControlTimeLine
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
            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
   146
        }
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   147
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   148
        public void PlayerPause()
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
            UserControlPlayer.playerPause();
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   151
        }
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   152
    }
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   153
}