private TraktShowSync CreateSyncData(TraktWatchListShow show) { if (show == null) { return(null); } List <TraktShowSync.Show> shows = new List <TraktShowSync.Show>(); TraktShowSync.Show syncShow = new TraktShowSync.Show { TVDBID = show.Tvdb, Title = show.Title, Year = show.Year }; shows.Add(syncShow); TraktShowSync syncData = new TraktShowSync { UserName = TraktSettings.Username, Password = TraktSettings.Password, Shows = shows }; return(syncData); }
private void OnShowSelected(GUIListItem item, GUIControl parent) { TraktWatchListShow show = item.TVTag as TraktWatchListShow; PublishShowSkinProperties(show); GUIImageHandler.LoadFanart(backdrop, show.Images.FanartImageFilename); }
private void OnShowSelected(GUIListItem item, GUIControl parent) { PreviousSelectedIndex = Facade.SelectedListItemIndex; TraktWatchListShow show = item.TVTag as TraktWatchListShow; PublishShowSkinProperties(show); GUIImageHandler.LoadFanart(backdrop, show.Images.Fanart.LocalImageFilename(ArtworkType.ShowFanart)); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { // wait for any background action to finish if (GUIBackgroundTask.Instance.IsBusy) { return; } switch (controlId) { // Facade case (50): if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { if (TraktSettings.EnableJumpToForTVShows) { CheckAndPlayEpisode(true); } else { GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } TraktWatchListShow selectedShow = (TraktWatchListShow)selectedItem.TVTag; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); } } break; // Layout Button case (2): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout); break; // Sort Button case (8): var newSortBy = GUICommon.ShowSortMenu(TraktSettings.SortByWatchListShows); if (newSortBy != null) { if (newSortBy.Field != TraktSettings.SortByWatchListShows.Field) { TraktSettings.SortByWatchListShows = newSortBy; PreviousSelectedIndex = 0; UpdateButtonState(); LoadWatchListShows(); } } break; default: break; } base.OnClicked(controlId, control, actionType); }
/// <summary> /// Loads an Image from memory into a facade item /// </summary> /// <param name="imageFilePath">Filename of image</param> protected void SetImageToGui(string imageFilePath) { if (string.IsNullOrEmpty(imageFilePath)) { return; } // determine the overlays to add to poster TraktWatchListShow show = TVTag as TraktWatchListShow; MainOverlayImage mainOverlay = MainOverlayImage.None; // only show watch list icon if viewing someone elses watch list if ((GUIWatchListShows.CurrentUser != TraktSettings.Username) && show.InWatchList) { mainOverlay = MainOverlayImage.Watchlist; } RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(show.RatingAdvanced); // get a reference to a MediaPortal Texture Identifier string suffix = mainOverlay.ToString().Replace(", ", string.Empty) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay); string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix); // build memory image Image memoryImage = null; if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None) { memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay); if (memoryImage == null) { return; } // load texture into facade item if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0) { ThumbnailImage = texture; IconImage = texture; IconImageBig = texture; } } else { ThumbnailImage = imageFilePath; IconImage = imageFilePath; IconImageBig = imageFilePath; } // if selected and is current window force an update of thumbnail this.UpdateItemIfSelected((int)TraktGUIWindows.WatchedListShows, ItemId); }
private void RemoveShowFromWatchList(TraktWatchListShow show) { Thread syncThread = new Thread(delegate(object obj) { TraktAPI.TraktAPI.SyncShowWatchList(CreateSyncData(obj as TraktWatchListShow), TraktSyncModes.unwatchlist); }) { IsBackground = true, Name = "RemoveWatchList" }; syncThread.Start(show); }
private void CheckAndPlayEpisode(bool jumpTo) { GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } TraktWatchListShow selectedShow = (TraktWatchListShow)selectedItem.TVTag; GUICommon.CheckAndPlayFirstUnwatched(selectedShow, jumpTo); }
public int Compare(TraktWatchListShow showX, TraktWatchListShow showY) { if (_sortField == SortingFields.WatchListInserted) { int rtn = showX.Inserted.CompareTo(showY.Inserted); if (_sortDirection == SortingDirections.Descending) { rtn = -rtn; } return(rtn); } return(Compare(showX as TraktShow, showY as TraktShow)); }
private void PublishShowSkinProperties(TraktWatchListShow show) { GUICommon.SetProperty("#Trakt.Show.WatchList.Inserted", show.Inserted.FromEpoch().ToShortDateString()); GUICommon.SetShowProperties(show); }
protected override void OnShowContextMenu() { GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } TraktWatchListShow selectedShow = (TraktWatchListShow)selectedItem.TVTag; IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Show Season Information listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo; if (CurrentUser == TraktSettings.Username) { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } else if (!selectedShow.InWatchList) { // viewing someone else's watch list and not in yours listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } // Add to Custom List listItem = new GUIListItem(Translation.AddToList + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Related Shows listItem = new GUIListItem(Translation.RelatedShows + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Show listItem = new GUIListItem(Translation.RateShow); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for show with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for show with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); break; case ((int)ContextMenuItem.AddToWatchList): AddShowToWatchList(selectedShow); selectedShow.InWatchList = true; OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveFromWatchList): PreviousSelectedIndex = this.Facade.SelectedListItemIndex; RemoveShowFromWatchList(selectedShow); if (_WatchListShows.Count() >= 1) { // remove from list var showsToExcept = new List <TraktWatchListShow>(); showsToExcept.Add(selectedShow); _WatchListShows = WatchListShows.Except(showsToExcept); userWatchList[CurrentUser] = _WatchListShows; LoadWatchListShows(); } else { // no more shows left ClearProperties(); GUIControl.ClearControl(GetID, Facade.GetID); _WatchListShows = null; userWatchList.Remove(CurrentUser); // notify and exit GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoShowWatchList); GUIWindowManager.ShowPreviousWindow(); return; } break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false); break; case ((int)ContextMenuItem.Related): RelatedShow relatedShow = new RelatedShow(); relatedShow.Title = selectedShow.Title; relatedShow.TVDbId = selectedShow.Tvdb; GUIRelatedShows.relatedShow = relatedShow; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedShows); break; case ((int)ContextMenuItem.Rate): GUICommon.RateShow(selectedShow); OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); if (CurrentUser != TraktSettings.Username) { GUIWatchListShows.ClearCache(TraktSettings.Username); } break; case ((int)ContextMenuItem.Shouts): GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.show; GUIShouts.ShowInfo = new ShowShout { IMDbId = selectedShow.Imdb, TVDbId = selectedShow.Tvdb, Title = selectedShow.Title }; GUIShouts.Fanart = selectedShow.Images.FanartImageFilename; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedShow); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedShow.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedShow.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }