コード例 #1
0
 public SearchAllResultsViewModel(IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, string keyword, IEnumerable <SynoTrack> lastResults, ITrackViewModelFactory trackViewModelFactory)
 {
     _eventAggregator       = eventAggregator;
     _pageSwitchingService  = pageSwitchingService;
     _trackViewModelFactory = trackViewModelFactory;
     if (pageSwitchingService == null)
     {
         throw new ArgumentNullException("pageSwitchingService");
     }
     if (keyword == null)
     {
         throw new ArgumentNullException("keyword");
     }
     if (lastResults == null)
     {
         throw new ArgumentNullException("lastResults");
     }
     if (trackViewModelFactory == null)
     {
         throw new ArgumentNullException("trackViewModelFactory");
     }
     ShowPlayQueueCommand = new DelegateCommand(OnShowPlayQueue);
     PlayLastCommand      = new DelegateCommand(OnPlayLast);
     Keyword       = keyword;
     SearchResults = new ObservableCollection <TrackViewModel>();
     foreach (var lastResult in lastResults)
     {
         // GUIDS will be generated later when / if inserted in the playqueue.
         SearchResults.Add(this._trackViewModelFactory.Create(Guid.Empty, lastResult, this._pageSwitchingService));
     }
 }
コード例 #2
0
ファイル: TrackViewModel.cs プロジェクト: salfab/open-syno
        public TrackViewModel(Guid guid, SynoTrack synoTrack, IPageSwitchingService pageSwitchingService, AlbumViewModelFactory albumViewModelFactory, IAudioStationSession session, IUrlParameterToObjectsPlateHeater urlParameterToObjectsPlateHeater, ITrackViewModelFactory trackViewModelFactory, INotificationService notificationService)
        {
            if (synoTrack == null)
            {
                throw new ArgumentNullException("synoTrack");
            }

            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            _trackViewModelFactory = trackViewModelFactory;
            _notificationService = notificationService;

            if (albumViewModelFactory == null) throw new ArgumentNullException("albumViewModelFactory");

            Guid = guid;
            TrackInfo = synoTrack;

            NavigateToContainingAlbumCommand = new DelegateCommand(OnNavigateToContainingAlbum);

            this._session = session;
            this._urlParameterToObjectsPlateHeater = urlParameterToObjectsPlateHeater;
            _albumViewModelFactory = albumViewModelFactory;
            _albumViewModelFactory = albumViewModelFactory;
            _pageSwitchingService = pageSwitchingService;
        }
コード例 #3
0
        public TrackViewModel(Guid guid, SynoTrack synoTrack, IPageSwitchingService pageSwitchingService, AlbumViewModelFactory albumViewModelFactory, IAudioStationSession session, IUrlParameterToObjectsPlateHeater urlParameterToObjectsPlateHeater, ITrackViewModelFactory trackViewModelFactory, INotificationService notificationService)
        {
            if (synoTrack == null)
            {
                throw new ArgumentNullException("synoTrack");
            }

            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            _trackViewModelFactory = trackViewModelFactory;
            _notificationService   = notificationService;

            if (albumViewModelFactory == null)
            {
                throw new ArgumentNullException("albumViewModelFactory");
            }

            Guid      = guid;
            TrackInfo = synoTrack;

            NavigateToContainingAlbumCommand = new DelegateCommand(OnNavigateToContainingAlbum);

            this._session = session;
            this._urlParameterToObjectsPlateHeater = urlParameterToObjectsPlateHeater;
            _albumViewModelFactory = albumViewModelFactory;
            _albumViewModelFactory = albumViewModelFactory;
            _pageSwitchingService  = pageSwitchingService;
        }
コード例 #4
0
 public ArtistDetailViewModelFactory(ISearchService searchService, AlbumViewModelFactory albumViewModelFactory, INavigatorService navigatorSevice, IPageSwitchingService pageSwitchingService, ITrackViewModelFactory session)
 {
     if (session == null) throw new ArgumentNullException("session");
     _searchService = searchService;
     _albumViewModelFactory = albumViewModelFactory;
     this._navigatorSevice = navigatorSevice;
     this._pageSwitchingService = pageSwitchingService;
     this._session = session;
 }
コード例 #5
0
 public SearchAllResultsViewModelFactory(IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, ITrackViewModelFactory trackViewModelFactory)
 {
     if (trackViewModelFactory == null)
     {
         throw new ArgumentNullException("trackViewModelFactory");
     }
     _eventAggregator       = eventAggregator;
     _pageSwitchingService  = pageSwitchingService;
     _trackViewModelFactory = trackViewModelFactory;
 }
