Exemplo n.º 1
0
        private string GetEntityID(ImageDownloadRequest req)
        {
            switch (req.ImageType)
            {
            case ImageEntityType.AniDB_Cover:

                AniDB_AnimeVM anime = req.ImageData as AniDB_AnimeVM;
                return(anime.AnimeID.ToString());

            case ImageEntityType.TvDB_Cover:

                TvDB_ImagePosterVM poster = req.ImageData as TvDB_ImagePosterVM;
                return(poster.TvDB_ImagePosterID.ToString());

            case ImageEntityType.TvDB_Banner:

                TvDB_ImageWideBannerVM banner = req.ImageData as TvDB_ImageWideBannerVM;
                return(banner.TvDB_ImageWideBannerID.ToString());

            case ImageEntityType.TvDB_Episode:

                TvDB_EpisodeVM episode = req.ImageData as TvDB_EpisodeVM;
                return(episode.TvDB_EpisodeID.ToString());

            case ImageEntityType.TvDB_FanArt:

                TvDB_ImageFanartVM fanart = req.ImageData as TvDB_ImageFanartVM;
                return(fanart.TvDB_ImageFanartID.ToString());

            case ImageEntityType.MovieDB_Poster:

                MovieDB_PosterVM moviePoster = req.ImageData as MovieDB_PosterVM;
                return(moviePoster.MovieDB_PosterID.ToString());

            case ImageEntityType.MovieDB_FanArt:

                MovieDB_FanartVM movieFanart = req.ImageData as MovieDB_FanartVM;
                return(movieFanart.MovieDB_FanartID.ToString());

            case ImageEntityType.Trakt_Poster:

                Trakt_ImagePosterVM traktPoster = req.ImageData as Trakt_ImagePosterVM;
                return(traktPoster.Trakt_ImagePosterID.ToString());

            case ImageEntityType.Trakt_Fanart:

                Trakt_ImageFanartVM trakFanart = req.ImageData as Trakt_ImageFanartVM;
                return(trakFanart.Trakt_ImageFanartID.ToString());

            case ImageEntityType.Trakt_Friend:

                Trakt_FriendVM trakFriend = req.ImageData as Trakt_FriendVM;
                return(trakFriend.Trakt_FriendID.ToString());

            case ImageEntityType.Trakt_ActivityScrobble:

                Trakt_ActivityScrobbleVM trakScrobble = req.ImageData as Trakt_ActivityScrobbleVM;
                return(trakScrobble.User.Trakt_FriendID.ToString());

            case ImageEntityType.Trakt_ShoutUser:

                Trakt_ShoutUserVM traktShoutUser = req.ImageData as Trakt_ShoutUserVM;
                return(traktShoutUser.User.Trakt_FriendID.ToString());

            case ImageEntityType.Trakt_Episode:

                Trakt_EpisodeVM trakEp = req.ImageData as Trakt_EpisodeVM;
                return(trakEp.Trakt_EpisodeID.ToString());

            case ImageEntityType.Trakt_WatchedEpisode:

                Trakt_WatchedEpisodeVM trakwEp = req.ImageData as Trakt_WatchedEpisodeVM;
                return(trakwEp.Trakt_EpisodeID.ToString());

            default:
                return("");
            }
        }
