예제 #1
0
        private void ShowContextMenu(int menuaction, bool iscontextmenu)
        {
            try
              {
            bool bCoverSelected = true;
            var selectedCover = new MFCover();
            GUIListItem currentitem = this.MFacade.SelectedListItem;
            if (currentitem == null || !(currentitem.TVTag is MFCover))
              bCoverSelected = false; //return;
            else
              selectedCover = currentitem.TVTag as MFCover;

            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            GUIListItem pItem;
            if (dlg == null) return;
            dlg.Reset();

            switch (menuaction)
            {
              case (int)MenuAction.MenuMain:
            #region main menu
            dlg.SetHeading(GUILocalizeStrings.Get(10799201)); // MyFilms Cover Manager

            //// disabled, can be used by just select the item
            //if (bCoverSelected)
            //{
            //  pItem = new GUIListItem(GUILocalizeStrings.Get(10798769)); // Select Cover as Default
            //  dlg.Add(pItem);
            //  pItem.ItemId = (int)MenuAction.UseAsDefault;
            //}

            pItem = new GUIListItem(GUILocalizeStrings.Get(10799204)); // Download Covers ...
            dlg.Add(pItem);
            pItem.ItemId = (int)MenuAction.MenuDownload;

            if (MyFilmsDetail.ExtendedStartmode(MyFilmsDetail.PluginMode.Extended, "CoverManager: Submenu 'create covers ...'"))
            {
              pItem = new GUIListItem(GUILocalizeStrings.Get(10799208)); // Create Covers ...
              dlg.Add(pItem);
              pItem.ItemId = (int)MenuAction.MenuCreate;
            }

            pItem = new GUIListItem(GUILocalizeStrings.Get(10799209)); // Delete Cover ...
            dlg.Add(pItem);
            pItem.ItemId = (int)MenuAction.MenuDelete;

            if (!loadingWorker.IsBusy) // don't allowing filtering until all data is loaded
            {
              pItem = new GUIListItem(GUILocalizeStrings.Get(10799210)); // Filter Cover ...
              dlg.Add(pItem);
              pItem.ItemId = (int)MenuAction.MenuFilter;
            }
            #endregion
            break;

              case (int)MenuAction.MenuDownload:
            #region submenu download covers ...
            dlg.SetHeading(GUILocalizeStrings.Get(10799204)); // Download Covers ...

            pItem = new GUIListItem(GUILocalizeStrings.Get(10798766));  // Load single Cover ...
            dlg.Add(pItem);
            pItem.ItemId = (int)MenuAction.LoadSingle;

            pItem = new GUIListItem(GUILocalizeStrings.Get(10798764)); // Load multiple Covers ...
            dlg.Add(pItem);
            pItem.ItemId = (int)MenuAction.LoadMultiple;

            pItem = new GUIListItem(GUILocalizeStrings.Get(10798761)); // Load Covers (TMDB)
            dlg.Add(pItem);
            pItem.ItemId = (int)MenuAction.LoadFromTmdb;
            #endregion
            break;

              case (int)MenuAction.MenuCreate:
            #region submenu create covers ...
            dlg.SetHeading(GUILocalizeStrings.Get(10799208));  // Create Covers ...

            if (MyFilmsDetail.ExtendedStartmode(MyFilmsDetail.PluginMode.Extended, "CoverManager: Creation of Covers from Movie not yet supported"))
            {
              pItem = new GUIListItem(GUILocalizeStrings.Get(10798728)); // create cover from movie ...
              dlg.Add(pItem);
              pItem.ItemId = (int)MenuAction.CreateFromMovie;

              pItem = new GUIListItem(GUILocalizeStrings.Get(10798729)); // Create cover from film as mosaic
              dlg.Add(pItem);
              pItem.ItemId = (int)MenuAction.CreateFromMovieAsMosaic;
            }
            #endregion
            break;

              case (int)MenuAction.MenuDelete:
            #region submenu delete covers ...
            dlg.SetHeading(GUILocalizeStrings.Get(10799209));  // Delete Covers ...

            if (bCoverSelected)
            {
              if (!loadingWorker.IsBusy && !string.IsNullOrEmpty(MyFilms.r[this.MovieId]["Picture"].ToString()))
              {
                pItem = new GUIListItem(GUILocalizeStrings.Get(10798810)); // Delete Movie Cover from DB
                dlg.Add(pItem);
                pItem.ItemId = (int)MenuAction.ClearMovieCover;
              }

              pItem = new GUIListItem(GUILocalizeStrings.Get(10799212)); //"Delete all 'Low'"
              dlg.Add(pItem);
              pItem.ItemId = (int)MenuAction.DeleteAllLow;

              pItem = new GUIListItem(GUILocalizeStrings.Get(10799213)); // "Delete all 'Medium'"
              dlg.Add(pItem);
              pItem.ItemId = (int)MenuAction.DeleteAllMedium;

              pItem = new GUIListItem(GUILocalizeStrings.Get(10799214)); // "Delete all 'High'"
              dlg.Add(pItem);
              pItem.ItemId = (int)MenuAction.DeleteAllHigh;

              pItem = new GUIListItem(GUILocalizeStrings.Get(10799211)); // Delete selected Cover
              dlg.Add(pItem);
              pItem.ItemId = (int)MenuAction.DeleteSelected;

              pItem = new GUIListItem(GUILocalizeStrings.Get(10799215)); // "Delete all except currently selected"
              dlg.Add(pItem);
              pItem.ItemId = (int)MenuAction.DeleteAllExceptSelected;
            }
            #endregion
            break;

              case (int)MenuAction.MenuFilter:
            #region submenu filter covers ... (calls extra method)
            dlg.SetHeading(GUILocalizeStrings.Get(10799210)); // Filter Cover ...

            pItem = new GUIListItem(GUILocalizeStrings.Get(10799221)); // All
            dlg.Add(pItem);
            pItem.ItemId = (int)MenuFilterAction.all;

            pItem = new GUIListItem(GUILocalizeStrings.Get(10799222)); // High
            dlg.Add(pItem);
            pItem.ItemId = (int)MenuFilterAction.high;

            pItem = new GUIListItem(GUILocalizeStrings.Get(10799223)); // Medium
            dlg.Add(pItem);
            pItem.ItemId = (int)MenuFilterAction.medium;

            pItem = new GUIListItem(GUILocalizeStrings.Get(10799224)); // Low
            dlg.Add(pItem);
            pItem.ItemId = (int)MenuFilterAction.low;
            #endregion
            break;
            }

            dlg.DoModal(GUIWindowManager.ActiveWindow);

            if (dlg.SelectedLabel == -1)
            {
              #region conditional return to main menu
              if (iscontextmenu)
              {
            switch (menuaction)
            {
              case (int)MenuAction.MenuMain:
                dlg.Reset();
                return;
              case (int)MenuAction.MenuDownload:
              case (int)MenuAction.MenuCreate:
              case (int)MenuAction.MenuDelete:
              case (int)MenuAction.MenuFilter:
                ShowContextMenu((int)MenuAction.MenuMain, true);
                break;
            }
              }
              else
              {
            return;
              }
              #endregion
            }

            string title = "";
            string mediapath = "";
            MyFilmsDetail.Searchtitles sTitles;
            switch (dlg.SelectedId) // what was chosen?
            {
              case (int)MenuAction.MenuDownload:
            dlg.Reset();
            this.ShowContextMenu((int)MenuAction.MenuDownload, iscontextmenu);
            break;
              case (int)MenuAction.MenuCreate:
            dlg.Reset();
            this.ShowContextMenu((int)MenuAction.MenuCreate, iscontextmenu);
            break;
              case (int)MenuAction.MenuDelete:
            dlg.Reset();
            this.ShowContextMenu((int)MenuAction.MenuDelete, iscontextmenu);
            break;
              case (int)MenuAction.MenuFilter:
            dlg.Reset();
            ShowFiltersMenu();
            break;

              case (int)MenuAction.LoadSingle:
            //downloadFanart(selectedCover);
            title = MyFilmsDetail.GetSearchTitle(MyFilms.r, MyFilms.conf.StrIndex, "");
            mediapath = MyFilmsDetail.GetMediaPathOfFirstFile(MyFilms.r, MyFilms.conf.StrIndex);
            sTitles = MyFilmsDetail.GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], mediapath);
            MyFilmsDetail.grabb_Internet_Informations(title, GetID, true, MyFilms.conf.StrGrabber_cnf, mediapath, MyFilmsDetail.GrabType.Cover, false, sTitles, SearchAnimation);
            // this.RefreshFacade(); // will be done by OnDetailsUpdated Message Handler
            break;
              case (int)MenuAction.LoadMultiple:
            //downloadFanart(selectedCover);
            title = MyFilmsDetail.GetSearchTitle(MyFilms.r, MyFilms.conf.StrIndex, "");
            mediapath = MyFilmsDetail.GetMediaPathOfFirstFile(MyFilms.r, MyFilms.conf.StrIndex);
            sTitles = MyFilmsDetail.GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], mediapath);
            MyFilmsDetail.grabb_Internet_Informations(title, GetID, true, MyFilms.conf.StrGrabber_cnf, mediapath, MyFilmsDetail.GrabType.MultiCovers, false, sTitles, SearchAnimation);
            // this.RefreshFacade(); // will be done by OnDetailsUpdated Message Handler
            break;
              case (int)MenuAction.LoadFromTmdb:
            sTitles = MyFilmsDetail.GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], "");
            MyFilmsDetail.Download_TMDB_Posters(sTitles.OriginalTitle, sTitles.TranslatedTitle, sTitles.Director, sTitles.Year.ToString(), false, GetID, sTitles.OriginalTitle, SearchAnimation);
            // this.RefreshFacade(); // will be done by OnDetailsUpdated Message Handler
            break;
              case (int)MenuAction.CreateFromMovie:
            //ToDo: Add Code for single image thumbnailer
            // this.RefreshFacade(); // will be done by OnDetailsUpdated Message Handler
            break;
              case (int)MenuAction.CreateFromMovieAsMosaic:
            //downloadFanart(selectedCover);
            MyFilmsDetail.CreateThumbFromMovie();
            // this.RefreshFacade(); // will be done by OnDetailsUpdated Message Handler
            break;
              case (int)MenuAction.DeleteSelected:
            // delete from DB, if it is the one currently selected
            if (NewArtworkFileName == selectedCover.FullPath)
            {
              NewArtworkFileName = "";
              sTitles = MyFilmsDetail.GetSearchTitles(MyFilms.r[this.MovieId], MyFilmsDetail.GetMediaPathOfFirstFile(MyFilms.r, this.MovieId));
              ArtworkFileName = MyFilmsDetail.GetOrCreateCoverFilename(MyFilms.r, this.MovieId, sTitles.MasterTitle);
              MyFilmsDetail.clearGUIProperty("picture");
              this.SaveChangesToDb();
            }
            selectedCover.Delete(AllTitles());
            // and reinit the display to get rid of it
            this.RefreshFacade();
            break;
              case (int)MenuAction.DeleteAllLow:
            this.DeleteSelectedFromGroup("Low");
            this.RefreshFacade();
            break;
              case (int)MenuAction.DeleteAllMedium:
            this.DeleteSelectedFromGroup("Medium");
            this.RefreshFacade();
            break;
              case (int)MenuAction.DeleteAllHigh:
            this.DeleteSelectedFromGroup("High");
            this.RefreshFacade();
            break;
              case (int)MenuAction.DeleteAllExceptSelected:
            DeleteAllExceptSelected(this.MFacade.SelectedListItemIndex);
            this.RefreshFacade();
            break;
              case (int)MenuAction.UseAsDefault:
            SetFacadeItemAsChosen(this.MFacade.SelectedListItemIndex);
            selectedCover.Chosen = true;
            this.SetDefaultCover(selectedCover);
            break;
              case (int)MenuAction.ClearMovieCover:
            dlg.Reset();
            this.RemoveMovieCoverFromDb();
            ClearProperties();
            UpdateFilterProperty(false);
            this.RefreshFacade();
            break;
            }
              }
              catch (Exception ex)
              {
            LogMyFilms.Debug("Exception in Artwork Chooser Context Menu: " + ex.Message);
              }
        }
