GetImages() static private method

Download all images attached to the GUI List Control TODO: Make part of a GUI Base Window
static private GetImages ( List itemsWithThumbs ) : void
itemsWithThumbs List List of images to get
return void
Example #1
0
        private void SendSearchResultsToFacade(IEnumerable <TraktUser> users)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (users == null || users.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound);
                GUIWindowManager.ShowPreviousWindow();
                Users = null;
                return;
            }

            int itemId     = 0;
            var userImages = new List <TraktImage>();

            // Add each user
            foreach (var user in users)
            {
                // add image to download
                var images = new TraktImage {
                    Avatar = user.Avatar
                };
                userImages.Add(images);

                var item = new GUIUserListItem(user.Username, (int)TraktGUIWindows.SearchUsers);

                item.Images          = images;
                item.TVTag           = user;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IconImage       = "defaultTraktUser.png";
                item.IconImageBig    = "defaultTraktUserBig.png";
                item.ThumbnailImage  = "defaultTraktUserBig.png";
                item.OnItemSelected += OnUserSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;
            }

            // Set Facade Layout
            Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout));
            GUIControl.FocusControl(GetID, Facade.GetID);

            if (SearchTermChanged)
            {
                PreviousSelectedIndex = 0;
            }
            Facade.SelectIndex(PreviousSelectedIndex);

            // set facade properties
            GUIUtils.SetProperty("#itemcount", users.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", users.Count().ToString(), users.Count() > 1 ? Translation.Users : Translation.User));

            // Download images Async and set to facade
            GUIUserListItem.GetImages(userImages);
        }
Example #2
0
        private void SendCommentsToFacade(IEnumerable <TraktComment> comments)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (comments == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            // this should not happen for replies as we only enter if more than one
            if (comments.Count() == 0)
            {
                string title = string.Empty;
                switch (ShoutType)
                {
                case ShoutTypeEnum.movie:
                    title = MovieInfo.Title;
                    break;

                case ShoutTypeEnum.show:
                    title = ShowInfo.Title;
                    break;

                case ShoutTypeEnum.season:
                    title = string.Format("{0} - {1} {2}", SeasonInfo.Title, Translation.Season, SeasonInfo.SeasonIdx);
                    break;

                case ShoutTypeEnum.episode:
                    title = EpisodeInfo.ToString();
                    break;
                }
                ClearProperties();
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoShoutsForItem, title));

                if (ExitIfNoShoutsFound)
                {
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
            }

            // filter out the duplicates!
            var distinctComments = comments.Where(s => s.Text != null && s.User != null).Distinct(new ShoutComparer());

            GUIUtils.SetProperty("#itemcount", distinctComments.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", distinctComments.Count(), distinctComments.Count() > 1 ? Translation.Comments : Translation.Shout));

            int selectedParentItem = 0;
            int selectedItemIndex  = 0;

            SelectedParentItems.TryGetValue(CurrentLevel, out selectedParentItem);

            int id         = 0;
            var userImages = new List <GUITraktImage>();

            // Add each user that shouted to the list
            foreach (var comment in distinctComments)
            {
                // add image to download
                var images = new GUITraktImage {
                    UserImages = comment.User.Images
                };
                userImages.Add(images);

                var shoutItem = new GUIUserListItem(comment.User.Username, (int)TraktGUIWindows.Shouts);

                shoutItem.Label2          = comment.CreatedAt.FromISO8601().ToShortDateString();
                shoutItem.Images          = images;
                shoutItem.TVTag           = comment;
                shoutItem.User            = comment.User;
                shoutItem.ItemId          = id++;
                shoutItem.IconImage       = "defaultTraktUser.png";
                shoutItem.IconImageBig    = "defaultTraktUserBig.png";
                shoutItem.ThumbnailImage  = "defaultTraktUserBig.png";
                shoutItem.OnItemSelected += OnCommentSelected;
                Utils.SetDefaultIcons(shoutItem);
                Facade.Add(shoutItem);

                // check if we should select this comment when returning from replies
                if (selectedParentItem == (int)comment.Id)
                {
                    selectedItemIndex = id - 1;
                }
            }

            // Enable / Disable GUI Controls
            EnableGUIButtons();

            // Set Facade Layout
            if (Facade.Count > 0)
            {
                Facade.SetCurrentLayout("List");
                GUIControl.FocusControl(GetID, Facade.GetID);

                Facade.SelectedListItemIndex = selectedItemIndex;
            }
            else
            {
                GUIControl.FocusControl(GetID, nextEpisodeButton.GetID);
            }

            // Download avatars Async and set to facade
            GUIUserListItem.GetImages(userImages);
        }
        private void SendFollowingToFacade(IEnumerable <TraktNetworkUser> following)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);
            ClearProperties();

            if (following == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ActivateWindow(GUIWindowManager.GetPreviousActiveWindow());
                return;
            }

            int followingCount = following.Count();

            GUIUtils.SetProperty("#itemcount", followingCount.ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", followingCount.ToString(), Translation.Followed));

            if (followingCount == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoFollowingTaunt);
                if (viewButton != null)
                {
                    // let user select another view since there is nothing to show here
                    GUIControl.FocusControl(GetID, viewButton.GetID);
                }
                else
                {
                    GUIWindowManager.ShowPreviousWindow();
                }
                return;
            }

            int id = 0;

            var userImages = new List <GUITraktImage>();

            // Add each user to the list
            foreach (var followee in following.OrderBy(f => f.FollowedAt.FromISO8601()).ToList())
            {
                // add image to download
                var images = new GUITraktImage {
                    UserImages = followee.User.Images
                };
                userImages.Add(images);

                var userItem = new GUIUserListItem(followee.User.Username, (int)TraktGUIWindows.Network);

                userItem.Label2          = followee.FollowedAt.FromISO8601().ToShortDateString();
                userItem.TVTag           = followee;
                userItem.User            = followee.User;
                userItem.Images          = images;
                userItem.ItemId          = id++;
                userItem.IsFollowed      = true;
                userItem.IconImage       = "defaultTraktUser.png";
                userItem.IconImageBig    = "defaultTraktUserBig.png";
                userItem.ThumbnailImage  = "defaultTraktUserBig.png";
                userItem.OnItemSelected += OnUserSelected;
                Utils.SetDefaultIcons(userItem);
                Facade.Add(userItem);
            }

            // restore previous selection
            if (Facade.Count <= PreviousUserSelectedIndex)
            {
                Facade.SelectedListItemIndex = 0;
            }
            else
            {
                Facade.SelectedListItemIndex = PreviousUserSelectedIndex;
            }

            // Set Facade Layout
            Facade.CurrentLayout = GUIFacadeControl.Layout.List;
            GUIControl.FocusControl(GetID, Facade.GetID);

            // Download avatars Async and set to facade
            GUIUserListItem.GetImages(userImages);
        }