Exemplo n.º 2
0
        public void RefreshTraktActivity()
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    TraktActivity.Clear();
                    TraktShouts.Clear();
                });

                JMMServerBinary.Contract_Trakt_Activity traktActivity = JMMServerVM.Instance.clientBinaryHTTP.GetTraktFriendInfo(20,
                                                                                                                                 false, true, false);

                if (traktActivity.HasTraktAccount)
                {
                    string blankImageName = @"/Images/blankposter.png";
                    if (AppSettings.DashMetroImageType == DashboardMetroImageType.Fanart)
                    {
                        blankImageName = @"/Images/blankfanart.png";
                    }

                    int numItems = 0;

                    // first get all the shouts
                    foreach (JMMServerBinary.Contract_Trakt_FriendActivity contractAct in traktActivity.TraktFriendActivity)
                    {
                        if (contractAct.ActivityAction == (int)TraktActivityAction.Shout)
                        {
                            if (contractAct.ActivityType == (int)TraktActivityType.Episode)
                            {
                                Trakt_ActivityShoutEpisodeVM shoutEp = new Trakt_ActivityShoutEpisodeVM(contractAct);

                                TraktShoutTile tile = new TraktShoutTile()
                                {
                                    ShowName            = shoutEp.Shout.ShowTitle,
                                    ShowPicture         = blankImageName,
                                    Details             = shoutEp.Shout.EpisodeDescription + Environment.NewLine + shoutEp.Shout.Text,
                                    ShoutDateString     = shoutEp.ActivityDateString,
                                    FriendName          = shoutEp.User.Username,
                                    FriendPicture       = blankImageName,
                                    OnlineShowPicture   = shoutEp.Shout.OnlineImagePath,
                                    OnlineFriendPicture = shoutEp.User.Avatar,
                                    URL      = shoutEp.Shout.Episode_Url,
                                    TileSize = "Large",
                                    Height   = 100
                                };

                                TraktShouts.Add(tile);
                                imagesToDownload.Add(tile);
                                numItems = 1;
                            }
                            else
                            {
                                Trakt_ActivityShoutShowVM shoutShow = new Trakt_ActivityShoutShowVM(contractAct);

                                TraktShoutTile tile = new TraktShoutTile()
                                {
                                    ShowName            = shoutShow.Shout.ShowTitle,
                                    ShowPicture         = blankImageName,
                                    Details             = shoutShow.Shout.Text,
                                    ShoutDateString     = shoutShow.ActivityDateString,
                                    FriendName          = shoutShow.User.Username,
                                    FriendPicture       = blankImageName,
                                    URL                 = shoutShow.Shout.TraktShow.url,
                                    OnlineShowPicture   = shoutShow.Shout.OnlineImagePath,
                                    OnlineFriendPicture = shoutShow.User.Avatar,
                                    TileSize            = "Large",
                                    Height              = 100
                                };

                                TraktShouts.Add(tile);
                                imagesToDownload.Add(tile);
                                numItems = 1;
                            }
                        }
                    }

                    if (TraktShouts.Count > 0)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                        {
                            TraktActivity.Add(TraktShouts[0]);
                        });
                    }

                    traktActivity = JMMServerVM.Instance.clientBinaryHTTP.GetTraktFriendInfo(AppSettings.DashMetro_TraktActivity_Items + 1,
                                                                                             false, false, true);

                    foreach (JMMServerBinary.Contract_Trakt_FriendActivity contractAct in traktActivity.TraktFriendActivity)
                    {
                        if (numItems == AppSettings.DashMetro_TraktActivity_Items)
                        {
                            break;
                        }

                        if (contractAct.ActivityAction == (int)TraktActivityAction.Scrobble)
                        {
                            Trakt_ActivityScrobbleVM scrobble = new Trakt_ActivityScrobbleVM(contractAct);

                            TraktActivityTile tile = new TraktActivityTile()
                            {
                                Scrobble       = scrobble,
                                ShowName       = scrobble.Episode.ShowTitle,
                                ShowPicture    = blankImageName,
                                EpisodeDetails = scrobble.Episode.EpisodeDescription,
                                URL            = scrobble.Episode.Episode_Url,
                                FriendName     = scrobble.User.Username,
                                FriendPicture  = blankImageName,
                                TileSize       = "Large",
                                Height         = 100
                            };

                            numItems++;

                            System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                            {
                                TraktActivity.Add(tile);
                            });

                            imagesToDownload.Add(tile);
                        }
                    }
                }
                else
                {
                    Trakt_SignupVM signup = new Trakt_SignupVM();
                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        TraktActivity.Add(signup);
                    });
                }

                OnFinishedProcess(new FinishedProcessEventArgs(DashboardMetroProcessType.TraktActivity));
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Exemplo n.º 3
0
        private string GetFileName(ImageDownloadRequest req, bool thumbNailOnly)
        {
            switch (req.ImageType)
            {
            case ImageEntityType.AniDB_Cover:

                AniDB_AnimeVM anime = req.ImageData as AniDB_AnimeVM;
                return(anime.PosterPathNoDefaultPlain);

            case ImageEntityType.TvDB_Cover:

                TvDB_ImagePosterVM poster = req.ImageData as TvDB_ImagePosterVM;
                return(poster.FullImagePathPlain);

            case ImageEntityType.TvDB_Banner:

                TvDB_ImageWideBannerVM banner = req.ImageData as TvDB_ImageWideBannerVM;
                return(banner.FullImagePathPlain);

            case ImageEntityType.TvDB_Episode:

                TvDB_EpisodeVM episode = req.ImageData as TvDB_EpisodeVM;
                return(episode.FullImagePathPlain);

            case ImageEntityType.TvDB_FanArt:

                TvDB_ImageFanartVM fanart = req.ImageData as TvDB_ImageFanartVM;

                if (thumbNailOnly)
                {
                    return(fanart.FullThumbnailPathPlain);
                }
                else
                {
                    return(fanart.FullImagePathPlain);
                }

            case ImageEntityType.MovieDB_Poster:

                MovieDB_PosterVM moviePoster = req.ImageData as MovieDB_PosterVM;
                return(moviePoster.FullImagePathPlain);

            case ImageEntityType.MovieDB_FanArt:

                MovieDB_FanartVM movieFanart = req.ImageData as MovieDB_FanartVM;
                return(movieFanart.FullImagePathPlain);

            case ImageEntityType.Trakt_Poster:

                Trakt_ImagePosterVM traktPoster = req.ImageData as Trakt_ImagePosterVM;
                return(traktPoster.FullImagePathPlain);

            case ImageEntityType.Trakt_Fanart:

                Trakt_ImageFanartVM trakFanart = req.ImageData as Trakt_ImageFanartVM;
                return(trakFanart.FullImagePathPlain);

            case ImageEntityType.Trakt_Friend:

                Trakt_FriendVM trakFriend = req.ImageData as Trakt_FriendVM;
                return(trakFriend.FullImagePathPlain);

            case ImageEntityType.Trakt_ActivityScrobble:

                Trakt_ActivityScrobbleVM trakScrobble = req.ImageData as Trakt_ActivityScrobbleVM;
                return(trakScrobble.UserFullImagePathPlain);

            case ImageEntityType.Trakt_ShoutUser:

                Trakt_ShoutUserVM trakShoutUser = req.ImageData as Trakt_ShoutUserVM;
                return(trakShoutUser.UserFullImagePathPlain);

            case ImageEntityType.Trakt_Episode:

                Trakt_EpisodeVM trakEp = req.ImageData as Trakt_EpisodeVM;
                return(trakEp.FullImagePathPlain);

            case ImageEntityType.Trakt_WatchedEpisode:

                Trakt_WatchedEpisodeVM trakwEp = req.ImageData as Trakt_WatchedEpisodeVM;
                return(trakwEp.FullImagePathPlain);

            default:
                return("");
            }
        }
