Exemplo n.º 1
0
 private void InitializeSubscriptions()
 {
     MessageTokens.Add(Messenger.Subscribe <PlayingMediaItemMessage>(Player_PlayingMediaItem, IsSenderEqualsPlayer));
     MessageTokens.Add(Messenger.Subscribe <CompletedMediaItemMessage>(MediaPlayer_CompletedMediaItem, IsSenderEqualsPlayer));
     MessageTokens.Add(Messenger.Subscribe <ViewModelSelectionChangingMessage <AudioDevice> >(Player_AudioDeviceChanging, IsSenderEqualsPlayer));
     MessageTokens.Add(Messenger.Subscribe <ViewModelSelectionChangingMessage <AudioDevice> >(Player_AudioDeviceChanged, IsSenderEqualsPlayer));
 }
Exemplo n.º 2
0
        public Cultures(ViewModelServiceContainer container)
            : base(container.Messenger)
        {
            _log     = container.Log;
            _manager = container.LocalizationService;

            MessageTokens.Add(Messenger.Subscribe <ViewModelSelectionChangedMessage <Culture> >(UpdateCulture));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StatusbarViewModel"/> class.
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="mediaPlayers">The media players.</param>
        public StatusbarViewModel(IVersionService version, IMessenger messenger)
            : base(messenger)
        {
            if (version == null)
            {
                throw new ArgumentNullException(nameof(version), $"{nameof(version)} {Resources.IsRequired}");
            }

            Version = version.Get();

            MessageTokens.Add(Messenger.Subscribe <ViewModelSelectionChangedMessage <Culture> >(UpdateLanguage));
            MessageTokens.Add(Messenger.Subscribe <ViewModelSelectionChangedMessage <MediaPlayer> >(UpdateMediaPlayer));
        }
Exemplo n.º 4
0
        public Playlist(ViewModelServiceContainer container, IValidator <Playlist> validator, IDialogViewModel dialogViewModel, IMediaItemMapper mediaItemMapper, PlaylistModel model)
            : base(model, validator, container?.Messenger)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container), $"{nameof(container)} {Resources.IsRequired}");
            }

            SkipChangeTracking = true;
            using (BusyStack.GetToken())
            {
                _itemsLock = new object();

                _mediaItemMapper  = mediaItemMapper ?? throw new ArgumentNullException(nameof(mediaItemMapper), $"{nameof(mediaItemMapper)} {Resources.IsRequired}");
                _dialogViewModel  = dialogViewModel ?? throw new ArgumentNullException(nameof(dialogViewModel), $"{nameof(dialogViewModel)} {Resources.IsRequired}");
                _sequenceProvider = container.SequenceService;

                _translator   = container.LocalizationService;
                _title        = model.Title;
                _description  = model.Description;
                _repeatMode   = (RepeatMode)model.RepeatMode;
                _isShuffeling = model.IsShuffeling;
                _sequence     = model.Sequence;

                RepeatModes = new RangeObservableCollection <RepeatMode>(Enum.GetValues(typeof(RepeatMode)).Cast <RepeatMode>().ToList());
                _history    = new Stack <int>();

                Items = new RangeObservableCollection <MediaItem>();
                _items.CollectionChanged += (o, e) => OnPropertyChanged(nameof(Count));

                BindingOperations.EnableCollectionSynchronization(Items, _itemsLock);
                View = CollectionViewSource.GetDefaultView(Items); // TODO add sorting by sequence
                OnPropertyChanged(nameof(Count));

                LoadFromFileCommand   = AsyncCommand.Create(LoadFromFile, () => CanLoadFromFile());
                LoadFromFolderCommand = AsyncCommand.Create(LoadFromFolder, () => CanLoadFromFolder());
                LoadFromUrlCommand    = AsyncCommand.Create(LoadFromUrl, () => CanLoadFromUrl());

                RemoveCommand      = new RelayCommand <object>(Remove, CanRemove);
                RemoveRangeCommand = new RelayCommand <IList>(RemoveRange, CanRemoveRange);
                ClearCommand       = new RelayCommand(() => Clear(), CanClear);

                AddRange(_mediaItemMapper.GetMany(model.MediaItems));

                MessageTokens.Add(Messenger.Subscribe <PlayingMediaItemMessage>(OnPlaybackItemChanged, m => m.PlaylistId == Id && _items.Contains(m.Content)));

                Validate();
            }
            SkipChangeTracking = false;
        }