--- a/src/FingersDance/MainSurfaceWindow.xaml.cs Tue Nov 24 12:57:18 2009 +0100
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Tue Nov 24 22:08:57 2009 +0100
@@ -462,6 +462,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")
@@ -488,51 +489,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;
@@ -628,9 +636,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)