Annotations are now colored with the same color as the pivot's button
authorcavaliet
Wed, 14 Oct 2009 17:08:43 +0200
changeset 150 569925b65604
parent 149 df197df887d3
child 151 5f011a5ce421
Annotations are now colored with the same color as the pivot's button
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs
src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs
src/FingersDance.Data/Annotation.cs
src/FingersDance.ViewModel/AnnotationViewModel.cs
src/FingersDance.Views/TimelineAnnotationView.xaml
src/FingersDance.Views/TimelineAnnotationView.xaml.cs
src/FingersDance.Views/TimelineView.xaml.cs
src/FingersDance/MainSurfaceWindow.xaml.cs
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Wed Oct 14 14:06:04 2009 +0200
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Wed Oct 14 17:08:43 2009 +0200
@@ -20,17 +20,17 @@
 			// Insert code required on object creation below this point.
 		}
 
-        public void Load(string path)
+        public void Load(string path, UInt32 intColor)
         {
             this.UserControlPlayer.initPlayer(path);
+            //Initialisation du Timer
+            UCTimeLine.initTimer(intColor);
             this.UserControlPlayer.playerPlay();
         }
 
         #region player
         private void UserControlPlayer_PlayerOpened(object sender, EventArgs e)
         {
-            //Initialisation du Timer
-            UCTimeLine.initTimer();
             //Initialisation du slider
             UCTimeLine.initslider(UserControlPlayer.TotalMilliseconds);
             //Demarrage du Timer
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Wed Oct 14 14:06:04 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Wed Oct 14 17:08:43 2009 +0200
@@ -41,6 +41,7 @@
         private CuttingViewModel CuttingVM;
         private Boolean AnnotWaiting = false;
         private float AnnotTcBegin;
+        private UInt32 IntColor;
 
         private AnnotationViewModel canceledAnnotationVM;
 
@@ -115,7 +116,7 @@
 
             // TEMP FOR DATA BINDING
             AnnotList = new List<Annotation>();
-            AnnotList.Add(new Annotation(0, 10, "Axe Cam 1"));
+            AnnotList.Add(new Annotation(0, 10, "Axe Cam 1", IntColor));
             //AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2"));
             //AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3"));
             //AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4"));
@@ -145,11 +146,13 @@
         }
 
         #region Timer
-        public void initTimer()
+        public void initTimer(UInt32 intColorPar)
         {
             timer = new DispatcherTimer();
             timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
             timer.Tick += new EventHandler(timer_Tick);
+
+            IntColor = intColorPar;
         }
 
         public void timerStart()
@@ -267,7 +270,7 @@
                 // If everything's fine, we create the new one
                 if (annotOk == true)
                 {
-                    AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType));
+                    AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color));
                     CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
                     tv.DataContext = null;
                     tv.DataContext = CuttingVM;
@@ -298,7 +301,7 @@
                 // if not, we mark the beginning
                 if (annotOk == true)
                 {
-                    AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString()));
+                    AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), IntColor));
                     CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
                     //Console.WriteLine("BEGIN currentTimecode = " + AnnotTcBegin + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
                     tv.DataContext = null;
@@ -326,7 +329,7 @@
                 if (annotOk == true)
                 {
                     AnnotList.RemoveAt(AnnotList.Count - 1);
-                    AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString()));
+                    AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), IntColor));
                     CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
                     //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
                     tv.DataContext = null;
--- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Wed Oct 14 14:06:04 2009 +0200
+++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Wed Oct 14 17:08:43 2009 +0200
@@ -29,11 +29,12 @@
 			// Insert code required on object creation below this point.
 		}
 
-        public UserControlUserPanel(Project p, string path)
+        public UserControlUserPanel(int idPar, UInt32 intColor, Project p, string path)
         {
             this.InitializeComponent();
+            id = idPar;
             _Project = p;
-            this.UserControlSyncSource.Load(path);
+            this.UserControlSyncSource.Load(path, intColor);
         }
 	}
 }
\ No newline at end of file
--- a/src/FingersDance.Data/Annotation.cs	Wed Oct 14 14:06:04 2009 +0200
+++ b/src/FingersDance.Data/Annotation.cs	Wed Oct 14 17:08:43 2009 +0200
@@ -8,7 +8,7 @@
     public class AnnotationAddedEventArg : EventArgs
     {
         private float _tcBegin;
-        private float _dur;  
+        private float _dur;
         private String _gestureType;
 
         public float TcBegin
@@ -16,20 +16,21 @@
             get { return this._tcBegin; }
         }
         public float Dur
