# HG changeset patch # User cavaliet # Date 1253201105 -7200 # Node ID 99d0037234746034650ed9f2a07a419fd12639d7 # Parent 7ce946833eaea124bdb079d6d41ab5147c3f257c data binding second step. we can add annotation by clicking on menu buttons or timeline. diff -r 7ce946833eae -r 99d003723474 src/FingersDance.ActionFactory/ActionGenerator.cs --- 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; } } } diff -r 7ce946833eae -r 99d003723474 src/FingersDance.Actions/ActionAddAnnotation.cs --- /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(); + } + } +} diff -r 7ce946833eae -r 99d003723474 src/FingersDance.Actions/FingersDance.Actions.csproj --- 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 @@ + @@ -98,5 +99,11 @@ + + + {2BCEE1BF-D3AC-478C-A26B-DFDB7420E965} + FingersDance.Control.TimeLine + + \ No newline at end of file diff -r 7ce946833eae -r 99d003723474 src/FingersDance.Control.Menu/FingersDance.Control.Menu.csproj --- 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 @@ {1E80D5A1-C45C-443B-8992-4A4D78D280FC} FingersDance.Actions + + {BE5AD2E7-8BC2-414A-AB92-34E4D7357740} + FingersDance.Control.SyncSource + + + {2BCEE1BF-D3AC-478C-A26B-DFDB7420E965} + FingersDance.Control.TimeLine + + + {4DC517DD-1601-481E-BAAC-6FE271417F46} + FingersDance.Control + + + + \ No newline at end of file diff -r 7ce946833eae -r 99d003723474 src/FingersDance.Control.Menu/UserControlMenu.xaml.cs --- 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 diff -r 7ce946833eae -r 99d003723474 src/FingersDance.Control.Player/UserControlPlayer.xaml.cs --- 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; diff -r 7ce946833eae -r 99d003723474 src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml --- 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 @@ - + diff -r 7ce946833eae -r 99d003723474 src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs --- 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 diff -r 7ce946833eae -r 99d003723474 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs --- 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 diff -r 7ce946833eae -r 99d003723474 src/FingersDance/FingersDance.csproj --- 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 @@ Always + + Always + diff -r 7ce946833eae -r 99d003723474 src/FingersDance/Resources/menu.xml --- 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 @@ Choregraphique - ChildChore1 + Saut 1 FingersDanceAnnotationButtonNiveau3 - ChildChore1 + ActionAddAnnotation - ChildChore2 + Pirouette 2 FingersDanceAnnotationButtonNiveau3 - ChildChore2 + ActionAddAnnotation FingersDanceAnnotationButtonNiveau2