Exemplo n.º 4
0
        public void RefreshTraktFriends(bool traktScrobbles, bool traktShouts)
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    TraktActivity.Clear();
                });

                JMMServerBinary.Contract_Trakt_Activity traktActivity = JMMServerVM.Instance.clientBinaryHTTP.GetTraktFriendInfo(AppSettings.Dash_TraktFriends_Items,
                                                                                                                                 AppSettings.Dash_TraktFriends_AnimeOnly, traktShouts, traktScrobbles);

                List <object> activity = new List <object>();

                if (traktActivity.HasTraktAccount)
                {
                    foreach (JMMServerBinary.Contract_Trakt_FriendFrequest contractFriend in traktActivity.TraktFriendRequests)
                    {
                        Trakt_FriendRequestVM req = new Trakt_FriendRequestVM(contractFriend);
                        activity.Add(req);
                    }

                    foreach (JMMServerBinary.Contract_Trakt_FriendActivity contractAct in traktActivity.TraktFriendActivity)
                    {
                        if (contractAct.ActivityAction == (int)TraktActivityAction.Scrobble)
                        {
                            Trakt_ActivityScrobbleVM scrobble = new Trakt_ActivityScrobbleVM(contractAct);

                            if (!string.IsNullOrEmpty(scrobble.UserFullImagePath) && !File.Exists(scrobble.UserFullImagePath))
                            {
                                // re-download the friends avatar image
                                try
                                {
                                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                                    {
                                        ImageDownloadRequest req = new ImageDownloadRequest(ImageEntityType.Trakt_ActivityScrobble, scrobble, true);
                                        MainWindow.imageHelper.DownloadImage(req);
                                    });
                                }
                                catch (Exception ex)
                                {
                                    logger.ErrorException(ex.ToString(), ex);
                                }
                            }

                            activity.Add(scrobble);
                        }
                        else if (contractAct.ActivityAction == (int)TraktActivityAction.Shout)
                        {
                            if (contractAct.ActivityType == (int)TraktActivityType.Episode)
                            {
                                Trakt_ActivityShoutEpisodeVM shoutEp = new Trakt_ActivityShoutEpisodeVM(contractAct);
                                activity.Add(shoutEp);
                            }
                            else
                            {
                                Trakt_ActivityShoutShowVM shoutShow = new Trakt_ActivityShoutShowVM(contractAct);
                                activity.Add(shoutShow);
                            }
                        }
                    }

                    foreach (JMMServerBinary.Contract_Trakt_Friend contract in traktActivity.TraktFriends)
                    {
                        if (contract.WatchedEpisodes != null && contract.WatchedEpisodes.Count > 0)
                        {
                            Trakt_FriendVM friend = new Trakt_FriendVM(contract);
                            activity.Add(friend);
                        }
                    }
                }
                else
                {
                    Trakt_SignupVM signup = new Trakt_SignupVM();
                    activity.Add(signup);
                }

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    foreach (object act in activity)
                    {
                        TraktActivity.Add(act);
                    }
                    ViewTraktActivity.Refresh();
                });
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
            finally
            {
            }
        }