Exemplo n.º 1
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));
 }
Exemplo n.º 2
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(ILocalizationService manager, IVersionService version, IMediaPlayersViewModel mediaPlayers)
        {
            _mediaplayers = mediaPlayers;

            _manager = manager;
            _manager.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == $"{nameof(ILocalizationService.CurrentLanguage)}")
                {
                    UpdateLanguage();
                }
            };

            Version = version.Get();

            UpdateLanguage();

            _mediaplayers.Loaded += (o, e) => UpdateMainMediaPlayer();
        }
Exemplo n.º 3
0
        public void Save(IMediaPlayersViewModel players, bool isRoot = true)
        {
            using (_busyStack.GetToken())
            {
                var saveRequired = false;
                for (var i = 0; i < players.Items.Count; i++)
                {
                    saveRequired = true;
                    Save(players.Items[i], false);

                    if (i % _saveThreshold == 0)
                    {
                        _context.SaveChanges();
                        saveRequired = false;
                    }
                }

                if (isRoot || saveRequired)
                {
                    _context.SaveChanges();
                }
            }
        }