示例#1
0
 private void cellularQualityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (doneLoading)
     {
         ApplicationDataContainer roamingSettings = ApplicationData.Current.RoamingSettings;
         AppConstants.CellStreamQuality = (AppConstants.StreamQuality)cellularQualityComboBox.SelectedIndex;
         roamingSettings.Values["cellStreamQuality"] = HelperMethods.GetStreamQualityString(AppConstants.CellStreamQuality);
     }
 }
 private void SetQualityComboBox(AppConstants.StreamQuality quality, ComboBox comboBox)
 {
     for (int i = 0; i < comboBox.Items.Count; i++)
     {
         ComboBoxItem item = comboBox.Items[i] as ComboBoxItem;
         if (item != null)
         {
             if ((string)item.Content == HelperMethods.GetStreamQualityString(quality))
             {
                 comboBox.SelectedIndex = i;
                 break;
             }
         }
     }
 }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            playPauseButton.IsEnabled = false;
            List <object> parameters = (List <object>)e.Parameter;

            stream    = (Stream)parameters[0];
            qualities = (Dictionary <AppConstants.StreamQuality, Uri>)parameters[1];

            volumeFlyout = new VolumeFlyout(volumeSlider, muteButton, volumeButton, streamElement);
            chatWindow   = new ChatWindow(Dispatcher, stream.channel.name, chatListView, scrollViewer, chatBox, sendButton);
            await chatWindow.LoadChatWindow();

            streamerImage.Fill = new ImageBrush()
            {
                ImageSource = new BitmapImage(stream.channel.logo)
            };
            await ResetStatus();

            foreach (KeyValuePair <AppConstants.StreamQuality, Uri> quality in qualities)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Content = HelperMethods.GetStreamQualityString(quality.Key);
                streamQualitiesComboBox.Items.Add(item);
            }
            await PlayStream();

            SetQualityComboBox(qualities.First(u => u.Value == streamElement.Source).Key, streamQualitiesComboBox);

            if (AppConstants.activeUser != null)
            {
                if (AppConstants.activeUser.authorized)
                {
                    int            followingOffset             = 0;
                    List <Channel> followingChannels           = new List <Channel>();
                    Total <List <Follow <Channel> > > channels = null;
                    do
                    {
                        channels = await AppConstants.activeUser.RetrieveFollowing(followingOffset, 100);

                        foreach (Follow <Channel> channel in channels.wrapped)
                        {
                            followingChannels.Add(channel.wrapped);
                        }
                        followingOffset += 100;
                    }while (channels.wrapped.Count != 0);
                    if (AppConstants.activeUser.authorizedScopes.Contains(TwixelAPI.Constants.TwitchConstants.Scope.UserFollowsEdit))
                    {
                        foreach (Channel channel in followingChannels)
                        {
                            if (channel.name == stream.channel.name)
                            {
                                followButton.Label = "Unfollow";
                                ((SymbolIcon)followButton.Icon).Symbol = Symbol.Clear;
                                break;
                            }
                        }
                    }
                    else
                    {
                        followButton.IsEnabled = false;
                    }
                }
                else
                {
                    followButton.IsEnabled = false;
                }
            }
            else
            {
                followButton.IsEnabled = false;
            }
            base.OnNavigatedTo(e);
            doneLoading = true;
        }