public void ResetHandler() { _mediaServer.Reset(); SendPropertyChanged(nameof(CurrentMedia)); _mediaTimer.Initialize(CurrentMedia.Duration, () => MediaHasEnded()); if (Play) { _mediaTimer.Start(); } }
private void InitializeTimer() { if (_settingsProvider.RefreshRate <= 0) { return; } _intervalTimer.Initialize(TimeSpan.FromMinutes(_settingsProvider.RefreshRate), ScanFolderPath); _intervalTimer.Start(); }
public void Start() { _readCount = 0; _timer.Elapsed += TimerElapsed; _timer.Start(); }
public MainWindowViewModel(ISettingsProvider settingsProvider, IServeMedia mediaServer, IMediaProvider mediaProvider, ISaveSettings settingsSaver, IIntervalTimer mediaTimer, IIntervalTimer previewTimer, IGetViewPreview viewPreviewProvider) { if (settingsProvider == null) { throw new ArgumentNullException(nameof(settingsProvider)); } if (mediaServer == null) { throw new ArgumentNullException(nameof(mediaServer)); } if (mediaProvider == null) { throw new ArgumentNullException(nameof(mediaProvider)); } if (settingsSaver == null) { throw new ArgumentNullException(nameof(settingsSaver)); } if (mediaTimer == null) { throw new ArgumentNullException(nameof(mediaTimer)); } if (previewTimer == null) { throw new ArgumentNullException(nameof(previewTimer)); } if (viewPreviewProvider == null) { throw new ArgumentNullException(nameof(viewPreviewProvider)); } _settingsProvider = settingsProvider; _mediaServer = mediaServer; _mediaProvider = mediaProvider; _settingsSaver = settingsSaver; _mediaTimer = mediaTimer; _previewTimer = previewTimer; _viewPreviewProvider = viewPreviewProvider; _settingsProvider.SettingsChanged += (s, o) => { var settingName = (o as System.Configuration.SettingChangingEventArgs).SettingName; switch (settingName) { case nameof(_settingsProvider.UseFade): App.Current.Dispatcher.BeginInvoke(new Action(() => SendPropertyChanged(nameof(UseFade)))); break; } }; _mediaProvider.MediaCollectionPopulated += (s, o) => App.Current.Dispatcher.BeginInvoke(new Action(() => SendPropertyChanged(nameof(CurrentMedia)))); _mediaProvider.MediaCollectionChanged += (s, o) => App.Current.Dispatcher.BeginInvoke(new Action(() => SendPropertyChanged(nameof(MediaCollection)))); _mediaServer.CurrentMediaUpdated += (s, o) => App.Current.Dispatcher.BeginInvoke(new Action(() => SendPropertyChanged(nameof(CurrentMedia)))); _mediaProvider.ForceUpdate(); SendPropertyChanged(nameof(_settingsProvider.ShowPreview)); _previewTimer.Initialize(TimeSpan.FromSeconds(1), () => UpdatePreview()); _previewTimer.Start(); }