/// <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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fills the datagridview with the VODList
        /// </summary>
        /// <param name="VODList">List of VOD objects to fill the datagridview</param>
        private void FillPastStreamsDataGridView(VODMasterObject VODList)
        {
            //Iprogress to update GUI Thread
            var addToDataGridView = new Progress <StreamDataGridViewValues>(value =>
            {
                if (value.IsGoodStreamObject)
                {
                    StreamDataGridView.Rows.Add(value.ButtonText, value.StreamTitle, value.StreamImage, value.StreamDescription);
                }
                else
                {
                    StreamDataGridView.Rows.Add(value.ButtonText, value.StreamTitle, value.StreamImage, value.StreamDescription);
                    NextButton.Visible     = false;
                    PreviousButton.Visible = false;
                }
            });
            var updateGUIThread = addToDataGridView as IProgress <StreamDataGridViewValues>;

            string videoType = VideoTypeComboBox.Text;

            try
            {
                SharedFunctions.ClearDataGridView(StreamDataGridView);

                _VODList        = VODList.data;
                _lastPagination = _pagination;
                _pagination     = VODList.pagination.cursor;

                Task.Run(() =>
                {
                    if (VODList.data.Count != 0)
                    {
                        foreach (var vod in VODList.data)
                        {
                            Bitmap bitmap;
                            string thumbnail = vod.thumbnail_url.Replace("%{width}", "300").Replace("%{height}", "200");

                            if (thumbnail != "")
                            {
                                bitmap = SharedFunctions.GetBitmapImage(thumbnail);
                            }
                            else
                            {
                                bitmap = new Bitmap(Properties.Resources.replacementIcon);
                            }

                            updateGUIThread.Report(new StreamDataGridViewValues("Download", vod.title, bitmap, vod.description, true));
                        }
                    }
                    else
                    {
                        updateGUIThread.Report(new StreamDataGridViewValues("No videos", "No videos under " + videoType + ". Please click Apply to reset the list with a new Video Type or pick a new streamer.", new Bitmap(Properties.Resources.RedX), "", false));
                    }
                });
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine(e.Message);
                updateGUIThread.Report(new StreamDataGridViewValues("No videos", "No more videos under " + videoType + ". Please click Apply to reset the list.", new Bitmap(Properties.Resources.RedX), "", false));
            }
        }