Example #1
0
        /// <summary>
        /// Gets followed streamers
        /// </summary>
        /// <returns>UserFollowData object wich has a list of followed streamers' information</returns>
        private async Task <UserFollowData> getFollowedStreamers()
        {
            //used
            UserFollowData returnValue = null;

            string twitchUserName = txtTwitchUserName.Text;
            int    twitchUserID;

            twitchUserID = await getUserID(twitchUserName);

            returnValue = APICalls.GetFollowedStreamers(twitchUserID);

            return(returnValue);
        }
        /// <summary>
        /// Loads the first 20 followed streamers and inserts them into datagridview
        /// </summary>
        /// <param name="followedStreamerObject">Objects to insert into the datagridview</param>
        private void LoadTabFollowedStreamers(UserFollowData followedStreamerObject)
        {
            //Iprogress to update GUI Thread
            var addToDataGridView = new Progress <StreamerDataGridViewValues>(value =>
            {
                StreamerDataGridView.Rows.Add(value.ButtonText, value.StreamerImage, value.StreamerName);
            });
            var updateGUIThread = addToDataGridView as IProgress <StreamerDataGridViewValues>;

            try
            {
                SharedFunctions.ClearDataGridView(StreamerDataGridView);
                _paginationStack.Push(followedStreamerObject.pagination.cursor);

                string streamerLoginNames = "";
                //Create followed streamer URL Query
                followedStreamerObject.Data.ForEach(streamerFollowed => streamerLoginNames = streamerLoginNames + streamerFollowed.to_id + "&id=");
                //Cleaning up last "&id="
                streamerLoginNames = streamerLoginNames.Substring(0, streamerLoginNames.Length - 3);


                UserDataInformation followedStreamersList = APICalls.GetStreamerInformation(streamerLoginNames);
                _followedStreamerInformation = followedStreamersList.User;

                Task.Run(() =>
                {
                    followedStreamersList.User.ForEach(streamer =>
                    {
                        Bitmap bitmap = SharedFunctions.GetBitmapImage(streamer.profile_image_url);
                        updateGUIThread.Report(new StreamerDataGridViewValues("Select", bitmap, streamer.login));
                    });
                });
            }
            catch (ArgumentOutOfRangeException e)
            {
                updateGUIThread.Report(new StreamerDataGridViewValues("No More Streamers", Properties.Resources.RedX,
                                                                      "Click Previous button to go back to streamers"));
                Console.WriteLine(e.Message);
            }
            catch (NullReferenceException e)
            {
                updateGUIThread.Report(new StreamerDataGridViewValues("No More Streamers", Properties.Resources.RedX,
                                                                      "Click Previous button to go back to streamers"));
                Console.WriteLine(e.Message);
            }
        }
Example #3
0
        private async Task <UserDataInformation> getUserInformation()
        {
            //used
            UserDataInformation user = null;
            UserFollowData      followedStreamerList = await getFollowedStreamers();

            string streamerLoginNames = "";

            //Create first 20 followed URL Query
            followedStreamerList.Data.ForEach(streamerFollowed => streamerLoginNames = streamerLoginNames + streamerFollowed.to_name + "&login="******"&login="
            streamerLoginNames = streamerLoginNames.Substring(0, streamerLoginNames.Length - 7);

            user = APICalls.GetStreamerInformation(streamerLoginNames);

            return(user);
        }