예제 #2
0
        void SetDefaultCover(MFCover cover)
        {
            NewArtworkFileName = !File.Exists(cover.FullPath) ? "" : cover.FullPath;
              MyFilmsDetail.setGUIProperty("picture", NewArtworkFileName);

              //MyFilmsDetail.Searchtitles sTitles = MyFilmsDetail.GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], "");
              //string currentPicture = MyFilmsDetail.getGUIProperty("picture");
              ////if ((r1[Index]["Picture"].ToString().IndexOf(":\\") == -1) && (r1[Index]["Picture"].ToString().Substring(0, 2) != "\\\\"))
              ////  MyFilms.conf.FileImage = MyFilms.conf.StrPathImg + "\\" + r1[Index]["Picture"].ToString();
              ////else
              ////  MyFilms.conf.FileImage = r1[Index]["Picture"].ToString();
              //if ((MyFilms.r[MyFilms.conf.StrIndex]["Picture"].ToString().IndexOf(":\\") == -1) && (MyFilms.r[MyFilms.conf.StrIndex]["Picture"].ToString().Substring(0, 2) != "\\\\"))
              //  currentPicture = MyFilms.conf.StrPathImg + "\\" + MyFilms.r[MyFilms.conf.StrIndex]["Picture"];
              //else
              //  currentPicture = MyFilms.r[MyFilms.conf.StrIndex]["Picture"].ToString();

              //if (string.IsNullOrEmpty(currentPicture))
              //  currentPicture = sTitles.FanartTitle + ".jpg";

              //LogMyFilms.Debug("setDefaultCover - currentPicture = '" + currentPicture + "'");
              //if (System.IO.File.Exists(currentPicture))
              //{
              //  //string safeName = Grabber.GrabUtil.CreateFilename(title);
              //  //filename = dirname + safeName + " [" + imageUrl.GetHashCode() + "].jpg";

              //  string newFile = System.IO.Path.GetFileNameWithoutExtension(currentPicture) + " [" + currentPicture.GetHashCode() + "]." + System.IO.Path.GetExtension(currentPicture);
              //  LogMyFilms.Debug("setDefaultCover - newFile = '" + newFile + "'");
              //  try
              //  {
              //    System.IO.File.Copy(currentPicture, newFile, true);
              //    File.Delete(currentPicture);
              //  }
              //  catch (Exception ex)
              //  {
              //    LogMyFilms.Debug("setDefaultCover - error renaming currentPicture: " + ex.Message + ex.StackTrace);
              //  }
              //}
              //try
              //{
              //  File.Copy(cover.FullPath, currentPicture, true);
              //  File.Delete(cover.FullPath);
              //  LogMyFilms.Debug("setDefaultCover - sucessfully set new Default Cover: '" + currentPicture + "'");
              //}
              //catch (Exception ex)
              //{
              //  LogMyFilms.Debug("setDefaultCover - error renaming currentPicture: " + ex.Message + ex.StackTrace);
              //}
        }
