Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
authorcavaliet
Fri, 16 Oct 2009 15:56:09 +0200
changeset 160 e940ca798fe3
parent 157 0fd2b41ab402
child 161 643d31851d02
Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
src/FingersDance.ActionFactory/ColorFactory.cs
src/FingersDance.ActionFactory/FingersDance.Factory.csproj
src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs
src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj
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.Data/FingersDance.Data.csproj
src/FingersDance.ViewModel/AnnotationViewModel.cs
src/FingersDance.ViewModel/FingersDance.ViewModels.csproj
src/FingersDance.Views/TimelineAnnotationView.xaml.cs
src/FingersDance/MainSurfaceWindow.xaml.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<string, string> _Colors;
+
+        static Dictionary<uint, string> _ColorsStringId;
+        static Dictionary<uint, Color> _Colors;
 
-        public Dictionary<string, string> Colors
+        public Dictionary<uint, string> ColorsStringId
+        {
+            get { return _ColorsStringId; }
+        }
+        public Dictionary<uint, Color> Colors
         {
             get { return _Colors; }
         }
 
         public ColorFactory()
         {
+            if (_ColorsStringId == null)
+            {
+                _ColorsStringId = new Dictionary<uint, string>();
+                _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<string, string>();
-                _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<uint, Color>();
+                _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));
             }
         }
     }
--- 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 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
+    <ProductVersion>9.0.30729</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{C7B905EA-0678-4DA0-8EF8-7F9CBD22818E}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -51,6 +51,9 @@
     <ErrorReport>prompt</ErrorReport>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="PresentationCore">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core">
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -63,6 +66,9 @@
     </Reference>
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
+    <Reference Include="WindowsBase">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ActionFactory.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;
                 }
 
--- 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 @@
       <Project>{2BCEE1BF-D3AC-478C-A26B-DFDB7420E965}</Project>
       <Name>FingersDance.Control.TimeLine</Name>
     </ProjectReference>
+    <ProjectReference Include="..\FingersDance.Data\FingersDance.Data.csproj">
+      <Project>{EAF384DB-2AE4-4132-839D-60F9DAFDEAD8}</Project>
+      <Name>FingersDance.Data</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
--- 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();
         }
 
--- 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<Annotation> AnnotList = new List<Annotation>();
         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<Annotation>();
-            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<Annotation>();
+            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)
             {
--- 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()
--- 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<AnnotationAddedEventArg> 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
--- 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 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
+    <ProductVersion>9.0.30729</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{EAF384DB-2AE4-4132-839D-60F9DAFDEAD8}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -33,6 +33,9 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="PresentationCore">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core">
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -46,8 +49,10 @@
     <Reference Include="System.Data" />
     <Reference Include="System.Deployment" />
     <Reference Include="System.Drawing" />
-    <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
+    <Reference Include="WindowsBase">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Annotation.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
--- 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 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
+    <ProductVersion>9.0.30729</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{E81BB080-0598-43AC-90CE-54D6570C4E9E}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -53,6 +53,9 @@
     <ErrorReport>prompt</ErrorReport>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="PresentationCore">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core">
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -66,8 +69,10 @@
     <Reference Include="System.Data" />
     <Reference Include="System.Deployment" />
     <Reference Include="System.Drawing" />
-    <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
+    <Reference Include="WindowsBase">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AnnotationViewModel.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)
--- 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;