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(RecommendationVM))
                {
                    RecommendationVM rec = obj as RecommendationVM;
                    if (rec == null)
                    {
                        return;
                    }

                    JMMServerVM.Instance.clientBinaryHTTP.IgnoreAnime(rec.RecommendedAnimeID, (int)RecommendationType.Download,
                                                                      JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                    DashboardVM.Instance.RefreshRecommendationsDownload();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
        private void RefreshData()
        {
            try
            {
                Window parentWindow = Window.GetWindow(this);
                parentWindow.Cursor = Cursors.Wait;

                Recs.Clear();

                List <JMMServerBinary.Contract_Recommendation> contracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(UserSettingsVM.Instance.DownloadsRecItems, JMMServerVM.Instance.CurrentUser.JMMUserID.Value,
                                                                             (int)RecommendationType.Download);

                foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
                {
                    RecommendationVM rec = new RecommendationVM();
                    rec.Populate(contract);
                    Recs.Add(rec);
                }

                ViewRecs.Refresh();

                parentWindow.Cursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Beispiel #3
0
        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;
            }

            RecommendationVM rec = m_Facade.SelectedListItem.TVTag as RecommendationVM;

            SetRec(rec);
        }
Beispiel #4
0
        void getDataWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            colRecs = e.Result as List <RecommendationVM>;

            if (colRecs == null || colRecs.Count == 0)
            {
                if (dummyAnyRecords != null)
                {
                    dummyAnyRecords.Visible = false;
                }
                setGUIProperty("Recommendations.Status", "No recommendations available");
                return;
            }

            if (dummyAnyRecords != null)
            {
                dummyAnyRecords.Visible = true;
            }

            foreach (RecommendationVM 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;

                RecommendationVM rec = m_Facade.SelectedListItem.TVTag as RecommendationVM;
                if (rec != null)
                {
                    SetRec(rec);
                }
            }
        }
Beispiel #5
0
        public void RefreshRecommendationsDownload()
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    RecommendationsDownload.Clear();
                });

                List <JMMServerBinary.Contract_Recommendation> contracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(UserSettingsVM.Instance.Dash_RecDownload_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value,
                                                                             (int)RecommendationType.Download);

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
                    {
                        RecommendationVM rec = new RecommendationVM();
                        rec.Populate(contract);
                        RecommendationsDownload.Add(rec);
                    }

                    // add a dummy object so that we can display a prompt
                    // for the user to sync thier votes
                    if (RecommendationsDownload.Count == 0)
                    {
                        RecommendationsDownload.Add(new SyncVotesDummy());
                    }

                    ViewRecommendationsDownload.Refresh();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Beispiel #6
0
        public void GetMissingRecommendationsDownload()
        {
            try
            {
                IsLoadingData = true;

                foreach (object obj in RecommendationsDownload)
                {
                    RecommendationVM rec = obj as RecommendationVM;
                    if (rec == null)
                    {
                        continue;
                    }

                    if (rec.Recommended_AnimeInfoNotExists)
                    {
                        string result = JMMServerVM.Instance.clientBinaryHTTP.UpdateAnimeData(rec.RecommendedAnimeID);
                        if (string.IsNullOrEmpty(result))
                        {
                            JMMServerBinary.Contract_AniDBAnime animeContract = JMMServerVM.Instance.clientBinaryHTTP.GetAnime(rec.RecommendedAnimeID);
                            System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, (Action) delegate()
                            {
                                rec.PopulateRecommendedAnime(animeContract);
                                ViewRecommendationsDownload.Refresh();
                            });
                        }
                    }
                }

                IsLoadingData = false;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Beispiel #7
0
        void getDataWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <RecommendationVM> tempRecs = new List <RecommendationVM>();

            int recType = 1;

            if (dummyModeDownload != null && dummyModeDownload.Visible)
            {
                recType = 2;
            }

            List <JMMServerBinary.Contract_Recommendation> contracts =
                JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(20, JMMServerVM.Instance.CurrentUser.JMMUserID, recType);

            foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
            {
                RecommendationVM rec = new RecommendationVM();
                rec.Populate(contract);
                tempRecs.Add(rec);
            }

            e.Result = tempRecs;
        }
Beispiel #8
0
        private void SetRec(RecommendationVM rec)
        {
            if (rec == null)
            {
                return;
            }

            clearGUIProperty("Recommendations.Rec.Title");
            clearGUIProperty("Recommendations.Rec.Description");
            clearGUIProperty("Recommendations.Rec.ApprovalRating");

            clearGUIProperty("Recommendations.BasedOn.Title");
            clearGUIProperty("Recommendations.BasedOn.VoteValue");


            setGUIProperty("Recommendations.Rec.Title", rec.Recommended_DisplayName);
            setGUIProperty("Recommendations.Rec.Description", rec.Recommended_Description);
            setGUIProperty("Recommendations.Rec.ApprovalRating", rec.Recommended_ApprovalRating);
            setGUIProperty("Recommendations.Rec.Image", rec.Recommended_PosterPath);

            try
            {
                if (rec.Recommended_AniDB_Anime != null)
                {
                    setGUIProperty("Recommendations.Rec.AniDBRating", rec.Recommended_AniDB_Anime.AniDBRatingFormatted);
                }
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write(ex.ToString());
            }

            setGUIProperty("Recommendations.BasedOn.Title", rec.BasedOn_DisplayName);
            setGUIProperty("Recommendations.BasedOn.VoteValue", rec.BasedOn_VoteValueFormatted);
            setGUIProperty("Recommendations.BasedOn.Image", rec.BasedOn_PosterPath);
        }
