public AlbumEditorViewModel(IMusicSession iMusicSession, IModifiableAlbum iModifiableAlbum)
        {
            _IModifiableAlbum = iModifiableAlbum;
            _Session = iMusicSession;

            ArtistSearchableFactory = new ArtistSearchableFactory(iMusicSession);

            GenreFactory = FactoryBuilder.Instanciate((n) => iMusicSession.GetGenreFactory().Create(n));

            Images = _IModifiableAlbum.Images;
            SelectedImages = new WrappedObservableCollection<IAlbumPicture>();
            

            if (Images.Count > 0)
                SelectedImage = Images[0];

            Images.CollectionChanged += Images_CollectionChanged;
                
            SelectedTracks = new WrappedObservableCollection<IModifiableTrack>();

            Authours = _IModifiableAlbum.Artists;
            _Genre = iMusicSession.GetGenreFactory().Get(_IModifiableAlbum.Genre);
            Genres = Register(iMusicSession.AllGenres.LiveOrderBy(global => global.FullName));

            Tracks = new WrappedObservableCollection<IModifiableTrack>(_IModifiableAlbum.Tracks.
                OrderBy(t => t.DiscNumber).ThenBy(t => t.TrackNumber).ThenBy(t => t.Name));

            SetFrontCover = Register(RelayCommand.Instanciate<IAlbumPicture>(SetToFront, ial => (ial != null) && Images.IndexOf(ial) > 0));
            ToLast = Register(RelayCommand.Instanciate<IAlbumPicture>(SetToLast, ial => (ial != null) && Images.IndexOf(ial) != Images.Count - 1));

            SplitImage = Register(RelayCommand.Instanciate<IAlbumPicture>(DoSplitImage, ial => ial != null));
            RotateImageRight = Register(RelayCommand.Instanciate<IAlbumPicture>((al)=>DoRotateImage(al,true), ial => ial != null));
            RotateImageLeft = Register(RelayCommand.Instanciate<IAlbumPicture>((al) => DoRotateImage(al, false), ial => ial != null));
            DeleteImage = Register(RelayCommand.Instanciate<IAlbumPicture>(DoDeleteImage, ial => ial != null));
            ImageFromFile = RelayCommand.Instanciate(DoImageFromFile);
            PasteImage = RelayCommand.InstanciateStatic(DoPasteImage, CanExecuteImage);

            DeleteTrack = Register(RelayCommand.Instanciate<IModifiableTrack>(DoDeleteTrack, ial => ial != null));
            WindowOpenTrack = Register(RelayCommand.Instanciate<IModifiableTrack>(DoWindowOpenTrack, ial => ial != null));
            UpdateFromFileName = Register(RelayCommand.Instanciate<IModifiableTrack>(DoUpdateFromFileName, ial => ial != null));
            RemoveTrackNumber= Register(RelayCommand.Instanciate<IModifiableTrack>(DoRemoveTrackNumber, ial => ial != null));
            PreFixByArtistName = Register(RelayCommand.Instanciate<IModifiableTrack>(DoPreFixByArtistName, ial => ial != null));
            ChangeDiscNumber = Register(RelayCommand.Instanciate<IModifiableTrack>(DoChangeDiscNumber, ial => ial != null));

            FindFromDB = RelayCommand.Instanciate(DoFindFromInternet);
            BrowseInternet = RelayCommand.Instanciate(FindOnInternet);
            OK = RelayCommand.Instanciate(DoCommit);
        }
        public CDAlbumDescriptorCreatorViewModel(AmbigueousCDInformationArgs cadi, IMusicSession session)
        {
            _CADI = cadi;
            _Session = session;

            _CDInfos.AddCollection(_CADI.CDInfos);

            _Authours = new ObservableCollection<IArtist>();
            _Authours.CollectionChanged += _Authours_CollectionChanged;

            if (CDInfos.Count == 0)
            {
                Created = Default.GetEditable();
            }
            else if (CDInfos.Count == 1)
            {
                Created = CDInfos[0].FindItem.GetEditable();
            }

            _ArtistSearchableFactory = new ArtistSearchableFactory(_Session);  
            
            GenreFactory = FactoryBuilder.Instanciate((n) => _Session.GetGenreFactory().Create(n));

            CommitCommand = RelayCommand.Instanciate(() => OnCommintCommand());

            InternetFind = RelayCommand.InstanciateAsync(() => FindAdditionalInfoFromWebAsync());

            iTunesFind = RelayCommand.InstanciateAsync(() => FindAdditionalInfoFromiTunesAsync());
        }
 private MusicEntitiesEditorViewModel(IMusicSession session)
 {
     _IMS = session;
     ArtistSearchableFactory = new ArtistSearchableFactory(session);
     
     Genres = Register( _IMS.AllGenres.LiveOrderBy(global => global.FullName));
     Commit = RelayCommand.Instanciate(DoCommit);
     GenreFactory = FactoryBuilder.Instanciate((n) => session.GetGenreFactory().Create(n));
     YearFactory = FactoryBuilder.Instanciate((n) => { int res = 0; int.TryParse(n, out res); return res; });
     NameFactory = FactoryBuilder.Instanciate((n) => n);
 }