--- a/src/FingersDance.ActionFactory/ColorFactory.cs Tue Nov 24 14:52:49 2009 +0100
+++ b/src/FingersDance.ActionFactory/ColorFactory.cs Wed Nov 25 10:48:46 2009 +0100
@@ -11,6 +11,7 @@
static Dictionary<uint, string> _ColorsStringId;
static Dictionary<uint, Color> _Colors;
+ static Dictionary<uint, Color> _ColorsOrig;
public Dictionary<uint, string> ColorsStringId
{
@@ -20,15 +21,24 @@
{
get { return _Colors; }
}
+ public Dictionary<uint, Color> ColorsOrig
+ {
+ get { return _ColorsOrig; }
+ }
public ColorFactory()
{
+ init();
+ }
+
+ private static void init()
+ {
if (_ColorsStringId == null)
{
_ColorsStringId = new Dictionary<uint, string>();
- _ColorsStringId.Add(0, "DefaultColor_xaml");
+ //_ColorsStringId.Add(0, "DefaultColor_xaml");
_ColorsStringId.Add(1, "Color_1_#FFFF00_xaml");
- _ColorsStringId.Add(2, "Color_2_#FFC800_xaml");
+ _ColorsStringId.Add(2, "Color_12_#00C800_xaml");
_ColorsStringId.Add(3, "Color_3_#FF7D00__xaml");
_ColorsStringId.Add(4, "Color_4_#FF0000_xaml");
_ColorsStringId.Add(5, "Color_5_#FF0064_xaml");
@@ -38,7 +48,7 @@
_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");
+ _ColorsStringId.Add(12, "Color_2_#FFC800_xaml");
}
if (_Colors == null)
@@ -46,7 +56,7 @@
_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(2, Color.FromRgb(0x00, 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));
@@ -56,8 +66,60 @@
_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));
+ _Colors.Add(12, Color.FromRgb(0xFF, 0xC8, 0x00));
+
+ _ColorsOrig = new Dictionary<uint, Color>();
+ _ColorsOrig.Add(0, Color.FromRgb(0x88, 0x88, 0x88));
+ _ColorsOrig.Add(1, Color.FromRgb(0xFF, 0xFF, 0x00));
+ _ColorsOrig.Add(2, Color.FromRgb(0x00, 0xC8, 0x00));
+ _ColorsOrig.Add(3, Color.FromRgb(0xFF, 0x7D, 0x00));
+ _ColorsOrig.Add(4, Color.FromRgb(0xFF, 0x00, 0x00));
+ _ColorsOrig.Add(5, Color.FromRgb(0xFF, 0x00, 0x64));
+ _ColorsOrig.Add(6, Color.FromRgb(0xC8, 0x0F, 0xA0));
+ _ColorsOrig.Add(7, Color.FromRgb(0x5A, 0x0F, 0xC8));
+ _ColorsOrig.Add(8, Color.FromRgb(0x23, 0x0F, 0xD2));
+ _ColorsOrig.Add(9, Color.FromRgb(0x00, 0x96, 0xFF));
+ _ColorsOrig.Add(10, Color.FromRgb(0x00, 0x96, 0x64));
+ _ColorsOrig.Add(11, Color.FromRgb(0x00, 0x64, 0x32));
+ _ColorsOrig.Add(12, Color.FromRgb(0xFF, 0xC8, 0x00));
}
}
+
+ public static void TakeOffColor(Color col)
+ {
+ init();
+ foreach(KeyValuePair<uint,Color> kvp in _Colors)
+ {
+ if (_Colors[kvp.Key] == col)
+ {
+ _Colors.Remove(kvp.Key);
+ return;
+ }
+ }
+ }
+
+ public static KeyValuePair<uint,Color> getAvailablePairUintColor()
+ {
+ init();
+ foreach(KeyValuePair<uint,Color> kvp in _Colors)
+ {
+ if (kvp.Value != Color.FromRgb(0x88, 0x88, 0x88))
+ return kvp;
+ }
+ return new KeyValuePair<uint,Color>();
+ }
+
+ public static uint getId(Color col)
+ {
+ init();
+ foreach (KeyValuePair<uint, Color> kvp in _ColorsOrig)
+ {
+ if (_ColorsOrig[kvp.Key] == col)
+ {
+ return kvp.Key;
+ }
+ }
+ return 0;
+ }
}
}
--- a/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs Tue Nov 24 14:52:49 2009 +0100
+++ b/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs Wed Nov 25 10:48:46 2009 +0100
@@ -118,20 +118,20 @@
{
try
{
- // We get all the ldt/project files from the current directory...
- List<String> existingProjects = new List<String>();
- String path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
- String ext = ".ldt";
- foreach (String filename in Directory.GetFiles(path))
- {
- if (filename.Substring(filename.Length-4).ToLower()==ext)
- existingProjects.Add(filename.Substring(path.Length + 1, filename.Length - ext.Length - path.Length - 1));
- }
- // ... and display them the the select box UserControlListProject
- UserControlListProject listProject = new UserControlListProject(existingProjects, AnnotationOrSearchMode);
- listProject.Name = "ListProject";
- LayoutRoot.Children.Add(listProject);
- listProject.EH_ListProject_ContactDown += new EventHandler(listProject_EH_ListProject_ContactDown);
+ // We get all the ldt/project files from the current directory...
+ List<String> existingProjects = new List<String>();
+ String path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
+ String ext = ".ldt";
+ foreach (String filename in Directory.GetFiles(path))
+ {
+ if (filename.Substring(filename.Length-4).ToLower()==ext)
+ existingProjects.Add(filename.Substring(path.Length + 1, filename.Length - ext.Length - path.Length - 1));
+ }
+ // ... and display them the the select box UserControlListProject
+ UserControlListProject listProject = new UserControlListProject(existingProjects, AnnotationOrSearchMode);
+ listProject.Name = "ListProject";
+ LayoutRoot.Children.Add(listProject);
+ listProject.EH_ListProject_ContactDown += new EventHandler(listProject_EH_ListProject_ContactDown);
}
catch (Exception)
{
@@ -143,8 +143,8 @@
void listProject_EH_ListProject_ContactDown(object sender, EventArgs e)
{
- try
- {
+ //try
+ //{
LayoutRoot.Children.Remove((UserControlListProject)sender);
if (((UserControlListProject)sender).SelectedItem.Equals("New Project"))
{
@@ -185,7 +185,15 @@
la.Add(Annotation);
Data.AddAnnotation(Annotation);
}
- loadedProject.Cuttings.Add(new Cutting(cuttingNode.Attribute("id").Value,cuttingNode.Element("title").Value,la));
+ String cutColorString = cuttingNode.Attribute("color").Value; // is type 0xRRGGBB
+ Byte rCut = Convert.ToByte(cutColorString.Substring(2, 2), 16);
+ Byte gCut = Convert.ToByte(cutColorString.Substring(4, 2), 16);
+ Byte bCut = Convert.ToByte(cutColorString.Substring(6, 2), 16);
+ Color cCut = Color.FromRgb(rCut, gCut, bCut);
+ // We take off the loaded color from the reference color list.
+ ColorFactory.TakeOffColor(cCut);
+ // We add the cutting to the loaded project
+ loadedProject.Cuttings.Add(new Cutting(cuttingNode.Attribute("id").Value, cuttingNode.Element("title").Value, la, cCut));
}
// We define the loaded project as the current session's project in annotation mode or the searched project in search mode
if (AnnotationOrSearchMode == "Annotation")
@@ -194,13 +202,13 @@
SearchedProject = loadedProject;
OpenProject();
}
- }
- catch (Exception)
- {
- Cutting = null;
- if (UC_Screen_NewCutting != null)
- UC_Screen_NewCutting(this, new EventArgs());
- }
+ //}
+ //catch (Exception)
+ //{
+ // Cutting = null;
+ // if (UC_Screen_NewCutting != null)
+ // UC_Screen_NewCutting(this, new EventArgs());
+ //}
}
private void ProjectInput_EH_NewProjectForm_ContactDown(object sender, EventArgs e)
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs Tue Nov 24 14:52:49 2009 +0100
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs Wed Nov 25 10:48:46 2009 +0100
@@ -33,13 +33,13 @@
// Insert code required on object creation below this point.
}
- public void Load(string path, Color col, Cutting cut, String AnnotOrSearchMode, Project searchedProj)
+ public void Load(string path, Cutting cut, String AnnotOrSearchMode, Project searchedProj)
{
this.UserControlPlayer.initPlayer(path);
AnnotationOrSearchMode = AnnotOrSearchMode;
searchedProject = searchedProj;
//Initialisation du Timer
- UCTimeLine.initTimer(col, cut);
+ UCTimeLine.initTimer(cut);
UserControlPlayer.playerPlay();
userControlTimeLine.OnSuccessAnnotation += new EventHandler(userControlTimeLine_OnSuccessAnnotation);
userControlTimeLine.AnnotationAdded += new EventHandler(userControlTimeLine_AnnotationAdded);
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Tue Nov 24 14:52:49 2009 +0100
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Wed Nov 25 10:48:46 2009 +0100
@@ -139,13 +139,14 @@
}
#region Timer
- public void initTimer(Color col, Cutting cutPar)
+ public void initTimer(Cutting cutPar)
{
timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
timer.Tick += new EventHandler(timer_Tick);
- CurrentColor = col;
+ if(cutPar!=null)
+ CurrentColor = cutPar.Color;
// DATA BINDING from the cutting sent in parameter (initialised before by the userPanel with the global project)
cut = cutPar;
--- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs Tue Nov 24 14:52:49 2009 +0100
+++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs Wed Nov 25 10:48:46 2009 +0100
@@ -54,13 +54,13 @@
// Insert code required on object creation below this point.
}
- public UserControlUserPanel(int idPar, Color col, Cutting cutPar, String path, String AnnotationOrSearchMode, Project searchedProj)
+ public UserControlUserPanel(int idPar, Cutting cutPar, String path, String AnnotationOrSearchMode, Project searchedProj)
{
this.InitializeComponent();
id = idPar;
cut = cutPar;
// We make the syncsrc load the good video and cutting
- this.UserControlSyncSource.Load(path, col, cut, AnnotationOrSearchMode, searchedProj);
+ this.UserControlSyncSource.Load(path, cut, AnnotationOrSearchMode, searchedProj);
UserControlSyncSource.OnSuccessAnnotation += new EventHandler(UserControlSyncSource_OnSuccessAnnotation);
// We make the menu load the good xml
UCMenu.MenuXmlFile = (AnnotationOrSearchMode == "Search") ? "menu_search.xml" : "menu.xml";
--- a/src/FingersDance.Data/Cutting.cs Tue Nov 24 14:52:49 2009 +0100
+++ b/src/FingersDance.Data/Cutting.cs Wed Nov 25 10:48:46 2009 +0100
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Windows.Media;
namespace FingersDance.Data
{
@@ -9,8 +10,16 @@
{
private String _id;
private List<Annotation> _annotList;
- private string _title;
+ private String _title;
+ private Color _color;
+ public Cutting(String idPar, String titlePar, List<Annotation> annotListPar, Color col)
+ {
+ this._id = idPar;
+ this._title = titlePar;
+ this._annotList = annotListPar;
+ this._color = col;
+ }
public Cutting(String idPar, String titlePar, List<Annotation> annotListPar)
{
this._id = idPar;
@@ -48,6 +57,16 @@
_annotList = value;
}
}
+ public Color Color
+ {
+ get { return _color; }
+ set
+ {
+ if (value == _color)
+ return;
+ _color = value;
+ }
+ }
}
}
--- a/src/FingersDance.ViewModel/CuttingViewModel.cs Tue Nov 24 14:52:49 2009 +0100
+++ b/src/FingersDance.ViewModel/CuttingViewModel.cs Wed Nov 25 10:48:46 2009 +0100
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Windows.Media;
using FingersDance.Data;
@@ -81,6 +82,17 @@
base.OnPropertyChanged("AnnotList");
}
}
+ public Color Color
+ {
+ get { return cut.Color; }
+ set
+ {
+ if (value == cut.Color)
+ return;
+ cut.Color = value;
+ base.OnPropertyChanged("Title");
+ }
+ }
public void setListFromAnnotations(List<Annotation> annotList, float annotWidth, Double scaleX)
{
--- a/src/FingersDance/MainSurfaceWindow.xaml.cs Tue Nov 24 14:52:49 2009 +0100
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Wed Nov 25 10:48:46 2009 +0100
@@ -467,6 +467,7 @@
{
//2-Creation du User Panel
Cutting newCutting = ((UserControlScreen)sender).Cutting;
+ uint UintIdColor = 0;
// We test if each Panel does not already own the sent cuttingVM
if (((UserControlScreen)sender).Cutting != null && ((UserControlScreen)sender).AnnotationOrSearchMode == "Annotation")
@@ -493,51 +494,58 @@
{
_mainviewmodel.Project.Cuttings.Add(newCutting);
_mainviewmodel.Project.CuttingsDict.Add(newCutting.Title, newCutting);
+ // In this case, we have to find a new color in the available ones.
+ KeyValuePair<uint,Color> kvp = ColorFactory.getAvailablePairUintColor();
+ newCutting.Color = kvp.Value;
+ UintIdColor = kvp.Key;
+ // Now we can take off this new color from the available colors
+ ColorFactory.TakeOffColor(kvp.Value);
+ }
+ else{
+ // If the color
+ UintIdColor = ColorFactory.getId(newCutting.Color);
}
}
-
// And now we build the new UserPanel
- Random c = new Random();
- uint color = (uint)c.Next(12) + 1; // for the number to be >0
switch (((UserControlScreen)sender).id)
{
case 1:
- UserControlPivot.ApplyColor(1, color);
- Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode, ((UserControlScreen)sender).SearchedProject);
+ UserControlPivot.ApplyColor(1, UintIdColor);
+ Panel1 = new UserControlUserPanel(1, newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode, ((UserControlScreen)sender).SearchedProject);
Panel1.Name = "UserPanel1";
Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
Panel1.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
- Panel1.idcolor = color;
+ Panel1.idcolor = UintIdColor;
//3-Rajout sur la Grid Root
root.Children.Add(Panel1);
break;
case 2:
- UserControlPivot.ApplyColor(2, color);
- Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode, ((UserControlScreen)sender).SearchedProject);
+ UserControlPivot.ApplyColor(2, UintIdColor);
+ Panel2 = new UserControlUserPanel(2, newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode, ((UserControlScreen)sender).SearchedProject);
Panel2.Name = "UserPanel2";
Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
Panel2.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
- Panel2.idcolor = color;
+ Panel2.idcolor = UintIdColor;
//3-Rajout sur la Grid Root
root.Children.Add(Panel2);
break;
case 3:
- UserControlPivot.ApplyColor(3, color);
- Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode, ((UserControlScreen)sender).SearchedProject);
+ UserControlPivot.ApplyColor(3, UintIdColor);
+ Panel3 = new UserControlUserPanel(3, newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode, ((UserControlScreen)sender).SearchedProject);
Panel3.Name = "UserPanel3";
Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
Panel3.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
- Panel3.idcolor = color;
+ Panel3.idcolor = UintIdColor;
//3-Rajout sur la Grid Root
root.Children.Add(Panel3);
break;
case 4:
- UserControlPivot.ApplyColor(4, color);
- Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode, ((UserControlScreen)sender).SearchedProject);
+ UserControlPivot.ApplyColor(4, UintIdColor);
+ Panel4 = new UserControlUserPanel(4, newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode, ((UserControlScreen)sender).SearchedProject);
Panel4.Name = "UserPanel4";
Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
Panel4.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
- Panel4.idcolor = color;
+ Panel4.idcolor = UintIdColor;
//3-Rajout sur la Grid Root
root.Children.Add(Panel4);
break;
@@ -633,9 +641,9 @@
XElement annotContent = (XElement)(d.Root.Elements().ToList()[2]).FirstNode;
foreach (Cutting cut in _mainviewmodel.Project.Cuttings)
{
- XElement cutNode = new XElement("decoupage", new XAttribute("id", cut.Id), new XAttribute("author", "perso"),
- new XElement("title",cut.Title),
- new XElement("abstract",""));
+ XElement cutNode = new XElement("decoupage", new XAttribute("id", cut.Id), new XAttribute("author", "perso"), new XAttribute("color", "0x" + cut.Color.ToString().Substring(3)), // Color.ToString() return #AARRGGBB and we keep only 0xRRGGBB);
+ new XElement("title", cut.Title),
+ new XElement("abstract", ""));
XElement cutElmts = new XElement("elements");
cutNode.Add(cutElmts);
foreach (Annotation annot in cut.AnnotList)