Ejemplo n.º 1
0
        protected override void OnShowContextMenu()
        {
            try
            {
                GUIListItem currentitem = m_Facade.SelectedListItem;
                if (currentitem == null || !(currentitem.TVTag is PosterContainer))
                {
                    return;
                }
                PosterContainer selectedPoster = currentitem.TVTag as PosterContainer;

                ContextMenu cmenu = new ContextMenu(Translation.Poster);
                cmenu.AddAction(selectedPoster.IsImageEnabled ? Translation.Disable : Translation.Enable, () =>
                {
                    bool endis = !selectedPoster.IsImageEnabled;
                    ShokoServerHelper.EnableDisablePoster(endis, selectedPoster, AnimeID);
                    ShowPosters();
                });
                if (selectedPoster.IsImageEnabled)
                {
                    cmenu.AddAction(selectedPoster.IsImageDefault ? Translation.RemoveAsDefault : Translation.SetAsDefault, () =>
                    {
                        bool isdef = !selectedPoster.IsImageDefault;
                        ShokoServerHelper.SetDefaultPoster(isdef, selectedPoster, AnimeID);
                        ShowPosters();
                    });
                }
                cmenu.Show();
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("Exception in Poster Chooser Context Menu: " + ex.Message + ex.StackTrace);
            }
        }
Ejemplo n.º 2
0
        private void ShowPosters()
        {
            GUIControl.ClearControl(this.GetID, m_Facade.GetID);
            List <PosterContainer> allPosters = new List <PosterContainer>();

            string displayname = "";

            AnimeSeriesVM ser = JMMServerHelper.GetSeries(MainWindow.GlobalSeriesID);

            if (ser != null)
            {
                displayname = ser.SeriesName;
                if (ser.CrossRef_AniDB_TvDBV2 != null && ser.CrossRef_AniDB_TvDBV2.Count > 0)
                {
                    AnimeID = ser.CrossRef_AniDB_TvDBV2[0].AnimeID;
                }
            }

            BaseConfig.MyAnimeLog.Write("ShowPosters for {0} - {1}", displayname, AnimeID);

            foreach (PosterContainer pstr in ser.AniDB_Anime.AniDB_AnimeCrossRefs.AllPosters)
            {
                if (!File.Exists(pstr.FullImagePath))
                {
                    continue;
                }

                allPosters.Add(pstr);
            }

            GUIListItem item = null;

            foreach (PosterContainer poster in allPosters)
            {
                item                 = new GUIListItem();
                item.IconImage       = item.IconImageBig = poster.FullImagePath;
                item.TVTag           = poster;
                item.OnItemSelected += new GUIListItem.ItemSelectedHandler(onFacadeItemSelected);
                m_Facade.Add(item);
            }

            if (m_Facade.Count > 0)
            {
                m_Facade.SelectedListItemIndex = 0;

                // Work around for Filmstrip not allowing to programmatically select item
                if (m_Facade.CurrentLayout == GUIFacadeControl.Layout.Filmstrip)
                {
                }

                PosterContainer selectedPoster = m_Facade.SelectedListItem.TVTag as PosterContainer;
                if (selectedPoster != null)
                {
                    SetPosterProperties(selectedPoster);
                }

                GUIControl.FocusControl(GetID, 50);
            }
        }
