client/src/Iri.Modernisation.Controls/ViewModel/NavigationBar/ConsultMenuVM.cs
author totetm <>
Thu, 11 Feb 2010 17:29:23 +0100
changeset 42 594fdedecf7f
parent 25 a9c815025a1b
permissions -rw-r--r--
Fixed| bouton close sur BookTimeLine Fixed| loading blocker sur les éléments du corpus vidéolivre (book a charger) Fixed| afficher l'état sur on load et loader sur les éléments du corpus vidéolivre ("book a charger") Fixed| bug du title sur book timline Fixed| Actualisation de l'affichage des annotations sur seek de la timline sans play Fixed| Seek possible quand play Fixed| Bug sur le placement tetris ? Fixed| texte par default sur les champs d'annotations

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SLExtensions.Input;
using Iri.Modernisation.BaseMVVM.Commands;
using Iri.Modernisation.BaseMVVM.ViewModel;
using Iri.Modernisation.Data.Models;
using System.Collections.Generic;
using System.Linq;
namespace Iri.Modernisation.Controls.ViewModel
{
    public class ConsultMenuVM : BaseMVVM.ViewModel.ViewModel
    {
        private List<ConsultVideoBookVM> _videoBooks = new List<ConsultVideoBookVM>();
        private List<ConsultVideoBookVM> list = new List<ConsultVideoBookVM>();
        /// <summary>
        /// VideoBooks Disponible
        /// </summary>
        public List<ConsultVideoBookVM> VideoBooks
      {
          get 
          {

              //_videoBooks.Sort(new VideoBookComparer());
              if (SearchWord != String.Empty)
              {
                  return list;
              }
              else
              {
                  return _videoBooks;
              }
          
          }
          set
          {
              list = value;
              OnPropertyChanged("VideoBooks");
          }
      }
      private bool _searchAuthor;
        /// <summary>
        /// Recherche par Auteur activée
        /// </summary>
      public bool SearchAuthor
      {
          get
          {
              return _searchAuthor;
          }
          set
          {
              _searchAuthor = value;
              OnPropertyChanged("SearchAuthor");
          }

      }

      private bool _searchContributer;
        /// <summary>
        /// Recherche par Contributeur activée
        /// </summary>
      public bool SearchContributer
      {
          get
          {
              return _searchContributer;
          }
          set
          {
              _searchContributer = value;
              OnPropertyChanged("SearchContributer");
          }
      }

      private bool _searchTag;
        /// <summary>
        /// Recherche par Tag
        /// </summary>
      public bool SearchTag
      {
          get
          {
              return _searchTag;
          }
          set
          {
              _searchTag = value;
              OnPropertyChanged("SearchTag");
          }
      }

      private String _searchWord= "";
      public String SearchWord 
      { 
          get
          {
              return _searchWord;
          }
          
          set 
          {
              _searchWord = value;
              OnPropertyChanged("SearchWord");
          } 
      }
     
        public ConsultMenuVM()
        {
            SearchAuthor = true;
          InitializeCommands();
        }

        private void InitializeCommands()
        {
           Commands.ConsultMenu.GetBook.Executed += new EventHandler<ExecutedEventArgs>(GetBook_Executed);
         }
        public ConsultMenuVM(List<VideoBook> argList)
        {
            //_videoBooks = argList;
            foreach(VideoBook vb in argList)
            {
                _videoBooks.Add(new ConsultVideoBookVM(vb));
            }
            SearchAuthor = true;
            InitializeCommands();
        }

        

        void GetBook_Executed(object sender, ExecutedEventArgs e)
        {
           
          /* if (SearchAuthor)
            {
                var query = from c in _videoBooks
                            where c.Author.UserName.Contains(_searchWord)
                            select c;
                VideoBooks = query.ToList();
            }
            if (SearchContributer)
            {
                List<VideoBook> temp = new List<VideoBook>();
                foreach (VideoBook Book in _videoBooks)
                {
                    foreach (VideoChapter Chapter in Book.Chapters)
                    {
                        foreach (Annotation Annotation in Chapter.Annotations)
                        {
                            if ( Annotation.Contributer.UserName.Contains(_searchWord))
                            {
                                temp.Add(Book);
                            }
                        }
                    }
                }
                VideoBooks = temp;
            }
            if(SearchTag)
            {
                List<VideoBook> temp = new List<VideoBook>();
                foreach (VideoBook Book in _videoBooks)
                {
                    foreach (VideoChapter Chapter in Book.Chapters)
                    {
                        foreach (Annotation Annotation in Chapter.Annotations)
                        {
                            if (Annotation.Tags.Contains(_searchWord))
                            {
                                temp.Add(Book);
                            }
                        }
                        foreach (SegmentIndex Segment in Chapter.Index)
                        {
                            if (Segment.Tags.Contains(_searchWord))
                            {
                                temp.Add(Book);
                            }
                        }
                    }
                }
                VideoBooks = temp;
            }*/
        }
       
    }
}