Beispiel #9
0
        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;
                }
                if (dummyModeDownload != null)
                {
                    dummyModeDownload.Visible = false;
                }

                setGUIProperty("Recommendations.CurrentView", "Watch");

                LoadData();
            }

            if (btnViewDownload != null && control == btnViewDownload)
            {
                this.btnViewDownload.IsFocused = false;
                m_Facade.Focus = true;

                if (dummyModeWatch != null)
                {
                    dummyModeWatch.Visible = false;
                }
                if (dummyModeDownload != null)
                {
                    dummyModeDownload.Visible = true;
                }

                setGUIProperty("Recommendations.CurrentView", "Download");

                LoadData();
            }

            if (this.btnGetMissingInfo != null && control == this.btnGetMissingInfo)
            {
                MainWindow.ServerHelper.DownloadRecommendedAnime();
                setGUIProperty("Recommendations.DownloadStatus", "Waiting on server...");
                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(RecommendationVM))
                {
                    RecommendationVM rec = item.TVTag as RecommendationVM;
                    if (rec != null)
                    {
                        if (dummyModeWatch != null && dummyModeWatch.Visible)
                        {
                            JMMServerBinary.Contract_AnimeEpisode ep = JMMServerVM.Instance.clientBinaryHTTP.GetNextUnwatchedEpisode(rec.Recommended_AnimeSeries.AnimeSeriesID.Value,
                                                                                                                                     JMMServerVM.Instance.CurrentUser.JMMUserID);
                            if (ep != null)
                            {
                                AnimeEpisodeVM aniEp = new AnimeEpisodeVM(ep);
                                MainWindow.vidHandler.ResumeOrPlay(aniEp);
                            }
                            else
                            {
                                Utils.DialogMsg("Error", "Could not find the first episode");
                            }
                        }

                        if (dummyModeDownload != null && dummyModeDownload.Visible)
                        {
                            AniDB_AnimeVM recanime = rec.Recommended_AniDB_Anime;
                            if (recanime != null)
                            {
                                DownloadHelper.SearchAnime(recanime);
                            }
                        }
                    }
                }
            }

            base.OnClicked(controlId, control, actionType);
        }
Beispiel #10
0
        protected override void OnShowContextMenu()
        {
            GUIListItem currentitem = this.m_Facade.SelectedListItem;

            if (currentitem == null)
            {
                return;
            }

            if (currentitem.TVTag.GetType() == typeof(RecommendationVM))
            {
                RecommendationVM rec = currentitem.TVTag as RecommendationVM;
                if (rec != null)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }

                    dlg.Reset();
                    dlg.SetHeading(rec.Recommended_DisplayName);
                    dlg.Add("Don't Show This Anime (Ignore)");
                    dlg.Add("Bookmark this Anime");
                    dlg.Add("Create Series for Anime");

                    dlg.DoModal(GUIWindowManager.ActiveWindow);

                    switch (dlg.SelectedLabel)
                    {
                    case 0:

                        int recType = 1;
                        if (dummyModeDownload != null && dummyModeDownload.Visible)
                        {
                            recType = 2;
                        }

                        JMMServerVM.Instance.clientBinaryHTTP.IgnoreAnime(rec.RecommendedAnimeID, recType,
                                                                          JMMServerVM.Instance.CurrentUser.JMMUserID);

                        LoadData();
                        break;

                    case 1:


                        BookmarkedAnimeVM bookmark = new BookmarkedAnimeVM();
                        bookmark.AnimeID     = rec.RecommendedAnimeID;
                        bookmark.Downloading = 0;
                        bookmark.Notes       = "";
                        bookmark.Priority    = 1;
                        if (bookmark.Save())
                        {
                            Utils.DialogMsg("Success", "Bookmark Created");
                        }

                        break;

                    case 2:

                        JMMServerBinary.Contract_AnimeSeries_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.CreateSeriesFromAnime(
                            rec.RecommendedAnimeID, null, JMMServerVM.Instance.CurrentUser.JMMUserID);
                        if (string.IsNullOrEmpty(resp.ErrorMessage))
                        {
                            Utils.DialogMsg("Success", "Series Created");
                        }
                        else
                        {
                            Utils.DialogMsg("Error", resp.ErrorMessage);
                        }

                        break;
                    }
                }
            }
        }