Ejemplo n.º 3
0
        public static void SetDefaultPoster(bool isDefault, PosterContainer poster, int animeID)
        {
            if (!VM_ShokoServer.Instance.ServerOnline)
            {
                return;
            }

            try
            {
                switch (poster.ImageType)
                {
                case ImageEntityType.TvDB_Cover:
                    VM_TvDB_ImagePoster tvPoster = (VM_TvDB_ImagePoster)poster.PosterObject;
                    VM_ShokoServer.Instance.ShokoServices.SetDefaultImage(isDefault, animeID,
                                                                          tvPoster.TvDB_ImagePosterID, (int)ImageEntityType.TvDB_Cover, (int)ImageSizeType.Poster);
                    tvPoster.IsImageDefault = isDefault;
                    break;

                /*
                 *     case ImageEntityType.Trakt_Poster:
                 *
                 *         VM_Trakt_ImagePoster traktPoster = (VM_Trakt_ImagePoster) poster.PosterObject;
                 *         VM_ShokoServer.Instance.ShokoServices.SetDefaultImage(isDefault, animeID,
                 *             traktPoster.Trakt_ImagePosterID, (int) ImageEntityType.Trakt_Poster, (int) ImageSizeType.Poster);
                 *         traktPoster.IsImageDefault = isDefault;
                 * break;
                 */
                case ImageEntityType.AniDB_Cover:
                    VM_AniDB_Anime anime = (VM_AniDB_Anime)poster.PosterObject;
                    VM_ShokoServer.Instance.ShokoServices.SetDefaultImage(isDefault, animeID,
                                                                          anime.AnimeID, (int)ImageEntityType.AniDB_Cover, (int)ImageSizeType.Poster);
                    anime.IsImageDefault = isDefault;
                    break;

                case ImageEntityType.MovieDB_Poster:
                    VM_MovieDB_Poster moviePoster = (VM_MovieDB_Poster)poster.PosterObject;
                    VM_ShokoServer.Instance.ShokoServices.SetDefaultImage(isDefault, animeID,
                                                                          moviePoster.MovieDB_PosterID, (int)ImageEntityType.MovieDB_Poster, (int)ImageSizeType.Poster);
                    moviePoster.IsImageDefault = isDefault;
                    break;
                }
                poster.IsImageDefault = isDefault;
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("SetDefaultPoster: " + ex.Message);
            }
        }
Ejemplo n.º 4
0
        public static void EnableDisablePoster(bool enabled, PosterContainer poster, int animeID)
        {
            try
            {
                if (!enabled && poster.IsImageDefault)
                {
                    SetDefaultPoster(false, poster, animeID);
                }

                switch (poster.ImageType)
                {
                case ImageEntityType.TvDB_Cover:
                    VM_TvDB_ImagePoster tvPoster = (VM_TvDB_ImagePoster)poster.PosterObject;
                    VM_ShokoServer.Instance.ShokoServices.EnableDisableImage(enabled, tvPoster.TvDB_ImagePosterID, (int)ImageEntityType.TvDB_Cover);
                    tvPoster.Enabled = enabled ? 1 : 0;
                    break;

                /*
                 * case ImageEntityType.Trakt_Poster:
                 *
                 *  VM_Trakt_ImagePoster traktPoster = (VM_Trakt_ImagePoster) poster.PosterObject;
                 *  VM_ShokoServer.Instance.ShokoServices.EnableDisableImage(enabled, traktPoster.Trakt_ImagePosterID, (int) ImageEntityType.Trakt_Poster);
                 *  traktPoster.Enabled = enabled ? 1 : 0;
                 * break;
                 */
                case ImageEntityType.AniDB_Cover:
                    VM_AniDB_Anime anime = (VM_AniDB_Anime)poster.PosterObject;
                    VM_ShokoServer.Instance.ShokoServices.EnableDisableImage(enabled, anime.AnimeID, (int)ImageEntityType.AniDB_Cover);
                    anime.ImageEnabled = enabled ? 1 : 0;
                    break;

                case ImageEntityType.MovieDB_Poster:
                    VM_MovieDB_Poster moviePoster = (VM_MovieDB_Poster)poster.PosterObject;
                    VM_ShokoServer.Instance.ShokoServices.EnableDisableImage(enabled, moviePoster.MovieDB_PosterID, (int)ImageEntityType.MovieDB_Poster);
                    moviePoster.Enabled = enabled ? 1 : 0;
                    break;
                }
                poster.IsImageEnabled = enabled;
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("SetDefaultPoster: " + ex.Message);
            }
        }
Ejemplo n.º 5
0
        private void SetPosterProperties(PosterContainer poster)
        {
            string isDefault = Translation.No;

            if (poster.IsImageDefault)
            {
                isDefault = Translation.Yes;
            }
            string isDisabled = Translation.No;

            if (!poster.IsImageEnabled)
            {
                isDisabled = Translation.Yes;
            }

            SetGUIProperty(GuiProperty.Posters_SelectedSource, poster.PosterSource);
            SetGUIProperty(GuiProperty.Posters_SelectedPosterIsDefault, isDefault);
            SetGUIProperty(GuiProperty.Posters_SelectedPosterIsDisabled, isDisabled);
        }
Ejemplo n.º 6
0
        // triggered when a selection change was made on the facade
        private void onFacadeItemSelected(GUIListItem item, GUIControl parent)
        {
            // if this is not a message from the facade, exit
            if (parent != m_Facade && parent != m_Facade.FilmstripLayout &&
                parent != m_Facade.ThumbnailLayout)
            {
                return;
            }

            PosterContainer selectedPoster = item.TVTag as PosterContainer;

            if (selectedPoster != null)
            {
                //set large image
                MainWindow.setGUIProperty("Posters.PosterPath", selectedPoster.FullImagePath);

                SetPosterProperties(selectedPoster);
            }
        }
Ejemplo n.º 7
0
        private void SetPosterProperties(PosterContainer poster)
        {
            string isDefault = "No";

            if (poster.IsImageDefault)
            {
                isDefault = "Yes";
            }

            string isDisabled = "No";

            if (!poster.IsImageEnabled)
            {
                isDisabled = "Yes";
            }


            MainWindow.setGUIProperty("Posters.SelectedSource", poster.PosterSource);
            MainWindow.setGUIProperty("Posters.SelectedPosterIsDefault", isDefault);
            MainWindow.setGUIProperty("Posters.SelectedPosterIsDisabled", isDisabled);
        }
Ejemplo n.º 8
0
        protected override void OnShowContextMenu()
        {
            try
            {
                GUIListItem currentitem = this.m_Facade.SelectedListItem;
                if (currentitem == null || !(currentitem.TVTag is PosterContainer))
                {
                    return;
                }
                PosterContainer selectedPoster = currentitem.TVTag as PosterContainer;

                IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg == null)
                {
                    return;
                }
                dlg.Reset();
                dlg.SetHeading("Poster");


                GUIListItem pItem;


                if (!selectedPoster.IsImageEnabled)
                {
                    pItem = new GUIListItem("Enable");
                    dlg.Add(pItem);
                }
                else
                {
                    pItem = new GUIListItem("Disable");
                    dlg.Add(pItem);
                }

                if (selectedPoster.IsImageEnabled)
                {
                    if (selectedPoster.IsImageDefault)
                    {
                        pItem = new GUIListItem("Remove as Default");
                        dlg.Add(pItem);
                    }
                    else
                    {
                        pItem = new GUIListItem("Set as Default");
                        dlg.Add(pItem);
                    }
                }


                // lets show it
                dlg.DoModal(GUIWindowManager.ActiveWindow);

                if (dlg.SelectedId == 1)                 // enabled/disable
                {
                    bool endis = !selectedPoster.IsImageEnabled;
                    JMMServerHelper.EnableDisablePoster(endis, selectedPoster, AnimeID);

                    ShowPosters();
                    return;
                }

                if (dlg.SelectedId == 2)
                {
                    bool isdef = !selectedPoster.IsImageDefault;
                    JMMServerHelper.SetDefaultPoster(isdef, selectedPoster, AnimeID);

                    ShowPosters();
                    return;
                }
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("Exception in Poster Chooser Context Menu: " + ex.Message + ex.StackTrace);
                return;
            }
        }