First Data binding for annotations and timeline
authorcavaliet
Wed, 16 Sep 2009 15:36:08 +0200
changeset 69 a4c44555f205
parent 68 5f547156bda6
child 70 4a2f4b9e971a
First Data binding for annotations and timeline
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml
src/FingersDance.Control.TimeLine/FingersDance.Control.TimeLine.csproj
src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml
src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
src/FingersDance.Data/Annotation.cs
src/FingersDance.Data/Cutting.cs
src/FingersDance.ViewModel/AnnotationViewModel.cs
src/FingersDance.ViewModel/CuttingViewModel.cs
src/FingersDance.ViewModel/FingersDance.ViewModels.csproj
src/FingersDance.ViewModel/Properties/AssemblyInfo.cs
src/FingersDance.ViewModel/Properties/Resources.Designer.cs
src/FingersDance.ViewModel/Properties/Settings.Designer.cs
src/FingersDance.ViewModel/ViewModelBase.cs
src/FingersDance.Views/TimelineView.xaml
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml	Wed Sep 16 15:36:08 2009 +0200
@@ -10,8 +10,8 @@
 	x:Name="UserControl" Height="384" Width="512">
 
     <Grid x:Name="LayoutRoot" Height="{Binding Path=ActualHeight, ElementName=UserControl, Mode=Default}" Width="{Binding Path=ActualWidth, ElementName=UserControl, Mode=Default}">
-        <Grid VerticalAlignment="Top" Height="50" x:Name="GridTimeLine">
-        	<FingersDance_Control_TimeLine:UserControlTimeLine Margin="40,0,8,0" Height="Auto" x:Name="UserControlTimeLine" DragStarted="UserControlTimeLine_DragStarted" DragCompleted="UserControlTimeLine_DragCompleted" TimerTick="UserControlTimeLine_TimerTick" d:LayoutOverrides="Height" Background="{x:Null}"/>
+        <Grid VerticalAlignment="Top" Height="100" x:Name="GridTimeLine">
+        	<FingersDance_Control_TimeLine:UserControlTimeLine Margin="40,0,8,-50" x:Name="UserControlTimeLine" DragStarted="UserControlTimeLine_DragStarted" DragCompleted="UserControlTimeLine_DragCompleted" TimerTick="UserControlTimeLine_TimerTick" d:LayoutOverrides="Height" Background="{x:Null}" />
         </Grid>
         <Grid HorizontalAlignment="Stretch" Width="Auto" Height="Auto" VerticalAlignment="Stretch" x:Name="GridPlayer" Margin="0,54,0,0">
         	<FingersDance_Control_Player:UserControlPlayer PlayerOpened="UserControlPlayer_PlayerOpened" x:Name="UserControlPlayer" VerticalAlignment="Stretch" d:LayoutOverrides="GridBox" Width="{Binding Path=ActualWidth, ElementName=GridPlayer, Mode=Default}" Margin="0,0,0,0" Height="{Binding Path=ActualHeight, ElementName=GridPlayer, Mode=Default}" />
--- a/src/FingersDance.Control.TimeLine/FingersDance.Control.TimeLine.csproj	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/FingersDance.Control.TimeLine.csproj	Wed Sep 16 15:36:08 2009 +0200
@@ -118,5 +118,19 @@
   <ItemGroup>
     <Resource Include="Resources\WindowBackground.jpg" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\FingersDance.Data\FingersDance.Data.csproj">
+      <Project>{EAF384DB-2AE4-4132-839D-60F9DAFDEAD8}</Project>
+      <Name>FingersDance.Data</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\FingersDance.ViewModel\FingersDance.ViewModels.csproj">
+      <Project>{E81BB080-0598-43AC-90CE-54D6570C4E9E}</Project>
+      <Name>FingersDance.ViewModels</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\FingersDance.Views\FingersDance.Views.csproj">
+      <Project>{0B308B6E-7B1E-46C0-ACC7-0B7EFC4D0B2C}</Project>
+      <Name>FingersDance.Views</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml	Wed Sep 16 15:36:08 2009 +0200
@@ -5,10 +5,12 @@
 	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 	mc:Ignorable="d"
 	x:Class="FingersDance.Control.TimeLine.UserControlTimeLine"