예제 #3
0
 void SetItemProperties(MFCover cover)
 {
     MyFilmsDetail.setGUIProperty("cover.selectedcoverresolution", cover.ImageResolution);
       MyFilmsDetail.setGUIProperty("cover.selectedcoverresolutionclass", cover.ImageResolutionClass);
       MyFilmsDetail.setGUIProperty("cover.selectedcoversize", cover.ImageSizeFriendly);
       MyFilmsDetail.setGUIProperty("cover.selectedcoversizenum", cover.ImageSize.ToString());
       MyFilmsDetail.setGUIProperty("cover.selectedcovername", cover.FileName);
       MyFilmsDetail.setGUIProperty("cover.selectedpreview", this.MFacade.SelectedListItem.Path);
 }
예제 #4
0
        //-------------------------------------------------------------------------------------------
        //  Get local Cover Image
        //-------------------------------------------------------------------------------------------
        public static IEnumerable<MFCover> GetLocalCover(DataRow[] r1, int Index, string currentPictureFilename)
        {
            List<MFCover> result = new List<MFCover>();
              string directoryname = "";
              string[] files = null;
              Int64 wsize = 0; // Temporary Filesize detection
              //string currentPicture = MyFilmsDetail.getGUIProperty("picture");

              //if ((r1[Index]["Picture"].ToString().IndexOf(":\\") == -1) && (r1[Index]["Picture"].ToString().Substring(0, 2) != "\\\\"))
              //  currentPictureFilename = MyFilms.conf.StrPathImg + "\\" + r1[Index]["Picture"];
              //else
              //  currentPictureFilename = r1[Index]["Picture"].ToString();

              if (string.IsNullOrEmpty(currentPictureFilename))
            return null;
              string searchPattern = GetCoverSearchPattern(currentPictureFilename);
              if (searchPattern == null)
            return null;

              directoryname = currentPictureFilename.Substring(0, currentPictureFilename.LastIndexOf("\\"));
              LogMyFilms.Debug("CoverManager - searchPattern = '" + searchPattern + "', directoryname = '" + directoryname + "'");

              if (!string.IsNullOrEmpty(directoryname))
              {
            files = Directory.GetFiles(directoryname, @"*" + searchPattern + @"*.jpg", SearchOption.TopDirectoryOnly);
            foreach (string filefound in files)
            {
              #region add found files
              wsize = new FileInfo(filefound).Length;
              var item = new MFCover();
              item.FileName = System.IO.Path.GetFileNameWithoutExtension(filefound);
              item.FullPath = filefound;

              //if (!File.Exists(localFile) || ImageFast.FastFromFile(localFile) == null) {}
              var newCover = Image.FromFile(filefound);
              item.ImageResolution = newCover.Width + " x " + newCover.Height;
              item.ImageWith = newCover.Width;
              item.ImageHeight = newCover.Height;

              if (newCover.Height > 800) item.ImageResolutionClass = "High";
              else if (newCover.Height > 400) item.ImageResolutionClass = "Medium";
              else if (newCover.Height > 0) item.ImageResolutionClass = "Low";
              else item.ImageResolutionClass = "Unknown";
              newCover.Dispose();

              item.ImageSize = new FileInfo(filefound).Length;
              item.ImageSizeFriendly = Helper.GetFileSize(wsize);
              result.Add(item);
              #endregion
            }
              }
              return result;
        }