コード例 #6
0
 public ArtistDetailViewModelFactory(ISearchService searchService, AlbumViewModelFactory albumViewModelFactory, INavigatorService navigatorSevice, IPageSwitchingService pageSwitchingService, ITrackViewModelFactory session)
 {
     if (session == null)
     {
         throw new ArgumentNullException("session");
     }
     _searchService             = searchService;
     _albumViewModelFactory     = albumViewModelFactory;
     this._navigatorSevice      = navigatorSevice;
     this._pageSwitchingService = pageSwitchingService;
     this._session = session;
 }
コード例 #7
0
 public ArtistDetailViewModel(SynoItem artist, ISearchService searchService, AlbumViewModelFactory albumViewModelFactory, INavigatorService navigatorSevice, IPageSwitchingService pageSwitchingService, ITrackViewModelFactory trackViewModelFactory)
 {
     if (trackViewModelFactory == null) throw new ArgumentNullException("trackViewModelFactory");
     this.Albums = new ObservableCollection<AlbumViewModel>();
     this.ArtistName = artist.Title;
     this.SimilarArtists = new ObservableCollection<IArtistViewModel>();
     this._searchService = searchService;
     _albumViewModelFactory = albumViewModelFactory;
     _navigatorSevice = navigatorSevice;
     _pageSwitchingService = pageSwitchingService;
     _trackViewModelFactory = trackViewModelFactory;
     this.PopulateAlbumsAsync(artist);
     GetSimilarArtistsAsync(artist);
 }
コード例 #8
0
 public ArtistDetailViewModel(SynoItem artist, ISearchService searchService, AlbumViewModelFactory albumViewModelFactory, INavigatorService navigatorSevice, IPageSwitchingService pageSwitchingService, ITrackViewModelFactory trackViewModelFactory)
 {
     if (trackViewModelFactory == null)
     {
         throw new ArgumentNullException("trackViewModelFactory");
     }
     this.Albums            = new ObservableCollection <AlbumViewModel>();
     this.ArtistName        = artist.Title;
     this.SimilarArtists    = new ObservableCollection <IArtistViewModel>();
     this._searchService    = searchService;
     _albumViewModelFactory = albumViewModelFactory;
     _navigatorSevice       = navigatorSevice;
     _pageSwitchingService  = pageSwitchingService;
     _trackViewModelFactory = trackViewModelFactory;
     this.PopulateAlbumsAsync(artist);
     GetSimilarArtistsAsync(artist);
 }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayQueueViewModel"/> class.
        /// </summary>
        /// <param name="eventAggregator">The event aggregator.</param>
        /// <param name="playbackService">The playback service.</param>
        /// <param name="openSynoSettings"></param>
        public PlayQueueViewModel(IEventAggregator eventAggregator, IPlaybackService playbackService, INotificationService notificationService, IOpenSynoSettings openSynoSettings, ILogService logService, ITrackViewModelFactory trackViewModelFactory, IPageSwitchingService pageSwitchingService)
        {
            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }

            if (playbackService == null)
            {
                throw new ArgumentNullException("playbackService");
            }

            if (notificationService == null)
            {
                throw new ArgumentNullException("notificationService");
            }

            if (openSynoSettings == null)
            {
                throw new ArgumentNullException("openSynoSettings");
            }

            if (trackViewModelFactory == null)
            {
                throw new ArgumentNullException("trackViewModelFactory");
            }

            if (pageSwitchingService == null)
            {
                throw new ArgumentNullException("pageSwitchingService");
            }

            _trackViewModelFactory = trackViewModelFactory;

            RemoveTracksFromQueueCommand = new DelegateCommand<IEnumerable<object>>(OnRemoveTracksFromQueue);

            Action consecutiveAlbumsIdPatcher = () =>
            {
                var previousAlbumGuid = Guid.Empty;
                string previousAlbumId = null;
                foreach (var trackViewModel in this.PlayQueueItems)
                {
                    if (previousAlbumId != trackViewModel.TrackInfo.ItemPid)
                    {
                        previousAlbumId = trackViewModel.TrackInfo.ItemPid;
                        previousAlbumGuid = Guid.NewGuid();
                    }
                    trackViewModel.ConsecutiveAlbumIdentifier = previousAlbumGuid;
                }
            };

            _playbackService = playbackService;
            this.PlayQueueItems = new ObservableCollection<TrackViewModel>(playbackService.GetTracksInQueue().Select(o => _trackViewModelFactory.Create(o.Guid, o.Track, this._pageSwitchingService)));
            this.PlayQueueItems.CollectionChanged += (s, ea) =>
                                                         {
                                                             consecutiveAlbumsIdPatcher();
                                                         };
            consecutiveAlbumsIdPatcher();
            _playbackService.PlayqueueChanged += this.OnPlayqueueChanged;

            // FIXME : using aggregated event is not a great idea here : we'd rather use a service : that would be cleaner and easier to debug !
            eventAggregator.GetEvent<CompositePresentationEvent<PlayListOperationAggregatedEvent>>().Subscribe(OnPlayListOperation, true);
            this._notificationService = notificationService;
            _openSynoSettings = openSynoSettings;
            _logService = logService;
            _pageSwitchingService = pageSwitchingService;
            _playbackService.TrackStarted += (o, e) =>
                                                 {
                                                     CurrentArtwork = new Uri(e.Track.AlbumArtUrl, UriKind.Absolute);
                                                     this.ActiveTrack = this._trackViewModelFactory.Create(e.Guid, e.Track, this._pageSwitchingService);
                                                 };

            _playbackService.BufferingProgressUpdated += (o, e) =>
                {
                    // throttle refresh through binding.
                    if (_lastBufferProgressUpdate.AddMilliseconds(500) < DateTime.Now || e.BytesLeft == 0)
                    {
                        _lastBufferProgressUpdate = DateTime.Now;
                        this.BufferedBytesCount = e.FileSize - e.BytesLeft;
                        this.CurrentFileSize = e.FileSize;
                        Debug.WriteLine("Download progress : " + (double)(e.FileSize - e.BytesLeft) / (double)e.FileSize * (double)100.0);
                    }
                };

            _playbackService.TrackCurrentPositionChanged += (o, e) =>
                {
                    CurrentPlaybackPercentComplete = e.PlaybackPercentComplete;;
                    CurrentTrackPosition = e.Position;
                };

            PlayCommand = new DelegateCommand<TrackViewModel>(o => OnPlay(o), track => track != null);
            PlayNextCommand = new DelegateCommand(OnPlayNext);
            PausePlaybackCommand = new DelegateCommand(OnPausePlayback);
            ResumePlaybackCommand = new DelegateCommand(OnResumePlayback);
            PlayPreviousCommand = new DelegateCommand(OnPlayPrevious);
            SavePlaylistCommand = new DelegateCommand<IEnumerable<TrackViewModel>>(OnSavePlaylist);
            SelectAllAlbumTracksCommand = new DelegateCommand<Guid>(OnSelectAllAlbumTracks);
        }
