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; }
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)); } }
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; }
public LoginViewModel(IPageSwitchingService pageSwitchingService, IEventAggregator eventAggregator, IAudioStationSession audioStationSession, IOpenSynoSettings synoSettings, ISignInService signInService, IPlaybackService playbackService) { if (pageSwitchingService == null) throw new ArgumentNullException("pageSwitchingService"); if (eventAggregator == null) throw new ArgumentNullException("eventAggregator"); if (audioStationSession == null) throw new ArgumentNullException("audioStationSession"); SignInCommand = new DelegateCommand(OnSignIn); _pageSwitchingService = pageSwitchingService; _eventAggregator = eventAggregator; _audioStationSession = audioStationSession; _synoSettings = synoSettings; _signInService = signInService; _signInService.SignInCompleted += OnSignInCompleted; // Unregister the registered events to make sure we don't execute the event handler twice in case of exceptions _signInService.CheckTokenValidityCompleted += (o, e) => { if (e.Error != null) { _signInService.CheckTokenValidityCompleted -= OnCheckTokenValidityCompleted; } }; _playbackService = playbackService; UserName = _synoSettings.UserName; UseSsl = _synoSettings.UseSsl; Password = _synoSettings.Password; Host = _synoSettings.Host; Port = _synoSettings.Port; }
public ArtistPanoramaViewModelFactory(ISearchService searchService, IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, INotificationService notificationService) { _searchService = searchService; this._notificationService = notificationService; _pageSwitchingService = pageSwitchingService; _eventAggregator = eventAggregator; }
/// <summary> /// Initializes a new instance of the <see cref="SearchResultItemViewModel"/> class. /// </summary> /// <param name="itemInfo">The item info.</param> /// <param name="eventAggregator">The event aggregator.</param> /// <param name="pageSwitchingService">The page switching service.</param> /// <param name="urlParameterToObjectsPlateHeater"></param> public SearchResultItemViewModel(SynoItem itemInfo, IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, IUrlParameterToObjectsPlateHeater urlParameterToObjectsPlateHeater) { if (itemInfo == null) throw new ArgumentNullException("itemInfo"); ItemSelectedCommand = new DelegateCommand(OnItemSelected); ItemInfo = itemInfo; _eventAggregator = eventAggregator; _pageSwitchingService = pageSwitchingService; _urlParameterToObjectsPlateHeater = urlParameterToObjectsPlateHeater; }
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; }
public SearchAllResultsViewModelFactory(IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, ITrackViewModelFactory trackViewModelFactory) { if (trackViewModelFactory == null) { throw new ArgumentNullException("trackViewModelFactory"); } _eventAggregator = eventAggregator; _pageSwitchingService = pageSwitchingService; _trackViewModelFactory = trackViewModelFactory; }
public ArtistPanoramaViewModel(SynoItem artist, IEnumerable<AlbumViewModel> albums, int activePanelIndex, ISearchService searchService, IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, INotificationService notificationService) { if (searchService == null) { throw new ArgumentNullException("searchService"); } if (eventAggregator == null) { throw new ArgumentNullException("eventAggregator"); } if (pageSwitchingService == null) { throw new ArgumentNullException("pageSwitchingService"); } if (artist == null) { throw new ArgumentNullException("artist"); } if (albums == null) { throw new ArgumentNullException("albums"); } PlayLastCommand = new DelegateCommand(OnPlayLast); PlayCommand = new DelegateCommand(OnPlay); CurrentArtistItemIndex = activePanelIndex; _searchService = searchService; this._notificationService = notificationService; // TODO : Use IoC or Factory or whatever, but something to be able to inject our own implementation _panoramaItemSwitchingService = new PanoramaItemSwitchingService(); _panoramaItemSwitchingService.ActiveItemChangeRequested += (s, e) => CurrentArtistItemIndex = e.NewItemIndex; _eventAggregator = eventAggregator; _pageSwitchingService = pageSwitchingService; this.ArtistAlbums = new ObservableCollection<AlbumViewModel>(); foreach (var albumViewModel in albums) { this.ArtistAlbums.Add(albumViewModel); } this.ArtistAlbums.CollectionChanged += StartMonitoringElements; foreach (var album in this.ArtistAlbums) { album.PropertyChanged += UpdateBusyness; } ShowPlayQueueCommand = new DelegateCommand(OnShowPlayQueue); _artist = artist; ArtistName = _artist.Title; }
public ArtistPanoramaViewModel(SynoItem artist, IEnumerable <AlbumViewModel> albums, int activePanelIndex, ISearchService searchService, IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, INotificationService notificationService) { if (searchService == null) { throw new ArgumentNullException("searchService"); } if (eventAggregator == null) { throw new ArgumentNullException("eventAggregator"); } if (pageSwitchingService == null) { throw new ArgumentNullException("pageSwitchingService"); } if (artist == null) { throw new ArgumentNullException("artist"); } if (albums == null) { throw new ArgumentNullException("albums"); } PlayLastCommand = new DelegateCommand(OnPlayLast); PlayCommand = new DelegateCommand(OnPlay); CurrentArtistItemIndex = activePanelIndex; _searchService = searchService; this._notificationService = notificationService; // TODO : Use IoC or Factory or whatever, but something to be able to inject our own implementation _panoramaItemSwitchingService = new PanoramaItemSwitchingService(); _panoramaItemSwitchingService.ActiveItemChangeRequested += (s, e) => CurrentArtistItemIndex = e.NewItemIndex; _eventAggregator = eventAggregator; _pageSwitchingService = pageSwitchingService; this.ArtistAlbums = new ObservableCollection <AlbumViewModel>(); foreach (var albumViewModel in albums) { this.ArtistAlbums.Add(albumViewModel); } this.ArtistAlbums.CollectionChanged += StartMonitoringElements; foreach (var album in this.ArtistAlbums) { album.PropertyChanged += UpdateBusyness; } ShowPlayQueueCommand = new DelegateCommand(OnShowPlayQueue); _artist = artist; ArtistName = _artist.Title; }
/// <summary> /// Initializes a new instance of the <see cref="SearchResultItemViewModel"/> class. /// </summary> /// <param name="itemInfo">The item info.</param> /// <param name="eventAggregator">The event aggregator.</param> /// <param name="pageSwitchingService">The page switching service.</param> /// <param name="urlParameterToObjectsPlateHeater"></param> public SearchResultItemViewModel(SynoItem itemInfo, IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, IUrlParameterToObjectsPlateHeater urlParameterToObjectsPlateHeater) { if (itemInfo == null) { throw new ArgumentNullException("itemInfo"); } ItemSelectedCommand = new DelegateCommand(OnItemSelected); ItemInfo = itemInfo; _eventAggregator = eventAggregator; _pageSwitchingService = pageSwitchingService; _urlParameterToObjectsPlateHeater = urlParameterToObjectsPlateHeater; }
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; }
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); }
/// <summary> /// Initializes a new instance of the <see cref="SearchResultsViewModel"/> class. /// </summary> /// <param name="pageSwitchingService">The page switching service.</param> public SearchResultsViewModel(IPageSwitchingService pageSwitchingService, ISearchResultItemViewModelFactory searchResultItemViewModelFactory) { if (pageSwitchingService == null) { throw new ArgumentNullException("pageSwitchingService"); } // register for search results updates _eventAggregator = IoC.Container.Get <IEventAggregator>(); _pageSwitchingService = pageSwitchingService; _searchResultItemViewModelFactory = searchResultItemViewModelFactory; FilterResultsCommand = new DelegateCommand <string>(OnFilterResults); // everytime the searchResults changes, we'll react to that change. _eventAggregator.GetEvent <CompositePresentationEvent <SearchResultsRetrievedAggregatedEvent> >().Subscribe(SearchResultsUpdated, true); }
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); }
public LoginViewModel(IPageSwitchingService pageSwitchingService, IEventAggregator eventAggregator, IAudioStationSession audioStationSession, IOpenSynoSettings synoSettings, ISignInService signInService, IPlaybackService playbackService) { if (pageSwitchingService == null) { throw new ArgumentNullException("pageSwitchingService"); } if (eventAggregator == null) { throw new ArgumentNullException("eventAggregator"); } if (audioStationSession == null) { throw new ArgumentNullException("audioStationSession"); } SignInCommand = new DelegateCommand(OnSignIn); _pageSwitchingService = pageSwitchingService; _eventAggregator = eventAggregator; _audioStationSession = audioStationSession; _synoSettings = synoSettings; _signInService = signInService; _signInService.SignInCompleted += OnSignInCompleted; // Unregister the registered events to make sure we don't execute the event handler twice in case of exceptions _signInService.CheckTokenValidityCompleted += (o, e) => { if (e.Error != null) { _signInService.CheckTokenValidityCompleted -= OnCheckTokenValidityCompleted; } }; _playbackService = playbackService; UserName = _synoSettings.UserName; UseSsl = _synoSettings.UseSsl; Password = _synoSettings.Password; Host = _synoSettings.Host; Port = _synoSettings.Port; }
public SearchViewModel(ISearchService searchService, IPageSwitchingService pageSwitchingService, IEventAggregator eventAggregator, ISignInService signInService, IUrlParameterToObjectsPlateHeater ticketUrlParameterToObjectPlateHeater) { _searchService = searchService; this._ticketUrlParameterToObjectPlateHeater = ticketUrlParameterToObjectPlateHeater; _pageSwitchingService = pageSwitchingService; _eventAggregator = eventAggregator; _signInService = signInService; // make sure the IsAppLoading is always up-to-date. signInService.SignInCompleted += (sender, ea) => IsAppLoading = ea.IsBusy; // just in case the event has previously been fired : we set its default value to the current value. IsAppLoading = _signInService.IsSigningIn; //_eventAggregator.GetEvent<CompositePresentationEvent<SynoTokenReceivedAggregatedEvent>>().Subscribe(OnSynoTokenReceived, false); StartSearchCommand = new DelegateCommand <string>(OnStartSearch); StartSearchAllCommand = new DelegateCommand <string>(OnStartSearchAll); ShowAboutBoxCommand = new DelegateCommand(OnShowAboutBox); SearchContextChangedCommand = new DelegateCommand <string>(OnSearchContextChanged); DispatchSearchCommand = new DelegateCommand <string>(OnDispatchSearch); ClearKeywordCommand = new DelegateCommand(OnClearKeyword); ShowPlayQueueCommand = new DelegateCommand(OnShowPlayQueue); }
public SearchViewModel(ISearchService searchService, IPageSwitchingService pageSwitchingService, IEventAggregator eventAggregator, ISignInService signInService, IUrlParameterToObjectsPlateHeater ticketUrlParameterToObjectPlateHeater) { _searchService = searchService; this._ticketUrlParameterToObjectPlateHeater = ticketUrlParameterToObjectPlateHeater; _pageSwitchingService = pageSwitchingService; _eventAggregator = eventAggregator; _signInService = signInService; // make sure the IsAppLoading is always up-to-date. signInService.SignInCompleted += (sender, ea) => IsAppLoading = ea.IsBusy; // just in case the event has previously been fired : we set its default value to the current value. IsAppLoading = _signInService.IsSigningIn; //_eventAggregator.GetEvent<CompositePresentationEvent<SynoTokenReceivedAggregatedEvent>>().Subscribe(OnSynoTokenReceived, false); StartSearchCommand = new DelegateCommand<string>(OnStartSearch); StartSearchAllCommand = new DelegateCommand<string>(OnStartSearchAll); ShowAboutBoxCommand = new DelegateCommand(OnShowAboutBox); SearchContextChangedCommand = new DelegateCommand<string>(OnSearchContextChanged); DispatchSearchCommand = new DelegateCommand<string>(OnDispatchSearch); ClearKeywordCommand = new DelegateCommand(OnClearKeyword); ShowPlayQueueCommand = new DelegateCommand(OnShowPlayQueue); }
/// <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); }
public SearchAllResultsViewModelFactory(IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService, ITrackViewModelFactory trackViewModelFactory) { if (trackViewModelFactory == null) throw new ArgumentNullException("trackViewModelFactory"); _eventAggregator = eventAggregator; _pageSwitchingService = pageSwitchingService; _trackViewModelFactory = trackViewModelFactory; }
/// <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); }
// Eventaggregator needs to be moved to .ctor public SearchResultItemViewModel Create(SynoItem result, IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService) { return(new SearchResultItemViewModel(result, eventAggregator, pageSwitchingService, _urlParameterToObjectsPlateHeater)); }
public TrackViewModel Create(Guid guid, SynoTrack track, IPageSwitchingService pageSwitchingService) { return(new TrackViewModel(guid, track, pageSwitchingService, _albumViewModelFactory, _session, _urlParameterToObjectsPlateHeater, this, notificationService)); }
public TrackViewModel Create(Guid guid, SynoTrack track, IPageSwitchingService pageSwitchingService) { return new TrackViewModel(guid, track, pageSwitchingService, _albumViewModelFactory, _session, _urlParameterToObjectsPlateHeater, this, notificationService); }
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)); } }
// Eventaggregator needs to be moved to .ctor public SearchResultItemViewModel Create(SynoItem result, IEventAggregator eventAggregator, IPageSwitchingService pageSwitchingService) { return new SearchResultItemViewModel(result, eventAggregator, pageSwitchingService, _urlParameterToObjectsPlateHeater); }