示例#1
0
    //--------------------------------------------------------------------------------------------
    //   Change Menu (and process corresponding actions)
    //--------------------------------------------------------------------------------------------
    private void Change_Menu(string choiceView)
    {
      if (downloadingWorker.IsBusy) downloadingWorker.CancelAsync(); // cancel person image download, if user does select any (other) action

      var ds = new AntMovieCatalog();
      // int ItemID = (int)MyFilms.r[MyFilms.conf.StrIndex]["Number"];
      // May wish to completely re-load the dataset before updating any fields if used in multi-user system, but would req concurrency locks etc so...

      var dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
      var dlgmenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
      var choiceViewMenu = new List<string>();

      var keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
      if (null == keyboard) return;
      keyboard.Reset();
      keyboard.SetLabelAsInitialText(false); // set to false, otherwise our intial text is cleared

      string title = string.Empty; // variable for searchtitle creation
      string mediapath = string.Empty; // variable for searchpath creation (for nfo/xml/xbmc reader)
      Searchtitles sTitles; // variable to get all searchtitles 
      var movie = new MFMovie(); // movie object for rating and trakt calls

      switch (choiceView)
      {
        case "mainmenu":

          #region show root menu
          if (dlgmenu == null) return;
          dlgmenu.Reset();
          dlgmenu.SetHeading(GUILocalizeStrings.Get(10798701)); // Options ...

          dlgmenu.Add(GUILocalizeStrings.Get(10798704)); //trailer menu "Trailer ..."
          choiceViewMenu.Add("trailermenu");

          if (MyFilms.conf.GlobalUnwatchedOnlyValue != null && MyFilms.conf.StrWatchedField.Length > 0)
          {
            if (MyFilms.conf.EnhancedWatchedStatusHandling)
            {
              int watchedCount = new MultiUserData(MyFilms.r[MyFilms.conf.StrIndex][BaseMesFilms.MultiUserStateField].ToString()).GetUserState(MyFilms.conf.StrUserProfileName).WatchedCount;
              dlgmenu.Add(watchedCount > 0 ? GUILocalizeStrings.Get(1079895) : GUILocalizeStrings.Get(1079894));
            }
            else
            {
              dlgmenu.Add(MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrWatchedField].ToString().ToLower() != MyFilms.conf.GlobalUnwatchedOnlyValue.ToLower() ? GUILocalizeStrings.Get(1079895) : GUILocalizeStrings.Get(1079894));
            }
            choiceViewMenu.Add("togglewatchedstatus");
          }

          dlgmenu.Add(GUILocalizeStrings.Get(931)); //rating
          choiceViewMenu.Add("rating");

          if (MyFilms.conf.StrFileType == Configuration.CatalogType.AntMovieCatalog4Xtended || MyFilms.conf.EnhancedWatchedStatusHandling) // user rating only for AMC4+ or when using enhanced watched handling
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798944)); // User Rating
            choiceViewMenu.Add("userrating");
          }

          if (MyFilms.conf.StrSuppressAutomatic || MyFilms.conf.StrSuppressManual)
          {
            dlgmenu.Add(GUILocalizeStrings.Get(1079830)); // Delete movie ...
            choiceViewMenu.Add("delete");
          }

          dlgmenu.Add(GUILocalizeStrings.Get(1079879)); //Search Infos to related persons (load persons in facadeview)
          choiceViewMenu.Add("moviepersonlist");

          dlgmenu.Add(GUILocalizeStrings.Get(10798702)); // Updates ...
          choiceViewMenu.Add("updatesmenu");

          // Add Submenu for useritemx mapping
          dlgmenu.Add(string.Format(GUILocalizeStrings.Get(10798771)));  // Global Mappings ...
          choiceViewMenu.Add("globalmappings");

          if (File.Exists(GUIGraphicsContext.Skin + @"\MyFilmsCoverManager.xml"))
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798763)); // Cover Manager ...
            choiceViewMenu.Add("covermanager");
          }

          dlgmenu.Add(GUILocalizeStrings.Get(10798767)); // Fanart Manager ...
          choiceViewMenu.Add("fanartmanager");

          //dlgmenu.Add(GUILocalizeStrings.Get(10798703)); // Fanart & Cover ...
          //choiceViewMenu.Add("fanartcovermenu");

          if (Helper.IsTraktAvailableAndEnabled) //  && MyFilms.conf.AllowTraktSync
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798775)); // Trakt external menu...
            choiceViewMenu.Add("traktinternal");

            if (Helper.IsTraktAvailableAndEnabledAndNewVersion)
            {
              if (MyFilmsDetail.ExtendedStartmode(MyFilmsDetail.PluginMode.Extended, "Detail context menu - old MF Trakt menu"))
              {
                dlgmenu.Add(GUILocalizeStrings.Get(10798775) + " (MF old menu)"); // Trakt ... (MF menu)
                choiceViewMenu.Add("trakt");
              }
            }
          }
          else LogMyFilms.Debug("trakt not found or wrong version - disabling context entry");

          if (Helper.IsSubCentralAvailableAndEnabled)
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798707)); // Subtitles ...
            choiceViewMenu.Add("subtitles");
          }
          else LogMyFilms.Debug("Subcentral not found or wrong version - disabling context entry");

          dlgmenu.DoModal(GetID);
          if (dlgmenu.SelectedLabel == -1)
          {
            // GUIControl.FocusControl(GetID, (int)Controls.CTRL_BtnPlay); // Added to return to main view after menu // Removed as it's causing an exception
            // return;
            break;
          }
          Change_Menu(choiceViewMenu[dlgmenu.SelectedLabel].ToLower());
          #endregion
          break;

        case "trailermenu":
          #region trailer menu
          if (dlgmenu == null) return;
          dlgmenu.Reset();
          choiceViewMenu.Clear();

          #region  local trailer ...
          dlgmenu.SetHeading(GUILocalizeStrings.Get(10798704));

          if (Helper.FieldIsSet(MyFilms.conf.StrStorageTrailer)) // StrDirStorTrailer only required for extended search
          {
            string trailercount = "";
            if (string.IsNullOrEmpty(MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrStorageTrailer].ToString().Trim()))
              trailercount = "0";
            else
            {
              string[] split1 = MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrStorageTrailer].ToString().Trim().Split(new Char[] { ';' });
              trailercount = split1.Count().ToString();
            }
            if (trailercount != "0")
            {
              dlgmenu.Add(GUILocalizeStrings.Get(10798710) + " (" + trailercount + ")"); //play trailer (<number trailers present>)
              choiceViewMenu.Add("playtrailer");
            }
          }
          #endregion

          dlgmenu.Add(GUILocalizeStrings.Get(10798711)); //search youtube trailer with onlinevideos
          choiceViewMenu.Add("playtraileronlinevideos");

          dlgmenu.Add(GUILocalizeStrings.Get(10798712)); //search apple itunes trailer with onlinevideos
          choiceViewMenu.Add("playtraileronlinevideosappleitunes");

          dlgmenu.Add(GUILocalizeStrings.Get(10798716)); //search IMDB trailer with onlinevideos
          choiceViewMenu.Add("playtraileronlinevideosimdbtrailer");

          dlgmenu.Add("FilmStarts.de (OnlineVideos)");
          choiceViewMenu.Add("playtraileronlinevideosfilmstarts");

          dlgmenu.Add("OnlineVideos ...");
          choiceViewMenu.Add("playtraileronlinevideosall");

          if (Helper.FieldIsSet(MyFilms.conf.StrStorageTrailer)) // StrDirStorTrailer only required for extended search
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798723)); //Search local Trailer and Update DB (local)
            choiceViewMenu.Add("trailer-register");

            dlgmenu.Add(GUILocalizeStrings.Get(10798725)); //delete Trailer entries from DB record
            choiceViewMenu.Add("trailer-delete");

            dlgmenu.Add(GUILocalizeStrings.Get(10798724)); //load IMDB Trailer, store locally and update DB
            // dlgmenu.Add(GUILocalizeStrings.Get(10798990)); // Load single trailer (TMDB)
            choiceViewMenu.Add("trailer-tmdb");
          }

          dlgmenu.DoModal(GetID);
          if (dlgmenu.SelectedLabel == -1)
          {
            Change_Menu("mainmenu");
            return;
          }
          Change_Menu(choiceViewMenu[dlgmenu.SelectedLabel].ToLower());
          #endregion
          break;

        case "playtraileronlinevideos":
          LaunchOnlineVideos("YouTube");
          break;
        case "playtraileronlinevideosappleitunes":
          LaunchOnlineVideos("iTunes Movie Trailers");
          break;
        case "playtraileronlinevideosimdbtrailer":
          LaunchOnlineVideos("IMDb Movie Trailers");
          break;
        case "playtraileronlinevideosfilmstarts":
          LaunchOnlineVideos("FilmStarts.de Trailer");
          break;

        case "playtraileronlinevideosall":
          #region show all OnlineVideos sites
          if (dlgmenu == null) return;
          dlgmenu.Reset();
          choiceViewMenu.Clear();

          dlgmenu.SetHeading("OnlineVideos ...");

          try
          {
            this.LoadOnlineVideosViews();
            foreach (string theOnlineVideosView in theOnlineVideosViews)
            {
              dlgmenu.Add(theOnlineVideosView);
              choiceViewMenu.Add(theOnlineVideosView);
            }
          }
          catch (Exception ex)
          {
            LogMyFilms.Warn("Error when trying to load OnlineVideos site list - Exceptoion: " + ex.Message);
          }
          dlgmenu.DoModal(GetID);
          if (dlgmenu.SelectedLabel == -1)
          {
            Change_Menu("mainmenu");
            return;
          }
          LaunchOnlineVideos(choiceViewMenu[dlgmenu.SelectedLabel]);
          #endregion
          break;

        case "playtrailer":
          #region play trailer
          // first check, if trailer files are available, offer options
          //if (Helper.FieldIsSet(MyFilms.conf.StrStorageTrailer)) // StrDirStorTrailer only required for extended search
          if (!string.IsNullOrEmpty(MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrStorageTrailer].ToString().Trim()))
          {
            trailerPlayed = true;
            Launch_Movie_Trailer(MyFilms.conf.StrIndex, GetID, m_SearchAnimation);
          }
          else
          {
            // Can add autosearch&register logic here before try starting trailers
            if (GUIUtils.ShowYesNoDialog(GUILocalizeStrings.Get(10798704), MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrSTitle].ToString() + "\n" + GUILocalizeStrings.Get(10798737) + "\n" + GUILocalizeStrings.Get(10798739))) //trailer ////no video found locally // Search local trailers  and update DB ?
            {
              SetProcessAnimationStatus(true, m_SearchAnimation);
              //LogMyFilms.Debug("SearchTrailerLocal() SelectedItemInfo from (MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrTitle1].ToString(): '" + (MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrTitle1].ToString() + "'"));
              LogMyFilms.Debug("(Auto search trailer after selecting PLAY) title: '" + (MyFilms.r[MyFilms.conf.StrIndex] + "'"));
              SearchTrailerLocal(MyFilms.r, MyFilms.conf.StrIndex, true, true);
              afficher_detail(true);
              SetProcessAnimationStatus(false, m_SearchAnimation);
              trailerPlayed = true;
              Launch_Movie_Trailer(MyFilms.conf.StrIndex, GetID, m_SearchAnimation);
            }
          }
          #endregion
          break;

        case "togglewatchedstatus":
          #region toggle watched status
          if (MyFilms.conf.EnhancedWatchedStatusHandling)
          {
            int watchedCount = new MultiUserData(MyFilms.r[MyFilms.conf.StrIndex][BaseMesFilms.MultiUserStateField].ToString()).GetUserState(MyFilms.conf.StrUserProfileName).WatchedCount;
            Watched_Toggle(MyFilms.r[MyFilms.conf.StrIndex], watchedCount <= 0);
          }
          else
          {
            Watched_Toggle(MyFilms.r[MyFilms.conf.StrIndex], MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrWatchedField].ToString().ToLower() == MyFilms.conf.GlobalUnwatchedOnlyValue.ToLower());
          }
          afficher_detail(true);
          #endregion
          break;

        case "rating":
          {
            #region DB rating
            MyFilmsDialogSetRating dlgRating = (MyFilmsDialogSetRating)GUIWindowManager.GetWindow(MyFilms.ID_MyFilmsDialogRating);
            if (MyFilms.r[MyFilms.conf.StrIndex]["Rating"].ToString().Length > 0)
            {
              dlgRating.Rating = (decimal)MyFilms.r[MyFilms.conf.StrIndex]["Rating"];
              if (dlgRating.Rating > 10) dlgRating.Rating = 10;
            }
            else dlgRating.Rating = 0;

            dlgRating.SetTitle(MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrTitle1].ToString());
            dlgRating.DoModal(GetID);
            // if (dlgRating.SelectedLabel == -1 || dlgmenu.SelectedLabel != 2)  // If "ESC" or not returning from "ok"
            if (dlgRating.Result == MyFilmsDialogSetRating.ResultCode.Cancel) // If "ESC" or not returning from "ok"
            {
              Change_Menu("mainmenu");
              return;
            }
            MyFilms.r[MyFilms.conf.StrIndex]["Rating"] = dlgRating.Rating;

            Update_XML_database();
            afficher_detail(true);

            //// tell any listeners that user rated the movie
            //movie = GetMovieFromRecord(MyFilms.r[MyFilms.conf.StrIndex]);
            //string value = dlgRating.Rating.ToString();
            //if (RateItem != null) RateItem(movie, value);
            #endregion
          }
          break;

        case "userrating":
          {
            #region User rating
            var dlgRating = (MyFilmsDialogSetRating)GUIWindowManager.GetWindow(MyFilms.ID_MyFilmsDialogRating);
            if (MyFilms.conf.EnhancedWatchedStatusHandling)
            {
              decimal wRating = new MultiUserData(MyFilms.r[MyFilms.conf.StrIndex][BaseMesFilms.MultiUserStateField].ToString()).GetUserState(MyFilms.conf.StrUserProfileName).UserRating;
              dlgRating.Rating = (wRating != decimal.MinValue) ? wRating : 5;
            }
            else
            {
              if (MyFilms.r[MyFilms.conf.StrIndex]["RatingUser"].ToString().Length > 0)
              {
                dlgRating.Rating = (decimal)MyFilms.r[MyFilms.conf.StrIndex]["RatingUser"];
              }
              else dlgRating.Rating = 5;
            }
            if (dlgRating.Rating > 10) dlgRating.Rating = 10;
            if (dlgRating.Rating < 0) dlgRating.Rating = 5;

            dlgRating.SetTitle(MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrTitle1].ToString());
            dlgRating.DoModal(GetID);
            // if (dlgRating.SelectedLabel == -1 || dlgmenu.SelectedLabel != 2)  // If "ESC" or not returning from "ok"
            if (dlgRating.Result == MyFilmsDialogSetRating.ResultCode.Cancel) // If "ESC" or not returning from "ok"
            {
              Change_Menu("mainmenu");
              return;
            }
            if (MyFilms.conf.EnhancedWatchedStatusHandling)
            {
              var userData = new MultiUserData(MyFilms.r[MyFilms.conf.StrIndex][BaseMesFilms.MultiUserStateField].ToString());
              userData.SetRating(MyFilms.conf.StrUserProfileName, dlgRating.Rating);
              MyFilms.r[MyFilms.conf.StrIndex][BaseMesFilms.MultiUserStateField] = userData.ResultValueString();
              SyncMusToExtendedFields(MyFilms.r[MyFilms.conf.StrIndex], userData, MyFilms.conf.StrUserProfileName);
            }
            else
            {
              MyFilms.r[MyFilms.conf.StrIndex]["RatingUser"] = dlgRating.Rating; // always set db value, so in enhanced wat hed mode it represents the lst chaned value ...
            }

            if (MyFilms.conf.StrUserProfileName.Length > 0)
            {
              if (dlgRating.Rating > MultiUserData.FavoriteRating)
                MyFilms.r[MyFilms.conf.StrIndex]["Favorite"] = MultiUserData.Add(MyFilms.r[MyFilms.conf.StrIndex]["Favorite"].ToString(), MyFilms.conf.StrUserProfileName);
              else
                MyFilms.r[MyFilms.conf.StrIndex]["Favorite"] = MultiUserData.Remove(MyFilms.r[MyFilms.conf.StrIndex]["Favorite"].ToString(), MyFilms.conf.StrUserProfileName);
            }

            Update_XML_database();
            afficher_detail(true);

            // tell any listeners that user rated the movie
            movie = GetMovieFromRecord(MyFilms.r[MyFilms.conf.StrIndex]);
            string value = dlgRating.Rating.ToString();
            if (RateItem != null) RateItem(movie, value);
            #endregion
          }
          break;

        case "updatesmenu":
          #region updates menu
          if (dlgmenu == null) return;
          dlgmenu.Reset();
          choiceViewMenu.Clear();
          dlgmenu.SetHeading(GUILocalizeStrings.Get(10798702)); // Updates ...

          if (MyFilms.conf.StrFileType == Configuration.CatalogType.AntMovieCatalog3 ||
              MyFilms.conf.StrFileType == Configuration.CatalogType.AntMovieCatalog4Xtended)
          {
            dlgmenu.Add(GUILocalizeStrings.Get(5910)); //Update Internet Movie Details
            choiceViewMenu.Add("grabber");
          }

          dlgmenu.Add(GUILocalizeStrings.Get(10798642)); // Update by Property (choosen within the UPdate List Property
          choiceViewMenu.Add("updproperty");

          if (ExtendedStartmode(MyFilmsDetail.PluginMode.Test, "Details context: remove all details"))
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798795)); // remove all movie details (selected film)
            choiceViewMenu.Add("updremovealldetails");
          }

          //if (Helper.FieldIsSet(MyFilms.conf.StrStorage) && (MyFilms.conf.WindowsFileDialog))
          if (Helper.FieldIsSet(MyFilms.conf.StrStorage))
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798636)); //filename
            choiceViewMenu.Add("fileselect");
          }

          if (ExtendedStartmode(MyFilmsDetail.PluginMode.Extended, "Details context: update mediainfos"))
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798708)); //update mediainfos
            choiceViewMenu.Add("updmediainfos");
          }

          if (MyFilms.conf.UseThumbsForPersons && !string.IsNullOrEmpty(MyFilms.conf.StrPathArtist))
          {
            dlgmenu.Add(GUILocalizeStrings.Get(1079883)); // Update info for all involved persons (IMDb)
            choiceViewMenu.Add("personimages");
          }

          dlgmenu.DoModal(GetID);
          if (dlgmenu.SelectedLabel == -1)
          {
            Change_Menu("mainmenu");
            return;
          }
          Change_Menu(choiceViewMenu[dlgmenu.SelectedLabel].ToLower());
          #endregion
          break;

        case "globalmappings": // map useritems from GUI
          #region globalmappings
          var dlg3 = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
          if (dlg3 == null) return;
          dlg3.Reset();
          dlg3.SetHeading(GUILocalizeStrings.Get(10798771)); // Display options ...
          var choiceGlobalMappings = new List<string>();

          #region populate menu
          dlg3.Add(GUILocalizeStrings.Get(10798820) + " 1 (" + MyFilms.conf.StritemDetails1 + "-" + MyFilms.conf.StrlabelDetails1 + ")"); // Details Display Item ....
          choiceGlobalMappings.Add("useritemdetails1");
          dlg3.Add(GUILocalizeStrings.Get(10798820) + " 2 (" + MyFilms.conf.StritemDetails2 + "-" + MyFilms.conf.StrlabelDetails2 + ")");
          choiceGlobalMappings.Add("useritemdetails2");
          dlg3.Add(GUILocalizeStrings.Get(10798820) + " 3 (" + MyFilms.conf.StritemDetails3 + "-" + MyFilms.conf.StrlabelDetails3 + ")");
          choiceGlobalMappings.Add("useritemdetails3");
          dlg3.Add(GUILocalizeStrings.Get(10798820) + " 4 (" + MyFilms.conf.StritemDetails4 + "-" + MyFilms.conf.StrlabelDetails4 + ")");
          choiceGlobalMappings.Add("useritemdetails4");
          dlg3.Add(GUILocalizeStrings.Get(10798820) + " 5 (" + MyFilms.conf.StritemDetails5 + "-" + MyFilms.conf.StrlabelDetails5 + ")");
          choiceGlobalMappings.Add("useritemdetails5");
          dlg3.Add(GUILocalizeStrings.Get(10798820) + " 6 (" + MyFilms.conf.StritemDetails6 + "-" + MyFilms.conf.StrlabelDetails6 + ")");
          choiceGlobalMappings.Add("useritemdetails6");

          // master-, secondary-  and sorttitle
          //dlg3.Add(GUILocalizeStrings.Get(10798790) + " (" + MyFilms.conf.StrTitle1 + "-" + BaseMesFilms.Translate_Column(MyFilms.conf.StrTitle1) + ")"); // mastertitle
          dlg3.Add(GUILocalizeStrings.Get(10798790) + " (" + MyFilms.conf.StrTitle1 + "-" + BaseMesFilms.TranslateColumn(MyFilms.conf.StrTitle1) + ")"); // mastertitle
          choiceGlobalMappings.Add("mastertitle");
          dlg3.Add(GUILocalizeStrings.Get(10798791) + " (" + MyFilms.conf.StrTitle2 + "-" + BaseMesFilms.TranslateColumn(MyFilms.conf.StrTitle2) + ")"); // secondary title
          choiceGlobalMappings.Add("secondarytitle");
          dlg3.Add(GUILocalizeStrings.Get(10798792) + " (" + MyFilms.conf.StrSTitle + "-" + BaseMesFilms.TranslateColumn(MyFilms.conf.StrSTitle) + ")"); // sort title
          choiceGlobalMappings.Add("sorttitle");
          #endregion

          dlg3.DoModal(GetID);
          if (dlg3.SelectedLabel == -1)
          {
            Change_Menu("mainmenu");
            return;
          }
          int selection = dlg3.SelectedLabel;
          string strUserItemSelection = choiceGlobalMappings[dlg3.SelectedLabel];
          dlg3.Reset();
          choiceGlobalMappings.Clear();

          dlg3.SetHeading(GUILocalizeStrings.Get(10798772)); // Choose field ...
          #region populate menu with choices
          switch (strUserItemSelection)
          {
            case "mastertitle":
            case "sorttitle":
              break;
            case "secondarytitle":
              dlg3.Add("<" + GUILocalizeStrings.Get(10798774) + ">"); // empty
              choiceGlobalMappings.Add("(none)");
              break;
            default:
              dlg3.Add("<" + GUILocalizeStrings.Get(10798774) + ">"); // empty
              choiceGlobalMappings.Add("");
              break;
          }
          if (selection > 5) // title fields
          {
            ArrayList displayItems = MyFilms.GetDisplayItems("titles");
            foreach (string[] displayItem in displayItems)
            {
              dlg3.Add(displayItem[0] + "-" + displayItem[1]);
              choiceGlobalMappings.Add(displayItem[0]);
            }
          }
          else // display item fields
          {
            ArrayList displayItems = MyFilms.GetDisplayItems("viewitems");
            foreach (string[] displayItem in displayItems)
            {
              dlg3.Add(displayItem[1] + " (" + displayItem[0] + ")");
              choiceGlobalMappings.Add(displayItem[0]);
            }
          }
          #endregion

          dlg3.DoModal(GetID);
          if (dlg3.SelectedLabel == -1)
          {
            Change_Menu("mainmenu");
            return;
          }

          string selectionLabel = choiceGlobalMappings[dlg3.SelectedLabel];
          dlg3.Reset();
          choiceGlobalMappings.Clear();
          LogMyFilms.Debug("Display Options - new field: '" + selectionLabel + "', new Label: '" + BaseMesFilms.TranslateColumn(selectionLabel) + "'.");
          MyFilms.UpdateUseritemWithValue(strUserItemSelection, selectionLabel);
          MyFilms.UpdateUserItems(); // save to currentconfig - save time for WinDeInit
          //Configuration.SaveConfiguration(Configuration.CurrentConfig, facadeFilms.SelectedListItem.ItemId, facadeFilms.SelectedListItem.Label);
          //Load_Config(Configuration.CurrentConfig, true);
          Init_Detailed_DB(false); // clear properties 
          afficher_detail(true);
          return;
          #endregion

        case "fanartcovermenu":
          #region fanart and cover menu (currently not used)
          if (dlgmenu == null) return;
          dlgmenu.Reset();
          choiceViewMenu.Clear();
          dlgmenu.SetHeading(GUILocalizeStrings.Get(10798703)); // Fanart & Cover ...

          int iCovercount = 0;
          bool success = int.TryParse(ChangeLocalCover((DataRow[])MyFilms.r, (int)MyFilms.conf.StrIndex, true, true), out iCovercount);
          if (iCovercount > 1)
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798762) + " " + ChangeLocalCover((DataRow[])MyFilms.r, (int)MyFilms.conf.StrIndex, true, true)); // Change Cover
            choiceViewMenu.Add("changecover");
          }

          //dlgmenu.Add(GUILocalizeStrings.Get(10798763)); // Covermanager ...
          //choiceViewMenu.Add("covermanager");

          dlgmenu.Add(GUILocalizeStrings.Get(10798766)); // Load single Cover ...
          choiceViewMenu.Add("loadcover");

          dlgmenu.Add(GUILocalizeStrings.Get(10798764)); // Load Covers ...
          choiceViewMenu.Add("loadmulticover");

          dlgmenu.Add(GUILocalizeStrings.Get(10798761)); // Load Covers (TMDB)
          choiceViewMenu.Add("tmdbposter");

          if (ExtendedStartmode(MyFilmsDetail.PluginMode.Extended, "Details context: Thumb creator)"))
          {
            dlgmenu.Add(GUILocalizeStrings.Get(10798728));
            //Create Thumb from movie - if no cover available, e.g. with documentaries
            choiceViewMenu.Add("cover-thumbnailer");
          }

          if (MyFilms.conf.StrFanart)
          {
            if (ExtendedStartmode(MyFilmsDetail.PluginMode.Extended, "Details context: Fanart Manager ..."))
            {
              dlgmenu.Add(GUILocalizeStrings.Get(10798766)); // Fanart Manager ...
              choiceViewMenu.Add("fanartmanager");
            }

            dlgmenu.Add(GUILocalizeStrings.Get(1079874)); // Remove Fanart
            choiceViewMenu.Add("deletefanart");

            dlgmenu.Add(GUILocalizeStrings.Get(1079851));
            // Create single fanart from movie as multi image (local)
            choiceViewMenu.Add("createfanartmultiimage");

            dlgmenu.Add(GUILocalizeStrings.Get(1079849)); // create single images fanart from movie (local)
            choiceViewMenu.Add("createfanartsingleimages");

            dlgmenu.Add(GUILocalizeStrings.Get(1079853)); // create fanart from movie (local)
            choiceViewMenu.Add("createfanart");

            if (!g_Player.Stopped && g_Player.HasVideo && !string.IsNullOrEmpty(g_Player.CurrentFile))
            {
              dlgmenu.Add(GUILocalizeStrings.Get(1079852));
              // Create single fanart from movie on current position (local)
              choiceViewMenu.Add("createfanartonposition");
            }

            dlgmenu.Add(GUILocalizeStrings.Get(1079862)); // Download Fanart (online)
            choiceViewMenu.Add("fanart");
          }

          dlgmenu.DoModal(GetID);
          if (dlgmenu.SelectedLabel == -1)
          {
            Change_Menu("mainmenu");
            return;
          }
          Change_Menu(choiceViewMenu[dlgmenu.SelectedLabel].ToLower());
          #endregion
          break;

        case "traktinternal":
          #region trakt internal menu - including context and noncontext items
          if (!TraktInternalMenu(MyFilms.currentMovie))
          {
            Change_Menu("mainmenu");
          }
          #endregion
          break;

        case "trakt":
          #region trakt main menu
          if (dlgmenu == null) return;
          dlgmenu.Reset();
          choiceViewMenu.Clear();
          dlgmenu.SetHeading(GUILocalizeStrings.Get(10798775)); // Trakt...

          dlgmenu.Add(GUILocalizeStrings.Get(10798776)); // 
          choiceViewMenu.Add("trakt-Main");

          //dlgmenu.Add(GUILocalizeStrings.Get(10798777)); // 
          //choiceViewMenu.Add("trakt-Calendar");

          dlgmenu.Add(GUILocalizeStrings.Get(10798778)); // Network
          choiceViewMenu.Add("trakt-Network");

          dlgmenu.Add(GUILocalizeStrings.Get(10798779)); // 
          choiceViewMenu.Add("trakt-RecommendationsMovies");

          dlgmenu.Add(GUILocalizeStrings.Get(10798780)); // 
          choiceViewMenu.Add("trakt-TrendingMovies");

          dlgmenu.Add(GUILocalizeStrings.Get(10798781)); // 
          choiceViewMenu.Add("trakt-WatchedListMovies");

          dlgmenu.Add(GUILocalizeStrings.Get(10798783)); // 
          choiceViewMenu.Add("trakt-AddToWatchedListMovies");

          dlgmenu.Add(GUILocalizeStrings.Get(10798786)); // 
          choiceViewMenu.Add("trakt-Lists");

          dlgmenu.Add(GUILocalizeStrings.Get(10798785)); // 
          choiceViewMenu.Add("trakt-AddRemoveMovieInUserlist");

          dlgmenu.Add(GUILocalizeStrings.Get(10798782)); // Shouts
          choiceViewMenu.Add("trakt-Shouts");

          dlgmenu.Add(GUILocalizeStrings.Get(10798784)); // Rate
          choiceViewMenu.Add("trakt-Rate");

          dlgmenu.Add(GUILocalizeStrings.Get(10798787)); // 
          choiceViewMenu.Add("trakt-RelatedMovies");

          dlgmenu.Add(GUILocalizeStrings.Get(10798788)); // Search people ...
          choiceViewMenu.Add("trakt-SearchPeople");

          dlgmenu.DoModal(GetID);
          if (dlgmenu.SelectedLabel == -1)
          {
            Change_Menu("mainmenu");
            return;
          }
          Change_Menu(choiceViewMenu[dlgmenu.SelectedLabel]);
          #endregion
          break;

        case "trakt-Main":
          GUIWindowManager.ActivateWindow((int)TraktGuiWindows.Main, "");
          break;

        case "trakt-Calendar":
          GUIWindowManager.ActivateWindow((int)TraktGuiWindows.Calendar, "");
          break;

        case "trakt-Network":
          GUIWindowManager.ActivateWindow((int)TraktGuiWindows.Network, "");
          break;

        case "trakt-RecommendationsMovies":
          GUIWindowManager.ActivateWindow((int)TraktGuiWindows.RecommendationsMovies, "");
          break;

        case "trakt-TrendingMovies":
          GUIWindowManager.ActivateWindow((int)TraktGuiWindows.TrendingMovies, "");
          break;

        case "trakt-WatchedListMovies":
          GUIWindowManager.ActivateWindow((int)TraktGuiWindows.WatchedListMovies, "");
          break;

        case "trakt-AddToWatchedListMovies":
          if (Helper.IsTraktAvailableAndEnabledAndNewVersion)
          {
            GUIUtils.ShowErrorDialog("This feature is no more supported - use the Trakt menu instead!");
          }
          else
          {
            GUIUtils.ShowErrorDialog("Your installed Trakt Version does not allow this feature!");
          }
          break;

        case "trakt-Lists":
          if (Helper.IsTraktAvailableAndEnabledAndNewVersion)
          {
            GUIWindowManager.ActivateWindow((int)TraktGuiWindows.Lists, "");
          }
          else
          {
            GUIUtils.ShowErrorDialog("Your installed Trakt Version does not allow this feature!");
          }
          break;

        case "trakt-AddRemoveMovieInUserlist":
          if (Helper.IsTraktAvailableAndEnabledAndNewVersion)
          {
            TraktAddRemoveMovieInUserlist(MyFilms.currentMovie, false);
          }
          else
          {
            GUIUtils.ShowErrorDialog("Your installed Trakt Version does not allow this feature!");
          }
          break;

        case "trakt-Shouts":
          movie = GetMovieFromRecord(MyFilms.r[MyFilms.conf.StrIndex]);
          this.TraktShout(movie);
          //TraktShout(MyFilms.currentMovie);
          //GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
          break;

        case "trakt-Rate":
          if (Helper.IsTraktAvailableAndEnabled)
          {
            GUIUtils.ShowErrorDialog("This feature is no more supported - use the Trakt menu instead!");
          }
          else
          {
            GUIUtils.ShowErrorDialog("Your installed Trakt Version does not allow this feature!");
          }
          break;

        case "trakt-RelatedMovies":
          if (Helper.IsTraktAvailableAndEnabled)
          {
            TraktRelatedMovies(MyFilms.currentMovie);
          }
          else
          {
            GUIUtils.ShowErrorDialog("Your installed Trakt Version does not allow this feature!");
          }
          break;

        case "trakt-SearchPeople":
          if (Helper.IsTraktAvailableAndEnabledAndNewVersion)
          {
            TraktSearchPeople(MyFilms.currentMovie);
          }
          else
          {
            GUIUtils.ShowErrorDialog("Your installed Trakt Version does not allow this feature!");
          }
          break;

        case "subtitles":
          if (MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrTitle1].ToString() != null) // ShowSubtitleMenu(MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrTitle1].ToString());
          {
            if (Helper.IsSubCentralAvailableAndEnabled) GUIWindowManager.ActivateWindow((int)MyFilms.ExternalPluginWindows.SubCentral);
          }
          break;

        case "fileselect":
          #region file selection (source)
          string wfile = string.Empty;
          string wdirectory = string.Empty;
          if (File.Exists(MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrStorage].ToString())) // Check if Sourcefile exists
          {
            wfile = MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrStorage].ToString();
            wdirectory = Path.GetDirectoryName(wfile);
          }
          keyboard.Reset();
          keyboard.SetLabelAsInitialText(false); // set to false, otherwise our intial text is cleared
          keyboard.Text = MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrStorage].ToString();
          keyboard.DoModal(GetID);
          wfile = keyboard.IsConfirmed ? keyboard.Text : string.Empty;
          if (wfile != string.Empty)
          {
            MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrStorage] = wfile;
            Update_XML_database();
            afficher_detail(true);
          }
          #endregion
          break;

        case "delete":
          {
            #region delete item
            if (dlgmenu == null) return;
            dlgmenu.Reset();
            choiceViewMenu.Clear();
            dlgmenu.SetHeading(GUILocalizeStrings.Get(1079830)); // Delete movie ...

            dlgmenu.Add(GUILocalizeStrings.Get(1079831)); // Remove movie from catalog
            choiceViewMenu.Add("removefromdb");

            dlgmenu.Add(GUILocalizeStrings.Get(1079832)); // Delete movie file(s) from disk
            choiceViewMenu.Add("deletefromdisk");

            dlgmenu.Add(GUILocalizeStrings.Get(1079833)); // Delete from catalog and disk
            choiceViewMenu.Add("deletefromdbanddisk");

            dlgmenu.DoModal(GetID);
            if (dlgmenu.SelectedLabel == -1)
            {
              Change_Menu("mainmenu");
              return;
            }
            Change_Menu(choiceViewMenu[dlgmenu.SelectedLabel].ToLower());
            #endregion
            break;
          }

        case "moviepersonlist":
          {
            #region display person list of current movie in main screen
            MyFilms.internalLoadParam = "moviepersonlist";
            GUIWindowManager.ActivateWindow(MyFilms.ID_MyFilms,false);
            #endregion
            break;
          }

        case "removefromdb":
          #region remove from DB
          
          dlgYesNo.Reset();
          dlgYesNo.SetHeading(GUILocalizeStrings.Get(1079831)); //Remove movie from catalog
          dlgYesNo.SetLine(2, GUILocalizeStrings.Get(433)); //confirm suppression
          dlgYesNo.DoModal(GetID);
          if (dlgYesNo.IsConfirmed)
          {
            // MyFilmsDetail.Suppress_Entry((DataRow[])MyFilms.r, (int)MyFilms.conf.StrIndex);
            ManualDelete(MyFilms.r[MyFilms.conf.StrIndex], true, false);
            // Update_XML_database();
            MyFilms.r = BaseMesFilms.ReadDataMovies(MyFilms.conf.StrDfltSelect, MyFilms.conf.StrFilmSelect, MyFilms.conf.StrSorta, MyFilms.conf.StrSortSens);
            afficher_detail(true);
            return;
          }
          if (dlgYesNo.SelectedLabel == -1)
          {
            Change_Menu("delete");
          }
          #endregion
          break;

        case "deletefromdisk":
          #region delete item from disk
          dlgYesNo.Reset();
          dlgYesNo.SetHeading(GUILocalizeStrings.Get(1079832)); //Delete movie file(s) from disk
          dlgYesNo.SetLine(1, GUILocalizeStrings.Get(927)); // warning
          dlgYesNo.SetLine(2, GUILocalizeStrings.Get(1079834));
          //If you confirm, you media files will physically be deleted !
          dlgYesNo.SetLine(3, GUILocalizeStrings.Get(1079835)); //Are you sure you want to delete movie ?
          dlgYesNo.DoModal(GetID);
          if (dlgYesNo.IsConfirmed)
          {
            ManualDelete(MyFilms.r[MyFilms.conf.StrIndex], false, true);
            MyFilms.r = BaseMesFilms.ReadDataMovies(MyFilms.conf.StrDfltSelect, MyFilms.conf.StrFilmSelect, MyFilms.conf.StrSorta, MyFilms.conf.StrSortSens);
            afficher_detail(true);
            return;
          }
          if (dlgYesNo.SelectedLabel == -1)
          {
            Change_Menu("delete");
          }
          #endregion
          break;

        case "deletefromdbanddisk":
          #region delete item from DB and disk
          dlgYesNo.Reset();
          dlgYesNo.SetHeading(GUILocalizeStrings.Get(1079833)); //Delete from catalog and disk
          dlgYesNo.SetLine(1, GUILocalizeStrings.Get(927)); // warning
          dlgYesNo.SetLine(2, GUILocalizeStrings.Get(1079834));
          //If you confirm, you media files will physically be deleted !
          dlgYesNo.SetLine(3, GUILocalizeStrings.Get(1079835)); //Are you sure you want to delete movie ?
          dlgYesNo.DoModal(GetID);
          if (dlgYesNo.IsConfirmed)
          {
            ManualDelete(MyFilms.r[MyFilms.conf.StrIndex], true, true);
            MyFilms.r = BaseMesFilms.ReadDataMovies(MyFilms.conf.StrDfltSelect, MyFilms.conf.StrFilmSelect, MyFilms.conf.StrSorta, MyFilms.conf.StrSortSens);
            afficher_detail(true);
            return;
          }
          if (dlgYesNo.SelectedLabel == -1)
          {
            Change_Menu("delete");
          }
          #endregion
          break;

        case "updproperty":
          {
            #region build menu
            List<string> choiceUpd = new List<string>();
            if (dlgmenu == null) return;
            dlgmenu.Reset();
            dlgmenu.SetHeading(GUILocalizeStrings.Get(10798643)); // menu

            dlgmenu.Add(" " + BaseMesFilms.TranslateColumn(MyFilms.conf.StrTitle1));
            choiceUpd.Add(MyFilms.conf.StrTitle1);

            if (Helper.FieldIsSet(MyFilms.conf.StrTitle2))
            {
              dlgmenu.Add(" " + BaseMesFilms.TranslateColumn(MyFilms.conf.StrTitle2));
              choiceUpd.Add(MyFilms.conf.StrTitle2);
            }

            if (Helper.FieldIsSet(MyFilms.conf.StrStorage)) // Source field / media file name
            {
              dlgmenu.Add(" " + BaseMesFilms.TranslateColumn(MyFilms.conf.StrStorage));
              choiceUpd.Add(MyFilms.conf.StrStorage);
            }

            string[] defaultupdateitems = new string[] { "Category", "Year", "Date", "Country", "Rating" };
            foreach (string wupd in defaultupdateitems)
            {
              dlgmenu.Add(" " + BaseMesFilms.TranslateColumn(wupd));
              choiceUpd.Add(wupd.Trim());
            }

            dlgmenu.Add(GUILocalizeStrings.Get(10798765)); // *** show all ***
            choiceUpd.Add("showall");

            dlgmenu.DoModal(GetID);
            if (dlgmenu.SelectedLabel == -1) Change_Menu("mainmenu"); // go back to main contextmenu

            // show all search fields, if selected ...
            if (choiceUpd[dlgmenu.SelectedLabel] == "showall")
            {
              dlgmenu.Reset();
              dlgmenu.SetHeading(GUILocalizeStrings.Get(10798643)); // menu
              choiceUpd.Clear();
              ArrayList displayItems = MyFilms.GetDisplayItems("view");
              foreach (string[] displayItem in displayItems)
              {
                string entry = (string.IsNullOrEmpty(displayItem[1])) ? displayItem[0] : displayItem[1];
                dlgmenu.Add(" " + entry);
                choiceUpd.Add(displayItem[0]);
                LogMyFilms.Debug("Update properties menu - add '{0}' as '{1}'", displayItem[0], entry);
              }
              dlgmenu.DoModal(GetID);
              if (dlgmenu.SelectedLabel == -1) Change_Menu("mainmenu"); // go back to main contextmenu
            }
            #endregion
            string wproperty = choiceUpd[dlgmenu.SelectedLabel];
            #region update selected property

            dlgmenu.Reset();
            keyboard.Reset();
            keyboard.SetLabelAsInitialText(false); // set to false, otherwise our intial text is cleared
            keyboard.Text = MyFilms.r[MyFilms.conf.StrIndex][wproperty].ToString();
            keyboard.DoModal(GetID);
            if (keyboard.IsConfirmed)
            {
              switch (ds.Movie.Columns[wproperty].DataType.Name)
              {
                case "Decimal":
                  try
                  {
                    MyFilms.r[MyFilms.conf.StrIndex][wproperty] = Convert.ToDecimal(keyboard.Text);
                  }
                  catch
                  {
                    GUIUtils.ShowOKDialog(GUILocalizeStrings.Get(10798642), GUILocalizeStrings.Get(10798644)); // wrong input
                    return;
                  }
                  break;
                case "Int32":
                  try
                  {
                    MyFilms.r[MyFilms.conf.StrIndex][wproperty] = Convert.ToInt32(keyboard.Text);
                  }
                  catch
                  {
                    GUIUtils.ShowOKDialog(GUILocalizeStrings.Get(10798642), GUILocalizeStrings.Get(10798644)); // wrong input
                    return;
                  }
                  break;
                default:
                  MyFilms.r[MyFilms.conf.StrIndex][wproperty] = keyboard.Text;
                  break;
              }
              Update_XML_database();
              afficher_detail(true);
            }
            break;

            #endregion
          }

        case "updremovealldetails":
          #region reset movie details
          ArrayList deleteItems = MyFilms.GetDisplayItems("deletedetails");
          foreach (string wproperty in deleteItems.Cast<string[]>().Select(displayItem => displayItem[0]).Where(wproperty => !string.IsNullOrEmpty(wproperty) && MyFilms.r[MyFilms.conf.StrIndex][wproperty] != DBNull.Value))
          {
            try
            {
              switch (ds.Movie.Columns[wproperty].DataType.Name)
              {
                case "DateTime":
                  MyFilms.r[MyFilms.conf.StrIndex][wproperty] = DateTime.Now;
                  break;
                case "Decimal":
                  MyFilms.r[MyFilms.conf.StrIndex][wproperty] = 0;
                  break;
                case "Int32":
                  MyFilms.r[MyFilms.conf.StrIndex][wproperty] = 0;
                  break;
                default:
                  MyFilms.r[MyFilms.conf.StrIndex][wproperty] = "";
                  break;
              }
              LogMyFilms.Debug("Delete value for property '" + wproperty + "'");
            }
            catch (Exception ex)
            {
              LogMyFilms.Debug("Error deleting value for property '" + wproperty + "', exception: ", ex.Message);
            }
          }
          Update_XML_database();
          afficher_detail(true);
          #endregion
          break;

        case "updmediainfos":
          {
            #region update mediainfo
            string FileDate = string.Empty;
            string VideoPlaytime = string.Empty;
            string VideoCodec = string.Empty;
            string VideoFormat = string.Empty;
            string VideoFormatProfile = string.Empty;
            string VideoBitRate = string.Empty;
            string VideoFrameRate = string.Empty;
            string VideoWidth = string.Empty;
            string VideoHeight = string.Empty;
            string VideoAspectRatio = string.Empty;

            string AudioCodec = string.Empty;
            string AudioFormat = string.Empty;
            string AudioFormatProfile = string.Empty;
            string AudioBitrate = string.Empty;
            string AudioChannels = string.Empty;
            string AudioTracks = string.Empty;

            string TextCount = string.Empty;

            long TotalSize = 0;
            int TotalRuntime = 0;

            string source = MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrStorage].ToString();
            string[] files = source.Split(new Char[] { ';' });

            foreach (string file in files)
            {
              LogMyFilms.Debug("Mediainfo - Filename: '" + file + "'");
              if (System.IO.File.Exists(file))
              {
                // Get File Date Added/Created
                FileDate = GetFileTimeStamps(file);
                LogMyFilms.Debug("Mediainfo - FileDate: '" + FileDate + "'");

                System.IO.FileInfo fi = new System.IO.FileInfo(file);
                TotalSize += fi.Length;

                // ReadMediaInfo(file, ref mediainfo);
                MediaInfo mediainfo = MediaInfo.GetInstance();

                // MediaInfo Object could not be created
                if (null == mediainfo)
                  return;

                // Check if File Exists and is not an Image type e.g. ISO (we can't extract mediainfo from that)
                if (System.IO.File.Exists(file) && !Helper.IsImageFile(file))
                {
                  try
                  {
                    LogMyFilms.Debug("Attempting to read Mediainfo for ", file.ToString());

                    // open file in MediaInfo
                    mediainfo.Open(file);

                    // check number of failed attempts at mediainfo extraction                    
                    int noAttempts = 0;

                    // Get Playtime (runtime)
                    string result = mediainfo.VideoPlaytime;

                    string LocalPlaytime = result != "-1" ? result : noAttempts.ToString();

                    VideoPlaytime = mediainfo.VideoPlaytime;
                    LogMyFilms.Debug("Mediainfo - VideoPlaytime: '" + VideoPlaytime + "'");
                    TotalRuntime += Int32.Parse(VideoPlaytime);

                    VideoCodec = mediainfo.VideoCodec;
                    LogMyFilms.Debug("Mediainfo - Videocodec: '" + VideoCodec + "'");
                    VideoFormat = mediainfo.VideoCodecFormat;
                    LogMyFilms.Debug("Mediainfo - VideoCodecFormat: '" + VideoFormat + "'");
                    VideoFormatProfile = mediainfo.VideoFormatProfile;
                    LogMyFilms.Debug("Mediainfo - VideoFormatProfile: '" + VideoFormatProfile + "'");
                    VideoBitRate = mediainfo.VideoBitrate;
                    LogMyFilms.Debug("Mediainfo - VideoBitrate: '" + VideoBitRate + "'");
                    VideoFrameRate = mediainfo.VideoFramesPerSecond;
                    LogMyFilms.Debug("Mediainfo - VideoFramesPerSecond: '" + VideoFrameRate + "'");
                    VideoWidth = mediainfo.VideoWidth;
                    LogMyFilms.Debug("Mediainfo - VideoWidth: '" + VideoWidth + "'");
                    VideoHeight = mediainfo.VideoHeight;
                    LogMyFilms.Debug("Mediainfo - VideoHeight: '" + VideoHeight + "'");
                    VideoAspectRatio = mediainfo.VideoAspectRatio;
                    LogMyFilms.Debug("Mediainfo - VideoAspectRatio: '" + VideoAspectRatio + "'");

                    AudioCodec = mediainfo.AudioCodec;
                    LogMyFilms.Debug("Mediainfo - AudioCodec: '" + AudioCodec + "'");
                    AudioFormat = mediainfo.AudioCodecFormat;
                    LogMyFilms.Debug("Mediainfo - AudioCodecFormat: '" + AudioFormat + "'");
                    AudioFormatProfile = mediainfo.AudioFormatProfile;
                    LogMyFilms.Debug("Mediainfo - AudioFormatProfile: '" + AudioFormatProfile + "'");
                    AudioBitrate = mediainfo.AudioBitrate;
                    LogMyFilms.Debug("Mediainfo - AudioBitrate: '" + AudioBitrate + "'");
                    AudioChannels = mediainfo.AudioChannelCount;
                    LogMyFilms.Debug("Mediainfo - AudioChannelCount: '" + AudioChannels + "'");
                    AudioTracks = mediainfo.AudioStreamCount;
                    LogMyFilms.Debug("Mediainfo - AudioStreamCount: '" + AudioTracks + "'");

                    TextCount = mediainfo.SubtitleCount;
                    LogMyFilms.Debug("Mediainfo - SubtitleCount: '" + TextCount + "'");

                    // MediaInfo cleanup
                    mediainfo.Close();
                  }
                  catch (Exception ex)
                  {
                    LogMyFilms.Debug("Error reading MediaInfo: ", ex.Message);
                  }

                }
                LogMyFilms.Debug("File '" + file + "' does not exist or is an image file");


              }
              else
                LogMyFilms.Debug("Mediainfo - File '" + file + "' does not exist !");
            }
            int size = (int)(TotalSize / 1024 / 1024);
            string strSize = string.Format("{0}", size);
            //string humanKBSize = string.Format("{0} KB", size);
            //string humanMBSize = string.Format("{0} MB", size / 1024);
            //string humanGBSize = string.Format("{0} GB", size / 1024 / 1024);
            LogMyFilms.Debug("Mediainfo - TotalSize: '" + strSize + "'");
            LogMyFilms.Debug("Mediainfo - TotalRuntime: '" + TotalRuntime.ToString() + "'");

            //MyFilms.r[MyFilms.conf.StrIndex]["Length"] = TotalRuntime.ToString();
            //MyFilms.r[MyFilms.conf.StrIndex]["VideoFormat"] = string.Empty;
            //MyFilms.r[MyFilms.conf.StrIndex]["VideoBitrate"] = string.Empty;
            //MyFilms.r[MyFilms.conf.StrIndex]["AudioFormat"] = string.Empty;
            //MyFilms.r[MyFilms.conf.StrIndex]["AudioBitrate"] = string.Empty;
            //MyFilms.r[MyFilms.conf.StrIndex]["Resolution"] = string.Empty;
            //MyFilms.r[MyFilms.conf.StrIndex]["Framerate"] = string.Empty;
            //MyFilms.r[MyFilms.conf.StrIndex]["Languages"] = string.Empty;
            //MyFilms.r[MyFilms.conf.StrIndex]["Subtitles"] = string.Empty;
            //MyFilms.r[MyFilms.conf.StrIndex]["DateAdded"] = string.Empty;
            //MyFilms.r[MyFilms.conf.StrIndex]["Size"] = string.Format("{0}", size); ;
            //MyFilms.r[MyFilms.conf.StrIndex]["Disks"] = split.Count().ToString();
            //MyFilms.r[MyFilms.conf.StrIndex]["Aspectratio"] = string.Empty;
            //Update_XML_database();
            //afficher_detail(true);
            #endregion
          }
          break;

        case "grabber":
          #region grabber
          bool wChooseScript = MyFilms.conf.StrGrabber_ChooseScript;
          if (!System.IO.File.Exists(MyFilms.conf.StrGrabber_cnf) && !MyFilms.conf.StrGrabber_ChooseScript)
          {
            dlgYesNo.SetHeading(GUILocalizeStrings.Get(107986));//my films
            dlgYesNo.SetLine(1, string.Format(GUILocalizeStrings.Get(1079875), MyFilms.conf.StrGrabber_cnf));//File doesn't exist. Do you want to choose it ?
            dlgYesNo.SetLine(2, GUILocalizeStrings.Get(1079878));//confirm suppression
            dlgYesNo.DoModal(GetID);
            if (dlgYesNo.IsConfirmed)
              wChooseScript = true;
            else
            {
              LogMyFilms.Info("My Films : The grabber config file doesn't exists. No grab Information done !");
              break;
            }
          }
          title = GetSearchTitle(MyFilms.r, MyFilms.conf.StrIndex, "");
          mediapath = GetMediaPathOfFirstFile(MyFilms.r, MyFilms.conf.StrIndex);
          sTitles = GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], mediapath);

          // this will be executed after background thread finished
          doUpdateDetailsViewByFinishEvent = true;
          grabb_Internet_Informations(title, GetID, wChooseScript, MyFilms.conf.StrGrabber_cnf, mediapath, GrabType.All, false, sTitles, m_SearchAnimation);
          // afficher_detail(true); // -> will be executes by OnDetailsUpdated message handler later ...
          SetProcessAnimationStatus(false, m_SearchAnimation); // make sure it's switched off
          #endregion
          break;

        case "ant-nfo-reader":
          GUIUtils.ShowOKDialog("Action not yet implemented");
          break;

        case "ant-nfo-writer":
          GUIUtils.ShowOKDialog("Action not yet implemented");
          break;

        case "trailer-tmdb":
          if (!Helper.IsOnlineVideosAvailableAndEnabled)
          {
            GUIUtils.ShowNotifyDialog("OnlineVideos is not available!");
            return;
          }
          SearchAndDownloadTrailerOnlineTMDB(MyFilms.r, MyFilms.conf.StrIndex, false, true, (MyFilms.conf.StrDirStorTrailer.Length > 0) ? MyFilms.conf.StrDirStorTrailer : null); // MyFilmsDetail.SearchAndDownloadTrailerOnlineTMDB(r, MyFilms.conf.StrIndex, false, true, null);
          break;

        case "cover-thumbnailer":
          CreateThumbFromMovie();
          GUIUtils.ShowOKDialog(GUILocalizeStrings.Get(107986), "Cover created from movie");
          //ToDo: Add Dialog to let user choose, if cover should replace existing one (remove skip existing logic for that!)
          break;

        case "trailer-register":
          {
            SetProcessAnimationStatus(true, m_SearchAnimation);
            //Zuerst Pfad lesen, dann Dateien suchen, in liste packen, Auswahlmenü präsentieren und zum Schluß Update des Records 
            // Suchen nach Files mit folgendem Kriterium:
            // 1.) ... die den Filmnamen im Filenamen haben und im Trailerverzeichnis gefunden werden (wahrscheinlich HD, daher an 1. Stelle setzen)
            // 2.) Im Verzeichnis des Films suchen nach Filmdateien die das Wort "Trailer" im Namen haben (Endung beliebig: avi, mov, flv, etc.)
            // 3.) Im (Trailer)-Suchpfad nach Verzeichnissen, die nach dem Filmnamen benannt sind - dann alle Files darin registrien

            LogMyFilms.Debug("SelectedItemInfo from (MyFilms.r[MyFilms.conf.StrIndex]: '" + (MyFilms.r[MyFilms.conf.StrIndex] + "'"));
            SearchTrailerLocal(MyFilms.r, MyFilms.conf.StrIndex, true, true);
            SetProcessAnimationStatus(false, m_SearchAnimation);
            afficher_detail(true);
            GUIUtils.ShowOKDialog(MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrSTitle].ToString(), result.Count.ToString() + " " + GUILocalizeStrings.Get(10798705), "", ""); // trailers found ! 
            break;
          }

        case "trailer-delete":
          dlgYesNo.SetHeading(GUILocalizeStrings.Get(107986));//my films
          dlgYesNo.SetLine(1, GUILocalizeStrings.Get(433));//confirm suppression
          dlgYesNo.DoModal(GetID);
          if (dlgYesNo.IsConfirmed)
          {
            DeleteTrailerFromDB(MyFilms.r, MyFilms.conf.StrIndex);
            //MyFilms.r = BaseMesFilms.ReadDataMovies(MyFilms.conf.StrDfltSelect, MyFilms.conf.StrFilmSelect, MyFilms.conf.StrSorta, MyFilms.conf.StrSortSens);
            afficher_detail(true);
          }
          break;

        case "personimages":
          if (!Helper.IsConnectedToInternet())
          {
            GUIUtils.ShowErrorDialog(GUILocalizeStrings.Get(703));
            break; // stop, if no internet available
          }
          Menu_LoadPersonImages();
          break;

        case "fanart":
          if (!Helper.IsConnectedToInternet())
          {
            GUIUtils.ShowErrorDialog(GUILocalizeStrings.Get(703));
            break; // stop, if no internet available
          }
          // Remove_Backdrops_Fanart(MyFilms.r[MyFilms.conf.StrIndex][MyFilms.conf.StrTitle1].ToString(), false); // do not remove, as user might only want to "update" fanart ...
          Menu_LoadFanart(false);
          break;

        case "createfanart": // create fanart from local media
          Menu_CreateFanart(GrabUtil.ArtworkFanartType.MultiImageWithMultipleSingleImages);
          break;

        case "createfanartsingleimages": // create single images fanart from local media
          Menu_CreateFanart(GrabUtil.ArtworkFanartType.MultipleSingleImages);
          break;

        case "createfanartmultiimage": // create single fanart from local media on pause position
          Menu_CreateFanart(GrabUtil.ArtworkFanartType.Multiimage);
          break;

        case "createfanartonposition": // create single fanart from local media on pause position
          Menu_CreateFanart_OnMoviePosition();
          afficher_detail(true);
          break;

        case "deletefanart":
          dlgYesNo.SetHeading(GUILocalizeStrings.Get(1079874));//Delete fanart
          dlgYesNo.SetLine(1, "");
          dlgYesNo.SetLine(2, GUILocalizeStrings.Get(433));//confirm suppression
          dlgYesNo.DoModal(GetID);
          if (dlgYesNo.IsConfirmed)
          {
            sTitles = GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], "");
            Remove_Backdrops_Fanart(sTitles.FanartTitle, false);
            Remove_Backdrops_Fanart(sTitles.OriginalTitle, false);
            Remove_Backdrops_Fanart(sTitles.TranslatedTitle, false);
            Remove_Backdrops_Fanart(sTitles.FormattedTitle, false);
            Remove_Backdrops_Fanart(sTitles.MasterTitle, false);
            Remove_Backdrops_Fanart(sTitles.SecondaryTitle, false);
            Remove_Backdrops_Fanart(sTitles.SortTitle, false);
            Thread.Sleep(50);
            afficher_detail(true);
          }
          break;

        case "changecover":
          string covercount = ChangeLocalCover((DataRow[])MyFilms.r, (int)MyFilms.conf.StrIndex, true, false);
          afficher_detail(true);
          SetProcessAnimationStatus(false, m_SearchAnimation);
          Change_Menu("fanartcovermenu"); // stay in cover toggle menu
          break;

        case "covermanager":
          LogMyFilms.Debug("Switching to Cover Manager Window");
          MyFilmsCoverManager cm = null;
          if (cm == null)
          {
            cm = new MyFilmsCoverManager();
            GUIWindow cmwindow = (GUIWindow)cm;
            GUIWindowManager.Add(ref cmwindow);
            cm.Init();
          }
          // cm.MovieID = MyFilms.conf.StrIndex; // will be set later in cm class
          cm.setPageTitle("Cover Manager");
          //sTitles = GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], GetMediaPathOfFirstFile(MyFilms.r, MyFilms.conf.StrIndex));
          //cm.ArtworkFileName = GetOrCreateCoverFilename(MyFilms.r, MyFilms.conf.StrIndex, sTitles.MasterTitle);
          GUIWindowManager.ActivateWindow(cm.GetID, false);
          break;

        case "fanartmanager":
          #region fanart manager
          LogMyFilms.Info("Fanart Manager : Not yet implemented - using old submenu instead!");
          if (dlgmenu == null) return;
          dlgmenu.Reset();
          choiceViewMenu.Clear();
          dlgmenu.SetHeading(GUILocalizeStrings.Get(10798767)); // Fanart Manager ...

          if (MyFilms.conf.StrFanart)
          {
            dlgmenu.Add(GUILocalizeStrings.Get(1079874)); // Remove Fanart
            choiceViewMenu.Add("deletefanart");

            dlgmenu.Add(GUILocalizeStrings.Get(1079851)); // Create single fanart from movie as multi image (local)
            choiceViewMenu.Add("createfanartmultiimage");

            dlgmenu.Add(GUILocalizeStrings.Get(1079849)); // create single images fanart from movie (local)
            choiceViewMenu.Add("createfanartsingleimages");

            dlgmenu.Add(GUILocalizeStrings.Get(1079853)); // create fanart from movie (local)
            choiceViewMenu.Add("createfanart");

            if (!g_Player.Stopped && g_Player.HasVideo && !string.IsNullOrEmpty(g_Player.CurrentFile))
            {
              dlgmenu.Add(GUILocalizeStrings.Get(1079852)); // Create single fanart from movie on current position (local)
              choiceViewMenu.Add("createfanartonposition");
            }

            dlgmenu.Add(GUILocalizeStrings.Get(1079862)); // Download Fanart (online)
            choiceViewMenu.Add("fanart");
          }

          dlgmenu.DoModal(GetID);
          if (dlgmenu.SelectedLabel == -1)
          {
            Change_Menu("mainmenu");
            return;
          }
          Change_Menu(choiceViewMenu[dlgmenu.SelectedLabel].ToLower());
          #endregion
          break;

        case "loadcover":
          title = GetSearchTitle(MyFilms.r, MyFilms.conf.StrIndex, "");
          mediapath = GetMediaPathOfFirstFile(MyFilms.r, MyFilms.conf.StrIndex);
          sTitles = GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], mediapath);
          grabb_Internet_Informations(title, GetID, true, MyFilms.conf.StrGrabber_cnf, mediapath, GrabType.Cover, false, sTitles, m_SearchAnimation);
          afficher_detail(true);
          SetProcessAnimationStatus(false, m_SearchAnimation); // make sure it's switched off
          break;

        case "loadmulticover":
          title = GetSearchTitle(MyFilms.r, MyFilms.conf.StrIndex, "");
          mediapath = GetMediaPathOfFirstFile(MyFilms.r, MyFilms.conf.StrIndex);
          sTitles = GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], mediapath);
          grabb_Internet_Informations(title, GetID, true, MyFilms.conf.StrGrabber_cnf, mediapath, GrabType.MultiCovers, false, sTitles, m_SearchAnimation);
          afficher_detail(true);
          SetProcessAnimationStatus(false, m_SearchAnimation); // make sure it's switched off
          break;

        case "tmdbposter":
          Menu_LoadTMDBposter();
          afficher_detail(true);
          break;

        default: // Main Contextmenu
          GUIUtils.ShowOKDialog("Action not yet implemented");
          return;
      }
    }
