private void ResetExampleLabels() { GUIControl.ClearControl(GetID, (int)Controls.CONTROL_EXAMPLE); GUIControl.ClearControl(GetID, (int)Controls.CONTROL_EXAMPLE2); const string exampleText = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; const string exampleText2 = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc.\n\n" + "Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante.\n\n" + "Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna.\n\n" + "Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. Nulla facilisi. Integer lacinia sollicitudin massa.\n\n" + "Cras metus. Sed aliquet risus a tortor. Integer id quam. Morbi mi. Quisque nisl felis, venenatis tristique, dignissim in, ultrices sit amet, augue. Proin sodales libero eget ante. Nulla quam. Aenean laoreet. Vestibulum nisi lectus, commodo ac, facilisis ac, ultricies eu, pede. Ut orci risus, accumsan porttitor, cursus quis, aliquet eget, justo. Sed pretium blandit orci.\n"; GUIControl.AddItemLabelControl(GetID, (int)Controls.CONTROL_EXAMPLE, exampleText); GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_EXAMPLE2, exampleText2); }
private void Search() { Log.Info("newsearch Search:{0} {1}", _searchKeyword, SearchFor); GUIControl.ClearControl(GetID, listResults.GetID); TvBusinessLayer layer = new TvBusinessLayer(); IList <Program> listPrograms = null; switch (SearchFor) { case SearchType.Genres: listPrograms = layer.SearchProgramsPerGenre("%" + _searchKeyword + "%", ""); break; case SearchType.KeyWord: listPrograms = layer.SearchProgramsByDescription("%" + _searchKeyword); break; case SearchType.Title: listPrograms = layer.SearchPrograms("%" + _searchKeyword); break; } if (listPrograms == null) { return; } if (listPrograms.Count == 0) { return; } Log.Info("newsearch found:{0} progs", listPrograms.Count); foreach (Program program in listPrograms) { GUIListItem item = new GUIListItem(); item.Label = TVUtil.GetDisplayTitle(program); string logo = Utils.GetCoverArt(Thumbs.TVChannel, program.ReferencedChannel().DisplayName); if (string.IsNullOrEmpty(logo)) { logo = "defaultVideoBig.png"; } item.ThumbnailImage = logo; item.IconImageBig = logo; item.IconImage = logo; item.TVTag = program; listResults.Add(item); } }
private void LoadRelatated() { if (Youtube2MP.NowPlayingEntry.RelatedVideosUri != null) { GUIControl.ClearControl(GetID, listControl.GetID); relatated.Clear(); Video video = Youtube2MP.request.Retrieve <Video>(new Uri("http://gdata.youtube.com/feeds/api/videos/" + Youtube2MP.NowPlayingEntry.VideoId)); YouTubeQuery query = new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", video.Author)); YouTubeFeed vidr = Youtube2MP.service.Query(query); if (vidr.Entries.Count > 0) { addVideos(vidr, query); } } }
private void RefreshActors() { // clear facade GUIControl.ClearControl(GetID, FacadeActors.GetID); // delete thumbs DeleteActorThumbs(); // clear properties ClearProperties(); // delete this series actors from database DBActor.ClearDB(SeriesId); // reload DownloadActorsList(); }
protected void FillSimilarList() { //if (GUIWindowManager.ActiveWindow != GetID) // return; if (listsimilar == null) { return; } GUIControl.ClearControl(GetID, listsimilar.GetID); if (similar == null || similar.Count < 1) { return; } foreach (GUIListItem item in similar) { listsimilar.Add(item); } listsimilar.SelectedListItemIndex = 0; }
private void ShowWideBanners() { GUIControl.ClearControl(this.GetID, m_Facade.GetID); AnimeSeriesVM ser = JMMServerHelper.GetSeries(MainWindow.GlobalSeriesID); if (ser != null) { if (ser.CrossRef_AniDB_TvDBV2 != null && ser.CrossRef_AniDB_TvDBV2.Count > 0) { AnimeID = ser.CrossRef_AniDB_TvDBV2[0].AnimeID; } } if (ser != null) { List <TvDB_ImageWideBannerVM> tvDBWideBanners = ser.AniDB_Anime.AniDB_AnimeCrossRefs.TvDBImageWideBanners; GUIListItem item = null; foreach (TvDB_ImageWideBannerVM banner in tvDBWideBanners) { item = new GUIListItem(); item.IconImage = item.IconImageBig = banner.FullImagePath; item.TVTag = banner; item.OnItemSelected += new GUIListItem.ItemSelectedHandler(onFacadeItemSelected); m_Facade.Add(item); } if (m_Facade.Count > 0) { m_Facade.SelectedListItemIndex = 0; TvDB_ImageWideBannerVM selectedBanner = m_Facade.SelectedListItem.TVTag as TvDB_ImageWideBannerVM; if (selectedBanner != null) { SetWideBannerProperties(selectedBanner); } GUIControl.FocusControl(GetID, 50); } } }
public void Sort() { if (facadeItems == null || facadeItems.Count < 1) { return; } facadeItems.Sort(new ListItemComparer(sortProperty, !sortAsc)); GUIControl.ClearControl(Plugin.WINDOW_ID, facade.GetID); for (int i = 0; i < facadeItems.Count; i++) { if (showSortValue) { facadeItems[i].SetLabel2(sortProperty); } GUIControl.AddListItemControl(Plugin.WINDOW_ID, facade.GetID, facadeItems[i]); } setFacadeIndex(0); }
protected void FillRelatedList() { //if (GUIWindowManager.ActiveWindow != GetID) // return; if (listControl == null) { return; } GUIControl.ClearControl(GetID, listControl.GetID); if (relatated == null || relatated.Count < 1) { return; } foreach (GUIListItem item in relatated) { listControl.Add(item); item.RefreshCoverArt(); } listControl.SelectedListItemIndex = 0; OnDownloadTimedEvent(null, null); GUIPropertyManager.SetProperty("#itemcount", listControl.Count.ToString()); }
protected void ClearLists() { relatated.Clear(); similar.Clear(); if (GUIWindowManager.ActiveWindow != GetID) { return; } lock (locker) { if (listControl != null) { GUIControl.ClearControl(GetID, listControl.GetID); } if (listsimilar != null) { GUIControl.ClearControl(GetID, listsimilar.GetID); } } }
private void LoadFacade(List <DBActor> actors) { // clear facade GUIControl.ClearControl(GetID, FacadeActors.GetID); // set number of actors property GUIPropertyManager.SetProperty("#itemcount", actors.Count().ToString()); // notify user if no actors to display and backout of window if (actors.Count == 0) { SetProperty("NoActors", Translation.NoActors); TVSeriesPlugin.ShowNotifyDialog(Translation.Actors, Translation.NoActors); GUIWindowManager.ShowPreviousWindow(); } // Add each actor to the list foreach (var actor in actors) { GUIActorListItem actorItem = new GUIActorListItem(actor.ToString()); actorItem.Item = actor; actorItem.IconImage = "defaultActor.png"; actorItem.IconImageBig = "defaultActor.png"; actorItem.ThumbnailImage = "defaultActor.png"; actorItem.OnItemSelected += OnActorSelected; Utils.SetDefaultIcons(actorItem); FacadeActors.Add(actorItem); } FacadeActors.SelectedListItemIndex = 0; // Download actor images async and set to facade GetImages(actors); // Set Facade Layout FacadeActors.CurrentLayout = (GUIFacadeControl.Layout)CurrentLayout; GUIControl.FocusControl(GetID, FacadeActors.GetID); }
private void SendPopularMoviesToFacade(TraktMoviesPopular PopularItems) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (PopularItems == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); PopularMoviePages = null; return; } // filter movies var filteredPopularList = FilterPopularMovies(PopularItems.Movies).Where(m => !string.IsNullOrEmpty(m.Title)).ToList(); // sort movies filteredPopularList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByPopularMovies.Field, TraktSettings.SortByPopularMovies.Direction)); int itemId = 0; var movieImages = new List <GUITmdbImage>(); // Add Previous Page Button if (PopularItems.CurrentPage != 1) { var prevPageItem = new GUIMovieListItem(Translation.PreviousPage, (int)TraktGUIWindows.PopularMovies); prevPageItem.IsPrevPageItem = true; prevPageItem.IconImage = "traktPreviousPage.png"; prevPageItem.IconImageBig = "traktPreviousPage.png"; prevPageItem.ThumbnailImage = "traktPreviousPage.png"; prevPageItem.OnItemSelected += OnPreviousPageSelected; prevPageItem.IsFolder = true; Facade.Add(prevPageItem); itemId++; } // Add each movie mark remote if not in collection foreach (var PopularItem in filteredPopularList) { // add image for download var images = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = PopularItem.Ids.Tmdb } }; movieImages.Add(images); var item = new GUIMovieListItem(PopularItem.Title, (int)TraktGUIWindows.PopularMovies); item.Label2 = PopularItem.Year == null ? "----" : PopularItem.Year.ToString(); item.TVTag = PopularItem; item.Movie = PopularItem; item.Images = images; item.IsPlayed = PopularItem.IsWatched(); item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Add Next Page Button if (PopularItems.CurrentPage != PopularItems.TotalPages) { var nextPageItem = new GUIMovieListItem(Translation.NextPage, (int)TraktGUIWindows.PopularMovies); nextPageItem.IsNextPageItem = true; nextPageItem.IconImage = "traktNextPage.png"; nextPageItem.IconImageBig = "traktNextPage.png"; nextPageItem.ThumbnailImage = "traktNextPage.png"; nextPageItem.OnItemSelected += OnNextPageSelected; nextPageItem.IsFolder = true; Facade.Add(nextPageItem); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", filteredPopularList.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", filteredPopularList.Count(), filteredPopularList.Count() > 1 ? Translation.Movies : Translation.Movie)); // Page Properties GUIUtils.SetProperty("#Trakt.Facade.CurrentPage", PopularItems.CurrentPage.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalPages", PopularItems.TotalPages.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalItemsPerPage", TraktSettings.MaxPopularMoviesRequest.ToString()); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void ClearFileItems() { GUIControl.ClearControl(GetID, facadeLayout.GetID); }
private void SendBoxOfficeToFacade(IEnumerable <TraktMovieBoxOffice> boxOffice) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (boxOffice == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); return; } if (boxOffice.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoBoxOffice); GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; var movieImages = new List <GUITmdbImage>(); // Add each movie foreach (var box in boxOffice.Where(b => !string.IsNullOrEmpty(b.Movie.Title))) { var item = new GUIMovieListItem(box.Movie.Title, (int)TraktGUIWindows.BoxOffice); // add image for download var image = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = box.Movie.Ids.Tmdb } }; movieImages.Add(image); item.Label2 = box.Movie.Year == null ? "----" : box.Movie.Year.ToString(); item.TVTag = box; item.Movie = box.Movie; item.Images = image; item.IsPlayed = box.Movie.IsWatched(); item.ItemId = Int32.MaxValue - itemId; // movie in collection doesnt nessararily mean // that the movie is locally available on this computer // as 'keep library clean' might not be enabled //item.IsRemote = !movie.InCollection; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", boxOffice.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", boxOffice.Count().ToString(), boxOffice.Count() > 1 ? Translation.Movies : Translation.Movie)); int totalRevenue = boxOffice.Sum(b => b.Revenue); GUIUtils.SetProperty("#Trakt.BoxOffice.Total.Revenue", string.Format("{0:C0}", totalRevenue)); GUIUtils.SetProperty("#Trakt.BoxOffice.Total.Revenue.Raw", totalRevenue.ToString()); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void LoadDirectory() { IList <Conflict> conflictsList = Conflict.ListAll(); btnConflicts.Visible = conflictsList.Count > 0; GUIControl.ClearControl(GetID, listSchedules.GetID); IList <Schedule> schedulesList = Schedule.ListAll(); int total = 0; bool showSeries = btnSeries.Selected; if ((selectedItem != null) && (showSeries)) { IList <Schedule> seriesList = TVHome.Util.GetRecordingTimes(selectedItem); GUIListItem item = new GUIListItem(); item.Label = ".."; item.IsFolder = true; listSchedules.Add(item); //don't increment total for ".." //total++; foreach (Schedule schedule in seriesList) { if (DateTime.Now > schedule.EndTime) { continue; } if (schedule.Canceled != Schedule.MinSchedule) { continue; } item = Schedule2ListItem(schedule); item.TVTag = schedule; listSchedules.Add(item); total++; } } else { foreach (Schedule rec in schedulesList) { GUIListItem item = new GUIListItem(); if (rec.ScheduleType != (int)ScheduleRecordingType.Once) { if (showSeries) { item = Schedule2ListItem(rec); item.TVTag = rec; item.IsFolder = true; listSchedules.Add(item); total++; } else { IList <Schedule> seriesList = TVHome.Util.GetRecordingTimes(rec); for (int serieNr = 0; serieNr < seriesList.Count; ++serieNr) { Schedule recSeries = (Schedule)seriesList[serieNr]; if (DateTime.Now > recSeries.EndTime) { continue; } if (recSeries.Canceled != Schedule.MinSchedule) { continue; } item = Schedule2ListItem(recSeries); item.MusicTag = rec; item.TVTag = recSeries; listSchedules.Add(item); total++; } } } //if (recs.Count > 1 && currentSortMethod == SortMethod.Date) else { //single recording if (showSeries) { continue; // do not show single recordings if showSeries is enabled } if (rec.IsSerieIsCanceled(rec.StartTime, rec.IdChannel)) { continue; } //Test if this is an instance of a series recording, if so skip it. if (rec.ReferencedSchedule() != null) { continue; } item = Schedule2ListItem(rec); item.TVTag = rec; listSchedules.Add(item); total++; } } //foreach (Schedule rec in itemlist) } //set object count label GUIPropertyManager.SetProperty("#itemcount", Utils.GetObjectCountLabel(total)); if (total == 0) { SetProperties(null, null); } OnSort(); UpdateButtonStates(); }
private void SendRecentlyWatchedToFacade(IEnumerable <TraktMovieHistory> recentlyWatched) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); // protected profiles might return null if (recentlyWatched == null || recentlyWatched.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.UserHasNotWatchedMovies); PreviousUser = CurrentUser; CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; var movieImages = new List <GUITmdbImage>(); // Add each item watched foreach (var recent in recentlyWatched) { // bad data in API if (recent.Movie == null) { continue; } // add image for download var images = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = recent.Movie.Ids.Tmdb } }; movieImages.Add(images); var item = new GUIMovieListItem(recent.Movie.Title, (int)TraktGUIWindows.RecentWatchedMovies); // add user watched date as second label item.Label2 = recent.WatchedAt.ToPrettyDateTime(); item.Date = recent.WatchedAt.FromISO8601().ToLongDateString(); item.Action = recent.Action; item.TVTag = recent.Movie; item.Movie = recent.Movie; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IsPlayed = CurrentUser != TraktSettings.Username ? recent.Movie.IsWatched() : false; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= recentlyWatched.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", recentlyWatched.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", recentlyWatched.Count().ToString(), recentlyWatched.Count() > 1 ? Translation.Movies : Translation.Movie)); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedShow = selectedItem.TVTag as TraktWatchListShow; if (selectedShow == null) { return; } var 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): TraktHelper.AddShowToWatchList(selectedShow); selectedShow.InWatchList = true; OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromWatchList): PreviousSelectedIndex = this.Facade.SelectedListItemIndex; TraktHelper.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): TraktHelper.ShowRelatedShows(selectedShow); break; case ((int)ContextMenuItem.Rate): GUICommon.RateShow(selectedShow); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); if (CurrentUser != TraktSettings.Username) { GUIWatchListShows.ClearCache(TraktSettings.Username); } break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowTVShowShouts(selectedShow); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedShow); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); 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(); }
/// <summary> /// this is actually loading a database view not a directory /// and this is done via view handler so parameter is not used /// but is needed to override method in base class /// </summary> /// <param name="strNotUsed">Used to implement method in base class but not used</param> protected override void LoadDirectory(string strNotUsed) { GUIWaitCursor.Show(); GUIListItem SelectedItem = facadeLayout.SelectedListItem; int previousLevel = ((MusicViewHandler)handler).PreviousLevel; string strSelectedItem = string.Empty; if (SelectedItem != null) { // if there is an item selected and we are loading a new view // then store the existing value so when we navigate back up through // the view levels we can focus on the item we had selected // we can not use current level in the name for the directory history // as current level gets updated before LoadDirectory is called // therefore use previous level which is set by the music view handler // when that returns (ie. that will be level of the view user has // made selection from as it has not been cleared yet) if (SelectedItem.IsFolder && SelectedItem.Label != "..") { m_history.Set(SelectedItem.Label, handler.LocalizedCurrentView + "." + previousLevel.ToString()); } } List <Song> songs; if (!((MusicViewHandler)handler).Execute(out songs)) { GUIWaitCursor.Hide(); Action action = new Action(); action.wID = Action.ActionType.ACTION_PREVIOUS_MENU; GUIGraphicsContext.OnAction(action); return; } GUIControl.ClearControl(GetID, facadeLayout.GetID); SwitchLayout(); List <GUIListItem> itemsToAdd = new List <GUIListItem>(); TimeSpan totalPlayingTime = new TimeSpan(); if (previousLevel > handler.CurrentLevel) { // only need to lookup values when navigating back up through the view strSelectedItem = m_history.Get(handler.LocalizedCurrentView + "." + handler.CurrentLevel.ToString()); } #region handle pin protected share if (songs.Count > 0) // some songs in there? { Song song = songs[0]; if (song.FileName.Length > 0) // does a filename exits { foreach (Share share in _shareList) { if (song.FileName.Contains(share.Path)) // compare it with shares { if (share.Pincode != string.Empty) // does it have a pincode? { GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0); GUIWindowManager.SendMessage(msg); // ask for the userinput if (msg.Label != share.Pincode) { songs.Clear(); } break; } } } } } #endregion if (handler.CurrentLevel > 0) { // add ".." folder item if not at bottom level of view GUIListItem pItem = new GUIListItem(".."); pItem.Path = string.Empty; pItem.IsFolder = true; Util.Utils.SetDefaultIcons(pItem); itemsToAdd.Add(pItem); } // Get current Filter used var currentFilter = (FilterDefinition)handler.View.Filters[handler.CurrentLevel]; for (int i = 0; i < songs.Count; ++i) { Song song = songs[i]; GUIListItem item = new GUIListItem(); MusicTag tag = new MusicTag(); tag = song.ToMusicTag(); item.AlbumInfoTag = song; item.MusicTag = tag; if (handler.CurrentLevel + 1 < handler.MaxLevels) { item.IsFolder = true; item.Label = MusicViewHandler.GetFieldValue(song, handler.CurrentLevelWhere); // If we are grouping on a specific value, we have in the Duration field the number of items // Use this in the sort field if (currentFilter.SqlOperator == "group") { item.Label2 = tag.Duration.ToString(); } else { SetSortLabel(ref item, CurrentSortMethod, handler.CurrentLevelWhere); } } else { item.IsFolder = false; if (!GUIMusicBaseWindow.SetTrackLabels(ref item, CurrentSortMethod)) { item.Label = song.Title; } } if (tag != null) { if (tag.Duration > 0) { totalPlayingTime = totalPlayingTime.Add(new TimeSpan(0, 0, tag.Duration)); } } item.Path = song.FileName; if (!string.IsNullOrEmpty(_currentPlaying) && item.Path.Equals(_currentPlaying, StringComparison.OrdinalIgnoreCase)) { item.Selected = true; } item.Duration = song.Duration; tag.TimesPlayed = song.TimesPlayed; item.Rating = song.Rating; item.Year = song.Year; item.OnRetrieveArt += new GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt); item.OnItemSelected += new GUIListItem.ItemSelectedHandler(item_OnItemSelected); itemsToAdd.Add(item); } itemsToAdd.Sort(new MusicSort(CurrentSortMethod, CurrentSortAsc)); int iItem = 0; // used to hold index of item to select bool itemSelected = false; for (int i = 0; i < itemsToAdd.Count; ++i) { if (!itemSelected && itemsToAdd[i].Label == strSelectedItem) { iItem = i; itemSelected = true; } facadeLayout.Add(itemsToAdd[i]); } int iTotalItems = facadeLayout.Count; if (iTotalItems > 0) { GUIListItem rootItem = facadeLayout[0]; if (rootItem.Label == "..") { iTotalItems--; } } //set object count label, total duration GUIPropertyManager.SetProperty("#itemcount", Util.Utils.GetObjectCountLabel(iTotalItems)); if (totalPlayingTime.TotalSeconds > 0) { GUIPropertyManager.SetProperty("#totalduration", Util.Utils.SecondsToHMSString((int)totalPlayingTime.TotalSeconds)); } else { GUIPropertyManager.SetProperty("#totalduration", string.Empty); } if (itemSelected) { GUIControl.SelectItemControl(GetID, facadeLayout.GetID, iItem); } else if (m_iItemSelected >= 0) { GUIControl.SelectItemControl(GetID, facadeLayout.GetID, m_iItemSelected); } else { SelectCurrentItem(); } UpdateButtonStates(); GUIWaitCursor.Hide(); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedMovie = selectedItem.TVTag as TraktWatchListMovie; if (selectedMovie == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // only allow removal if viewing your own watch list if (CurrentUser == TraktSettings.Username) { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } else if (!selectedMovie.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; // Mark As Watched if (!selectedMovie.Watched) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (selectedMovie.Watched) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } // Add to Library // Don't allow if it will be removed again on next sync // movie could be part of a DVD collection if (!selectedMovie.InCollection && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedMovie.InCollection) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } // Related Movies listItem = new GUIListItem(Translation.RelatedMovies + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Movie listItem = new GUIListItem(Translation.RateMovie); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { // Trailers listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (!selectedMovie.InCollection && TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for movie with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (!selectedMovie.InCollection && TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for movie 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.MarkAsWatched): TraktHelper.MarkMovieAsWatched(selectedMovie); if (CurrentUser != TraktSettings.Username) { if (selectedMovie.Plays == 0) { selectedMovie.Plays = 1; } selectedMovie.Watched = true; selectedItem.IsPlayed = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); GUIWatchListMovies.ClearCache(TraktSettings.Username); } else { // when marking a movie as seen via API, it will remove from watch list // we should do the same in GUI PreviousSelectedIndex = this.Facade.SelectedListItemIndex; if (_WatchListMovies.Count() >= 1) { // remove from list var moviesToExcept = new List <TraktWatchListMovie>(); moviesToExcept.Add(selectedMovie); _WatchListMovies = WatchListMovies.Except(moviesToExcept); userWatchList[CurrentUser] = _WatchListMovies; LoadWatchListMovies(); } else { // no more movies left ClearProperties(); GUIControl.ClearControl(GetID, Facade.GetID); _WatchListMovies = null; userWatchList.Remove(CurrentUser); // notify and exit GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoMovieWatchList); GUIWindowManager.ShowPreviousWindow(); return; } } break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.MarkMovieAsUnWatched(selectedMovie); selectedMovie.Watched = false; selectedItem.IsPlayed = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddMovieToWatchList(selectedMovie, true); selectedMovie.InWatchList = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromWatchList): PreviousSelectedIndex = this.Facade.SelectedListItemIndex; TraktHelper.RemoveMovieFromWatchList(selectedMovie, true); if (_WatchListMovies.Count() >= 1) { // remove from list var moviesToExcept = new List <TraktWatchListMovie>(); moviesToExcept.Add(selectedMovie); _WatchListMovies = WatchListMovies.Except(moviesToExcept); userWatchList[CurrentUser] = _WatchListMovies; LoadWatchListMovies(); } else { // no more movies left ClearProperties(); GUIControl.ClearControl(GetID, Facade.GetID); _WatchListMovies = null; userWatchList.Remove(CurrentUser); // notify and exit GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoMovieWatchList); GUIWindowManager.ShowPreviousWindow(); return; } break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveMovieInUserList(selectedMovie.Title, selectedMovie.Year, selectedMovie.IMDBID, false); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowMovieTrailersMenu(selectedMovie); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddMovieToLibrary(selectedMovie); selectedMovie.InCollection = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (CurrentUser != TraktSettings.Username) { GUIWatchListMovies.ClearCache(TraktSettings.Username); } break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromLibrary(selectedMovie); selectedMovie.InCollection = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (CurrentUser != TraktSettings.Username) { GUIWatchListMovies.ClearCache(TraktSettings.Username); } break; case ((int)ContextMenuItem.Related): TraktHelper.ShowRelatedMovies(selectedMovie); break; case ((int)ContextMenuItem.Rate): GUICommon.RateMovie(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (CurrentUser != TraktSettings.Username) { GUIWatchListMovies.ClearCache(TraktSettings.Username); } break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowMovieShouts(selectedMovie); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedMovie.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedMovie.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
private void SendSearchResultsToFacade(IEnumerable <TraktEpisodeSummaryEx> episodes) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (episodes == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); Episodes = null; return; } if (episodes.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound); GUIWindowManager.ShowPreviousWindow(); Episodes = null; return; } int itemId = 0; var showImages = new List <GUITmdbImage>(); // Add each show foreach (var episodeSummary in episodes) { // add images for download var images = new GUITmdbImage { EpisodeImages = new TmdbEpisodeImages { Id = episodeSummary.Show.Ids.Tmdb, Season = episodeSummary.Episode.Season, Episode = episodeSummary.Episode.Number, AirDate = episodeSummary.Episode.FirstAired == null ? null : episodeSummary.Episode.FirstAired.FromISO8601().ToLocalTime().ToShortDateString() } }; showImages.Add(images); var item = new GUIEpisodeListItem(episodeSummary.ToString(), (int)TraktGUIWindows.SearchEpisodes); item.Label2 = episodeSummary.Show.Year.ToString(); item.TVTag = episodeSummary; item.Episode = episodeSummary.Episode; item.Show = episodeSummary.Show; item.Images = images; item.IsPlayed = episodeSummary.Episode.IsWatched(episodeSummary.Show); item.ItemId = Int32.MaxValue - itemId; item.IconImage = "defaultTraktEpisode.png"; item.IconImageBig = "defaultTraktEpisodeBig.png"; item.ThumbnailImage = "defaultTraktEpisodeBig.png"; item.OnItemSelected += OnEpisodeSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); if (SearchTermChanged) { PreviousSelectedIndex = 0; } Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", episodes.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", episodes.Count().ToString(), episodes.Count() > 1 ? Translation.Episodes : Translation.Episode)); // Download images Async and set to facade GUIEpisodeListItem.GetImages(showImages); }
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); }
/// <summary> /// On Message /// </summary> /// <param name="message"></param> /// <returns></returns> public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: { // fetch settings for the current capture card _cropSettings = TvCropManager.CropSettings; GUILabelControl cardLabel = GetControl((int)Controls.CONTROL_CARD_LABEL) as GUILabelControl; cardLabel.Visible = false; foreach (int iCtl in Enum.GetValues(typeof(Controls))) { if (GetControl(iCtl) is GUISpinControl) { GUISpinControl cntl = (GUISpinControl)GetControl(iCtl); cntl.ShowRange = false; } } GUIControl.ClearControl(GetID, (int)Controls.CONTROL_CROP_TOP); for (int i = 0; i <= 200; ++i) { GUIControl.AddItemLabelControl(GetID, (int)Controls.CONTROL_CROP_TOP, i.ToString()); } GUIControl.SelectItemControl(GetID, (int)Controls.CONTROL_CROP_TOP, _cropSettings.Top); GUIControl.ClearControl(GetID, (int)Controls.CONTROL_CROP_BOTTOM); for (int i = 0; i <= 200; ++i) { GUIControl.AddItemLabelControl(GetID, (int)Controls.CONTROL_CROP_BOTTOM, i.ToString()); } GUIControl.SelectItemControl(GetID, (int)Controls.CONTROL_CROP_BOTTOM, _cropSettings.Bottom); GUIControl.ClearControl(GetID, (int)Controls.CONTROL_CROP_LEFT); for (int i = 0; i <= 200; ++i) { GUIControl.AddItemLabelControl(GetID, (int)Controls.CONTROL_CROP_LEFT, i.ToString()); } GUIControl.SelectItemControl(GetID, (int)Controls.CONTROL_CROP_LEFT, _cropSettings.Left); GUIControl.ClearControl(GetID, (int)Controls.CONTROL_CROP_RIGHT); for (int i = 0; i <= 200; ++i) { GUIControl.AddItemLabelControl(GetID, (int)Controls.CONTROL_CROP_RIGHT, i.ToString()); } GUIControl.SelectItemControl(GetID, (int)Controls.CONTROL_CROP_RIGHT, _cropSettings.Right); break; } case GUIMessage.MessageType.GUI_MSG_CLICKED: { int iControl = message.SenderControlId; if (iControl == (int)Controls.CONTROL_EXIT) { Close(); } else if (iControl == (int)Controls.CONTROL_CROP_TOP) { // do not use message.Label, because it's empty for "page up/down", causing exceptions _cropSettings.Top = (GetControl(iControl) as GUISpinControl).Value; } else if (iControl == (int)Controls.CONTROL_CROP_BOTTOM) { _cropSettings.Bottom = (GetControl(iControl) as GUISpinControl).Value; } else if (iControl == (int)Controls.CONTROL_CROP_LEFT) { _cropSettings.Left = (GetControl(iControl) as GUISpinControl).Value; } else if (iControl == (int)Controls.CONTROL_CROP_RIGHT) { _cropSettings.Right = (GetControl(iControl) as GUISpinControl).Value; } // ativate & save settings for the current capture card TvCropManager.CropSettings = _cropSettings; break; } } return(base.OnMessage(message)); }
private void ShowCharacters() { GUIControl.ClearControl(GetID, m_Facade.GetID); if (dummyMainCharExists != null) { dummyMainCharExists.Visible = false; } if (dummyMainActorExists != null) { dummyMainActorExists.Visible = false; } if (dummySeriesExists != null) { dummySeriesExists.Visible = false; } BaseConfig.MyAnimeLog.Write("CharWindow.GlobalSeriesID = {0}", MainWindow.GlobalSeriesID.ToString()); charList.Clear(); if (serMain?.Anime == null) { ClearGUIProperty(GuiProperty.Title); ClearGUIProperty(GuiProperty.Character_Name); ClearGUIProperty(GuiProperty.Character_KanjiName); ClearGUIProperty(GuiProperty.Actor_Name); ClearGUIProperty(GuiProperty.Actor_KanjiName); ClearGUIProperty(GuiProperty.Character_CharacterCount); return; } serMain = ShokoServerHelper.GetSeries(MainWindow.GlobalSeriesID); if (serMain != null) { mainAnime = serMain.Anime; } else { return; } if (mainAnime == null) { return; } SetGUIProperty(GuiProperty.Character_Main_Title, mainAnime.FormattedTitle); charList = mainAnime.Characters; if (dummyCharactersExist != null) { dummyCharactersExist.Visible = charList.Count > 0; } SetGUIProperty(GuiProperty.Character_CharacterCount, charList.Count.ToString(Globals.Culture)); SetGUIProperty(GuiProperty.Title, serMain.SeriesName); string imagePathNoPicture = GUIGraphicsContext.Skin + @"\Media\MyAnime3\anime3_blankchar.png"; foreach (CL_AniDB_Character aniChar in charList) { string imagePath = imagePathNoPicture; if (!string.IsNullOrEmpty(aniChar.GetPosterPath()) && File.Exists(aniChar.GetPosterPath())) { imagePath = aniChar.GetPosterPath(); } GUIListItem item = new GUIListItem(""); item.IconImage = item.IconImageBig = imagePath; item.TVTag = aniChar; item.OnItemSelected += onFacadeItemSelected; m_Facade.Add(item); } if (m_Facade.Count > 0) { m_Facade.SelectedListItemIndex = 0; CL_AniDB_Character aniChar = m_Facade.SelectedListItem.TVTag as CL_AniDB_Character; if (aniChar != null) { SetCharacterProperties(aniChar); } } }
private void SendCalendarToFacade(Dictionary <string, List <TraktMovieCalendar> > calendar) { // check if we got a bad response if (calendar == null) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.ErrorCalendar); // set defaults MovieCalendar = null; LastRequest = new DateTime(); return; } // clear facade GUIControl.ClearControl(GetID, Facade.GetID); int itemCount = 0; var movieImages = new List <GUITmdbImage>(); // Add Previous Days Item so user can go back to previous calendar entries var prevItem = new GUIListItem(string.Format(Translation.PreviousDays, TraktSettings.MovieCalendarMaxDays)) { IconImage = "traktPreviousPage.png", IconImageBig = "traktPreviousPage.png", ThumbnailImage = "traktPreviousPage.png", TVTag = "previous", IsFolder = true }; prevItem.OnItemSelected += OnPrevWeekSelected; Facade.Add(prevItem); // Add each days episodes to the list // Use Label3 of facade for Day/Group Idenitfier foreach (var day in calendar) { var moviesInDay = day.Value; // filter hidden shows if (FilterHiddenMovies && !string.IsNullOrEmpty(TraktSettings.UserAccessToken)) { // for each hidden trakt show in the calendar, remove from our request // this only needs to be done if we have manually hidden a movie whilst using a cached calendar moviesInDay.RemoveAll(m => m.Movie.IsHidden("calendar")); } if (moviesInDay.Count() > 0) { // add day header var item = new GUIListItem(); item.Label3 = GetDayHeader(day.Key.FromISO8601()); item.IconImage = "defaultTraktPoster.png"; item.IconImageBig = "defaultTraktPosterBig.png"; item.ThumbnailImage = "defaultTraktPosterBig.png"; item.OnItemSelected += OnCalendarDateSelected; Utils.SetDefaultIcons(item); Facade.Add(item); foreach (var calendarItem in moviesInDay) { var movieItem = new GUIMovieListItem(calendarItem.Movie.Title, (int)TraktGUIWindows.CalendarMovies); // add image for download var images = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = calendarItem.Movie.Ids.Tmdb } }; movieImages.Add(images); // extended skin properties movieItem.Date = DateTime.Parse(day.Key).ToLongDateString(); movieItem.SelectedIndex = (itemCount + 1).ToString(); movieItem.Images = images; movieItem.TVTag = calendarItem; movieItem.Movie = calendarItem.Movie; movieItem.ItemId = Int32.MaxValue - itemCount; movieItem.IsPlayed = calendarItem.Movie.IsWatched(); movieItem.IconImage = "defaultTraktPoster.png"; movieItem.IconImageBig = "defaultTraktPosterBig.png"; movieItem.ThumbnailImage = "defaultTraktPosterBig.png"; movieItem.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(movieItem); Facade.Add(movieItem); itemCount++; } } } // if nothing airing this week, then indicate to user if (itemCount == 0) { var item = new GUIListItem() { Label3 = Translation.NoMoviesThisWeek, IconImage = "defaultTraktPoster.png", IconImageBig = "defaultTraktPosterBig.png", ThumbnailImage = "defaultTraktPosterBig.png" }; item.OnItemSelected += OnCalendarDateSelected; Utils.SetDefaultIcons(item); Facade.Add(item); } // Add Next Days Item so user can fetch next days calendar var nextItem = new GUIListItem(string.Format(Translation.NextDays, TraktSettings.MovieCalendarMaxDays)) { IconImage = "traktNextPage.png", IconImageBig = "traktNextPage.png", ThumbnailImage = "traktNextPage.png", TVTag = "next", IsFolder = true }; nextItem.OnItemSelected += OnNextWeekSelected; Facade.Add(nextItem); // Set Facade Layout Facade.CurrentLayout = GUIFacadeControl.Layout.List; GUIControl.FocusControl(GetID, Facade.GetID); // if we cached the last selected index then use it // e.g. returning from another window and the cache has not expired if (PreviousSelectedIndex > 0) { Facade.SelectedListItemIndex = PreviousSelectedIndex; } else { // beginning of a page has a previous button // and a date header, so skip 2 items Facade.SelectedListItemIndex = 2; } // set facade properties GUIUtils.SetProperty("#itemcount", itemCount.ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", itemCount.ToString(), itemCount > 1 ? Translation.Movies : Translation.Movie)); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void SendRecentlyWatchedToFacade(IEnumerable <TraktActivity.Activity> activities) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); // protected profiles might return null if (activities == null || activities.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.UserHasNotWatchedEpisodes); PreviousUser = CurrentUser; CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; var showImages = new List <TraktImage>(); // Add each item watched foreach (var activity in activities) { // bad data in API if (activity.Show == null || activity.Episode == null) { continue; } var episodeSummary = new TraktEpisodeSummary { Episode = activity.Episode, Show = activity.Show }; // skip invalid episodes if (episodeSummary.Episode.Number == 0) { continue; } var item = new GUIEpisodeListItem(episodeSummary.ToString(), (int)TraktGUIWindows.RecentWatchedEpisodes); // add images for download var images = new TraktImage { EpisodeImages = activity.Episode.Images, ShowImages = activity.Show.Images }; showImages.Add(images); // add user watched date as second label item.Label2 = activity.Timestamp.FromEpoch().ToShortDateString(); item.TVTag = episodeSummary; item.Date = activity.Timestamp.FromEpoch().ToLongDateString(); item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IsPlayed = activity.Episode.Watched; item.IconImage = "defaultTraktEpisode.png"; item.IconImageBig = "defaultTraktEpisodeBig.png"; item.ThumbnailImage = "defaultTraktEpisodeBig.png"; item.OnItemSelected += OnEpisodeSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= activities.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", activities.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", activities.Count().ToString(), activities.Count() > 1 ? Translation.Episodes : Translation.Episode)); // Download show images Async and set to facade GUIEpisodeListItem.GetImages(showImages); }
private void SendWatchListShowsToFacade(IEnumerable <TraktWatchListShow> shows) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (shows.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoShowWatchList, CurrentUser)); CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } // sort shows var showList = shows.ToList(); showList.Sort(new GUIListItemShowSorter(TraktSettings.SortByWatchListShows.Field, TraktSettings.SortByWatchListShows.Direction)); int itemId = 0; var showImages = new List <TraktImage>(); // Add each show foreach (var show in showList) { // add image for download var images = new TraktImage { ShowImages = show.Images }; showImages.Add(images); GUIShowListItem item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.WatchedListShows); item.Label2 = show.Year.ToString(); item.TVTag = show; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnShowSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= shows.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", shows.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", shows.Count().ToString(), shows.Count() > 1 ? Translation.SeriesPlural : Translation.Series)); // Download show images Async and set to facade GUIShowListItem.GetImages(showImages); }
private void SendTrendingMoviesToFacade(IEnumerable <TraktTrendingMovie> movies) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (movies.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoTrendingMovies); GUIWindowManager.ShowPreviousWindow(); return; } // filter movies movies = GUICommon.FilterTrendingMovies(movies); // sort movies var movieList = movies.Where(m => !string.IsNullOrEmpty(m.Title)).ToList(); movieList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByTrendingMovies.Field, TraktSettings.SortByTrendingMovies.Direction)); int itemId = 0; var movieImages = new List <TraktImage>(); // Add each movie mark remote if not in collection foreach (var movie in movieList) { // add image for download var images = new TraktImage { MovieImages = movie.Images }; movieImages.Add(images); var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.TrendingMovies); item.Label2 = movie.Year == "0" ? "----" : movie.Year; item.TVTag = movie; item.Images = images; item.IsPlayed = movie.Watched; item.ItemId = Int32.MaxValue - itemId; // movie in collection doesnt nessararily mean // that the movie is locally available on this computer // as 'keep library clean' might not be enabled //item.IsRemote = !movie.InCollection; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", movies.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie)); GUIUtils.SetProperty("#Trakt.Trending.PeopleCount", movies.Sum(m => m.Watchers).ToString()); GUIUtils.SetProperty("#Trakt.Trending.Description", string.Format(Translation.TrendingMoviePeople, movies.Sum(m => m.Watchers).ToString(), movies.Count().ToString())); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void SendWatchListMoviesToFacade(IEnumerable <TraktWatchListMovie> movies) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (movies.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoMovieWatchList, CurrentUser)); CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } // sort movies var movieList = movies.Where(m => !string.IsNullOrEmpty(m.Title)).ToList(); movieList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByWatchListMovies.Field, TraktSettings.SortByWatchListMovies.Direction)); int itemId = 0; var movieImages = new List <TraktImage>(); // Add each movie foreach (var movie in movieList) { // add image for download var images = new TraktImage { MovieImages = movie.Images }; movieImages.Add(images); var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.WatchedListMovies); item.Label2 = movie.Year; item.TVTag = movie; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IsPlayed = movie.Watched; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= movies.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", movies.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie)); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
void DisplayOnlineSites(bool newDataRetrieved, int indexToSelect) { GUIPropertyManager.SetProperty("#OnlineVideos.owner", String.Empty); GUIPropertyManager.SetProperty("#OnlineVideos.desc", String.Empty); if (newDataRetrieved) { SetFilterButtonOptions(); } if (Sites.Updater.OnlineSites == null || Sites.Updater.OnlineSites.Length == 0) { return; } GUIListItem selectedItem = GUI_infoList.SelectedListItem; GUIControl.ClearControl(GetID, GUI_infoList.GetID); var localSitesDic = OnlineVideoSettings.Instance.SiteSettingsList.ToDictionary(s => s.Name, s => s); var onlyLocalSites = OnlineVideoSettings.Instance.SiteSettingsList.ToDictionary(s => s.Name, s => s); List <OnlineVideosWebservice.Site> filteredsortedSites = new List <OnlineVideos.OnlineVideosWebservice.Site>(Sites.Updater.OnlineSites); filteredsortedSites.ForEach(os => { if (localSitesDic.ContainsKey(os.Name)) { onlyLocalSites.Remove(os.Name); } }); filteredsortedSites.AddRange(onlyLocalSites.Select(ls => new OnlineVideosWebservice.Site() { Name = ls.Value.Name, IsAdult = ls.Value.ConfirmAge, Description = ls.Value.Description, Language = ls.Value.Language, LastUpdated = ls.Value.LastUpdated })); filteredsortedSites = filteredsortedSites.FindAll(SitePassesFilter); filteredsortedSites.Sort(CompareSiteForSort); foreach (OnlineVideosWebservice.Site site in filteredsortedSites) { if (!site.IsAdult || !OnlineVideoSettings.Instance.UseAgeConfirmation || OnlineVideoSettings.Instance.AgeConfirmed) { GUIListItem loListItem = new GUIListItem(site.Name); loListItem.TVTag = site; loListItem.Label2 = site.Language; loListItem.Label3 = site.LastUpdated.ToLocalTime().ToString("g", OnlineVideoSettings.Instance.Locale); string image = SiteImageExistenceCache.GetImageForSite(site.Name, "", "Icon", false); if (!string.IsNullOrEmpty(image)) { loListItem.IconImage = image; loListItem.ThumbnailImage = image; } if (!string.IsNullOrEmpty(site.Owner_FK)) { loListItem.PinImage = GUIGraphicsContext.Skin + @"\Media\OnlineVideos\" + site.State.ToString() + ".png"; } loListItem.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(OnSiteSelected); loListItem.IsPlayed = localSitesDic.ContainsKey(site.Name); // GetLocalSite(site.Name) != -1; GUI_infoList.Add(loListItem); if ((selectedItem != null && selectedItem.Label == loListItem.Label) || selectedSite == loListItem.Label || (indexToSelect > -1 && GUI_infoList.Count - 1 == indexToSelect)) { GUI_infoList.SelectedListItemIndex = GUI_infoList.Count - 1; } } } if (GUI_infoList.Count > 0) { GUIControl.SelectItemControl(GetID, GUI_infoList.GetID, GUI_infoList.SelectedListItemIndex); } selectedSite = null; //set object count and type labels GUIPropertyManager.SetProperty("#itemcount", GUI_infoList.Count.ToString()); GUIPropertyManager.SetProperty("#itemtype", Translation.Instance.Sites); }
private void ShowCharacters() { GUIControl.ClearControl(GetID, m_Facade.GetID); BaseConfig.MyAnimeLog.Write("ActorWindow.GlobalSeiyuuID = {0}", MainWindow.GlobalSeiyuuID.ToString(CultureInfo.InvariantCulture)); charList.Clear(); seiyuu = null; seiyuu = VM_ShokoServer.Instance.ShokoServices.GetAniDBSeiyuu(MainWindow.GlobalSeiyuuID); if (seiyuu == null) { ClearGUIProperty(GuiProperty.Actors_Actor_Name); ClearGUIProperty(GuiProperty.Actors_Actor_Poster); ClearGUIProperty(GuiProperty.Actors_Character_CharacterCount); return; } SetGUIProperty(GuiProperty.Actors_Actor_Name, seiyuu.SeiyuuName); string imagePath = GUIGraphicsContext.Skin + @"\Media\MyAnime3\anime3_blankchar.png"; if (File.Exists(seiyuu.GetPosterPath())) { imagePath = seiyuu.GetPosterPath(); } SetGUIProperty(GuiProperty.Actors_Actor_Poster, imagePath); charList = VM_ShokoServer.Instance.ShokoServices.GetCharactersForSeiyuu(MainWindow.GlobalSeiyuuID); bool missingImages = false; string imagePathNoPicture = GUIGraphicsContext.Skin + @"\Media\MyAnime3\anime3_blankchar.png"; foreach (CL_AniDB_Character aniChar in charList) { imagePath = imagePathNoPicture; if (!string.IsNullOrEmpty(aniChar.GetPosterPath()) && File.Exists(aniChar.GetPosterPath())) { imagePath = aniChar.GetPosterPath(); } else { missingImages = true; } GUIListItem item = new GUIListItem(string.Empty); item.IconImage = item.IconImageBig = imagePath; item.TVTag = aniChar; item.OnItemSelected += onFacadeItemSelected; m_Facade.Add(item); BaseConfig.MyAnimeLog.Write(aniChar.ToString()); } if (dummyCharactersExist != null) { dummyCharactersExist.Visible = charList.Count > 0; } SetGUIProperty(GuiProperty.Actors_Character_CharacterCount, charList.Count.ToString(Globals.Culture)); if (m_Facade.Count > 0) { m_Facade.SelectedListItemIndex = 0; CL_AniDB_Character aniChar = m_Facade.SelectedListItem.TVTag as CL_AniDB_Character; if (aniChar != null) { SetCharacterProperties(aniChar); } } if (missingImages) { GetMissingInfo(); } }
void ShowOptionsForSite(OnlineVideosWebservice.Site site) { SiteSettings localSite = null; int localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(site.Name, out localSite); GUIDialogMenu dlgSel = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlgSel.ShowQuickNumbers = false; if (dlgSel != null) { dlgSel.Reset(); dlgSel.SetHeading(Translation.Instance.Actions); if (localSiteIndex == -1) { if (site.State != OnlineVideosWebservice.SiteState.Broken) { dlgSel.Add(Translation.Instance.AddToMySites); } } else { if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 2 && site.State != OnlineVideosWebservice.SiteState.Broken) { dlgSel.Add(Translation.Instance.UpdateMySite); dlgSel.Add(Translation.Instance.UpdateMySiteSkipCategories); } dlgSel.Add(Translation.Instance.RemoveFromMySites); } if (GUI_infoList.Count > 1) { dlgSel.Add(Translation.Instance.RemoveAllFromMySites); dlgSel.Add(Translation.Instance.UpdateAll); dlgSel.Add(Translation.Instance.UpdateAllSkipCategories); } if (!string.IsNullOrEmpty(site.Owner_FK) && localSiteIndex >= 0) // !only local && ! only global { dlgSel.Add(Translation.Instance.ShowReports); if (site.State != OnlineVideosWebservice.SiteState.Broken) { dlgSel.Add(Translation.Instance.ReportBroken); } } } dlgSel.DoModal(GUIWindowManager.ActiveWindow); if (dlgSel.SelectedId == -1) { return; // ESC used, nothing selected } if (dlgSel.SelectedLabelText == Translation.Instance.AddToMySites || dlgSel.SelectedLabelText == Translation.Instance.UpdateMySite || dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories) { if (CheckOnlineVideosVersion()) { Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback( () => { bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites(null, new List <OnlineVideosWebservice.Site> { site }, false, dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories); if (updateResult == true) { newDllsDownloaded = true; } else if (updateResult == null) { newDataSaved = true; } return(updateResult != false); }, (success, result) => { if (success && (bool)result) { SiteImageExistenceCache.UnCacheImageForSite(site.Name); RefreshDisplayedOnlineSites(); } }, Translation.Instance.GettingSiteXml, true); } } else if (dlgSel.SelectedLabelText == Translation.Instance.UpdateAll || dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories) { if (CheckOnlineVideosVersion()) { GUIDialogProgress dlgPrgrs = PrepareProgressDialog(Translation.Instance.FullUpdate); new System.Threading.Thread(delegate() { bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) => { if (dlgPrgrs != null) { if (!string.IsNullOrEmpty(m)) { dlgPrgrs.SetLine(1, m); } if (p != null) { dlgPrgrs.SetPercentage(p.Value); } return(dlgPrgrs.ShouldRenderLayer()); } else { return(true); } }, GUI_infoList.ListItems.Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList(), dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories); if (updateResult == true) { newDllsDownloaded = true; } else if (updateResult == null) { newDataSaved = true; } if (updateResult != false) { SiteImageExistenceCache.ClearCache(); } if (dlgPrgrs != null) { dlgPrgrs.Close(); } GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { RefreshDisplayedOnlineSites(); return(0); }, 0, 0, null); }) { Name = "OVSelectUpdate", IsBackground = true }.Start(); } } else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveFromMySites) { OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex); OnlineVideoSettings.Instance.SaveSites(); newDataSaved = true; RefreshDisplayedOnlineSites(GUI_infoList.SelectedListItemIndex); } else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveAllFromMySites) { bool needRefresh = false; foreach (var siteToRemove in GUI_infoList.ListItems.Where(g => g.IsPlayed).Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList()) { localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(siteToRemove.Name, out localSite); if (localSiteIndex >= 0) { OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex); needRefresh = true; } } if (needRefresh) { OnlineVideoSettings.Instance.SaveSites(); newDataSaved = true; RefreshDisplayedOnlineSites(); } } else if (dlgSel.SelectedLabelText == Translation.Instance.ShowReports) { Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback( () => { OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService(); return(ws.GetReports(site.Name)); }, (success, result) => { if (success) { OnlineVideosWebservice.Report[] reports = result as OnlineVideosWebservice.Report[]; if (reports == null || reports.Length == 0) { GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlg != null) { dlg.Reset(); dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon")); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetText(Translation.Instance.NoReportsForSite); dlg.DoModal(GUIWindowManager.ActiveWindow); } } else { selectedSite = site.Name; GUIControl.ClearControl(GetID, GUI_infoList.GetID); Array.Sort(reports, new Comparison <OnlineVideosWebservice.Report>(delegate(OnlineVideosWebservice.Report a, OnlineVideosWebservice.Report b) { return(b.Date.CompareTo(a.Date)); })); foreach (OnlineVideosWebservice.Report report in reports) { string shortMsg = report.Message.Replace(Environment.NewLine, " ").Replace("\n", " ").Replace("\r", " "); GUIListItem loListItem = new GUIListItem(shortMsg.Length > 44 ? shortMsg.Substring(0, 40) + " ..." : shortMsg); loListItem.TVTag = report; loListItem.Label2 = report.Type.ToString(); loListItem.Label3 = report.Date.ToString("g", OnlineVideoSettings.Instance.Locale); loListItem.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(OnReportSelected); GUI_infoList.Add(loListItem); } GUIControl.SelectItemControl(GetID, GUI_infoList.GetID, 0); GUIPropertyManager.SetProperty("#itemcount", GUI_infoList.Count.ToString()); GUIPropertyManager.SetProperty("#itemtype", Translation.Instance.Reports); } } }, Translation.Instance.GettingReports, true); } else if (dlgSel.SelectedLabelText == Translation.Instance.ReportBroken) { if (CheckOnlineVideosVersion()) { if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 1) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(site.Name); dlg.SetLine(1, Translation.Instance.PleaseUpdateLocalSite); dlg.DoModal(GUIWindowManager.ActiveWindow); } } else { string userReason = ""; if (GUIOnlineVideos.GetUserInputString(ref userReason, false)) { if (userReason.Length < 15) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, Translation.Instance.PleaseEnterDescription); dlg.DoModal(GUIWindowManager.ActiveWindow); } } else { OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService(); string message = ""; bool success = ws.SubmitReport(site.Name, userReason, OnlineVideosWebservice.ReportType.Broken, out message); GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, success ? Translation.Instance.Done : Translation.Instance.Error); dlg.SetLine(2, message); dlg.DoModal(GUIWindowManager.ActiveWindow); } if (success) { // reload online sites OnlineVideos.Sites.Updater.GetRemoteOverviews(true); RefreshDisplayedOnlineSites(); } } } } } } }