protected override void OnPageLoad() { base.OnPageLoad(); // Clear GUI Properties ClearProperties(); // Requires Login if (!GUICommon.CheckLogin()) { return; } // Init Properties InitProperties(); // Load Watched History LoadRecentlyWatchedEpisodes(); }
protected override void OnPageLoad() { base.OnPageLoad(); // Clear GUI Properties ClearProperties(); // Requires Login if (!GUICommon.CheckLogin()) { return; } // Init Properties InitProperties(); // Load WatchList Movies LoadWatchListMovies(); }
protected override void OnPageLoad() { base.OnPageLoad(); // Clear GUI Properties ClearProperties(); // Requires Login if (!GUICommon.CheckLogin()) { return; } // Init Properties InitProperties(); // Load Recently Added LoadRecentComments(); }
protected override void OnPageLoad() { base.OnPageLoad(); // Clear GUI Properties GUICommon.ClearListProperties(); // Requires Login if (!GUICommon.CheckLogin()) { return; } // Init Properties InitProperties(); // Load Lists basis type LoadLists(); }
protected override void OnPageLoad() { base.OnPageLoad(); // Clear GUI properties ClearProperties(); // Requires Login if (!GUICommon.CheckLogin()) { return; } // Initialize InitProperties(); // Load User Profile LoadUserProfile(); }
protected override void OnPageLoad() { base.OnPageLoad(); // Clear GUI Properties ClearProperties(); // Requires Login if (!GUICommon.CheckLogin()) { return; } // Init Properties InitProperties(); // Load Trending Movies LoadRecommendedMovies(); }
protected override void OnPageLoad() { base.OnPageLoad(); // Clear GUI properties ClearProperties(); // Requires Login if (!GUICommon.CheckLogin()) { return; } // Initialize InitProperties(); // Enable/Disable GUI prev/next buttons EnableGUIButtons(); // Load Shouts for Selected item LoadCommentsList(); }
public static void AddRemoveEpisodeInUserList(string username, string title, string year, string season, string episode, string tvdbid, bool remove) { if (!GUICommon.CheckLogin(false)) { return; } GUIBackgroundTask.Instance.ExecuteInBackgroundAndCallback(() => { return(TraktLists.GetListsForUser(username)); }, delegate(bool success, object result) { if (success) { IEnumerable <TraktUserList> customlists = result as IEnumerable <TraktUserList>; // get slug of lists selected List <string> slugs = TraktLists.GetUserListSelections(customlists.ToList()); if (slugs == null || slugs.Count == 0) { return; } TraktListItem item = new TraktListItem { Type = TraktItemType.episode.ToString(), Title = title, Year = Convert.ToInt32(year), Season = Convert.ToInt32(season), Episode = Convert.ToInt32(episode), TvdbId = tvdbid }; AddRemoveItemInList(slugs, item, remove); } }, Translation.GettingLists, true); }
public static void RemoveMovieFromWatchList(string title, string year, string imdbid, bool updateMovingPicturesFilters) { if (!GUICommon.CheckLogin(false)) { return; } TraktMovieSync syncObject = BasicHandler.CreateMovieSyncData(title, year, imdbid); if (syncObject == null) { return; } Thread syncThread = new Thread(delegate(object obj) { TraktSyncResponse response = TraktAPI.TraktAPI.SyncMovieLibrary(obj as TraktMovieSync, TraktSyncModes.unwatchlist); if (response == null || response.Status != "success") { return; } if (updateMovingPicturesFilters && IsMovingPicturesAvailableAndEnabled) { // Update Categories & Filters MovingPictures.ClearWatchListCache(); MovingPictures.UpdateCategoriesAndFilters(); } GUI.GUIWatchListMovies.ClearCache(TraktSettings.Username); }) { IsBackground = true, Name = "RemoveWatchList" }; syncThread.Start(syncObject); }
/// <summary> /// Shows a Trakt Rate Dialog /// </summary> /// <param name="rateObject">Type of object being rated</param> public static int ShowRateDialog <T>(T rateObject) { if (!GUICommon.CheckLogin(false)) { return(-1); } if (GUIGraphicsContext.form.InvokeRequired) { ShowRateDialogDelegate <T> d = ShowRateDialog <T>; return((int)GUIGraphicsContext.form.Invoke(d, rateObject)); } TraktRateValue currentRating = TraktRateValue.unrate; var ratingDlg = (GUIRateDialog)GUIWindowManager.GetWindow(GUIRateDialog.ID); ratingDlg.Reset(); ratingDlg.SetHeading(Translation.RateHeading); // if item is not rated, it will default to seven if (rateObject is TraktSyncEpisodeRated) { var item = rateObject as TraktSyncEpisodeRated; ratingDlg.SetLine(1, string.Format("{0}x{1} - {2}", item.Season, item.Number, item.Title)); ratingDlg.Rated = item.Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Rating); } else if (rateObject is TraktSyncShowRatedEx) { // for when episode ids are not available we need to sync with both episode and show details var item = rateObject as TraktSyncShowRatedEx; ratingDlg.SetLine(1, string.Format("{0} - {1}x{2}", item.Title, item.Seasons[0].Number, item.Seasons[0].Episodes[0].Number)); ratingDlg.Rated = item.Seasons[0].Episodes[0].Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Seasons[0].Episodes[0].Rating); } else if (rateObject is TraktSyncShowRated) { var item = rateObject as TraktSyncShowRated; ratingDlg.SetLine(1, item.Title); ratingDlg.Rated = item.Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Rating); } else if (rateObject is TraktSyncSeasonRatedEx) { // for when season ids are not available we need to sync with both season and show details var item = rateObject as TraktSyncSeasonRatedEx; ratingDlg.SetLine(1, string.Format("{0} - {1} {2}", item.Title, Translation.Season, item.Seasons[0].Number)); ratingDlg.Rated = item.Seasons[0].Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Seasons[0].Rating); } else { var item = rateObject as TraktSyncMovieRated; ratingDlg.SetLine(1, item.Title); ratingDlg.Rated = item.Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Rating); } // show dialog ratingDlg.DoModal(ratingDlg.GetID); if (!ratingDlg.IsSubmitted) { return(-1); } TraktSyncResponse response = null; if (rateObject is TraktSyncEpisodeRated) { var item = rateObject as TraktSyncEpisodeRated; currentRating = ratingDlg.Rated; item.Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncEpisodeRated).Rating > 0) { response = TraktAPI.TraktAPI.AddEpisodeToRatings(obj as TraktSyncEpisodeRated); } else { response = TraktAPI.TraktAPI.RemoveEpisodeFromRatings(obj as TraktEpisode); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else if (rateObject is TraktSyncShowRatedEx) { // for when episode ids are not available we need to sync with both episode and show details var item = rateObject as TraktSyncShowRatedEx; currentRating = ratingDlg.Rated; item.Seasons[0].Episodes[0].Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncShowRatedEx).Seasons[0].Episodes[0].Rating > 0) { response = TraktAPI.TraktAPI.AddEpisodeToRatingsEx(obj as TraktSyncShowRatedEx); } else { response = TraktAPI.TraktAPI.RemoveEpisodeFromRatingsEx(obj as TraktSyncShowRatedEx); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else if (rateObject is TraktSyncShowRated) { var item = rateObject as TraktSyncShowRated; currentRating = ratingDlg.Rated; item.Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncShowRated).Rating > 0) { response = TraktAPI.TraktAPI.AddShowToRatings(obj as TraktSyncShowRated); } else { response = TraktAPI.TraktAPI.RemoveShowFromRatings(obj as TraktShow); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else if (rateObject is TraktSyncSeasonRatedEx) { // for when season ids are not available we need to sync with both season and show details var item = rateObject as TraktSyncSeasonRatedEx; currentRating = ratingDlg.Rated; item.Seasons[0].Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncSeasonRatedEx).Seasons[0].Rating > 0) { response = TraktAPI.TraktAPI.AddSeasonToRatingsEx(obj as TraktSyncSeasonRatedEx); } else { response = TraktAPI.TraktAPI.RemoveSeasonFromRatingsEx(obj as TraktSyncSeasonRatedEx); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else { var item = rateObject as TraktSyncMovieRated; currentRating = ratingDlg.Rated; item.Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncMovieRated).Rating > 0) { response = TraktAPI.TraktAPI.AddMovieToRatings(obj as TraktSyncMovieRated); } else { response = TraktAPI.TraktAPI.RemoveMovieFromRatings(obj as TraktMovie); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } return((int)currentRating); }
/// <summary> /// Shows a Trakt Rate Dialog /// </summary> /// <param name="rateObject">Type of object being rated</param> public static int ShowRateDialog <T>(T rateObject) { // Wait playback is fully stopped to avoid loop on stop while (g_Player.FullScreen || GUIGraphicsContext.Vmr9Active) { Thread.Sleep(10); } if (!GUICommon.CheckLogin(false)) { return(-1); } if (GUIGraphicsContext.form.InvokeRequired) { ShowRateDialogDelegate <T> d = ShowRateDialog <T>; return((int)GUIGraphicsContext.form.Invoke(d, rateObject)); } // The WiFi Remote is using an older version of the API which causes a conflict after recent refactoring // This check is put in place so it does not cripple users experience when rate dialog is invoked if (!TraktHelper.IsWifiRemotePluginCompatible) { GUIUtils.ShowOKDialog(Translation.Error, Translation.WifiRemotePluginInCompatible); return(-1); } TraktRateValue currentRating = TraktRateValue.unrate; var ratingDlg = (GUIRateDialog)GUIWindowManager.GetWindow(GUIRateDialog.ID); ratingDlg.Reset(); ratingDlg.SetHeading(Translation.RateHeading); // if item is not rated, it will default to seven if (rateObject is TraktSyncEpisodeRated) { var item = rateObject as TraktSyncEpisodeRated; ratingDlg.SetLine(1, string.Format("{0}x{1} - {2}", item.Season, item.Number, item.Title)); ratingDlg.Rated = item.Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Rating); } else if (rateObject is TraktSyncShowRatedEx) { // for when episode ids are not available we need to sync with both episode and show details var item = rateObject as TraktSyncShowRatedEx; ratingDlg.SetLine(1, string.Format("{0} - {1}x{2}", item.Title, item.Seasons[0].Number, item.Seasons[0].Episodes[0].Number)); ratingDlg.Rated = item.Seasons[0].Episodes[0].Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Seasons[0].Episodes[0].Rating); } else if (rateObject is TraktSyncShowRated) { var item = rateObject as TraktSyncShowRated; ratingDlg.SetLine(1, item.Title); ratingDlg.Rated = item.Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Rating); } else if (rateObject is TraktSyncSeasonRatedEx) { // for when season ids are not available we need to sync with both season and show details var item = rateObject as TraktSyncSeasonRatedEx; ratingDlg.SetLine(1, string.Format("{0} - {1} {2}", item.Title, Translation.Season, item.Seasons[0].Number)); ratingDlg.Rated = item.Seasons[0].Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Seasons[0].Rating); } else { var item = rateObject as TraktSyncMovieRated; ratingDlg.SetLine(1, item.Title); ratingDlg.Rated = item.Rating == 0 ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Rating); } // show dialog ratingDlg.DoModal(ratingDlg.GetID); if (!ratingDlg.IsSubmitted) { return(-1); } TraktSyncResponse response = null; if (rateObject is TraktSyncEpisodeRated) { var item = rateObject as TraktSyncEpisodeRated; currentRating = ratingDlg.Rated; item.Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncEpisodeRated).Rating > 0) { response = TraktAPI.TraktAPI.AddEpisodeToRatings(obj as TraktSyncEpisodeRated); } else { response = TraktAPI.TraktAPI.RemoveEpisodeFromRatings(obj as TraktEpisode); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else if (rateObject is TraktSyncShowRatedEx) { // for when episode ids are not available we need to sync with both episode and show details var item = rateObject as TraktSyncShowRatedEx; currentRating = ratingDlg.Rated; item.Seasons[0].Episodes[0].Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncShowRatedEx).Seasons[0].Episodes[0].Rating > 0) { response = TraktAPI.TraktAPI.AddEpisodeToRatingsEx(obj as TraktSyncShowRatedEx); } else { response = TraktAPI.TraktAPI.RemoveEpisodeFromRatingsEx(obj as TraktSyncShowRatedEx); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else if (rateObject is TraktSyncShowRated) { var item = rateObject as TraktSyncShowRated; currentRating = ratingDlg.Rated; item.Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncShowRated).Rating > 0) { response = TraktAPI.TraktAPI.AddShowToRatings(obj as TraktSyncShowRated); } else { response = TraktAPI.TraktAPI.RemoveShowFromRatings(obj as TraktShow); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else if (rateObject is TraktSyncSeasonRatedEx) { // for when season ids are not available we need to sync with both season and show details var item = rateObject as TraktSyncSeasonRatedEx; currentRating = ratingDlg.Rated; item.Seasons[0].Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncSeasonRatedEx).Seasons[0].Rating > 0) { response = TraktAPI.TraktAPI.AddSeasonToRatingsEx(obj as TraktSyncSeasonRatedEx); } else { response = TraktAPI.TraktAPI.RemoveSeasonFromRatingsEx(obj as TraktSyncSeasonRatedEx); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else { var item = rateObject as TraktSyncMovieRated; currentRating = ratingDlg.Rated; item.Rating = (int)currentRating; var rateThread = new Thread((obj) => { if ((obj as TraktSyncMovieRated).Rating > 0) { response = TraktAPI.TraktAPI.AddMovieToRatings(obj as TraktSyncMovieRated); } else { response = TraktAPI.TraktAPI.RemoveMovieFromRatings(obj as TraktMovie); } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } return((int)currentRating); }