data binding second step. we can add annotation by clicking on menu buttons or timeline.
authorcavaliet
Thu, 17 Sep 2009 17:25:05 +0200
changeset 75 99d003723474
parent 74 7ce946833eae
child 76 5af0f0a8706d
data binding second step. we can add annotation by clicking on menu buttons or timeline.
src/FingersDance.ActionFactory/ActionGenerator.cs
src/FingersDance.Actions/ActionAddAnnotation.cs
src/FingersDance.Actions/FingersDance.Actions.csproj
src/FingersDance.Control.Menu/FingersDance.Control.Menu.csproj
src/FingersDance.Control.Menu/UserControlMenu.xaml.cs
src/FingersDance.Control.Player/UserControlPlayer.xaml.cs
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs
src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
src/FingersDance/FingersDance.csproj
src/FingersDance/Resources/menu.xml
--- a/src/FingersDance.ActionFactory/ActionGenerator.cs	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance.ActionFactory/ActionGenerator.cs	Thu Sep 17 17:25:05 2009 +0200
@@ -15,12 +15,21 @@
             actionDict.Add("ActionPlayMedia", typeof(FingersDance.Actions.ActionPlayMedia));
             actionDict.Add("ActionShowMessage", typeof(FingersDance.Actions.ActionShowMessage));
             actionDict.Add("ActionOpenMedia", typeof(FingersDance.Actions.ActionOpenMedia));
-            actionDict.Add("ActionStopMedia", typeof(FingersDance.Actions.ActionStopMedia));            
+            actionDict.Add("ActionStopMedia", typeof(FingersDance.Actions.ActionStopMedia));
+
+            actionDict.Add("ActionAddAnnotation", typeof(FingersDance.Actions.ActionAddAnnotation));
         }
 
-        public ActionBase GetAction(string T, object Args)
+        public ActionBase GetAction(String T, Object Args)
         {
-            return (ActionBase)Activator.CreateInstance(actionDict[T]);
+
+            try
+            {
+                ActionBase ab = (ActionBase)Activator.CreateInstance(actionDict[T], Args);
+                return ab;
+            }
+            catch (Exception ex) { }
+            return null;
         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FingersDance.Actions/ActionAddAnnotation.cs	Thu Sep 17 17:25:05 2009 +0200
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using FingersDance.Control.TimeLine;
+
+namespace FingersDance.Actions
+{
+    public class ActionAddAnnotation : FingersDance.Actions.ActionBase
+    {
+        private string _Text = "";
+        private UserControlTimeLine myTimeline;
+
+        public ActionAddAnnotation()
+        {
+            
+        }
+
+        public ActionAddAnnotation(string text)
+        {
+            _Text = text;
+        }
+
+        public ActionAddAnnotation(UserControlTimeLine uct)
+        {
+            myTimeline = uct;
+        }
+
+        public void Execute()
+        {
+            if (myTimeline != null)
+                myTimeline.addAnnotation();
+        }
+    }
+}
--- a/src/FingersDance.Actions/FingersDance.Actions.csproj	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance.Actions/FingersDance.Actions.csproj	Thu Sep 17 17:25:05 2009 +0200
@@ -60,6 +60,7 @@
     <Reference Include="Microsoft.Surface.Presentation.Generic" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="ActionAddAnnotation.cs" />
     <Compile Include="ActionBase.cs" />
     <Compile Include="ActionOpenMedia.cs" />
     <Compile Include="ActionPlayMedia.cs" />
@@ -98,5 +99,11 @@
   <ItemGroup>
     <Resource Include="Resources\WindowBackground.jpg" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\FingersDance.Control.TimeLine\FingersDance.Control.TimeLine.csproj">
+      <Project>{2BCEE1BF-D3AC-478C-A26B-DFDB7420E965}</Project>
+      <Name>FingersDance.Control.TimeLine</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
--- a/src/FingersDance.Control.Menu/FingersDance.Control.Menu.csproj	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance.Control.Menu/FingersDance.Control.Menu.csproj	Thu Sep 17 17:25:05 2009 +0200
@@ -142,6 +142,21 @@
       <Project>{1E80D5A1-C45C-443B-8992-4A4D78D280FC}</Project>
       <Name>FingersDance.Actions</Name>
     </ProjectReference>
+    <ProjectReference Include="..\FingersDance.Control.SyncSource\FingersDance.Control.SyncSource.csproj">
+      <Project>{BE5AD2E7-8BC2-414A-AB92-34E4D7357740}</Project>
+      <Name>FingersDance.Control.SyncSource</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\FingersDance.Control.TimeLine\FingersDance.Control.TimeLine.csproj">
+      <Project>{2BCEE1BF-D3AC-478C-A26B-DFDB7420E965}</Project>
+      <Name>FingersDance.Control.TimeLine</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\FingersDance.Control\FingersDance.Control.csproj">
+      <Project>{4DC517DD-1601-481E-BAAC-6FE271417F46}</Project>
+      <Name>FingersDance.Control</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <WCFMetadata Include="Service References\" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
--- a/src/FingersDance.Control.Menu/UserControlMenu.xaml.cs	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance.Control.Menu/UserControlMenu.xaml.cs	Thu Sep 17 17:25:05 2009 +0200
@@ -12,6 +12,11 @@
 using System.Xml.Serialization;
 using System.Reflection;
 
+using FingersDance.ActionFactory;
+using FingersDance.Actions;
+using FingersDance.Control.SyncSource;
+using FingersDance.Control.TimeLine;
+
 namespace FingersDance.Control.Menu
 {
 	public partial class UserControlMenu
@@ -19,9 +24,9 @@
 		public UserControlMenu()
 		{
 			this.InitializeComponent();
+
+            // Insert code required on object creation below this point.
             initChildSize();
-
-			// Insert code required on object creation below this point.
 		}
 
         //Premet de deplacer les sous menus vers la droite pour avoir un effect tree view
@@ -75,6 +80,8 @@
                  }
                  else
                  {
+                     ItemButton.ContactDown += ActionButton_ContactDown;
+                     ItemButton.Click += ActionButton_ContactDown;
                      ItemButton.Action = item.Action;
                      MItem.Children.Add(ItemButton);
                  }
@@ -86,9 +93,29 @@
              }
          }
 
+         void ActionButton_ContactDown(object sender, RoutedEventArgs e)
+         {
+             // Generate action
+             // We get the instance of the user panel
+             UserControl userPanel = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent;
+             // Its content...
+             Grid o = (Grid)userPanel.Content;
+             // and the UserControlSyncSource within the grid...
+             UserControlSyncSource syncSrc = (UserControlSyncSource)((Grid)o.Children[0]).Children[0];
+             // and finally the timeline
+             UserControlTimeLine tl = syncSrc.userControlTimeLine;
+
+             String actionId = ((CustomSurfaceButton)sender).Action;
+             ActionGenerator ag = new ActionGenerator();
+             ActionBase ab = ag.GetAction(actionId, tl);
+             if(ab!=null)
+                 ab.Execute();
+         }
+
          private void ButtonMenu_ContactDown(object sender, RoutedEventArgs e)
          {
              foreach (UIElement Child in ((Panel)((CustomSurfaceButton)sender).Parent).Children)
+             {
                  try
                  {
                      if (((StackPanel)Child).Name.Equals(((Microsoft.Surface.Presentation.Controls.SurfaceButton)sender).Content.ToString().Replace(' ', '_') + "Panel"))
@@ -105,6 +132,7 @@
                      }
                  }
                  catch (Exception ex) { }
+             }
          }
 
         #region Events
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Thu Sep 17 17:25:05 2009 +0200
@@ -59,7 +59,7 @@
             //DirectoryInfo info = Directory.GetParent(@".");
             FileInfo assemblyPath = new FileInfo(Assembly.GetExecutingAssembly().Location);
             DirectoryInfo info = assemblyPath.Directory;
-            MediaElementVideo.Source = new Uri(@"" + info.FullName.ToString() + "\\Resources\\Lake.wmv", UriKind.Relative);
+            MediaElementVideo.Source = new Uri(@"" + info.FullName.ToString() + "\\Resources\\oneflat.wmv", UriKind.Relative);
             MediaElementVideo.LoadedBehavior = MediaState.Manual;
             MediaElementVideo.UnloadedBehavior = MediaState.Manual;
             MediaElementVideo.ScrubbingEnabled= true;
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml	Thu Sep 17 17:25:05 2009 +0200
@@ -11,7 +11,7 @@
 
     <Grid x:Name="LayoutRoot" Height="{Binding Path=ActualHeight, ElementName=UserControl, Mode=Default}" Width="{Binding Path=ActualWidth, ElementName=UserControl, Mode=Default}">
         <Grid VerticalAlignment="Top" Height="100" x:Name="GridTimeLine">