示例#2
0
    //-------------------------------------------------------------------------------------------
    //  Load detailed db fields : export fields to skin as '#myfilms.<ant db column name> 
    //-------------------------------------------------------------------------------------------
    public static void Load_Detailed_DB(int itemId)
    {
      LogMyFilms.Debug("Load_Detailed_DB() - ItemId: '" + itemId + "'");
      var stopwatch = new Stopwatch(); stopwatch.Reset(); stopwatch.Start();
      string wstrformat = "";

      if (MyFilms.r == null || itemId > MyFilms.r.Length - 1)
      {
        LogMyFilms.Warn("Load_Detailed_DB() - Failed loading details - index '" + itemId + "' not within current dataset ... now clearing properties ...");
        Init_Detailed_DB(false);
        return;
      }
      #region always clear person properties in film details ...
      clearGUIProperty("person.name.value");
      clearGUIProperty("person.dateofbirth.value");
      clearGUIProperty("person.placeofbirth.value");
      clearGUIProperty("person.biography.value");
      //clearGUIProperty("person.dateofdeath.value");
      //clearGUIProperty("person.placeofdeath.value");
      //clearGUIProperty("person.movies.value");
      //clearGUIProperty("person.lastupdate.value");
      #endregion

      using (var ds = new AntMovieCatalog())
      {
        foreach (DataColumn dc in ds.Movie.Columns)
        {
          string wstring = "";
          string wstring2 = "";
          //LogMyFilms.Debug("PropertyManager: Set Properties for DB Column '" + dc.ColumnName + "' - '" + BaseMesFilms.Translate_Column(dc.ColumnName) + "'");

          if (MyFilms.r.Length > itemId && MyFilms.r[itemId][dc.ColumnName] != null) // make sure, it is a valid part of current loaded dataset "r"
          {
            #region set userdefined properties for main screen
            if (MyFilms.conf.Stritem1.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item1.label", MyFilms.conf.Strlabel1);
              if (MyFilms.conf.Stritem1.ToLower() == "date")
                setGUIProperty("user.item1.field", "w" + MyFilms.conf.Stritem1.ToLower());
              else
                setGUIProperty("user.item1.field", MyFilms.conf.Stritem1.ToLower());
              setGUIProperty("user.item1.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.Stritem2.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item2.label", MyFilms.conf.Strlabel2);
              if (MyFilms.conf.Stritem2.ToLower() == "date")
                setGUIProperty("user.item2.field", "w" + MyFilms.conf.Stritem2.ToLower());
              else
                setGUIProperty("user.item2.field", MyFilms.conf.Stritem2.ToLower());
              setGUIProperty("user.item2.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.Stritem3.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item3.label", MyFilms.conf.Strlabel3);
              if (MyFilms.conf.Stritem3.ToLower() == "date")
                setGUIProperty("user.item3.field", "w" + MyFilms.conf.Stritem3.ToLower());
              else
                setGUIProperty("user.item3.field", MyFilms.conf.Stritem3.ToLower());
              setGUIProperty("user.item3.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.Stritem4.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item4.label", MyFilms.conf.Strlabel4);
              if (MyFilms.conf.Stritem4.ToLower() == "date")
                setGUIProperty("user.item4.field", "w" + MyFilms.conf.Stritem4.ToLower());
              else
                setGUIProperty("user.item4.field", MyFilms.conf.Stritem4.ToLower());
              setGUIProperty("user.item4.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.Stritem5.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item5.label", MyFilms.conf.Strlabel5);
              if (MyFilms.conf.Stritem5.ToLower() == "date")
                setGUIProperty("user.item5.field", "w" + MyFilms.conf.Stritem5.ToLower());
              else
                setGUIProperty("user.item5.field", MyFilms.conf.Stritem5.ToLower());
              setGUIProperty("user.item5.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            #endregion

            #region set userdefined properties for details screen
            if (MyFilms.conf.StritemDetails1.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem1.label", MyFilms.conf.StrlabelDetails1);
              if (MyFilms.conf.StritemDetails1.ToLower() == "date")
                setGUIProperty("user.detailsitem1.field", "w" + MyFilms.conf.StritemDetails1.ToLower());
              else
                setGUIProperty("user.detailsitem1.field", MyFilms.conf.StritemDetails1.ToLower());
              setGUIProperty("user.detailsitem1.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails2.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem2.label", MyFilms.conf.StrlabelDetails2);
              if (MyFilms.conf.Stritem2.ToLower() == "date")
                setGUIProperty("user.detailsitem2.field", "w" + MyFilms.conf.StritemDetails2.ToLower());
              else
                setGUIProperty("user.detailsitem2.field", MyFilms.conf.StritemDetails2.ToLower());
              setGUIProperty("user.detailsitem2.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails3.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem3.label", MyFilms.conf.StrlabelDetails3);
              if (MyFilms.conf.Stritem3.ToLower() == "date")
                setGUIProperty("user.detailsitem3.field", "w" + MyFilms.conf.StritemDetails3.ToLower());
              else
                setGUIProperty("user.detailsitem3.field", MyFilms.conf.StritemDetails3.ToLower());
              setGUIProperty("user.detailsitem3.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails4.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem4.label", MyFilms.conf.StrlabelDetails4);
              if (MyFilms.conf.Stritem4.ToLower() == "date")
                setGUIProperty("user.detailsitem4.field", "w" + MyFilms.conf.StritemDetails4.ToLower());
              else
                setGUIProperty("user.detailsitem4.field", MyFilms.conf.StritemDetails4.ToLower());
              setGUIProperty("user.detailsitem4.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails5.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem5.label", MyFilms.conf.StrlabelDetails5);
              if (MyFilms.conf.Stritem5.ToLower() == "date")
                setGUIProperty("user.detailsitem5.field", "w" + MyFilms.conf.StritemDetails5.ToLower());
              else
                setGUIProperty("user.detailsitem5.field", MyFilms.conf.StritemDetails5.ToLower());
              setGUIProperty("user.detailsitem5.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails6.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem6.label", MyFilms.conf.StrlabelDetails6);
              if (MyFilms.conf.Stritem5.ToLower() == "date")
                setGUIProperty("user.detailsitem6.field", "w" + MyFilms.conf.StritemDetails6.ToLower());
              else
                setGUIProperty("user.detailsitem6.field", MyFilms.conf.StritemDetails6.ToLower());
              setGUIProperty("user.detailsitem6.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            #endregion

            #region set userdefined watched and rating field
            if (MyFilms.conf.StrWatchedField.ToLower() == dc.ColumnName.ToLower())
            {
              if (MyFilms.conf.EnhancedWatchedStatusHandling)
              {
                var userData = new MultiUserData(MyFilms.r[itemId][BaseMesFilms.MultiUserStateField].ToString());
                UserState user = userData.GetUserState(MyFilms.conf.StrUserProfileName);
                setGUIProperty("user.watched.value", user.WatchedCount > 0 ? "true" : "");
                setGUIProperty("user.watcheddate.value", (user.WatchedCount > 0 && user.WatchedDate > MultiUserData.NoWatchedDate) ? user.WatchedDate.ToShortDateString() : "");
                setGUIProperty("user.watchedcount.value", user.WatchedCount.ToString());
                setGUIProperty("user.name.value", (user.UserName != MyFilms.DefaultUsername) ? user.UserName : "");
                setGUIProperty("user.watchedcountglobal.value", userData.GetGlobalState().WatchedCount.ToString());
                setGUIProperty("user.rating.value", (user.UserRating > MultiUserData.NoRating) ? Math.Round(user.UserRating, 1).ToString() : "");
              }
              else
              {
                setGUIProperty("user.name.value", "");
                setGUIProperty("user.watched.value", MyFilms.r[itemId][dc.ColumnName].ToString().ToLower() != MyFilms.conf.GlobalUnwatchedOnlyValue.ToLower() ? "true" : "");
                decimal userRating = MultiUserData.NoRating;
                if (MyFilms.r[itemId]["RatingUser"].ToString().Length > 0)
                {
                  if (!(decimal.TryParse(MyFilms.r[itemId]["RatingUser"].ToString(), out userRating))) userRating = MultiUserData.NoRating;
                }
                setGUIProperty("user.rating.value", (userRating > MultiUserData.NoRating) ? Math.Round(userRating, 1).ToString() : "");
              }
            }
            #endregion

            #region set userdefined source and sourcetrailer
            if (MyFilms.conf.StrStorage.ToLower() == dc.ColumnName.ToLower())
            {
              string sourceFull = MyFilms.r[itemId][dc.ColumnName].ToString();
              string name = "";
              string path = "";
              string longname = "";
              string count = "";
              setGUIProperty("user.source.value", sourceFull);
              MyFilms.currentMovie.File = sourceFull;
              if (!string.IsNullOrEmpty(sourceFull.Trim()))
              {
                string[] split = sourceFull.Trim().Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                count = split.Count().ToString();
                foreach (string s in split.Select(x => x.Trim()).Where(x => x.LastIndexOf("\\", StringComparison.Ordinal) > 0))
                {
                  if (name.Length > 0) name += "; ";
                  name += s.Substring(s.LastIndexOf("\\", System.StringComparison.Ordinal) + 1);
                  if (path.Length > 0) path += "; ";
                  path += s.Substring(0, s.LastIndexOf("\\", System.StringComparison.Ordinal));
                  if (longname.Length > 0) longname += "; ";
                  string temppath = s.Substring(0, s.LastIndexOf("\\", System.StringComparison.Ordinal));
                  longname += (temppath.LastIndexOf("\\", System.StringComparison.Ordinal) > 0) ? temppath.Substring(temppath.LastIndexOf("\\", System.StringComparison.Ordinal) + 1) + "\\" + name : s;
                }
              }
              setGUIProperty("user.source.count", count);
              setGUIProperty("user.source.filepath", path);
              setGUIProperty("user.source.filename", name);
              setGUIProperty("user.source.shortname", longname);
            }

            if (MyFilms.conf.StrStorageTrailer.ToLower() == dc.ColumnName.ToLower())
            {
              string sourceFull = MyFilms.r[itemId][dc.ColumnName].ToString();
              string name = "";
              string path = "";
              string longname = "";
              string count = "";
              setGUIProperty("user.sourcetrailer.value", sourceFull);
              MyFilms.currentMovie.Trailer = sourceFull;
              if (!string.IsNullOrEmpty(sourceFull.Trim()))
              {
                string[] split = sourceFull.Trim().Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                count = split.Count().ToString();
                foreach (string s in split.Select(x => x.Trim()).Where(x => x.LastIndexOf("\\", StringComparison.Ordinal) > 0))
                {
                  if (name.Length > 0) name += "; ";
                  name += s.Substring(s.LastIndexOf("\\", System.StringComparison.Ordinal) + 1);
                  if (path.Length > 0) path += "; ";
                  path += s.Substring(0, s.LastIndexOf("\\", System.StringComparison.Ordinal));
                  if (longname.Length > 0) longname += "; ";
                  string temppath = s.Substring(0, s.LastIndexOf("\\", System.StringComparison.Ordinal));
                  longname += (temppath.LastIndexOf("\\", System.StringComparison.Ordinal) > 0) ? temppath.Substring(temppath.LastIndexOf("\\", System.StringComparison.Ordinal) + 1) + "\\" + name : s;
                }
              }
              setGUIProperty("user.sourcetrailer.count", count);
              setGUIProperty("user.sourcetrailer.filepath", path);
              setGUIProperty("user.sourcetrailer.filename", name);
              setGUIProperty("user.sourcetrailer.shortname", longname);
            }
            #endregion

            #region set all db fields ...
            switch (dc.ColumnName.ToLower())
            {
              case "translatedtitle":
              case "originaltitle":
              case "formattedtitle":
                #region titles
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  if (MyFilms.r[itemId][dc.ColumnName].ToString().Contains(MyFilms.conf.TitleDelim))
                  {
                    wstring = MyFilms.r[itemId][dc.ColumnName].ToString().Substring(MyFilms.r[itemId][dc.ColumnName].ToString().LastIndexOf(MyFilms.conf.TitleDelim) + 1);
                    wstring2 = MyFilms.r[itemId][dc.ColumnName].ToString().Substring(0, MyFilms.r[itemId][dc.ColumnName].ToString().LastIndexOf(MyFilms.conf.TitleDelim));
                  }
                  else
                  {
                    wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                    wstring2 = "";
                  }

                if (MyFilms.conf.StrTitle1.ToLower() == (dc.ColumnName.ToLower()))
                {
                  setGUIProperty("user.mastertitle.value", wstring);
                  setGUIProperty("user.mastertitle.groupname", wstring2);
                }
                if (MyFilms.conf.StrTitle2.ToLower() == (dc.ColumnName.ToLower()))
                {
                  setGUIProperty("user.secondarytitle.value", wstring);
                  setGUIProperty("user.secondarytitle.groupname", wstring2);
                }
                #endregion
                break;
              case "length":
                #region length
                int length = 0;
                if (MyFilms.r[itemId]["Length"].ToString().Length > 0) wstring = MyFilms.r[itemId]["Length"].ToString();
                setGUIProperty("db.length.value", wstring);
                bool success = int.TryParse(wstring, out length);
                MyFilms.currentMovie.Length = (success) ? length : 0;
                break;
                #endregion
              case "actors":
                #region actors
                if (MyFilms.r[itemId]["Actors"].ToString().Length > 0)
                {
                  wstring = MyFilms.r[itemId]["Actors"].ToString().Replace('|', '\n');
                  wstring = System.Web.HttpUtility.HtmlDecode(MediaPortal.Util.HTMLParser.removeHtml(wstring));

                  //IEnumerable<DbPersonInfo> persons = MyFilms.Search_String_Persons(wstring, false);
                  //foreach (DbPersonInfo t in persons)
                  //{
                  //  MyFilms.currentMovie.Actors.Add(t.Name);
                  //}
                }
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                Load_Detailed_DB_PushActorsToSkin(wstring);
                break;
                #endregion
              case "director":
              case "producer":
              case "writer":
                //wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                //if (wstring.Length > 0)
                //{
                //  wstring = System.Web.HttpUtility.HtmlDecode(MediaPortal.Util.HTMLParser.removeHtml(wstring));
                //  IEnumerable<DbPersonInfo> persons = MyFilms.Search_String_Persons(wstring, false);
                //  foreach (DbPersonInfo t in persons)
                //  {
                //    switch (dc.ColumnName.ToLower())
                //    {
                //      case "director":
                //        MyFilms.currentMovie.Directors.Add(t.Name);
                //        break;
                //      case "producer":
                //        MyFilms.currentMovie.Producers.Add(t.Name);
                //        break;
                //      case "writer":
                //        MyFilms.currentMovie.Writers.Add(t.Name);
                //        break;
                //    }
                //  }
                //}
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "");
                break;
              
              case "description":
              case "comments":
                #region description & comment
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                {
                  wstring = System.Web.HttpUtility.HtmlEncode(MyFilms.r[itemId][dc.ColumnName].ToString().Replace('’', '\''));
                  wstring = wstring.Replace('|', '\n').Replace('…', '.');
                  wstring = System.Web.HttpUtility.HtmlDecode(MediaPortal.Util.HTMLParser.removeHtml(wstring));
                }
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                break;
                #endregion
              case "date":
                #region date
                if (MyFilms.r[itemId]["Date"].ToString().Length > 0)
                  wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                break;
                #endregion
              case "videoformat":
                #region videoformat
                if (MyFilms.r[itemId]["VideoFormat"].ToString().Length > 0)
                  wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                wstrformat = "V:" + MyFilms.r[itemId]["VideoFormat"].ToString();
                break;
                #endregion
              case "audioformat":
                #region audioformat
                if (MyFilms.r[itemId]["AudioFormat"].ToString().Length > 0)
                {
                  wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                  if (wstrformat.Length > 1)
                    wstrformat = wstrformat + ", A:" + MyFilms.r[itemId]["AudioFormat"].ToString();
                  else
                    wstrformat = "A:" + MyFilms.r[itemId]["AudioFormat"].ToString();
                }
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                setGUIProperty("db.calc.format" + ".value", wstrformat);
                break;
                #endregion
              case "rating":
              case "ratinguser":
                #region rating
                wstring = "";
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                //try { MyFilms.conf.W_rating = (decimal)MyFilms.r[ItemId][dc.ColumnName]; }
                //catch { MyFilms.conf.W_rating = 0; }
                try
                {
                  wstring = ((decimal)MyFilms.r[itemId][dc.ColumnName]).ToString("0.0");
                }
                catch
                {
                  wstring = "";
                }
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                break;
                #endregion

              // fields to skip (do not publish)
              case "contents_id":
              case "dateadded":
              case "picture":
              case "watched":
                break;
              case "fanart":
                if (MyFilms.currentMovie.Fanart.Length == 0 && MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  MyFilms.currentMovie.Fanart = MyFilms.r[itemId][dc.ColumnName].ToString();
                break;
              case "imdb_id":
                #region imdb_id
                MyFilms.currentMovie.IMDBNumber = MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "";
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "");
                break;
                #endregion
              case "isonline":
                #region set online status
                if (MyFilms.InitialIsOnlineScan) // if availability scanner did run - either by autostart or manually
                {
                  if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  {
                    switch (MyFilms.r[itemId][dc.ColumnName].ToString())
                    {
                      case "True":
                        setGUIProperty("user.source.isonline", "available");
                        break;
                      case "False":
                        if (Helper.FieldIsSet(MyFilms.conf.StrStorage)) // if there is source field set
                        {
                          setGUIProperty("user.source.isonline", MyFilms.r[itemId][MyFilms.conf.StrStorage].ToString().Length > 0
                                                                   ? "offline"
                                                                   : "unavailable");
                        }
                        else
                          setGUIProperty("user.source.isonline", "unavailable");
                        break;
                    }
                  }
                  else
                    setGUIProperty("user.source.isonline", "unknown"); // should not happen, if scanner did run ...
                }
                else
                {
                  if (Helper.FieldIsSet(MyFilms.conf.StrStorage)) // if there is source field set
                  {
                    if (MyFilms.r[itemId][MyFilms.conf.StrStorage].ToString().Length > 0) // if there is source info available ...
                    {
                      setGUIProperty("user.source.isonline", MyFilms.conf.ScanMediaOnStart ? "unknown" : "available");
                    }
                    else
                      setGUIProperty("user.source.isonline", "unavailable");
                  }
                  else if (MyFilms.conf.SearchFile.ToLower() == "true" || MyFilms.conf.SearchFile.ToLower() == "yes") // if search is enabled in setup
                    setGUIProperty("user.source.isonline", "unknown");
                  else
                    setGUIProperty("user.source.isonline", "unavailable");
                }
                break;
                #endregion
              case "isonlinetrailer":
                #region set trailer online status
                if (MyFilms.InitialIsOnlineScan)
                {
                  if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  {
                    if (MyFilms.r[itemId][dc.ColumnName].ToString() == "True")
                      setGUIProperty("user.sourcetrailer.isonline", "available");
                    else
                    {
                      if (Helper.FieldIsSet(MyFilms.conf.StrStorageTrailer))
                      {
                        setGUIProperty("user.sourcetrailer.isonline", MyFilms.r[itemId][MyFilms.conf.StrStorageTrailer].ToString().Length > 0
                            ? "offline"
                            : "unavailable");
                      }
                      else
                        setGUIProperty("user.sourcetrailer.isonline", "unavailable");
                    }
                  }
                  else
                    setGUIProperty("user.sourcetrailer.isonline", "unknown"); // should not happen, if scanner did run ...
                }
                else
                {
                  if (Helper.FieldIsSet(MyFilms.conf.StrStorageTrailer))
                  {
                    if (MyFilms.r[itemId][MyFilms.conf.StrStorageTrailer].ToString().Length > 0)
                    {
                      setGUIProperty("user.sourcetrailer.isonline", MyFilms.conf.ScanMediaOnStart
                        ? "unknown"
                        : "available");
                    }
                    else
                      setGUIProperty("user.sourcetrailer.isonline", "unavailable");
                  }
                  //else if (MyFilms.conf.SearchFileTrailer.ToLower() == "true" || MyFilms.conf.SearchFileTrailer.ToLower() == "yes") // if search is enabled in setup
                  //  setGUIProperty("user.sourcetrailer.isonline", "unknown");
                  else
                    setGUIProperty("user.sourcetrailer.isonline", "unavailable");
                }
                break;
                #endregion
              case "resolution":
                #region set calculated aspectratio and image format
                string ar = "";
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  try
                  {
                    decimal aspectratio;
                    wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                    setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                    if (!Decimal.TryParse(MyFilms.r[itemId]["Aspectratio"].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out aspectratio)) // if no media info data available, calculate data from video resolution - might not be exact DAR (display aspect ratio) // if (!Decimal.TryParse(MyFilms.r[itemId]["Aspectratio"].ToString().Replace(".", CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator).Replace(",", CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator), out aspectratio)) // if no media info data available, calculate data from video resolution - might not be exact DAR (display aspect ratio)
                    {
                      string[] arSplit = wstring.Split(new string[] { "x" }, StringSplitOptions.RemoveEmptyEntries);
                      aspectratio = Math.Round(decimal.Divide(Convert.ToInt32(arSplit[0]), Convert.ToInt32(arSplit[1])), 2);
                    }
                    //Formats:
                    //1,33 -> 4:3
                    //1,78 -> 16:9 / widescreen
                    //1,85 -> widescreen
                    //2,35+ -> cinemascope
                    if (aspectratio < (decimal)(1.4)) ar = "4:3";
                    else if (aspectratio < (decimal)(1.9)) ar = "16:9";
                    else if (aspectratio >= (decimal)(1.9)) ar = "cinemascope";
                    wstring = aspectratio.ToString(CultureInfo.InstalledUICulture);
                  }
                  catch { LogMyFilms.Info("Error calculating aspectratio !"); }
                setGUIProperty("db.calc.aspectratio.value", wstring);
                setGUIProperty("db.calc.imageformat.value", ar);
                break;
                #endregion
              case "certification":
                #region set cleaned certification for logos
                wstring = MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "";
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                wstring = Regex.Replace(wstring, @"\(|\)", ""); // strip ( and )
                wstring = Regex.Replace(wstring, @"^.*\s", ""); // strip start until forst white char
                setGUIProperty("db.certification.logo.value", wstring.Trim());
                break;
                #endregion
              case "year":
                #region year
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                {
                  int year = 0;
                  setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", MyFilms.r[itemId][dc.ColumnName].ToString());
                  Int32.TryParse(MyFilms.r[itemId][dc.ColumnName].ToString(), out year);
                  MyFilms.currentMovie.Year = year;
                }

                else
                {
                  setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", "");
                  MyFilms.currentMovie.Year = 0;
                }
                break;
                #endregion

              default:
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "");
                break;

            }
            #endregion
          }
        }
      }
      //// for catalog using "search" instead storage field
      //if (string.IsNullOrEmpty(MyFilms.currentMovie.File)) // use search method only if required...
      //{
      //  if ((MyFilms.conf.SearchFile == "True") || (MyFilms.conf.SearchFile == "yes"))
      //  {
      //    string movieName = MyFilms.r[ItemId][MyFilms.conf.ItemSearchFile].ToString();
      //    movieName = movieName.Substring(movieName.LastIndexOf(MyFilms.conf.TitleDelim) + 1).Trim();
      //    if (MyFilms.conf.ItemSearchFile.Length > 0)
      //    {
      //      MyFilms.currentMovie.File = Search_FileName(movieName, MyFilms.conf.StrDirStor).Trim();
      //    }
      //  }
      //}

      stopwatch.Stop();
      LogMyFilms.Debug("Load_Detailed_DB() - load details finished (" + stopwatch.ElapsedMilliseconds + " ms).");
    }
示例#3
0
    //-------------------------------------------------------------------------------------------
    //  Add watch count by one
    //-------------------------------------------------------------------------------------------        
    private static void AddWatchedCount(DataRow row, string userprofilename)
    {
      //// ToDo: Could also populate "watched history" here (future version)
      var userData = new MultiUserData(row[BaseMesFilms.MultiUserStateField].ToString());
      userData.AddWatchedCountByOne(userprofilename);
      row[BaseMesFilms.MultiUserStateField] = userData.ResultValueString();
      SyncMusToExtendedFields(row, userData, userprofilename);

      // following is disabled, as we already send MovieWatched message, that is used by registered apps. We loose setting the number of watches for the external apps though
      //// tell any listeners that user watched the movie
      //MFMovie movie = GetMovieFromRecord(row);
      //if (WatchedItem != null && MyFilms.conf.AllowTraktSync)
      //  WatchedItem(movie, true, userData.GetUserState(userprofilename).WatchedCount);
    }
示例#4
0
 private static void SyncMusToExtendedFields(DataRow row, MultiUserData userData, string userprofilename)
 {
   row["DateWatched"] = (userData.GetUserState(userprofilename).WatchedDate == MultiUserData.NoWatchedDate || userData.GetUserState(MyFilms.conf.StrUserProfileName).Watched == false) ? Convert.DBNull : userData.GetUserState(userprofilename).WatchedDate;
   row["RatingUser"] = (userData.GetUserState(userprofilename).UserRating == -1) ? Convert.DBNull : userData.GetUserState(userprofilename).UserRating;
   row[MyFilms.conf.StrWatchedField] = userData.GetUserState(userprofilename).Watched ? "true" : MyFilms.conf.GlobalUnwatchedOnlyValue.ToLower();
   // row["LastPosition"] = (userData.GetUserState(userprofilename).ResumeData == -1) ? Convert.DBNull : userData.GetUserState(userprofilename).ResumeData;
   //if (MyFilms.conf.StrUserProfileName.Length > 0 && row["RatingUser"] != System.Convert.DBNull && row["RatingUser"] != MultiUserData.NoRating)
   //{
   //  string newValue = (row["RatingUser"] > MultiUserData.FavoriteRating) ? MultiUserData.Add(row["Favorite"].ToString(), MyFilms.conf.StrUserProfileName) : MultiUserData.Remove(row["Favorite"].ToString(), MyFilms.conf.StrUserProfileName);
   //  row["Favorite"] = (string.IsNullOrEmpty(newValue)) ? Convert.DBNull : newValue;
   //}
 }
示例#5
0
    //-------------------------------------------------------------------------------------------
    //  Set an entry from the database to watched/unwatched
    //-------------------------------------------------------------------------------------------        
    // public static void Watched_Toggle(DataRow[] r1, int Index, bool watched)
    public static void Watched_Toggle(DataRow row, bool watched)
    {
      if (MyFilms.conf.EnhancedWatchedStatusHandling)
      {
        var userData = new MultiUserData(row[BaseMesFilms.MultiUserStateField].ToString());
        userData.SetWatched(MyFilms.conf.StrUserProfileName, watched);
        row[BaseMesFilms.MultiUserStateField] = userData.ResultValueString();
        SyncMusToExtendedFields(row, userData, MyFilms.conf.StrUserProfileName);
      }
      else
      {
        row[MyFilms.conf.StrWatchedField] = watched ? "true" : MyFilms.conf.GlobalUnwatchedOnlyValue.ToLower();
      }
      LogMyFilms.Info("Database movie changed 'watchedstatus' by setting '" + MyFilms.conf.StrWatchedField + "' to '" + row[MyFilms.conf.StrWatchedField] + "' for movie: " + row[MyFilms.conf.StrTitle1]);

      Update_XML_database();

      // tell any listeners that user rated the movie
      MFMovie movie = GetMovieFromRecord(row);
      if (WatchedItem != null)
        WatchedItem(movie, watched, ((watched) ? 1 : 0));
    }