private void SetRec(VM_Recommendation rec) { if (rec == null) { return; } SetGUIProperty(GuiProperty.Recommendations_Rec_Title, rec.Recommended_DisplayName); SetGUIProperty(GuiProperty.Recommendations_Rec_Description, rec.Recommended_Description); SetGUIProperty(GuiProperty.Recommendations_Rec_ApprovalRating, rec.Recommended_ApprovalRating); SetGUIProperty(GuiProperty.Recommendations_Rec_Image, rec.Recommended_PosterPath); try { if (rec.Recommended_AniDB_Anime != null) { SetGUIProperty(GuiProperty.Recommendations_Rec_AniDBRating, rec.Recommended_AniDB_Anime.AniDBRatingFormatted); } else { ClearGUIProperty(GuiProperty.Recommendations_Rec_AniDBRating); } } catch (Exception ex) { BaseConfig.MyAnimeLog.Write(ex.ToString()); } SetGUIProperty(GuiProperty.Recommendations_BasedOn_Title, rec.BasedOn_DisplayName); SetGUIProperty(GuiProperty.Recommendations_BasedOn_VoteValue, rec.BasedOn_VoteValueFormatted); SetGUIProperty(GuiProperty.Recommendations_BasedOn_Image, rec.BasedOn_PosterPath); }
private void CommandBinding_IgnoreAnimeDownload(object sender, ExecutedRoutedEventArgs e) { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(VM_Recommendation)) { VM_Recommendation rec = obj as VM_Recommendation; if (rec == null) { return; } VM_ShokoServer.Instance.ShokoServices.IgnoreAnime(rec.RecommendedAnimeID, (int)RecommendationType.Download, VM_ShokoServer.Instance.CurrentUser.JMMUserID); VM_Dashboard.Instance.RefreshRecommendationsDownload(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
protected override void OnShowContextMenu() { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) { return; } if (currentitem.TVTag.GetType() == typeof(VM_Recommendation)) { VM_Recommendation rec = currentitem.TVTag as VM_Recommendation; if (rec != null) { ContextMenu cmenu = new ContextMenu(rec.Recommended_DisplayName); cmenu.AddAction(Translation.DontShowThisAnime, () => { int recType = 1; VM_ShokoServer.Instance.ShokoServices.IgnoreAnime(rec.RecommendedAnimeID, recType, VM_ShokoServer.Instance.CurrentUser.JMMUserID); LoadData(); }); cmenu.AddAction(Translation.BookmarkThisAnime, () => { VM_BookmarkedAnime bookmark = new VM_BookmarkedAnime(); bookmark.AnimeID = rec.RecommendedAnimeID; bookmark.Downloading = 0; bookmark.Notes = ""; bookmark.Priority = 1; if (bookmark.Save()) { Utils.DialogMsg(Translation.Sucess, Translation.BookmarkCreated); } }); cmenu.AddAction(Translation.CreateSeriesForAnime, () => { CL_Response <CL_AnimeSeries_User> resp = VM_ShokoServer.Instance.ShokoServices.CreateSeriesFromAnime( rec.RecommendedAnimeID, null, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (string.IsNullOrEmpty(resp.ErrorMessage)) { Utils.DialogMsg(Translation.Sucess, Translation.SeriesCreated); } else { Utils.DialogMsg(Translation.Error, resp.ErrorMessage); } }); cmenu.Show(); } } }
private void onFacadeItemSelected(GUIListItem item, GUIControl parent) { //BaseConfig.MyAnimeLog.Write("Facade Item Selected"); // if this is not a message from the facade, exit if (parent != m_Facade && parent != m_Facade.FilmstripLayout) { return; } VM_Recommendation rec = m_Facade.SelectedListItem.TVTag as VM_Recommendation; SetRec(rec); }
void getDataWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { colRecs = e.Result as List <VM_Recommendation>; if (colRecs == null || colRecs.Count == 0) { if (dummyAnyRecords != null) { dummyAnyRecords.Visible = false; } SetGUIProperty(GuiProperty.Recommendations_Status, Translation.NoRecommendationsAvailable); return; } if (dummyAnyRecords != null) { dummyAnyRecords.Visible = true; } foreach (VM_Recommendation rec in colRecs) { GUIListItem item = new GUIListItem(""); //AniDB_AnimeVM anime = rec.AnimeSeries.AniDB_Anime; item.IconImage = item.IconImageBig = rec.Recommended_PosterPath; item.TVTag = rec; item.OnItemSelected += new GUIListItem.ItemSelectedHandler(onFacadeItemSelected); m_Facade.Add(item); } if (m_Facade.Count > 0) { m_Facade.SelectedListItemIndex = 0; VM_Recommendation rec = m_Facade.SelectedListItem.TVTag as VM_Recommendation; if (rec != null) { SetRec(rec); } } }
public void GetMissingRecommendationsDownload() { try { IsLoadingData = true; foreach (object obj in RecommendationsDownload) { VM_Recommendation rec = obj as VM_Recommendation; if (rec == null) { continue; } if (!rec.Recommended_AnimeInfoExists) { string result = VM_ShokoServer.Instance.ShokoServices.UpdateAnimeData(rec.RecommendedAnimeID); if (string.IsNullOrEmpty(result)) { VM_AniDB_Anime anime = (VM_AniDB_Anime)VM_ShokoServer.Instance.ShokoServices.GetAnime(rec.RecommendedAnimeID); System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, (Action) delegate { rec.Recommended_AniDB_Anime = anime; ViewRecommendationsDownload.Refresh(); }); } } } IsLoadingData = false; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType) { if (MA3WindowManager.HandleWindowChangeButton(control)) { return; } if (btnViewWatch != null && control == btnViewWatch) { this.btnViewWatch.IsFocused = false; m_Facade.Focus = true; if (dummyModeWatch != null) { dummyModeWatch.Visible = true; } SetGUIProperty(GuiProperty.Recommendations_CurrentView, Translation.Watch); LoadData(); } if (btnViewDownload != null && control == btnViewDownload) { this.btnViewDownload.IsFocused = false; m_Facade.Focus = true; if (dummyModeWatch != null) { dummyModeWatch.Visible = false; } SetGUIProperty(GuiProperty.Recommendations_CurrentView, Translation.Download); LoadData(); } if (this.btnGetMissingInfo != null && control == this.btnGetMissingInfo) { MainWindow.ServerHelper.DownloadRecommendedAnime(); SetGUIProperty(GuiProperty.Recommendations_Status, Translation.WaitingOnServer + "..."); GUIControl.FocusControl(GetID, 50); return; } if (control == this.m_Facade) { // show the files if we are looking at a torrent GUIListItem item = m_Facade.SelectedListItem; if (item == null || item.TVTag == null) { return; } if (item.TVTag.GetType() == typeof(VM_Recommendation)) { VM_Recommendation rec = item.TVTag as VM_Recommendation; if (rec != null) { if (dummyModeWatch != null && dummyModeWatch.Visible) { VM_AnimeEpisode_User aniEp = (VM_AnimeEpisode_User)VM_ShokoServer.Instance.ShokoServices.GetNextUnwatchedEpisode(rec.Recommended_AnimeSeries.AnimeSeriesID, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (aniEp != null) { MainWindow.vidHandler.ResumeOrPlay(aniEp); } else { Utils.DialogMsg(Translation.Error, Translation.CouldNotFindFirstEpisode); } } } } } base.OnClicked(controlId, control, actionType); }