public MedialibViewModel(Dispatcher dispatcher, SMPSettings settings) { this.CustomWindowPlacementSettings = new CustomWindowPlacementSettings(settings.MedialibSettings); this.MediaFiles = CollectionViewSource.GetDefaultView(new MedialibObservableCollection(null)); // Do a selection/filtering when nothing new has been changed for 400 ms and it isn't // an empty string... and don't filter for the same thing twice. this.ObservableForProperty(x => x.SelectedGenre) .Throttle(TimeSpan.FromMilliseconds(400), RxApp.MainThreadScheduler) .Select(x => x.Value) //.Where(x => !string.IsNullOrWhiteSpace(x)) .DistinctUntilChanged() .Subscribe(x => FilterByGenreSelection(x)); this.ObservableForProperty(x => x.SelectedArtist) .Throttle(TimeSpan.FromMilliseconds(400), RxApp.MainThreadScheduler) .Select(x => x.Value) //.Where(x => !string.IsNullOrWhiteSpace(x)/* && !string.IsNullOrEmpty(this.SelectedGenre)*/) .DistinctUntilChanged() .Subscribe(x => FilterByArtistSelection(this.SelectedGenre, x)); this.ObservableForProperty(x => x.SelectedAlbum) .Throttle(TimeSpan.FromMilliseconds(400), RxApp.MainThreadScheduler) .Select(x => x.Value) //.Where(x => !string.IsNullOrWhiteSpace(x)/* && !string.IsNullOrEmpty(this.SelectedGenre) && !string.IsNullOrEmpty(this.SelectedArtist)*/) .DistinctUntilChanged() .Subscribe(x => FilterByAlbumSelection()); }
public PlayControlViewModel(Dispatcher dispatcher, SMPSettings settings, PlaylistsViewModel playlistsViewModel, MedialibViewModel medialibViewModel) { this.playlistsViewModel = playlistsViewModel; this.medialibViewModel = medialibViewModel; this.SMPSettings = settings; this.PlayerEngine.PlayNextFileAction = () => { if (this.SMPSettings.PlayerSettings.RepeatMode) { if (this.CanPlayOrPause()) { var file = this.playlistsViewModel.GetCurrentPlayListFile(); if (file != null) { this.PlayerEngine.Play(file); } } } else { if (this.CanPlayNext()) { this.PlayNext(); } } }; }
public MainWindowViewModel(Dispatcher dispatcher) { this.smpSettings = this.ReadSettings(); this.CustomWindowPlacementSettings = new CustomWindowPlacementSettings(this.smpSettings.MainSettings); this.PlayerEngine.Configure(dispatcher, this.smpSettings); this.MedialibViewModel = new MedialibViewModel(dispatcher, this.smpSettings); this.PlaylistsViewModel = new PlaylistsViewModel(dispatcher, this.smpSettings); this.MainViewModel = new MainViewModel(dispatcher) { PlayControlViewModel = new PlayControlViewModel(dispatcher, this.smpSettings, this.PlaylistsViewModel, this.MedialibViewModel), PlayInfoViewModel = new PlayInfoViewModel(dispatcher) }; }
public PlaylistsViewModel(Dispatcher dispatcher, SMPSettings settings) { this.smpSettings = settings; this.SelectedPlayListFiles = new ObservableCollection <IMediaFile>(); }
private void WriteSettings(SMPSettings settings) { var settingsAsJson = JsonConvert.SerializeObject(settings, Formatting.Indented); File.WriteAllText(SMPSettings.SettingsFile, settingsAsJson); }