コード例 #1
0
        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());
        }
コード例 #2
0
        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();
                    }
                }
            };
        }
コード例 #3
0
 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)
     };
 }
コード例 #4
0
 public PlaylistsViewModel(Dispatcher dispatcher, SMPSettings settings)
 {
     this.smpSettings           = settings;
     this.SelectedPlayListFiles = new ObservableCollection <IMediaFile>();
 }
コード例 #5
0
        private void WriteSettings(SMPSettings settings)
        {
            var settingsAsJson = JsonConvert.SerializeObject(settings, Formatting.Indented);

            File.WriteAllText(SMPSettings.SettingsFile, settingsAsJson);
        }