# HG changeset patch # User cavaliet # Date 1255701369 -7200 # Node ID e940ca798fe30eb9f10f353257c9e1109fa48a33 # Parent 0fd2b41ab4024559c92727ce07f76e45443f28bf Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list. diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.ActionFactory/ColorFactory.cs --- a/src/FingersDance.ActionFactory/ColorFactory.cs Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.ActionFactory/ColorFactory.cs Fri Oct 16 15:56:09 2009 +0200 @@ -2,37 +2,61 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Windows.Media; namespace FingersDance.Factory { public class ColorFactory { - static Dictionary _Colors; + + static Dictionary _ColorsStringId; + static Dictionary _Colors; - public Dictionary Colors + public Dictionary ColorsStringId + { + get { return _ColorsStringId; } + } + public Dictionary Colors { get { return _Colors; } } public ColorFactory() { + if (_ColorsStringId == null) + { + _ColorsStringId = new Dictionary(); + _ColorsStringId.Add(0, "DefaultColor_xaml"); + _ColorsStringId.Add(1, "Color_1_#FFFF00_xaml"); + _ColorsStringId.Add(2, "Color_2_#FFC800_xaml"); + _ColorsStringId.Add(3, "Color_3_#FF7D00__xaml"); + _ColorsStringId.Add(4, "Color_4_#FF0000_xaml"); + _ColorsStringId.Add(5, "Color_5_#FF0064_xaml"); + _ColorsStringId.Add(6, "Color_6_#C80FA0_xaml"); + _ColorsStringId.Add(7, "Color_7_#5A0FC8_xaml"); + _ColorsStringId.Add(8, "Color_8_#230FD2_xaml"); + _ColorsStringId.Add(9, "Color_9_#0096FF__xaml"); + _ColorsStringId.Add(10, "Color_10_#009664_xaml"); + _ColorsStringId.Add(11, "Color_11_#006432_xaml"); + _ColorsStringId.Add(12, "Color_12_#00C800_xaml"); + } + if (_Colors == null) { - - _Colors = new Dictionary(); - _Colors.Add("Default", "DefaultColor_xaml"); - _Colors.Add("Color_1", "Color_1_#FFFF00_xaml"); - _Colors.Add("Color_2", "Color_2_#FFC800_xaml"); - _Colors.Add("Color_3", "Color_3_#FF7D00__xaml"); - _Colors.Add("Color_4", "Color_4_#FF0000_xaml"); - _Colors.Add("Color_5", "Color_5_#FF0064_xaml"); - _Colors.Add("Color_6", "Color_6_#C80FA0_xaml"); - _Colors.Add("Color_7", "Color_7_#5A0FC8_xaml"); - _Colors.Add("Color_8", "Color_8_#230FD2_xaml"); - _Colors.Add("Color_9", "Color_9_#0096FF__xaml"); - _Colors.Add("Color_10", "Color_10_#009664_xaml"); - _Colors.Add("Color_11", "Color_11_#006432_xaml"); - _Colors.Add("Color_12", "Color_12_#00C800_xaml"); + _Colors = new Dictionary(); + _Colors.Add(0, Color.FromRgb(0x88, 0x88, 0x88)); + _Colors.Add(1, Color.FromRgb(0xFF, 0xFF, 0x00)); + _Colors.Add(2, Color.FromRgb(0xFF, 0xC8, 0x00)); + _Colors.Add(3, Color.FromRgb(0xFF, 0x7D, 0x00)); + _Colors.Add(4, Color.FromRgb(0xFF, 0x00, 0x00)); + _Colors.Add(5, Color.FromRgb(0xFF, 0x00, 0x64)); + _Colors.Add(6, Color.FromRgb(0xC8, 0x0F, 0xA0)); + _Colors.Add(7, Color.FromRgb(0x5A, 0x0F, 0xC8)); + _Colors.Add(8, Color.FromRgb(0x23, 0x0F, 0xD2)); + _Colors.Add(9, Color.FromRgb(0x00, 0x96, 0xFF)); + _Colors.Add(10, Color.FromRgb(0x00, 0x96, 0x64)); + _Colors.Add(11, Color.FromRgb(0x00, 0x64, 0x32)); + _Colors.Add(12, Color.FromRgb(0x00, 0xC8, 0x00)); } } } diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.ActionFactory/FingersDance.Factory.csproj --- a/src/FingersDance.ActionFactory/FingersDance.Factory.csproj Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.ActionFactory/FingersDance.Factory.csproj Fri Oct 16 15:56:09 2009 +0200 @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {C7B905EA-0678-4DA0-8EF8-7F9CBD22818E} Library @@ -51,6 +51,9 @@ prompt + + 3.0 + 3.5 @@ -63,6 +66,9 @@ + + 3.0 + diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs --- a/src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs Fri Oct 16 15:56:09 2009 +0200 @@ -67,23 +67,23 @@ SurfaceButtonPlayer4_ContactDown(this, null); } - public void ApplyColor(int id, string color) + public void ApplyColor(int id, uint color) { try { switch (id) { case 1: - SurfaceButtonPlayer1.Background = (Brush)FindResource((new ColorFactory()).Colors[color]); + SurfaceButtonPlayer1.Background = (Brush)FindResource((new ColorFactory()).ColorsStringId[color]); break; case 2: - SurfaceButtonPlayer2.Background = (Brush)FindResource((new ColorFactory()).Colors[color]); + SurfaceButtonPlayer2.Background = (Brush)FindResource((new ColorFactory()).ColorsStringId[color]); break; case 3: - SurfaceButtonPlayer3.Background = (Brush)FindResource((new ColorFactory()).Colors[color]); + SurfaceButtonPlayer3.Background = (Brush)FindResource((new ColorFactory()).ColorsStringId[color]); break; case 4: - SurfaceButtonPlayer4.Background = (Brush)FindResource((new ColorFactory()).Colors[color]); + SurfaceButtonPlayer4.Background = (Brush)FindResource((new ColorFactory()).ColorsStringId[color]); break; } diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj --- a/src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj Fri Oct 16 15:56:09 2009 +0200 @@ -140,6 +140,10 @@ {2BCEE1BF-D3AC-478C-A26B-DFDB7420E965} FingersDance.Control.TimeLine + + {EAF384DB-2AE4-4132-839D-60F9DAFDEAD8} + FingersDance.Data + \ No newline at end of file diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs --- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs Fri Oct 16 15:56:09 2009 +0200 @@ -8,6 +8,7 @@ using System.Windows.Media.Animation; using System.Windows.Navigation; using FingersDance.Control.TimeLine; +using FingersDance.Data; namespace FingersDance.Control.SyncSource { @@ -20,11 +21,11 @@ // Insert code required on object creation below this point. } - public void Load(string path, UInt32 intColor) + public void Load(string path, Color col, Cutting projCutting) { this.UserControlPlayer.initPlayer(path); //Initialisation du Timer - UCTimeLine.initTimer(intColor); + UCTimeLine.initTimer(col, projCutting); this.UserControlPlayer.playerPlay(); } diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs --- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Fri Oct 16 15:56:09 2009 +0200 @@ -35,13 +35,13 @@ public event EventHandler TimerTick; private double totalmilliseconds; - + private List AnnotList = new List(); private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item private CuttingViewModel CuttingVM; private Boolean AnnotWaiting = false; private float AnnotTcBegin; - private UInt32 IntColor; + private Color CurrentColor; private AnnotationViewModel canceledAnnotationVM; @@ -114,16 +114,6 @@ // When the timeline is resized, we catch the resize event to define TimelineView's good scale this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); - // TEMP FOR DATA BINDING - AnnotList = new List(); - 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")); - //AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5")); - Cutting cut = new Cutting("titre de cutting", AnnotList); - CuttingVM = new CuttingViewModel(cut, AnnotWidth); - tv.DataContext = CuttingVM; tv.listview.PreviewContactDown += listview_PreviewContactDown; SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled); @@ -131,7 +121,6 @@ UserControlTimeLine_SizeChanged(null, null); slider_ContactTapGesture(this, null); - } @@ -141,18 +130,30 @@ Double futurScale = (this.ActualWidth-30) / (totalmilliseconds / 1000); //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS tv.RenderTransform = new ScaleTransform(futurScale,1); - //Console.WriteLine("futurScale = " + futurScale); + //tv.Width = this.ActualWidth - 30; } #region Timer - public void initTimer(UInt32 intColorPar) + public void initTimer(Color col, Cutting cutPar) { timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 100); timer.Tick += new EventHandler(timer_Tick); - IntColor = intColorPar; + CurrentColor = col; + + // DATA BINDING from the cutting sent in parameter (initialised before by the userPanel with the global project) + AnnotList = new List(); + AnnotList.Add(new Annotation(0, 10, "Axe Cam 1", CurrentColor)); + //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")); + //AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5")); + cutPar = new Cutting("titre de cutting", AnnotList); + CuttingVM = new CuttingViewModel(cutPar, AnnotWidth); + tv.DataContext = CuttingVM; + } public void timerStart() @@ -185,6 +186,7 @@ #endregion + #region SliderDrag private void sliderPosition_DragStarted(object sender, DragStartedEventArgs e) { isDragging = true; @@ -212,6 +214,7 @@ { //startOrEndAnnotation(); } + #endregion public Boolean isAnnotationAccepted(AnnotationViewModel avm) { @@ -301,9 +304,8 @@ // if not, we mark the beginning if (annotOk == true) { - AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), IntColor)); + AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), CurrentColor)); CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); - //Console.WriteLine("BEGIN currentTimecode = " + AnnotTcBegin + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); tv.DataContext = null; tv.DataContext = CuttingVM; AnnotWaiting = true; @@ -329,7 +331,7 @@ if (annotOk == true) { AnnotList.RemoveAt(AnnotList.Count - 1); - AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), IntColor)); + AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor)); CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); tv.DataContext = null; @@ -339,7 +341,6 @@ } } - private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) { FrameworkElement findSource = e.OriginalSource as FrameworkElement; @@ -407,7 +408,6 @@ private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e) { - Console.WriteLine("onDragCanceled = " + sender + ", ((ContentControl)e.Cursor.Visual).Content = " + ((ContentControl)e.Cursor.Visual).Content); // We check if the annotation is well one of the current annotations if (CuttingVM != null) { @@ -419,7 +419,6 @@ private void confirmCancelPopup_ConfirmYesOrNo(object sender, ConfirmEventArgs e) { - //Consolenfirm = " + e.Confirmed); // We check if the annotation is well one of the current annotations if (CuttingVM != null && canceledAnnotationVM != null && e.Confirmed == true) { diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs --- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs Fri Oct 16 15:56:09 2009 +0200 @@ -29,12 +29,12 @@ // Insert code required on object creation below this point. } - public UserControlUserPanel(int idPar, UInt32 intColor, Project p, string path) + public UserControlUserPanel(int idPar, Color col, Project p, string path) { this.InitializeComponent(); id = idPar; _Project = p; - this.UserControlSyncSource.Load(path, intColor); + this.UserControlSyncSource.Load(path, col, _Project.Cutting); } public void PlayerPause() diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.Data/Annotation.cs --- a/src/FingersDance.Data/Annotation.cs Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.Data/Annotation.cs Fri Oct 16 15:56:09 2009 +0200 @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Windows.Media; namespace FingersDance.Data { @@ -40,11 +41,11 @@ private float _tcBegin; private float _dur; private string _gestureType; - private UInt32 _color; + private Color _color; //public event EventHandler AnnotationAdded; - public Annotation(float tcBeginPar, float durPar, string gesturePar, UInt32 colorPar) + public Annotation(float tcBeginPar, float durPar, string gesturePar, Color colorPar) { this._tcBegin = tcBeginPar; this._dur = durPar; @@ -85,7 +86,7 @@ _gestureType = value; } } - public UInt32 Color + public Color Color { get { return _color; } set diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.Data/FingersDance.Data.csproj --- a/src/FingersDance.Data/FingersDance.Data.csproj Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.Data/FingersDance.Data.csproj Fri Oct 16 15:56:09 2009 +0200 @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {EAF384DB-2AE4-4132-839D-60F9DAFDEAD8} Library @@ -33,6 +33,9 @@ 4 + + 3.0 + 3.5 @@ -46,8 +49,10 @@ - + + 3.0 + diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.ViewModel/AnnotationViewModel.cs --- a/src/FingersDance.ViewModel/AnnotationViewModel.cs Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.ViewModel/AnnotationViewModel.cs Fri Oct 16 15:56:09 2009 +0200 @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Windows.Media; using FingersDance.Data; @@ -12,7 +13,7 @@ private float _tcBegin; private float _dur; private String _gestureType; - private UInt32 _color; + private Color _color; private float _marginLeft; @@ -58,7 +59,7 @@ base.OnPropertyChanged("GestureType"); } } - public UInt32 Color + public Color Color { get { return _color; } set diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.ViewModel/FingersDance.ViewModels.csproj --- a/src/FingersDance.ViewModel/FingersDance.ViewModels.csproj Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.ViewModel/FingersDance.ViewModels.csproj Fri Oct 16 15:56:09 2009 +0200 @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {E81BB080-0598-43AC-90CE-54D6570C4E9E} Library @@ -53,6 +53,9 @@ prompt + + 3.0 + 3.5 @@ -66,8 +69,10 @@ - + + 3.0 + diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance.Views/TimelineAnnotationView.xaml.cs --- a/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Fri Oct 16 15:56:09 2009 +0200 @@ -55,14 +55,14 @@ 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); + //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((Color)value); return scb; } public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture) diff -r 0fd2b41ab402 -r e940ca798fe3 src/FingersDance/MainSurfaceWindow.xaml.cs --- a/src/FingersDance/MainSurfaceWindow.xaml.cs Fri Oct 16 09:02:04 2009 +0200 +++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Fri Oct 16 15:56:09 2009 +0200 @@ -408,33 +408,33 @@ return; Random c = new Random(); - int color = c.Next(12); + uint color = (uint)c.Next(12) + 1; // for the number to be >0 switch (((UserControlScreen)sender).id) { case 1: - UserControlPivot.ApplyColor(1, "Color_" + color); - Panel1 = new UserControlUserPanel(1, 0xFF5A0FC8, newProject, _mainviewmodel.Session.VideoPath); + UserControlPivot.ApplyColor(1, color); + Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newProject, _mainviewmodel.Session.VideoPath); Panel1.Name = "UserPanel1"; //3-Rajout sur la Grid Root root.Children.Add(Panel1); break; case 2: - UserControlPivot.ApplyColor(2, "Color_" + color); - Panel2 = new UserControlUserPanel(2, 0xFFC80FA0, newProject, _mainviewmodel.Session.VideoPath); + UserControlPivot.ApplyColor(2, color); + Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newProject, _mainviewmodel.Session.VideoPath); Panel2.Name = "UserPanel2"; //3-Rajout sur la Grid Root root.Children.Add(Panel2); break; case 3: - UserControlPivot.ApplyColor(3, "Color_" + color); - Panel3 = new UserControlUserPanel(3, 0xFFFFFF00, newProject, _mainviewmodel.Session.VideoPath); + UserControlPivot.ApplyColor(3, color); + Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newProject, _mainviewmodel.Session.VideoPath); Panel3.Name = "UserPanel3"; //3-Rajout sur la Grid Root root.Children.Add(Panel3); break; case 4: - UserControlPivot.ApplyColor(4, "Color_" + color); - Panel4 = new UserControlUserPanel(4, 0xFF0096FF, newProject, _mainviewmodel.Session.VideoPath); + UserControlPivot.ApplyColor(4, color); + Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newProject, _mainviewmodel.Session.VideoPath); Panel4.Name = "UserPanel4"; //3-Rajout sur la Grid Root root.Children.Add(Panel4); @@ -454,22 +454,22 @@ switch(e.PanelNumber) { case 1: - UserControlPivot.ApplyColor(1, "Default"); + UserControlPivot.ApplyColor(1, 0); root.Children.Remove(Panel1); Panel1 = null; break; case 2: - UserControlPivot.ApplyColor(2, "Default"); + UserControlPivot.ApplyColor(2, 0); root.Children.Remove(Panel2); Panel2 = null; break; case 3: - UserControlPivot.ApplyColor(3, "Default"); + UserControlPivot.ApplyColor(3, 0); root.Children.Remove(Panel3); Panel3 = null; break; case 4: - UserControlPivot.ApplyColor(4, "Default"); + UserControlPivot.ApplyColor(4, 0); root.Children.Remove(Panel4); Panel4 = null; break;