private void MonitorStreamsModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == nameof(MonitorStreamsModel.CanRefreshLivestreams))
     {
         CanRefreshLivestreams = MonitorStreamsModel.CanRefreshLivestreams;
     }
     else if (e.PropertyName == nameof(MonitorStreamsModel.SelectedLivestream) || e.PropertyName == nameof(MonitorStreamsModel.CanOpenStream))
     {
         var selectedLivestream = MonitorStreamsModel.SelectedLivestream;
         CanOpenChat = selectedLivestream != null && selectedLivestream.ApiClient.HasChatSupport;
         // would like a nicer way of resetting the stream qualities when changing selected streams or the currently selected stream changes between offline/online
         StreamQualities.Clear();
         if (MonitorStreamsModel.CanOpenStream)
         {
             if (selectedLivestream.IsPartner) // twitch partner specific
             {
                 StreamQualities.AddRange(Enum.GetNames(typeof(StreamQuality)));
             }
             else
             {
                 StreamQualities.AddRange(new[] { StreamQuality.Best.ToString(), StreamQuality.Worst.ToString(), });
             }
             MonitorStreamsModel.SetDefaultSelectedStreamQuality();
         }
     }
 }
Esempio n. 2
0
        public TopStreamsViewModel(
            IMonitorStreamsModel monitorStreamsModel,
            ISettingsHandler settingsHandler,
            StreamLauncher streamLauncher,
            INavigationService navigationService,
            IApiClientFactory apiClientFactory)
        {
            if (monitorStreamsModel == null)
            {
                throw new ArgumentNullException(nameof(monitorStreamsModel));
            }
            if (settingsHandler == null)
            {
                throw new ArgumentNullException(nameof(settingsHandler));
            }
            if (streamLauncher == null)
            {
                throw new ArgumentNullException(nameof(streamLauncher));
            }
            if (navigationService == null)
            {
                throw new ArgumentNullException(nameof(navigationService));
            }
            if (apiClientFactory == null)
            {
                throw new ArgumentNullException(nameof(apiClientFactory));
            }

            this.monitorStreamsModel = monitorStreamsModel;
            this.settingsHandler     = settingsHandler;
            this.streamLauncher      = streamLauncher;
            this.navigationService   = navigationService;
            this.apiClientFactory    = apiClientFactory;

            ItemsPerPage = STREAM_TILES_PER_PAGE;
            StreamQualities.AddRange(Enum.GetNames(typeof(StreamQuality)));

            PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(Page))
                {
                    NotifyOfPropertyChange(() => CanPrevious);
                }
            };
        }