client/src/Iri.Modernisation.Controls/ViewModel/AnnotationMaker/AnnotationMakerVM.cs
changeset 34 4d9ebc6fbbe8
parent 30 644e3cd48034
child 35 43bb1b8ed555
equal deleted inserted replaced
33:8a41c4969cc1 34:4d9ebc6fbbe8
    13 using Iri.Modernisation.BaseMVVM.Commands;
    13 using Iri.Modernisation.BaseMVVM.Commands;
    14 using Iri.Modernisation.Data.Models;
    14 using Iri.Modernisation.Data.Models;
    15 using System.Collections.Generic;
    15 using System.Collections.Generic;
    16 using System.Linq;
    16 using System.Linq;
    17 using Iri.Modernisation.Controls.View;
    17 using Iri.Modernisation.Controls.View;
       
    18 using Iri.Modernisation.Data.LDTClass;
    18 namespace Iri.Modernisation.Controls.ViewModel
    19 namespace Iri.Modernisation.Controls.ViewModel
    19 {
    20 {
    20 
    21 
    21     /// <summary>
    22     /// <summary>
    22     /// ViewModel du module d'annotation
    23     /// ViewModel du module d'annotation
    35                 return _refElement;
    36                 return _refElement;
    36             }
    37             }
    37             set
    38             set
    38             {
    39             {
    39                 _refElement = value;
    40                 _refElement = value;
    40 
    41                 if(value!=null)
       
    42                 {
    41                 _newAnnotation = new Annotation(((PolemicElement)value).Chapter);
    43                 _newAnnotation = new Annotation(((PolemicElement)value).Chapter);
    42                
    44                 Title = String.Empty;
       
    45                 Description = String.Empty;
       
    46                 Tags = String.Empty;
       
    47                 SelectedType = FactoryVideoLivre.AnnotationDescriptions[0];
    43                 BasicRelation = new PolemicLink() { FromElement = ((PolemicElement)value), ToElement = _newAnnotation, Type = null};
    48                 BasicRelation = new PolemicLink() { FromElement = ((PolemicElement)value), ToElement = _newAnnotation, Type = null};
    44                 PolemicRelation = new PolemicLink();
    49                 PolemicRelation = new PolemicLink();
    45                 PolemicRelation.FromElement = _newAnnotation;
    50                 PolemicRelation.FromElement = _newAnnotation;
    46                 Begin = ((PolemicElement)value).TimerIn.TotalMilliseconds;
    51                 Begin = ((PolemicElement)value).TimerIn.TotalMilliseconds;
    47                 End = ((PolemicElement)value).TimerOut.TotalMilliseconds;
    52                 End = ((PolemicElement)value).TimerOut.TotalMilliseconds;
       
    53                 }
    48                 OnPropertyChanged(String.Empty);
    54                 OnPropertyChanged(String.Empty);
    49                 //OnPropertyChanged("RefElement");
    55                 //OnPropertyChanged("RefElement");
    50                 //OnPropertyChanged("IsControlEnable");
    56                 //OnPropertyChanged("IsControlEnable");
    51                 
    57                 
    52             }
    58             }
   302 
   308 
   303       
   309       
   304 
   310 
   305         private void OkClickAnnotationMaker_Executed(object sender, ExecutedEventArgs e)
   311         private void OkClickAnnotationMaker_Executed(object sender, ExecutedEventArgs e)
   306         {
   312         {
   307             String message = "Ok clicked "+SelectedType.Title+" \n";
   313             LDTElement newAnnotation = new LDTElement();
   308             message += _begin + "-->" + _end;
   314             newAnnotation.Title = Title;
   309             message += "\n" + Title;
   315             newAnnotation.Abstract = Description;
   310             message += "\n" + Description;
   316             newAnnotation.Begin = Begin;
       
   317             newAnnotation.Dur = End - Begin;
       
   318             newAnnotation.Tags = _tags;
   311             
   319             
   312                 foreach (string tag in _tags)
   320             newAnnotation.Color = int.Parse(_selectedType.Color.A.ToString() + _selectedType.Color.R.ToString() + _selectedType.Color.G.ToString() + _selectedType.Color.B.ToString());
   313                 {
   321            
   314                     message += "\n|-" + tag;
   322             
   315                 }
   323             LDTFile newfile = new LDTFile()
   316 
   324             {
   317                 message += "PolemicLink "+PolemicRelation.Type.Title;
   325                 Medias  = new List<LDTMedia>()
   318             MessageBox.Show(message);
   326                 {
       
   327                     new LDTMedia()
       
   328                     {
       
   329                         Src = _refElement.Chapter.Book.IriPath
       
   330                     }
       
   331                 },
       
   332                 Relations = new List<LDTRelation>()
       
   333                 {
       
   334                     new LDTRelation()
       
   335                     {
       
   336                         IdElementFrom = _basicRelation.FromElement.Id,
       
   337                         IdElementTo = _basicRelation.ToElement.Id,
       
   338                         //Title = _basicRelation.Title
       
   339                     }
       
   340                 },
       
   341                 Annotations = new List<LDTAnnotationsContent>()
       
   342                 {
       
   343                     new LDTAnnotationsContent()
       
   344                     {
       
   345                         Content = new List<LDTAnnotationsDecoupage>()
       
   346                         {
       
   347                             new LDTAnnotationsDecoupage()
       
   348                             {
       
   349                                 Elements = new List<LDTElement>()
       
   350                                 {
       
   351                                     newAnnotation
       
   352                                 }
       
   353                             }
       
   354                         }
       
   355                     }
       
   356                 }
       
   357 
       
   358             };
       
   359             if (this._polemicRelation.ToElement != null)
       
   360             {
       
   361                 LDTRelation polemicRelation = new LDTRelation()
       
   362                 {
       
   363                     IdElementFrom = _polemicRelation.FromElement.Id,
       
   364                     IdElementTo = _polemicRelation.ToElement.Id,
       
   365                     Title = _polemicRelation.Title
       
   366                 };
       
   367                 newfile.Relations.Add(polemicRelation);
       
   368             }
       
   369             MessageBox.Show(newfile.ToString());
       
   370             _refElement = null;
       
   371             OnPropertyChanged("IsControlEnable");
   319         }
   372         }
   320 
   373 
   321         /// <summary>
   374         /// <summary>
   322         /// Constructeur par défaut
   375         /// Constructeur par défaut
   323         /// </summary>
   376         /// </summary>
   354             }
   407             }
   355            
   408            
   356         }
   409         }
   357 
   410 
   358 
   411 
       
   412 
   359     }
   413     }
   360    
   414    
   361 }
   415 }