+    xmlns:vw="clr-namespace:FingersDance.Views;assembly=FingersDance.Views"
 	x:Name="UserControl"
 	d:DesignWidth="383" xmlns:Custom="http://schemas.microsoft.com/surface/2008" Height="Auto" Background="{x:Null}" d:DesignHeight="33">
 
 	<Grid x:Name="LayoutRoot" Width="Auto" Height="Auto" Background="{x:Null}">
 		<Custom:SurfaceSlider  Height="Auto" x:Name="slider" Value="0.5" Width="Auto" Thumb.DragStarted="sliderPosition_DragStarted" Thumb.DragCompleted="sliderPosition_DragCompleted" Margin="0,0,30,0" Background="#19FFFFFF" />
-	</Grid>
+        <vw:TimelineView x:Name="tv" Height="130"/>
+    </Grid>
 </UserControl>
\ No newline at end of file
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Wed Sep 16 15:36:08 2009 +0200
@@ -1,4 +1,5 @@
 using System;
+using System.Collections.Generic;
 using System.IO;
 using System.Net;
 using System.Windows;
@@ -11,6 +12,9 @@
 using Microsoft.Surface.Presentation.Controls;
 using System.Windows.Threading;
 
+using FingersDance.Data;
+using FingersDance.ViewModels;
+
 namespace FingersDance.Control.TimeLine
 {
 	public partial class UserControlTimeLine
@@ -85,11 +89,24 @@
 			this.InitializeComponent();
 
 			// Insert code required on object creation below this point.
+            
 		}
 
         public void initslider(double totalmilliseconds)
         {
             slider.Maximum = totalmilliseconds;
+
+
+            // TEMP FOR DATA BINDING
+            List<Annotation> annotList = new List<Annotation>();
+            annotList.Add(new Annotation(0, 10, "Axe Cam 1"));
+            annotList.Add(new Annotation(10, 20, "Mvt Cam 2"));
+            annotList.Add(new Annotation(30, 40, "Saut 3"));
+            Cutting cut = new Cutting("titre de cutting", annotList);
+            CuttingViewModel cutvm = new CuttingViewModel(cut);
+            tv.DataContext = cut;
+
+
         }
 
         #region Timer
