Пример #1
0
        public Playlist(ViewModelServiceContainer container, IValidator <Playlist> validator, DialogViewModel dialogViewModel, Data.Playlist model)
            : base(model, validator, container.Messenger)
        {
            using (BusyStack.GetToken())
            {
                _itemsLock        = new object();
                _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);
                OnPropertyChanged(nameof(Count));

                InitializeCommands();
                Validate();
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlaylistMapper"/> class.
        /// </summary>
        /// <param name="dialogViewModel">The dialog view model.</param>
        public PlaylistMapper(IMediaItemMapper mediaItemMapper, DialogViewModel dialogViewModel, ILocalizationService translator, ISequenceProvider sequenceProvider, IMapleLog log, IValidator <Playlist> validator)
            : base(translator, sequenceProvider, log, validator)
        {
            _dialogViewModel = dialogViewModel ?? throw new ArgumentNullException(nameof(dialogViewModel));
            _mediaItemMapper = mediaItemMapper ?? throw new ArgumentNullException(nameof(mediaItemMapper));

            InitializeMapper();
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlaylistMapper"/> class.
        /// </summary>
        /// <param name="dialogViewModel">The dialog view model.</param>
        public PlaylistMapper(ViewModelServiceContainer container, IMediaItemMapper mediaItemMapper, DialogViewModel dialogViewModel, IValidator <Playlist> validator)
            : base(container, validator)
        {
            _dialogViewModel = dialogViewModel ?? throw new ArgumentNullException(nameof(dialogViewModel), $"{nameof(dialogViewModel)} {Resources.IsRequired}");
            _mediaItemMapper = mediaItemMapper ?? throw new ArgumentNullException(nameof(mediaItemMapper), $"{nameof(mediaItemMapper)} {Resources.IsRequired}");

            InitializeMapper();
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaPlayers"/> class.
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="playerFactory">The player factory.</param>
 /// <param name="repo">The repo.</param>
 /// <param name="devices">The devices.</param>
 /// <param name="dialog">The dialog.</param>
 public MediaPlayers(IMapleLog log, ILocalizationService translationService, IMediaPlayerMapper mediaPlayerMapper, Func <IMediaPlayer> playerFactory, Func <IMediaRepository> repo, AudioDevices devices, DialogViewModel dialog, ISequenceProvider sequenceProvider)
     : base(log, translationService, sequenceProvider)
 {
     _playerFactory     = playerFactory ?? throw new ArgumentNullException(nameof(playerFactory));
     _devices           = devices ?? throw new ArgumentNullException(nameof(devices));
     _dialog            = dialog ?? throw new ArgumentNullException(nameof(dialog));
     _repositoryFactory = repo ?? throw new ArgumentNullException(nameof(repo));
     _mediaPlayerMapper = mediaPlayerMapper ?? throw new ArgumentNullException(nameof(mediaPlayerMapper));
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Playlist" /> class.
        /// </summary>
        /// <param name="translator">The translator.</param>
        /// <param name="mediaItemMapper">The media item mapper.</param>
        /// <param name="dialogViewModel">The dialog view model.</param>
        /// <param name="model">The model.</param>
        /// <exception cref="System.ArgumentNullException">dialogViewModel</exception>
        /// <exception cref="System.ArgumentException"></exception>
        public Playlist(ILocalizationService translator, IMediaItemMapper mediaItemMapper, ISequenceProvider sequenceProvider, IValidator <Playlist> validator, DialogViewModel dialogViewModel, Data.Playlist model)
            : base(model, validator)
        {
            using (_busyStack.GetToken())
            {
                _itemsLock        = new object();
                _sequenceProvider = sequenceProvider ?? throw new ArgumentNullException(nameof(sequenceProvider));
                _dialogViewModel  = dialogViewModel ?? throw new ArgumentNullException(nameof(dialogViewModel));
                _translator       = translator ?? throw new ArgumentNullException(nameof(translator));
                _mediaItemMapper  = mediaItemMapper ?? throw new ArgumentNullException(nameof(mediaItemMapper));

                Items       = new RangeObservableCollection <MediaItem>();
                RepeatModes = new ObservableCollection <RepeatMode>(Enum.GetValues(typeof(RepeatMode)).Cast <RepeatMode>().ToList());
                History     = new Stack <int>();

                BindingOperations.EnableCollectionSynchronization(Items, _itemsLock);

                _title        = model.Title;
                _description  = model.Description;
                _id           = model.Id;
                _repeatMode   = (RepeatMode)model.RepeatMode;
                _isShuffeling = model.IsShuffeling;
                _sequence     = model.Sequence;
                _createdBy    = model.CreatedBy;
                _createdOn    = model.CreatedOn;
                _updatedBy    = model.UpdatedBy;
                _updatedOn    = model.UpdatedOn;

                if (model.MediaItems == null)
                {
                    throw new ArgumentException($"{model.MediaItems} cannot be null");
                }

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

                Items.CollectionChanged += (o, e) =>
                {
                    OnPropertyChanged(nameof(Count));
                };

                View = CollectionViewSource.GetDefaultView(Items);
                OnPropertyChanged(nameof(Count));

                InitializeCommands();
                IntializeValidation();

                Validate();
            }
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MediaPlayers"/> class.
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="playerFactory">The player factory.</param>
        /// <param name="repositoryFactory">The repo.</param>
        /// <param name="devices">The devices.</param>
        /// <param name="dialog">The dialog.</param>
        public MediaPlayers(ViewModelServiceContainer container,
                            IMediaPlayerMapper mediaPlayerMapper,
                            Func <IMediaPlayer> playerFactory,
                            Func <IMediaRepository> repositoryFactory,
                            AudioDevices devices,
                            DialogViewModel dialog)
            : base(container)
        {
            _playerFactory     = playerFactory ?? throw new ArgumentNullException(nameof(playerFactory), $"{nameof(playerFactory)} {Resources.IsRequired}");
            _devices           = devices ?? throw new ArgumentNullException(nameof(devices), $"{nameof(devices)} {Resources.IsRequired}");
            _dialog            = dialog ?? throw new ArgumentNullException(nameof(dialog), $"{nameof(dialog)} {Resources.IsRequired}");
            _repositoryFactory = repositoryFactory ?? throw new ArgumentNullException(nameof(repositoryFactory), $"{nameof(repositoryFactory)} {Resources.IsRequired}");
            _mediaPlayerMapper = mediaPlayerMapper ?? throw new ArgumentNullException(nameof(mediaPlayerMapper), $"{nameof(mediaPlayerMapper)} {Resources.IsRequired}");

            _notificationService = container.NotificationService;
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShellViewModel"/> class.
 /// </summary>
 /// <param name="translationManager">The translation manager.</param>
 /// <param name="scenes">The scenes.</param>
 /// <param name="statusBarViewModel">The status bar view model.</param>
 /// <param name="dialogViewModel">The dialog view model.</param>
 /// <param name="playlists">The playlists.</param>
 /// <param name="mediaPlayers">The media players.</param>
 /// <param name="uiColorsViewModel">The UI colors view model.</param>
 /// <param name="optionsViewModel">The options view model.</param>
 public ShellViewModel(ILocalizationService translationManager,
                       Scenes scenes,
                       StatusbarViewModel statusBarViewModel,
                       DialogViewModel dialogViewModel,
                       IPlaylistsViewModel playlists,
                       IMediaPlayersViewModel mediaPlayers,
                       OptionsViewModel optionsViewModel)
 {
     TranslationManager = translationManager ?? throw new ArgumentNullException(nameof(translationManager));
     Scenes             = scenes ?? throw new ArgumentNullException(nameof(scenes));
     StatusbarViewModel = statusBarViewModel ?? throw new ArgumentNullException(nameof(statusBarViewModel));
     DialogViewModel    = dialogViewModel ?? throw new ArgumentNullException(nameof(dialogViewModel));
     Playlists          = playlists ?? throw new ArgumentNullException(nameof(playlists));
     MediaPlayers       = mediaPlayers ?? throw new ArgumentNullException(nameof(mediaPlayers));
     OptionsViewModel   = optionsViewModel ?? throw new ArgumentNullException(nameof(optionsViewModel));
 }