コード例 #10
0
 public SearchAllResultsViewModelFactory(IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, ITrackViewModelFactory trackViewModelFactory)
 {
     if (trackViewModelFactory == null) throw new ArgumentNullException("trackViewModelFactory");
     _eventAggregator = eventAggregator;
     _pageSwitchingService = pageSwitchingService;
     _trackViewModelFactory = trackViewModelFactory;
 }
コード例 #11
0
 public SearchAllResultsViewModel(IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, string keyword, IEnumerable<SynoTrack> lastResults, ITrackViewModelFactory trackViewModelFactory)
 {
     _eventAggregator = eventAggregator;
     _pageSwitchingService = pageSwitchingService;
     _trackViewModelFactory = trackViewModelFactory;
     if (pageSwitchingService == null) throw new ArgumentNullException("pageSwitchingService");
     if (keyword == null) throw new ArgumentNullException("keyword");
     if (lastResults == null) throw new ArgumentNullException("lastResults");
     if (trackViewModelFactory == null) throw new ArgumentNullException("trackViewModelFactory");
     ShowPlayQueueCommand = new DelegateCommand(OnShowPlayQueue);
     PlayLastCommand = new DelegateCommand(OnPlayLast);
     Keyword = keyword;
     SearchResults = new ObservableCollection<TrackViewModel>();
     foreach (var lastResult in lastResults)
     {
         // GUIDS will be generated later when / if inserted in the playqueue.
         SearchResults.Add(this._trackViewModelFactory.Create(Guid.Empty, lastResult, this._pageSwitchingService));
     }
 }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayQueueViewModel"/> class.
        /// </summary>
        /// <param name="eventAggregator">The event aggregator.</param>
        /// <param name="playbackService">The playback service.</param>
        /// <param name="openSynoSettings"></param>
        public PlayQueueViewModel(IEventAggregator eventAggregator, IPlaybackService playbackService, INotificationService notificationService, IOpenSynoSettings openSynoSettings, ILogService logService, ITrackViewModelFactory trackViewModelFactory, IPageSwitchingService pageSwitchingService)
        {
            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }

            if (playbackService == null)
            {
                throw new ArgumentNullException("playbackService");
            }

            if (notificationService == null)
            {
                throw new ArgumentNullException("notificationService");
            }

            if (openSynoSettings == null)
            {
                throw new ArgumentNullException("openSynoSettings");
            }

            if (trackViewModelFactory == null)
            {
                throw new ArgumentNullException("trackViewModelFactory");
            }

            if (pageSwitchingService == null)
            {
                throw new ArgumentNullException("pageSwitchingService");
            }

            _trackViewModelFactory = trackViewModelFactory;

            RemoveTracksFromQueueCommand = new DelegateCommand <IEnumerable <object> >(OnRemoveTracksFromQueue);

            Action consecutiveAlbumsIdPatcher = () =>
            {
                var    previousAlbumGuid = Guid.Empty;
                string previousAlbumId   = null;
                foreach (var trackViewModel in this.PlayQueueItems)
                {
                    if (previousAlbumId != trackViewModel.TrackInfo.ItemPid)
                    {
                        previousAlbumId   = trackViewModel.TrackInfo.ItemPid;
                        previousAlbumGuid = Guid.NewGuid();
                    }
                    trackViewModel.ConsecutiveAlbumIdentifier = previousAlbumGuid;
                }
            };

            _playbackService    = playbackService;
            this.PlayQueueItems = new ObservableCollection <TrackViewModel>(playbackService.GetTracksInQueue().Select(o => _trackViewModelFactory.Create(o.Guid, o.Track, this._pageSwitchingService)));
            this.PlayQueueItems.CollectionChanged += (s, ea) =>
            {
                consecutiveAlbumsIdPatcher();
            };
            consecutiveAlbumsIdPatcher();
            _playbackService.PlayqueueChanged += this.OnPlayqueueChanged;

            // FIXME : using aggregated event is not a great idea here : we'd rather use a service : that would be cleaner and easier to debug !
            eventAggregator.GetEvent <CompositePresentationEvent <PlayListOperationAggregatedEvent> >().Subscribe(OnPlayListOperation, true);
            this._notificationService = notificationService;
            _openSynoSettings         = openSynoSettings;
            _logService                    = logService;
            _pageSwitchingService          = pageSwitchingService;
            _playbackService.TrackStarted += (o, e) =>
            {
                CurrentArtwork   = new Uri(e.Track.AlbumArtUrl, UriKind.Absolute);
                this.ActiveTrack = this._trackViewModelFactory.Create(e.Guid, e.Track, this._pageSwitchingService);
            };

            _playbackService.BufferingProgressUpdated += (o, e) =>
            {
                // throttle refresh through binding.
                if (_lastBufferProgressUpdate.AddMilliseconds(500) < DateTime.Now || e.BytesLeft == 0)
                {
                    _lastBufferProgressUpdate = DateTime.Now;
                    this.BufferedBytesCount   = e.FileSize - e.BytesLeft;
                    this.CurrentFileSize      = e.FileSize;
                    Debug.WriteLine("Download progress : " + (double)(e.FileSize - e.BytesLeft) / (double)e.FileSize * (double)100.0);
                }
            };

            _playbackService.TrackCurrentPositionChanged += (o, e) =>
            {
                CurrentPlaybackPercentComplete = e.PlaybackPercentComplete;;
                CurrentTrackPosition           = e.Position;
            };

            PlayCommand                 = new DelegateCommand <TrackViewModel>(o => OnPlay(o), track => track != null);
            PlayNextCommand             = new DelegateCommand(OnPlayNext);
            PausePlaybackCommand        = new DelegateCommand(OnPausePlayback);
            ResumePlaybackCommand       = new DelegateCommand(OnResumePlayback);
            PlayPreviousCommand         = new DelegateCommand(OnPlayPrevious);
            SavePlaylistCommand         = new DelegateCommand <IEnumerable <TrackViewModel> >(OnSavePlaylist);
            SelectAllAlbumTracksCommand = new DelegateCommand <Guid>(OnSelectAllAlbumTracks);
        }