Exemplo n.º 1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (AppConstants.activeUser.authorized)
            {
                user = AppConstants.activeUser;
                try
                {
                    channel = await user.RetrieveChannel();
                }
                catch (TwixelException ex)
                {
                    await HelperMethods.ShowErrorDialog(ex);
                }
                if (channel != null)
                {
                    statusTextBox.Text = channel.status;
                    if (channel.game != null)
                    {
                        gameTextBox.Text = channel.game;
                    }
                    await PlayStream();
                }

                volumeFlyout = new VolumeFlyout(volumeSlider, muteButton, volumeButton, streamPlayer);
                chatWindow   = new ChatWindow(Dispatcher, user.name, chatListView, chatScrollViewer, chatBox, sendButton);
                await chatWindow.LoadChatWindow();

                streamKeyTextBox.Text = user.streamKey;
                await LoadOnlineStreams();
                await LoadFollowingChannels();
                await LoadBlockedUsers();
                await LoadChannelEditors();
            }
            base.OnNavigatedTo(e);
        }
        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;
        }