--- a/src/FingersDance.Data/Annotation.cs	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.Data/Annotation.cs	Wed Sep 16 15:36:08 2009 +0200
@@ -5,21 +5,21 @@
 
 namespace FingersDance.Data
 {
-    class AnnotationAddedEventArg : EventArgs
+    public class AnnotationAddedEventArg : EventArgs
     {
         private float _tcBegin;
         private float _dur;  
         private String _gestureType;
 
-        public float tcBegin
+        public float TcBegin
         {
             get { return this._tcBegin; }
         }
-        public float dur
+        public float Dur
         {  
             get { return this._dur; }
         }  
-        public String gestureType
+        public String GestureType
         {  
             get { return this._gestureType; }
         }
@@ -34,22 +34,53 @@
 
     }
 
-    class Annotation
+    public class Annotation
     {
-        private float tcBegin;
-        private float dur;
-        private string gestureType;
+        private float _tcBegin;
+        private float _dur;
+        private string _gestureType;
 
-        public event EventHandler<AnnotationAddedEventArg> AnnotationAdded;
+        //public event EventHandler<AnnotationAddedEventArg> AnnotationAdded;
 
         public Annotation(float tcBeginPar, float durPar, string gesturePar)
         {
-            this.tcBegin = tcBeginPar;
-            this.dur = durPar;
-            this.gestureType = gesturePar;
+            this._tcBegin = tcBeginPar;
+            this._dur = durPar;
+            this._gestureType = gesturePar;
+
+            //AnnotationAdded(this, new AnnotationAddedEventArg(_tcBegin, _dur, _gestureType));
+
+        }
 
-            AnnotationAdded(this, new AnnotationAddedEventArg(tcBegin, dur, gestureType));
-
+        public float TcBegin
+        {
+            get { return _tcBegin; }
+            set
+            {
+                if (value == _tcBegin || float.IsNaN(value))
+                    return;
+                _tcBegin = value;
+            }
+        }
+        public float Dur
+        {
+            get { return _dur; }
+            set
+            {
+                if (value == _dur || float.IsNaN(value))
+                    return;
+                _dur = value;
+            }
+        }
+        public String GestureType
+        {
+            get { return _gestureType; }
+            set
+            {
+                if (value == _gestureType || String.IsNullOrEmpty(value))
+                    return;
+                _gestureType = value;
+            }
         }
         
     }
--- a/src/FingersDance.Data/Cutting.cs	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.Data/Cutting.cs	Wed Sep 16 15:36:08 2009 +0200
@@ -5,16 +5,36 @@
 
 namespace FingersDance.Data
 {
-    class Cutting
+    public class Cutting
     {
-        private List<Annotation> annotList;
-        private string title;
+        private List<Annotation> _annotList;
+        private string _title;
 
         public Cutting(string titlePar, List<Annotation> annotListPar)
         {
-            this.title = titlePar;
-            this.annotList = annotListPar;
+            this._title = titlePar;
+            this._annotList = annotListPar;
             
         }
+
+        public String Title
+        {
+            get { return _title; }
+            set
+            {
+                if (value == _title || String.IsNullOrEmpty(value))
+                    return;
+                _title = value;
+            }
+        }
+        public List<Annotation> AnnotList
+        {
+            get { return _annotList; }
+            set
+            {
+                _annotList = value;
+            }
+        }
+
     }
 }
--- a/src/FingersDance.ViewModel/AnnotationViewModel.cs	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.ViewModel/AnnotationViewModel.cs	Wed Sep 16 15:36:08 2009 +0200
@@ -3,15 +3,23 @@
 using System.Linq;
 using System.Text;
 
-namespace FingersDance.ViewModel
+using FingersDance.Data;
+
+namespace FingersDance.ViewModels
 {
-    class AnnotationViewModel : ViewModelBase
+    public class AnnotationViewModel : ViewModelBase
     {
         private float _tcBegin;
         private float _dur;
         private String _gestureType;
 
-        public float tcBegin
+        public AnnotationViewModel(Annotation a) {
+            this._tcBegin = a.TcBegin;
+            this._dur = a.Dur;
+            this._gestureType = a.GestureType;
+        }
+
+        public float TcBegin
         {
             get { return _tcBegin; }
             set {
@@ -21,7 +29,7 @@
                 base.OnPropertyChanged("TcBegin");
             }
         }
-        public float dur
+        public float Dur
         {
             get { return _dur; }
             set
@@ -32,7 +40,7 @@
                 base.OnPropertyChanged("Dur");
             }
         }
-        public String gestureType
+        public String GestureType
         {
             get { return _gestureType; }
             set
--- a/src/FingersDance.ViewModel/CuttingViewModel.cs	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.ViewModel/CuttingViewModel.cs	Wed Sep 16 15:36:08 2009 +0200
@@ -3,13 +3,24 @@
 using System.Linq;
 using System.Text;
 
-namespace FingersDance.ViewModel
+using FingersDance.Data;
+
+namespace FingersDance.ViewModels
 {
-    class CuttingViewModel : ViewModelBase
+    public class CuttingViewModel : ViewModelBase
     {
         private string _title;
         private List<AnnotationViewModel> _annotList = new List<AnnotationViewModel>();
-        
+
+        public CuttingViewModel(Cutting c) {
+
+            this._title = c.Title;
+            this._annotList = new List<AnnotationViewModel>();
+            foreach (Annotation annot in c.AnnotList)
+                this._annotList.Add(new AnnotationViewModel(annot));
+
+        }
+
         public String Title
         {
             get { return _title; }
--- a/src/FingersDance.ViewModel/FingersDance.ViewModels.csproj	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.ViewModel/FingersDance.ViewModels.csproj	Wed Sep 16 15:36:08 2009 +0200
@@ -8,8 +8,8 @@
     <ProjectGuid>{E81BB080-0598-43AC-90CE-54D6570C4E9E}</ProjectGuid>
     <OutputType>Library</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>FingersDance.ViewModel</RootNamespace>
-    <AssemblyName>FingersDance.ViewModel</AssemblyName>
+    <RootNamespace>FingersDance.ViewModels</RootNamespace>
+    <AssemblyName>FingersDance.ViewModels</AssemblyName>
     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <StartupObject>
@@ -61,6 +61,7 @@
     <Compile Include="Properties\Resources.Designer.cs">
       <AutoGen>True</AutoGen>
       <DependentUpon>Resources.resx</DependentUpon>
+      <DesignTime>True</DesignTime>
     </Compile>
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
@@ -73,6 +74,12 @@
     </Compile>
     <Compile Include="ViewModelBase.cs" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\FingersDance.Data\FingersDance.Data.csproj">
+      <Project>{EAF384DB-2AE4-4132-839D-60F9DAFDEAD8}</Project>
+      <Name>FingersDance.Data</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
--- a/src/FingersDance.ViewModel/Properties/AssemblyInfo.cs	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.ViewModel/Properties/AssemblyInfo.cs	Wed Sep 16 15:36:08 2009 +0200
@@ -5,11 +5,11 @@
 // General Information about an assembly is controlled through the following 
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
-[assembly: AssemblyTitle("FingersDance.ViewModel")]
+[assembly: AssemblyTitle("FingersDance.ViewModels")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("FingersDance.ViewModel")]
+[assembly: AssemblyProduct("FingersDance.ViewModels")]
 [assembly: AssemblyCopyright("Copyright ©  2009")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
--- a/src/FingersDance.ViewModel/Properties/Resources.Designer.cs	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.ViewModel/Properties/Resources.Designer.cs	Wed Sep 16 15:36:08 2009 +0200
@@ -8,10 +8,10 @@
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace FingersDance.ViewModel.Properties
-{
-
-
+namespace FingersDance.ViewModels.Properties {
+    using System;
+    
+    
     /// <summary>
     ///   A strongly-typed resource class, for looking up localized strings, etc.
     /// </summary>
@@ -22,48 +22,40 @@
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class Resources
-    {
-
+    internal class Resources {
+        
         private static global::System.Resources.ResourceManager resourceMan;
-
+        
         private static global::System.Globalization.CultureInfo resourceCulture;
-
+        
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal Resources()
-        {
+        internal Resources() {
         }
-
+        
         /// <summary>
         ///   Returns the cached ResourceManager instance used by this class.
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager
-        {
-            get
-            {
-                if ((resourceMan == null))
-                {
-                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FingersDance.ViewModel.Properties.Resources", typeof(Resources).Assembly);
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FingersDance.ViewModels.Properties.Resources", typeof(Resources).Assembly);
                     resourceMan = temp;
                 }
                 return resourceMan;
             }
         }
-
+        
         /// <summary>
         ///   Overrides the current thread's CurrentUICulture property for all
         ///   resource lookups using this strongly typed resource class.
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture
-        {
-            get
-            {
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
                 return resourceCulture;
             }
-            set
-            {
+            set {
                 resourceCulture = value;
             }
         }
--- a/src/FingersDance.ViewModel/Properties/Settings.Designer.cs	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.ViewModel/Properties/Settings.Designer.cs	Wed Sep 16 15:36:08 2009 +0200
@@ -8,21 +8,17 @@
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace FingersDance.ViewModel.Properties
-{
-
-
+namespace FingersDance.ViewModels.Properties {
+    
+    
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
-    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
-    {
-
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
-        public static Settings Default
-        {
-            get
-            {
+        
+        public static Settings Default {
+            get {
                 return defaultInstance;
             }
         }
--- a/src/FingersDance.ViewModel/ViewModelBase.cs	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.ViewModel/ViewModelBase.cs	Wed Sep 16 15:36:08 2009 +0200
@@ -5,7 +5,7 @@
 using System.ComponentModel;
 using System.Diagnostics;
 
-namespace FingersDance.ViewModel
+namespace FingersDance.ViewModels
 {
     /// <summary>
     /// Base class for all ViewModel classes in the application.
--- a/src/FingersDance.Views/TimelineView.xaml	Wed Sep 16 09:07:27 2009 +0200
+++ b/src/FingersDance.Views/TimelineView.xaml	Wed Sep 16 15:36:08 2009 +0200
@@ -11,8 +11,13 @@
                 <GridView>
                     <GridViewColumn 
                         Header="Gesture Type"
-                        DisplayMemberBinding="{Binding Path=GestureType}" 
-                    />
+                        DisplayMemberBinding="{Binding Path=GestureType}" />
+                    <GridViewColumn 
+                        Header="Tc Begin"
+                        DisplayMemberBinding="{Binding Path=TcBegin}" />
+                    <GridViewColumn 
+                        Header="Dur"
+                        DisplayMemberBinding="{Binding Path=Dur}" />
                 </GridView>
             </ListView.View>
         </ListView>