-        {  
+        {
             get { return this._dur; }
-        }  
+        }
         public String GestureType
-        {  
+        {
             get { return this._gestureType; }
         }
 
-        public AnnotationAddedEventArg(float tcBegin, float dur, String gestureType) {
+        public AnnotationAddedEventArg(float tcBegin, float dur, String gestureType)
+        {
 
             this._tcBegin = tcBegin;
             this._dur = dur;
             this._gestureType = gestureType;
-        
+
         }
 
     }
@@ -39,14 +40,16 @@
         private float _tcBegin;
         private float _dur;
         private string _gestureType;
+        private UInt32 _color;
 
         //public event EventHandler<AnnotationAddedEventArg> AnnotationAdded;
 
-        public Annotation(float tcBeginPar, float durPar, string gesturePar)
+        public Annotation(float tcBeginPar, float durPar, string gesturePar, UInt32 colorPar)
         {
             this._tcBegin = tcBeginPar;
             this._dur = durPar;
             this._gestureType = gesturePar;
+            this._color = colorPar;
 
             //AnnotationAdded(this, new AnnotationAddedEventArg(_tcBegin, _dur, _gestureType));
 
@@ -82,7 +85,17 @@
                 _gestureType = value;
             }
         }
-        
+        public UInt32 Color
+        {
+            get { return _color; }
+            set
+            {
+                if (value == _color)
+                    return;
+                _color = value;
+            }
+        }
+
     }
 
 }
--- a/src/FingersDance.ViewModel/AnnotationViewModel.cs	Wed Oct 14 14:06:04 2009 +0200
+++ b/src/FingersDance.ViewModel/AnnotationViewModel.cs	Wed Oct 14 17:08:43 2009 +0200
@@ -12,20 +12,24 @@
         private float _tcBegin;
         private float _dur;
         private String _gestureType;
+        private UInt32 _color;
 
         private float _marginLeft;
 
-        public AnnotationViewModel(Annotation a, float marginLeft) {
+        public AnnotationViewModel(Annotation a, float marginLeft)
+        {
             this._tcBegin = a.TcBegin;
             this._dur = a.Dur;
             this._gestureType = a.GestureType;
+            this._color = a.Color;
             this._marginLeft = marginLeft;
         }
 
         public float TcBegin
         {
             get { return _tcBegin; }
-            set {
+            set
+            {
                 if (value == _tcBegin || float.IsNaN(value))
                     return;
                 _tcBegin = value;
@@ -54,6 +58,16 @@
                 base.OnPropertyChanged("GestureType");
             }
         }
+        public UInt32 Color
+        {
+            get { return _color; }
+            set
+            {
+                if (value == _color)
+                    return;
+                _color = value;
+            }
+        }
         public float MarginLeft
         {
             get { return _marginLeft; }
--- a/src/FingersDance.Views/TimelineAnnotationView.xaml	Wed Oct 14 14:06:04 2009 +0200
+++ b/src/FingersDance.Views/TimelineAnnotationView.xaml	Wed Oct 14 17:08:43 2009 +0200
@@ -12,16 +12,17 @@
     <UserControl.Resources>
         <vw:ThicknessSingleValueConverter x:Name="myThicknessSingleValueConverter" x:Key="myThicknessSingleValueConverter"/>
         <vw:VisibilityConverter x:Name="myVisibilityConverter" x:Key="myVisibilityConverter"/>
+        <vw:ColorConverter x:Name="myColorConverter" x:Key="myColorConverter"/>
     </UserControl.Resources>
     <Custom:SurfaceUserControl x:Name="LayoutRoot" Margin="{Binding Path=MarginLeft, Converter={StaticResource myThicknessSingleValueConverter}}"
                                >
         <Grid>
             <Rectangle Fill="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding Path=Dur}" Height="40" Opacity="0.0"/>
             <TextBox HorizontalAlignment="Left" Text="{Binding Path=GestureType}" Width="40" Margin="0,20,0,0" Visibility="{Binding Path=Dur, Converter={StaticResource myVisibilityConverter}}"/>
-            <Ellipse Stroke="Green" Fill="{x:Null}" Margin="-3,16,0,0" Height="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="8"/>
-            <Ellipse Fill="Green" Margin="-2,17,0,0" Height="6" VerticalAlignment="Top" HorizontalAlignment="Left" Width="6" Visibility="{Binding Path=Dur, Converter={StaticResource myVisibilityConverter}}" />
-            <Rectangle Fill="Green" HorizontalAlignment="Left" VerticalAlignment="Top" Width="2" Height="17"/>
-            <Rectangle Fill="Green" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding Path=Dur}" Height="2"/>
+            <Ellipse Stroke="{Binding Path=Color, Converter={StaticResource myColorConverter}}" Fill="{x:Null}" Margin="-3,16,0,0" Height="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="8"/>
+            <Ellipse Fill="{Binding Path=Color, Converter={StaticResource myColorConverter}}" Margin="-2,17,0,0" Height="6" VerticalAlignment="Top" HorizontalAlignment="Left" Width="6" Visibility="{Binding Path=Dur, Converter={StaticResource myVisibilityConverter}}" />
+            <Rectangle Fill="{Binding Path=Color, Converter={StaticResource myColorConverter}}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="2" Height="17"/>
+            <Rectangle Fill="{Binding Path=Color, Converter={StaticResource myColorConverter}}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding Path=Dur}" Height="2"/>
         </Grid>
     </Custom:SurfaceUserControl>
 </UserControl>
\ No newline at end of file
--- a/src/FingersDance.Views/TimelineAnnotationView.xaml.cs	Wed Oct 14 14:06:04 2009 +0200
+++ b/src/FingersDance.Views/TimelineAnnotationView.xaml.cs	Wed Oct 14 17:08:43 2009 +0200
@@ -47,7 +47,7 @@
     {
         public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
         {
-            Visibility v = ((float)value>0) ? Visibility.Visible : Visibility.Hidden;
+            Visibility v = ((float)value > 0) ? Visibility.Visible : Visibility.Hidden;
             return v;
         }
         public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
@@ -55,4 +55,19 @@
             return 1.0;
         }
     }
+
+    public class ColorConverter : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+        {
+            UInt32 argb = (UInt32)value;
+            Color c = Color.FromArgb((Byte)((argb >> 24) & 0xFF), (Byte)((argb >> 16) & 0xFF), (Byte)((argb >> 8) & 0xFF), (Byte)(argb & 0xFF));
+            SolidColorBrush scb = new SolidColorBrush(c);
+            return scb;
+        }
+        public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
+        {
+            return 1.0;
+        }
+    }
 }
