Exemplo n.º 1
0
        public AudioPlayerViewModel(
            IMessenger messenger,
            OpenSettingsCommand openSettingsCommand,
            PlayPauseTrackCommand playPauseCommand,
            PlayPreviousTrackCommand playPreviousCommand,
            PlayNextTrackCommand playNextCommand,
            EditTrackCommand editTrackCommand,
            ShowInExplorerCommand showInExplorerCommand,
            DropItemIntoAudioPlayerCommand dropItemCommand)
            : base(messenger)
        {
            if (openSettingsCommand == null) throw new ArgumentNullException("openSettingsCommand");
            if (playPauseCommand == null) throw new ArgumentNullException("playPauseCommand");
            if (playPreviousCommand == null) throw new ArgumentNullException("playPreviousCommand");
            if (playNextCommand == null) throw new ArgumentNullException("playNextCommand");
            if (editTrackCommand == null) throw new ArgumentNullException("editTrackCommand");
            if (showInExplorerCommand == null) throw new ArgumentNullException("showInExplorerCommand");
            if (dropItemCommand == null) throw new ArgumentNullException("dropItemCommand");
            OpenSettingsCommand = openSettingsCommand;
            PlayPauseCommand = playPauseCommand;
            PlayPreviousCommand = playPreviousCommand;
            PlayNextCommand = playNextCommand;
            EditTrackCommand = editTrackCommand;
            ShowInExplorerCommand = showInExplorerCommand;
            DropItemCommand = dropItemCommand;

            messenger.Register<PlayerStoppedEvent>(this, _ => RaisePropertyChanged(() => Track));
            messenger.Register<PlayerLoadedEvent>(this, OnLoaded);
            messenger.Register<PlayerPlayingEvent>(this, _ => RaisePropertyChanged(() => Track));
        }
Exemplo n.º 2
0
        public TrackLibraryViewModel(
            IMessenger messenger,
            ImportFilesIntoLibraryCommand importFilesCommand,
            RemoveTracksFromLibraryCommand removeTracksCommand,
            PlayPauseTrackCommand playCommand,
            SearchLibraryCommand searchCommand,
            ShowInExplorerCommand showInExplorerCommand,
            OpenSettingsCommand openSettingsCommand,
            EditTrackCommand editTrackCommand,
            ITrackLibraryItemViewModelFactory itemFactory)
            : base(messenger)
        {
            
            if (importFilesCommand == null) throw new ArgumentNullException("importFilesCommand");
            if (removeTracksCommand == null) throw new ArgumentNullException("removeTracksCommand");
            if (playCommand == null) throw new ArgumentNullException("playCommand");
            if (searchCommand == null) throw new ArgumentNullException("searchCommand");
            if (showInExplorerCommand == null) throw new ArgumentNullException("showInExplorerCommand");
            if (openSettingsCommand == null) throw new ArgumentNullException("openSettingsCommand");
            if (editTrackCommand == null) throw new ArgumentNullException("editTrackCommand");
            if (itemFactory == null) throw new ArgumentNullException("itemFactory");

            items = new ObservableCollection<TrackLibraryItemViewModel>();
            ItemsView = CollectionViewSource.GetDefaultView(items);
            PlayPauseCommand = playCommand;
            this.itemFactory = itemFactory;

            messenger.Register<TrackAddedToLibraryEvent>(this, OnTrackAddedToLibrary);
            messenger.Register<TrackRemovedFromLibraryEvent>(this, OnTrackRemoved);
            messenger.Register<SearchRequestedEvent>(this, OnSearchRequested);
            messenger.Register<SearchTextClearedEvent>(this, OnSearchTextCleared);
            messenger.Register<SearchBoxFocusRequestedEvent>(this, OnSearchBoxFocusRequested);
            messenger.Register<TrackLibraryLoadedEvent>(this, OnTrackLibraryLoaded);

            SearchCommand = searchCommand;
            ShowInExplorerCommand = showInExplorerCommand;
            OpenSettingsCommand = openSettingsCommand;
            EditTrackCommand = editTrackCommand;

            ImportFilesCommand = importFilesCommand;
            RemoveCommand = removeTracksCommand;
        }