client/src/Iri.Modernisation.Controls/ViewModel/AnnotationMaker/AnnotationMakerVM.cs
changeset 34 4d9ebc6fbbe8
parent 30 644e3cd48034
child 35 43bb1b8ed555
--- a/client/src/Iri.Modernisation.Controls/ViewModel/AnnotationMaker/AnnotationMakerVM.cs	Tue Jan 19 09:49:26 2010 +0100
+++ b/client/src/Iri.Modernisation.Controls/ViewModel/AnnotationMaker/AnnotationMakerVM.cs	Tue Jan 19 09:49:56 2010 +0100
@@ -15,6 +15,7 @@
 using System.Collections.Generic;
 using System.Linq;
 using Iri.Modernisation.Controls.View;
+using Iri.Modernisation.Data.LDTClass;
 namespace Iri.Modernisation.Controls.ViewModel
 {
 
@@ -37,14 +38,19 @@
             set
             {
                 _refElement = value;
-
+                if(value!=null)
+                {
                 _newAnnotation = new Annotation(((PolemicElement)value).Chapter);
-               
+                Title = String.Empty;
+                Description = String.Empty;
+                Tags = String.Empty;
+                SelectedType = FactoryVideoLivre.AnnotationDescriptions[0];
                 BasicRelation = new PolemicLink() { FromElement = ((PolemicElement)value), ToElement = _newAnnotation, Type = null};
                 PolemicRelation = new PolemicLink();
                 PolemicRelation.FromElement = _newAnnotation;
                 Begin = ((PolemicElement)value).TimerIn.TotalMilliseconds;
                 End = ((PolemicElement)value).TimerOut.TotalMilliseconds;
+                }
                 OnPropertyChanged(String.Empty);
                 //OnPropertyChanged("RefElement");
                 //OnPropertyChanged("IsControlEnable");
@@ -304,18 +310,65 @@
 
         private void OkClickAnnotationMaker_Executed(object sender, ExecutedEventArgs e)
         {
-            String message = "Ok clicked "+SelectedType.Title+" \n";
-            message += _begin + "-->" + _end;
-            message += "\n" + Title;
-            message += "\n" + Description;
+            LDTElement newAnnotation = new LDTElement();
+            newAnnotation.Title = Title;
+            newAnnotation.Abstract = Description;
+            newAnnotation.Begin = Begin;
+            newAnnotation.Dur = End - Begin;
+            newAnnotation.Tags = _tags;
+            
+            newAnnotation.Color = int.Parse(_selectedType.Color.A.ToString() + _selectedType.Color.R.ToString() + _selectedType.Color.G.ToString() + _selectedType.Color.B.ToString());
+           
             
-                foreach (string tag in _tags)
+            LDTFile newfile = new LDTFile()
+            {
+                Medias  = new List<LDTMedia>()
+                {
+                    new LDTMedia()
+                    {
+                        Src = _refElement.Chapter.Book.IriPath
+                    }
+                },
+                Relations = new List<LDTRelation>()
                 {
-                    message += "\n|-" + tag;
+                    new LDTRelation()
+                    {
+                        IdElementFrom = _basicRelation.FromElement.Id,
+                        IdElementTo = _basicRelation.ToElement.Id,
+                        //Title = _basicRelation.Title
+                    }
+                },
+                Annotations = new List<LDTAnnotationsContent>()
+                {
+                    new LDTAnnotationsContent()
+                    {
+                        Content = new List<LDTAnnotationsDecoupage>()
+                        {
+                            new LDTAnnotationsDecoupage()
+                            {
+                                Elements = new List<LDTElement>()
+                                {
+                                    newAnnotation
+                                }
+                            }
+                        }
+                    }
                 }
 
-                message += "PolemicLink "+PolemicRelation.Type.Title;
-            MessageBox.Show(message);
+            };
+            if (this._polemicRelation.ToElement != null)
+            {
+                LDTRelation polemicRelation = new LDTRelation()
+                {
+                    IdElementFrom = _polemicRelation.FromElement.Id,
+                    IdElementTo = _polemicRelation.ToElement.Id,
+                    Title = _polemicRelation.Title
+                };
+                newfile.Relations.Add(polemicRelation);
+            }
+            MessageBox.Show(newfile.ToString());
+            _refElement = null;
+            OnPropertyChanged("IsControlEnable");
         }
 
         /// <summary>
@@ -356,6 +409,7 @@
         }
 
 
+
     }
    
 }