-        	<FingersDance_Control_TimeLine:UserControlTimeLine Margin="40,0,8,0" x:Name="UserControlTimeLine" DragStarted="UserControlTimeLine_DragStarted" DragCompleted="UserControlTimeLine_DragCompleted" TimerTick="UserControlTimeLine_TimerTick" d:LayoutOverrides="Height" Background="{x:Null}" />
+        	<FingersDance_Control_TimeLine:UserControlTimeLine Margin="40,0,8,0" x:Name="UCTimeLine" 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.SyncSource/UserControlSyncSource.xaml.cs	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Thu Sep 17 17:25:05 2009 +0200
@@ -25,11 +25,11 @@
         private void UserControlPlayer_PlayerOpened(object sender, EventArgs e)
         {
             //Initialisation du Timer
-            UserControlTimeLine.initTimer();
+            UCTimeLine.initTimer();
             //Initialisation du slider
-            UserControlTimeLine.initslider(UserControlPlayer.TotalMilliseconds);
+            UCTimeLine.initslider(UserControlPlayer.TotalMilliseconds);
             //Demarrage du Timer
-            UserControlTimeLine.timerStart();
+            UCTimeLine.timerStart();
 
         }
         #endregion
@@ -52,22 +52,27 @@
         #region SynSource pour chaque X milliseconds
         private void UserControlTimeLine_TimerTick(object sender, EventArgs e)
         {
-            if (!UserControlTimeLine.IsDragging)
+            if (!UCTimeLine.IsDragging)
             {
-                UserControlTimeLine.Slider.Value = UserControlPlayer.Player.Position.TotalMilliseconds;
+                UCTimeLine.Slider.Value = UserControlPlayer.Player.Position.TotalMilliseconds;
             }
-            if (UserControlTimeLine.FinishedDragging)
+            if (UCTimeLine.FinishedDragging)
             {
-                int SliderValue = (int)UserControlTimeLine.Slider.Value;
+                int SliderValue = (int)UCTimeLine.Slider.Value;
                 TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue);
 
                 UserControlPlayer.Player.Position = ts;
                 UserControlPlayer.playerPlay();
 
-                UserControlTimeLine.IsDragging = false;
-                UserControlTimeLine.FinishedDragging = false;
+                UCTimeLine.IsDragging = false;
+                UCTimeLine.FinishedDragging = false;
             }
         }
         #endregion
+
+        public UserControlTimeLine userControlTimeLine
+        {
+            get { return this.UCTimeLine; }
+        }
     }
 }
\ No newline at end of file
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Thu Sep 17 17:25:05 2009 +0200
@@ -188,13 +188,16 @@
 
         private void slider_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
         {
+            addAnnotation();
+        }
 
-            cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180+(numAnnot-6)*20 - ((numAnnot-1) * annotWidth), 10, numAnnot.ToString())));
+        public void addAnnotation()
+        {
+            cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 + (numAnnot - 6) * 20 - ((numAnnot - 1) * annotWidth), 10, numAnnot.ToString())));
             tv.DataContext = null;
             tv.DataContext = cutvm;
             numAnnot++;
         }
-        
 
 	}
 }
\ No newline at end of file
--- a/src/FingersDance/FingersDance.csproj	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance/FingersDance.csproj	Thu Sep 17 17:25:05 2009 +0200
@@ -123,6 +123,9 @@
     <Content Include="Resources\Lake.wmv">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <Content Include="Resources\oneflat.wmv">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
     <Resource Include="FingersDance.xml" />
   </ItemGroup>
   <ItemGroup>
--- a/src/FingersDance/Resources/menu.xml	Thu Sep 17 13:06:22 2009 +0200
+++ b/src/FingersDance/Resources/menu.xml	Thu Sep 17 17:25:05 2009 +0200
@@ -65,16 +65,16 @@
 					<Name>Choregraphique</Name>
 					<Items>
 						<Item>
-							<Name>ChildChore1</Name>
+							<Name>Saut 1</Name>
 							<Items/>
 							<Ressource>FingersDanceAnnotationButtonNiveau3</Ressource>
-							<Action>ChildChore1</Action>
+							<Action>ActionAddAnnotation</Action>
 						</Item>
 						<Item>
-							<Name>ChildChore2</Name>
+							<Name>Pirouette 2</Name>
 							<Items/>
 							<Ressource>FingersDanceAnnotationButtonNiveau3</Ressource>
-							<Action>ChildChore2</Action>
+							<Action>ActionAddAnnotation</Action>
 						</Item>
 					</Items>
 					<Ressource>FingersDanceAnnotationButtonNiveau2</Ressource>