client/src/Iri.Modernisation.Controls/ViewModel/AnnotationMaker/AnnotationMakerVM.cs
changeset 39 0f2bde8fdfeb
parent 38 bd33267300aa
child 42 594fdedecf7f
equal deleted inserted replaced
38:bd33267300aa 39:0f2bde8fdfeb
    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 System.IO;
    18 using Iri.Modernisation.Data.LDTClass;
    19 using Iri.Modernisation.Data.LDTClass;
    19 
       
    20 namespace Iri.Modernisation.Controls.ViewModel
    20 namespace Iri.Modernisation.Controls.ViewModel
    21 {
    21 {
    22 
    22 
    23     /// <summary>
    23     /// <summary>
    24     /// ViewModel du module d'annotation
    24     /// ViewModel du module d'annotation
   320 
   320 
   321         private void OkClickAnnotationMaker_Executed(object sender, ExecutedEventArgs e)
   321         private void OkClickAnnotationMaker_Executed(object sender, ExecutedEventArgs e)
   322         {
   322         {
   323             _newAnnotation.Type = _selectedType ;
   323             _newAnnotation.Type = _selectedType ;
   324             _basicRelation.ToElement = _newAnnotation;
   324             _basicRelation.ToElement = _newAnnotation;
       
   325             _basicRelation.Type = _newAnnotation.Type;
       
   326             _refElement.Chapter.Annotations.Add(_newAnnotation);
       
   327             _refElement.Chapter.Book.BasicLinks.Add(_basicRelation);
       
   328             if(_polemicRelation.ToElement != null)
       
   329             {
       
   330                 _refElement.Chapter.Book.PolemicLinks.Add(_polemicRelation);
       
   331             }
       
   332 
   325             LDTElement newAnnotation = new LDTElement(_newAnnotation);
   333             LDTElement newAnnotation = new LDTElement(_newAnnotation);
   326             
   334             
   327            /* 
   335            /* 
   328             newAnnotation.Title = Title;
   336             newAnnotation.Title = Title;
   329             newAnnotation.Abstract = Description;
   337             newAnnotation.Abstract = Description;
   333             newAnnotation.Color = int.Parse(_selectedType.Color.A.ToString() + _selectedType.Color.R.ToString() + _selectedType.Color.G.ToString() + _selectedType.Color.B.ToString());
   341             newAnnotation.Color = int.Parse(_selectedType.Color.A.ToString() + _selectedType.Color.R.ToString() + _selectedType.Color.G.ToString() + _selectedType.Color.B.ToString());
   334            */
   342            */
   335             
   343             
   336             LDTFile newfile = new LDTFile()
   344             LDTFile newfile = new LDTFile()
   337             {
   345             {
       
   346                
   338                 Medias  = new List<LDTMedia>()
   347                 Medias  = new List<LDTMedia>()
   339                 {
   348                 {
   340                     new LDTMedia()
   349                     new LDTMedia()
   341                     {
   350                     {
   342                         Src = _refElement.Chapter.Book.IriPath
   351                         Src = _refElement.Chapter.Book.IriPath
   343                     }
   352                     }
   344                 },
   353                 },
   345                 Relations = new List<LDTRelation>()
   354                 BasicRelations = new List<LDTRelation>()
   346                 {
   355                 {
   347                     new LDTRelation()
   356                     new LDTRelation()
   348                     {
   357                     {
   349                         IdElementFrom = _basicRelation.FromElement.Id,
   358                         IdElementFrom = _basicRelation.FromElement.Id,
   350                         IdElementTo = _basicRelation.ToElement.Id,
   359                         IdElementTo = _basicRelation.ToElement.Id,
   351                         //Title = _basicRelation.Title
   360                         //Title = _basicRelation.Title
   352                     }
   361                     }
   353                 },
   362                 },
       
   363 
   354                 Annotations = new List<LDTAnnotationsContent>()
   364                 Annotations = new List<LDTAnnotationsContent>()
   355                 {
   365                 {
   356                     new LDTAnnotationsContent()
   366                     new LDTAnnotationsContent()
   357                     {
   367                     {
   358                         Content = new List<LDTAnnotationsDecoupage>()
   368                         Content = new List<LDTAnnotationsDecoupage>()
   375                 {
   385                 {
   376                     IdElementFrom = _polemicRelation.FromElement.Id,
   386                     IdElementFrom = _polemicRelation.FromElement.Id,
   377                     IdElementTo = _polemicRelation.ToElement.Id,
   387                     IdElementTo = _polemicRelation.ToElement.Id,
   378                     Title = _polemicRelation.Title
   388                     Title = _polemicRelation.Title
   379                 };
   389                 };
   380                 newfile.Relations.Add(polemicRelation);
   390                 newfile.BasicRelations.Add(polemicRelation);
   381             }
   391             }
       
   392 
       
   393 
   382             //MessageBox.Show(newfile.ToString());
   394             //MessageBox.Show(newfile.ToString());
   383            
   395 
   384             /** HttpSend For Web Mode **/
   396             /* HttpSend For Web Mode */
   385            /* Application app = Application.Current as Application;
   397             Application app = Application.Current as Application;
   386             HttpSender helper = new HttpSender(new Uri("http://mtotet.free.fr/TestHttpSender/index.php"), "POST",
   398             HttpSender helper = new HttpSender(new Uri(FactoryVideoLivre.UpdateBookService, UriKind.RelativeOrAbsolute), "POST",
   387                 new KeyValuePair<string, string>("authKey", "123456" ),
   399                 new KeyValuePair<string, string>("newAnnotation",System.Windows.Browser.HttpUtility.UrlEncode(
   388                 new KeyValuePair<string, string>("newAnnotation", newfile.ToString()),
   400                                                                     System.Windows.Browser.HttpUtility.HtmlEncode(
   389                 new KeyValuePair<string, string>("msg", "303"));
   401                                                                         _refElement.Chapter.Book.GetLDTFile().ToString())
       
   402                                                     )),
       
   403                 new KeyValuePair<String,String>("ldtFileURI",_refElement.Chapter.Book.LdtPath));
   390             helper.ResponseComplete += new HttpResponseCompleteEventHandler(helper_ResponseComplete);
   404             helper.ResponseComplete += new HttpResponseCompleteEventHandler(helper_ResponseComplete);
   391             helper.Execute();*/
   405             helper.Execute();
       
   406              
       
   407         
       
   408           /*  HttpSendHelper hsh = new HttpSendHelper("POST", FactoryVideoLivre.UpdateBookService,
       
   409                 new Dictionary<String, String> { 
       
   410                                                    { "ldtIs", "world" },
       
   411                                                    {"AnnotationLdtFile",newfile.ToString()} 
       
   412                                                 });
       
   413             hsh.Execute();*/
       
   414 
   392 
   415 
   393         /** Local Mode **/
   416         /** Local Mode **/
   394             Commands.AnnotationMaker.NewAnnotationFinished.Execute(_newAnnotation,_refElement);
   417             Commands.AnnotationMaker.NewAnnotationFinished.Execute(_newAnnotation,_refElement);
   395 
   418 
   396             /********/
   419             /********/
   398 
   421 
   399             _refElement = null;
   422             _refElement = null;
   400             OnPropertyChanged("IsControlEnable");
   423             OnPropertyChanged("IsControlEnable");
   401            
   424            
   402         }
   425         }
   403 
   426         
   404         private String _sendAnnotationResponse;
   427         private String _sendAnnotationResponse;
   405         public String SendAnnotationResponse
   428         public String SendAnnotationResponse
   406         {
   429         {
   407             get
   430             get
   408             {
   431             {