Example #4
0
        private void SendFriendsToFacade(IEnumerable <TraktNetworkUser> friends)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);
            ClearProperties();

            int friendCount = friends.Count();

            GUIUtils.SetProperty("#itemcount", friendCount.ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", friendCount.ToString(), friendCount > 1 ? Translation.Friends : Translation.Friend));

            if (friendCount == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoFriendsTaunt);
                if (viewButton != null)
                {
                    // let user select another view since there is nothing to show here
                    GUIControl.FocusControl(GetID, viewButton.GetID);
                }
                else
                {
                    GUIWindowManager.ShowPreviousWindow();
                }
                return;
            }

            int id = 0;

            var userImages = new List <TraktImage>();

            // Add each friend to the list
            foreach (var friend in friends.OrderBy(f => f.ApprovedDate))
            {
                // add image to download
                var images = new TraktImage {
                    Avatar = friend.Avatar
                };
                userImages.Add(images);

                var userItem = new GUIUserListItem(friend.Username, (int)TraktGUIWindows.Network);

                userItem.Label2          = friend.ApprovedDate.FromEpoch().ToShortDateString();
                userItem.Images          = images;
                userItem.TVTag           = friend;
                userItem.ItemId          = id++;
                userItem.IsFriend        = true;
                userItem.IconImage       = "defaultTraktUser.png";
                userItem.IconImageBig    = "defaultTraktUserBig.png";
                userItem.ThumbnailImage  = "defaultTraktUserBig.png";
                userItem.OnItemSelected += OnUserSelected;
                Utils.SetDefaultIcons(userItem);
                Facade.Add(userItem);
            }

            // restore previous selection
            if (Facade.Count <= PreviousUserSelectedIndex)
            {
                Facade.SelectedListItemIndex = 0;
            }
            else
            {
                Facade.SelectedListItemIndex = PreviousUserSelectedIndex;
            }

            // Set Facade Layout
            Facade.SetCurrentLayout("List");
            GUIControl.FocusControl(GetID, Facade.GetID);

            // Download avatars Async and set to facade
            GUIUserListItem.GetImages(userImages);
        }
        private void SendShoutsToFacade(IEnumerable <TraktShout> shouts)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (shouts == null || shouts.Count() == 0)
            {
                if (shouts != null)
                {
                    string title = string.Empty;
                    switch (ShoutType)
                    {
                    case ShoutTypeEnum.movie:
                        title = MovieInfo.Title;
                        break;

                    case ShoutTypeEnum.show:
                        title = ShowInfo.Title;
                        break;

                    case ShoutTypeEnum.episode:
                        title = string.Format(EpisodeInfo.ToString());
                        break;
                    }
                    ClearProperties();
                    GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoShoutsForItem, title));
                }
                if (ExitIfNoShoutsFound)
                {
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
            }

            GUIUtils.SetProperty("#itemcount", shouts.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", shouts.Count(), shouts.Count() > 1 ? Translation.Shouts : Translation.Shout));

            int id         = 0;
            var userImages = new List <TraktImage>();

            // Add each user that shouted to the list
            foreach (var shout in shouts)
            {
                // add image to download
                var images = new TraktImage {
                    Avatar = shout.User.Avatar
                };
                userImages.Add(images);

                var shoutItem = new GUIUserListItem(shout.User.Username, (int)TraktGUIWindows.Shouts);

                shoutItem.Label2          = shout.InsertedDate.FromEpoch().ToShortDateString();
                shoutItem.Images          = images;
                shoutItem.TVTag           = shout;
                shoutItem.ItemId          = id++;
                shoutItem.IconImage       = "defaultTraktUser.png";
                shoutItem.IconImageBig    = "defaultTraktUserBig.png";
                shoutItem.ThumbnailImage  = "defaultTraktUserBig.png";
                shoutItem.OnItemSelected += OnShoutSelected;
                Utils.SetDefaultIcons(shoutItem);
                Facade.Add(shoutItem);
            }

            // Enable / Disable GUI Controls
            EnableGUIButtons();

            // Set Facade Layout
            if (Facade.Count > 0)
            {
                Facade.SetCurrentLayout("List");
                GUIControl.FocusControl(GetID, Facade.GetID);

                Facade.SelectedListItemIndex = 0;
            }
            else
            {
                GUIControl.FocusControl(GetID, nextEpisodeButton.GetID);
            }

            // Download avatars Async and set to facade
            GUIUserListItem.GetImages(userImages);
        }