public MainWindowContext()
        {
            #region Liste GroupedTag

            GroupedTag = new ObservableCollection <GroupedTagViewModel>();

            // Chargement de la liste des GroupedTagViewModel depuis la liste des TagViewModel
            var result = from tag in TagViewModel.GetAll()
                         group tag.Libelle by tag.Libelle
                         into grp
                         select new GroupedTagViewModel
            {
                Libelle    = grp.Key,
                Count      = grp.Count(),
                IsSelected = false,
                Command    = SelectGroupedTagCommand
            };

            result.ToList().ForEach(t => GroupedTag.Add(t));

            if (WPFTools.IsDesignMode)
            {
                GroupedTag.First(gtvm => gtvm.Libelle == "Tag 2").IsSelected = true;
            }

            GroupedTagDisponibles        = new ListCollectionView(GroupedTag);
            GroupedTagDisponibles.Filter = o => !((GroupedTagViewModel)o).IsSelected;

            GroupedTagSelectionner        = new ListCollectionView(GroupedTag);
            GroupedTagSelectionner.Filter = o => ((GroupedTagViewModel)o).IsSelected;

            #endregion Liste GroupedTag

            #region Liste Media correspondant

            MediaCorrespondant = new ObservableCollection <MediaViewModel>();

            // Lors de l'Initialisation aucun GroupedTag n'est selectionne donc aucun Media n'est selectionner

            MediaCorrespondantCollectionView = CollectionViewSource.GetDefaultView(MediaCorrespondant);

            if (MediaCorrespondantCollectionView == null)
            {
                throw new NullReferenceException("'MediaCorrespondantCollectionView' is null in Constructor");
            }

            MediaCorrespondantCollectionView.CurrentChanged += OnMediaCorrespondantCollectionViewCurrentChanged;

            #endregion Liste Media correspondant

            if (GroupedTagDisponibles.Count > 0)
            {
                CalculerRapportInterTagDisponible();
            }
        }
예제 #2
0
        private static void INITIALISER_TAG()
        {
            Guid id28        = MediaViewModel.GetAll().First(d => d.Nom == "28 jours plus tard").ID_Media;
            Guid idMassacre1 = MediaViewModel.GetAll().First(d => d.Nom == "Massacre à la tronçonneuse 1").ID_Media;
            Guid idMassacre2 = MediaViewModel.GetAll().First(d => d.Nom == "Massacre à la tronçonneuse 2").ID_Media;
            Guid idDexter1   = MediaViewModel.GetAll().First(d => d.Nom == "Dexter 1").ID_Media;
            Guid idDexter2   = MediaViewModel.GetAll().First(d => d.Nom == "Dexter 2").ID_Media;
            Guid idMylene1   = MediaViewModel.GetAll().First(d => d.Nom == "Mylene1").ID_Media;

            if (TagViewModel.GetAll().Count == 0)
            {
                TagViewModel tag = new TagViewModel();
                tag.Libelle     = "Horreur";
                tag.FK_ID_Media = id28;
                tag.save();

                tag             = new TagViewModel();
                tag.Libelle     = "Film";
                tag.FK_ID_Media = id28;
                tag.save();


                tag             = new TagViewModel();
                tag.Libelle     = "Trash";
                tag.FK_ID_Media = idMassacre1;
                tag.save();

                tag             = new TagViewModel();
                tag.Libelle     = "Film";
                tag.FK_ID_Media = idMassacre1;
                tag.save();

                tag             = new TagViewModel();
                tag.Libelle     = "Massacre";
                tag.FK_ID_Media = idMassacre1;
                tag.save();


                tag             = new TagViewModel();
                tag.Libelle     = "Trash";
                tag.FK_ID_Media = idMassacre2;
                tag.save();

                tag             = new TagViewModel();
                tag.Libelle     = "Film";
                tag.FK_ID_Media = idMassacre2;
                tag.save();

                tag             = new TagViewModel();
                tag.Libelle     = "Massacre";
                tag.FK_ID_Media = idMassacre2;
                tag.save();

                tag             = new TagViewModel();
                tag.Libelle     = "Dexter";
                tag.FK_ID_Media = idDexter1;
                tag.save();

                tag             = new TagViewModel();
                tag.Libelle     = "Dexter";
                tag.FK_ID_Media = idDexter2;
                tag.save();

                tag             = new TagViewModel();
                tag.Libelle     = "Mylene";
                tag.FK_ID_Media = idMylene1;
                tag.save();
            }
        }