--- a/src/FingersDance.Views/TimelineView.xaml.cs	Wed Oct 14 14:06:04 2009 +0200
+++ b/src/FingersDance.Views/TimelineView.xaml.cs	Wed Oct 14 17:08:43 2009 +0200
@@ -23,9 +23,6 @@
     public partial class TimelineView : UserControl
     {
 
-        private Boolean hasDragCanceledHandler = false;
-
-
         public TimelineView()
         {
             InitializeComponent();
--- a/src/FingersDance/MainSurfaceWindow.xaml.cs	Wed Oct 14 14:06:04 2009 +0200
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs	Wed Oct 14 17:08:43 2009 +0200
@@ -383,25 +383,25 @@
                 switch (((UserControlScreen)sender).id)
                 {
                     case 1:
-                        Panel1 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
+                        Panel1 = new UserControlUserPanel(1, 0xFF5A0FC8, newProject, _mainviewmodel.Session.VideoPath);
                         Panel1.Name = "UserPanel1";
                         //3-Rajout sur la Grid Root
                         root.Children.Add(Panel1);
                         break;
                     case 2:
-                        Panel2 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
+                        Panel2 = new UserControlUserPanel(2, 0xFFC80FA0, newProject, _mainviewmodel.Session.VideoPath);
                         Panel2.Name = "UserPanel2";
                         //3-Rajout sur la Grid Root
                         root.Children.Add(Panel2);
                         break;
                     case 3:
-                        Panel3 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
+                        Panel3 = new UserControlUserPanel(3, 0xFFFFFF00, newProject, _mainviewmodel.Session.VideoPath);
                         Panel3.Name = "UserPanel3";
                         //3-Rajout sur la Grid Root
                         root.Children.Add(Panel3);
                         break;
                     case 4:
-                        Panel4 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
+                        Panel4 = new UserControlUserPanel(4, 0xFF0096FF, newProject, _mainviewmodel.Session.VideoPath);
                         Panel4.Name = "UserPanel4";
                         //3-Rajout sur la Grid Root
                         root.Children.Add(Panel4);