SetProperties() private method

private SetProperties ( bool isFolder ) : void
isFolder bool
return void
    private void OnItemSelected(GUIListItem item, GUIControl parent)
    {
      GUIPropertyManager.SetProperty("#groupmovielist", string.Empty);
      string strView = string.Empty;
      int currentViewlvl = 0;
      
      if (handler != null)
      {
        strView = handler.CurrentLevelWhere.ToLowerInvariant();
        currentViewlvl = handler.CurrentLevel;

        if (handler.CurrentLevel > 0)
        {
          FilterDefinition defCurrent = (FilterDefinition) handler.View.Filters[handler.CurrentLevel - 1];
          string selectedValue = defCurrent.SelectedValue;
          Int32 iSelectedValue;
          
          if (Int32.TryParse(selectedValue, out iSelectedValue))
          {
            if (strView == "actor" || strView == "director")
            {
              selectedValue = VideoDatabase.GetActorNameById(iSelectedValue);
            }

            if (strView == "genre")
            {
              selectedValue = VideoDatabase.GetGenreById(iSelectedValue);
            }

            if (strView == "user groups")
            {
              selectedValue = VideoDatabase.GetUserGroupById(iSelectedValue);
            }
          }

          GUIPropertyManager.SetProperty("#currentmodule",
                                         String.Format("{0}/{1} - {2}", GUILocalizeStrings.Get(100006),
                                                       handler.LocalizedCurrentView, selectedValue));
        }
      }

      if (item.Label == "..")
      {
        IMDBMovie notMovie = new IMDBMovie();
        notMovie.IsEmpty = true;
        notMovie.SetProperties(true, string.Empty);
        IMDBActor notActor = new IMDBActor();
        notActor.SetProperties();
        return;
      }
      
      // Set current item if thumb thread is working (thread can still update thumbs while user changed
      // item) thus preventing sudden jump to initial selected item before thread start
      if (_setThumbs != null && _setThumbs.IsAlive)
      {
        currentSelectedItem = facadeLayout.SelectedListItemIndex;
      }

      IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
      
      if (movie == null)
      {
        movie = new IMDBMovie();
      }
      
      if (!string.IsNullOrEmpty(movie.VideoFileName))
      {
        movie.SetProperties(false, movie.VideoFileName);
      }
      else
      {
        switch (strView)
        {
          case "actorindex":
          case "directorindex":
          case "titleindex":
            movie.IsEmpty = true;
            movie.SetProperties(false, string.Empty);
            break;

          default:
            movie.SetProperties(false, string.Empty);
            break;
        }
        
        // Set title properties for other views (year, genres..)
        if (!string.IsNullOrEmpty(item.Label))
        {
          GUIPropertyManager.SetProperty("#title", item.Label);

          if (item.MusicTag != null)
          {
            GUIPropertyManager.SetProperty("#groupmovielist", item.MusicTag.ToString());
          }
        }
      }
      
      IMDBActor actor = VideoDatabase.GetActorInfo(movie.ActorID);
      
      if (actor != null)
      {
        actor.SetProperties();
      }
      else
      {
        actor = new IMDBActor();
        actor.SetProperties();
      }

      if (movie.ID >= 0)
      {
        string titleExt = movie.Title + "{" + movie.ID + "}";
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
        
        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
      
      if (movie.Actor != string.Empty)
      {
        GUIPropertyManager.SetProperty("#title", movie.Actor);
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieActors, movie.ActorID.ToString());
        
        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
      
      // Random movieId by view (for FA) for selected group
      ArrayList mList = new ArrayList();
      GetItemViewHistory(strView, mList, currentViewlvl);
    }
    protected override void LoadDirectory(string strNewDirectory)
    {
      GUIWaitCursor.Show();
      currentFolder = strNewDirectory;
      GUIControl.ClearControl(GetID, facadeLayout.GetID);
      ArrayList itemlist = new ArrayList();
      ArrayList movies = new ArrayList();

      if (_searchMovie)
      {
        string sql = "SELECT DISTINCT " +
                     "movieinfo.idMovie," +
                     "movieinfo.idDirector," +
                     "movieinfo.strDirector," +
                     "movieinfo.strPlotOutline," +
                     "movieinfo.strPlot," +
                     "movieinfo.strTagLine," +
                     "movieinfo.strVotes," +
                     "movieinfo.fRating," +
                     "movieinfo.strCast," +
                     "movieinfo.strCredits," +
                     "movieinfo.iYear," +
                     "movieinfo.strGenre," +
                     "movieinfo.strPictureURL," +
                     "movieinfo.strTitle," +
                     "movieinfo.IMDBID," +
                     "movieinfo.mpaa," +
                     "movieinfo.runtime," +
                     "movieinfo.iswatched," +
                     "movieinfo.strUserReview," +
                     "movieinfo.strFanartURL," +
                     "movieinfo.dateAdded," +
                     "movieinfo.dateWatched," +
                     "movieinfo.studios," +
                     "movieinfo.country," +
                     "movieinfo.language," +
                     "movieinfo.lastupdate, " +
			               "movieinfo.strSortTitle " +
                     "FROM movieinfo " +
                     "INNER JOIN actorlinkmovie ON actorlinkmovie.idMovie = movieinfo.idMovie " +
                     "INNER JOIN actors ON actors.idActor = actorlinkmovie.idActor " +
                     "WHERE "+ _searchMovieDbField + " LIKE '%" + _searchMovieString + "%' " +
                     "ORDER BY movieinfo.strTitle ASC";

        VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, false, false);
      }
      else if (_searchActor && handler.CurrentLevelWhere != "title")
      {
        string sql = string.Empty;
        
        if (handler.CurrentLevelWhere == "director")
        {
          sql = "SELECT idActor, strActor, imdbActorId FROM actors INNER JOIN movieinfo ON movieinfo.idDirector = actors.idActor WHERE strActor LIKE '%" 
                + _searchActorString + 
                "%' ORDER BY strActor ASC";
        }
        else
        {
          sql = "SELECT * FROM actors WHERE strActor LIKE '%" + _searchActorString + "%' ORDER BY strActor ASC";
        }
        
        VideoDatabase.GetMoviesByFilter(sql, out movies, true, false, false, false);
      }
      else
      {
        movies = ((VideoViewHandler)handler).Execute();
      }

      GUIControl.ClearControl(GetID, facadeLayout.GetID);
      SwitchLayout();

      if (handler.CurrentLevel > 0)
      {
        GUIListItem listItem = new GUIListItem("..");
        listItem.Path = string.Empty;
        listItem.IsFolder = true;
        Util.Utils.SetDefaultIcons(listItem);
        listItem.OnItemSelected += OnItemSelected;
        itemlist.Add(listItem);
        SetLabel(listItem);
        ((VideoViewHandler)handler).SetLabel(listItem.AlbumInfoTag as IMDBMovie, ref listItem);
        facadeLayout.Add(listItem);
      }

      VirtualDirectory vDir = new VirtualDirectory();
      // Get protected share paths for videos
      vDir.LoadSettings("movies");

      foreach (IMDBMovie movie in movies)
      {
        GUIListItem item = new GUIListItem();
        item.Label = movie.Title;

        if (handler.CurrentLevelWhere != "user groups")
        {
          if (handler.CurrentLevel + 1 < handler.MaxLevels)
          {
            item.IsFolder = true;
          }
          else
          {
            item.IsFolder = false;
          }
        }
        else
        {
          if (string.IsNullOrEmpty(movie.Title) && handler.CurrentLevel + 1 < handler.MaxLevels)
          {
            item.IsFolder = true;
            item.IsRemote = true;
          }
          else
          {
            item.IsFolder = false;
          }
        }

        item.Path = movie.File;

        // Protected movies validation, checks item and if it is inside protected shares.
        // If item is inside PIN protected share, checks if user validate PIN with Unlock
        // command from context menu and returns "True" if all is ok and item will be visible
        // in movie list. Non-protected item will skip check and will be always visible.
        if (!string.IsNullOrEmpty(item.Path))
        {
          if (!IsItemPinProtected(item, vDir))
            continue;
        }
        //
        item.Duration = movie.RunTime * 60;
        item.AlbumInfoTag = movie;
        item.Year = movie.Year;
        item.DVDLabel = movie.DVDLabel;
        item.Rating = movie.Rating;
        item.IsPlayed = movie.Watched > 0;

        try
        {
          if (item.Path.ToUpperInvariant().Contains(@"\VIDEO_TS"))
          {
            item.Label3 = MediaTypes.DVD.ToString() + " #" + movie.WatchedCount;;
          }
          else if (item.Path.ToUpperInvariant().Contains(@"\BDMV"))
          {
            item.Label3 = MediaTypes.BD.ToString() + " #" + movie.WatchedCount;
          }
          else if (VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
          {
            item.Label3 = MediaTypes.ISO.ToString() + " #" + movie.WatchedCount; ;
          }
          else
          {
            item.Label3 = movie.WatchedPercent + "% #" + movie.WatchedCount;
          }
        }
        catch (Exception){}
        
        item.OnItemSelected += OnItemSelected;
        SetLabel(item);
        ((VideoViewHandler)handler).SetLabel(item.AlbumInfoTag as IMDBMovie, ref item);
        // Movie/group content list skin property will read from musictag
        item.MusicTag = SetMovieListGroupedBy(item);
        facadeLayout.Add(item);
        itemlist.Add(item);
      }

      // Sort
      facadeLayout.Sort(new VideoSort(CurrentSortMethod, CurrentSortAsc));
      int itemIndex = 0;
      string viewFolder = SetItemViewHistory();
      string selectedItemLabel = m_history.Get(viewFolder);
      
      if (string.IsNullOrEmpty(selectedItemLabel) && facadeLayout.SelectedListItem != null)
      {
        selectedItemLabel = facadeLayout.SelectedListItem.Label;
      }

      int itemCount = itemlist.Count;
      
      if (itemlist.Count > 0)
      {
        GUIListItem rootItem = (GUIListItem)itemlist[0];
        if (rootItem.Label == "..")
        {
          itemCount--;
        }
      }

      //set object count label
      GUIPropertyManager.SetProperty("#itemcount", Util.Utils.GetObjectCountLabel(itemCount));

      // Clear info for zero result
      if (itemlist.Count == 0)
      {
        GUIListItem item = new GUIListItem();
        item.Label = GUILocalizeStrings.Get(284);
        IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
        movie = new IMDBMovie();
        item.AlbumInfoTag = movie;
        movie.SetProperties(false, string.Empty);
        itemlist.Add(item);
        facadeLayout.Add(item);
      }

      bool itemSelected = false;
      
      if (handler.CurrentLevel < handler.MaxLevels)
      {
        for (int i = 0; i < facadeLayout.Count; ++i)
        {
          GUIListItem item = facadeLayout[itemIndex];
          
          if (item.Label == selectedItemLabel)
          {
            currentSelectedItem = itemIndex;
            itemSelected = true;
            break;
          }

          itemIndex++;
        }
        
        switch (handler.CurrentLevelWhere.ToLowerInvariant())
        {
          case "genre":
            SetGenreThumbs(itemlist);
            break;

          case "user groups":
            SetUserGroupsThumbs(itemlist);
            break;

          case "actor":
          case "director":
            SetActorThumbs(itemlist);
            break;

          case "year":
            SetYearThumbs(itemlist);
            break;

          case "actorindex":
          case "directorindex":
          case "titleindex":
            foreach (GUIListItem itemAbc in itemlist)
            {
              itemAbc.IconImageBig = @"alpha\" + itemAbc.Label + ".png";
              itemAbc.IconImage = @"alpha\" + itemAbc.Label + ".png";
              itemAbc.ThumbnailImage = @"alpha\" + itemAbc.Label + ".png";
            }
            break;

          default:
            // Assign thumbnails also for the custom views. Bugfix for Mantis 0001471: 
            // Cover image thumbs missing in My Videos when view Selection is by "watched"
            SetIMDBThumbs(itemlist);
            break;
        }
      }
      else
      {
        SetIMDBThumbs(itemlist);
      }

      if (itemSelected)
      {
        GUIControl.SelectItemControl(GetID, facadeLayout.GetID, currentSelectedItem);
      }
      else
      {
        SelectCurrentItem();
      }

      UpdateButtonStates();
      GUIWaitCursor.Hide();
    }
    private void OnItemSelected(GUIListItem item, GUIControl parent)
    {
      if (item.Label == "..")
      {
        IMDBMovie notMovie = new IMDBMovie();
        notMovie.SetProperties(true, string.Empty);
        IMDBActor notActor = new IMDBActor();
        notActor.SetProperties();
        return;
      }
      IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;

      if (movie == null)
      {
        movie = new IMDBMovie();
      }

      ArrayList files = new ArrayList();
      VideoDatabase.GetFilesForMovie(movie.ID, ref files);

      if (files.Count > 0)
      {
        movie.SetProperties(false, (string)files[0]);
      }
      else
      {
        movie.SetProperties(false, string.Empty);
      }

      if (movie.ID >= 0)
      {
        string titleExt = movie.Title + "{" + movie.ID + "}";
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);

        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
    }
 private void SetMovieProperties(string path)
 {
   bool isFile = false;
   if (Util.Utils.IsVideo(path))
     isFile = true;
   IMDBMovie info = new IMDBMovie();
   if (path == "..")
   {
     info.Reset();
     info.SetProperties(true);
     return;
   }
   bool isDirectory = false;
   bool isMultiMovieFolder = false;
   bool isFound = false;
   try
   {
     if (Directory.Exists(path))
     {
       isDirectory = true;
       string[] files = Directory.GetFiles(path);
       foreach (string file in files)
       {
         IMDBMovie movie = new IMDBMovie();
         VideoDatabase.GetMovieInfo(file, ref movie);
         if (!movie.IsEmpty)
         {
           if (!isFound)
           {
             info = movie;
             isFound = true;
           }
           else
           {
             isMultiMovieFolder = true;
             break;
           }
         }
       }
     }
     else
     {
       VideoDatabase.GetMovieInfo(path, ref info);
     }
     if (info.IsEmpty)
     {
       FetchMatroskaInfo(path, isDirectory, ref info);
     }
     if (info.IsEmpty && File.Exists(path + @"\VIDEO_TS\VIDEO_TS.IFO")) //still empty and is ripped DVD
     {
       VideoDatabase.GetMovieInfo(path + @"\VIDEO_TS\VIDEO_TS.IFO", ref info);
       isFile = true;
     }
     if (info.IsEmpty)
     {
       if (_markWatchedFiles)
       {
         int fID = VideoDatabase.GetFileId(path);
         byte[] resumeData = null;
         int timeStopped = VideoDatabase.GetMovieStopTimeAndResumeData(fID, out resumeData);
         if (timeStopped > 0 || resumeData != null)
           info.Watched = 1;
       }
     }
     if (isMultiMovieFolder || !isFile)
     {
       info.Reset();
       info.SetProperties(true);
       return;
     }
     info.SetProperties(false);
   }
   catch (Exception) {}
 }
    protected override void LoadDirectory(string strNewDirectory)
    {
      if (facadeLayout != null)
      {
        GUIWaitCursor.Show();
        try
        {
          GUIListItem SelectedItem = facadeLayout.SelectedListItem;
          if (SelectedItem != null)
          {
            if (SelectedItem.IsFolder && SelectedItem.Label != "..")
            {
              m_history.Set(SelectedItem.Label, currentFolder);
            }
          }
          currentFolder = strNewDirectory;
          facadeLayout.Clear();

          string strObjects = string.Empty;

          ArrayList itemlist = new ArrayList();

          PlayList playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO);
          /* copy playlist from general playlist*/
          int iCurrentSong = -1;
          if (playlistPlayer.CurrentPlaylistType == PlayListType.PLAYLIST_VIDEO)
          {
            iCurrentSong = playlistPlayer.CurrentSong;
          }

          string strFileName;
          for (int i = 0; i < playlist.Count; ++i)
          {
            PlayListItem item = playlist[i];
            strFileName = item.FileName;

            GUIListItem pItem = new GUIListItem(item.Description);
            pItem.Path = strFileName;
            pItem.IsFolder = false;
            //pItem.m_bIsShareOrDrive = false;

            if (item.Duration > 0)
            {
              int nDuration = item.Duration;
              if (nDuration > 0)
              {
                string str = Util.Utils.SecondsToHMSString(nDuration);
                pItem.Label2 = str;
              }
              else
              {
                pItem.Label2 = string.Empty;
              }
            }
            pItem.OnItemSelected += OnItemSelected;
            itemlist.Add(pItem);
            Util.Utils.SetDefaultIcons(pItem);
          }

          iCurrentSong = 0;
          strFileName = string.Empty;
          //	Search current playlist item
          if ((m_nTempPlayListWindow == GetID && m_strTempPlayListDirectory.IndexOf(currentFolder) >= 0 &&
               g_Player.Playing
               && playlistPlayer.CurrentPlaylistType == PlayListType.PLAYLIST_VIDEO_TEMP)
              ||
              (GetID == (int)Window.WINDOW_VIDEO_PLAYLIST &&
               playlistPlayer.CurrentPlaylistType == PlayListType.PLAYLIST_VIDEO
               && g_Player.Playing))
          {
            iCurrentSong = playlistPlayer.CurrentSong;
            if (iCurrentSong >= 0)
            {
              playlist = playlistPlayer.GetPlaylist(playlistPlayer.CurrentPlaylistType);
              if (iCurrentSong < playlist.Count)
              {
                PlayListItem item = playlist[iCurrentSong];
                strFileName = item.FileName;
              }
            }
          }

          SetIMDBThumbs(itemlist);

          string strSelectedItem = m_history.Get(currentFolder);
          int iItem = 0;
          foreach (GUIListItem item in itemlist)
          {
            facadeLayout.Add(item);

            //	synchronize playlist with current directory
            if (strFileName.Length > 0 && item.Path == strFileName)
            {
              item.Selected = true;
            }
          }
          for (int i = 0; i < facadeLayout.Count; ++i)
          {
            GUIListItem item = facadeLayout[i];
            if (item.Label == strSelectedItem)
            {
              GUIControl.SelectItemControl(GetID, facadeLayout.GetID, iItem);
              break;
            }
            iItem++;
          }
          int iTotalItems = itemlist.Count;
          if (itemlist.Count > 0)
          {
            GUIListItem rootItem = (GUIListItem)itemlist[0];
            if (rootItem.Label == "..")
            {
              iTotalItems--;
            }
          }

          //set object count label
          GUIPropertyManager.SetProperty("#itemcount", Util.Utils.GetObjectCountLabel(iTotalItems));

          if (currentSelectedItem >= 0)
          {
            GUIControl.SelectItemControl(GetID, facadeLayout.GetID, currentSelectedItem);
          }
          else if (itemlist.Count > 0)
          {
            GUIControl.SelectItemControl(GetID, facadeLayout.GetID, 0);
          }
          else
          {
            IMDBMovie movie = new IMDBMovie();
            movie.SetProperties(false, string.Empty);
          }
          UpdateButtonStates();
          GUIWaitCursor.Hide();
        }
        catch (Exception ex)
        {
          GUIWaitCursor.Hide();
          Log.Error("GUIVideoPlaylist: An error occured while loading the directory - {0}", ex.Message);
        }
      }
    }
    protected override void OnPageLoad()
    {
      base.OnPageLoad();
      
      currentLayout = Layout.Playlist;
      facadeLayout.CurrentLayout = currentLayout;

      LoadDirectory(string.Empty);
      if (g_Player.Playing && playlistPlayer.CurrentPlaylistType == PlayListType.PLAYLIST_VIDEO)
      {
        int iSong = playlistPlayer.CurrentSong;
        if (iSong >= 0 && iSong <= facadeLayout.Count)
        {
          GUIControl.SelectItemControl(GetID, facadeLayout.GetID, iSong);
        }
      }
      if (facadeLayout.Count <= 0)
      {
        GUIControl.FocusControl(GetID, btnLayouts.GetID);
        IMDBMovie movie = new IMDBMovie();
        movie.SetProperties(false, string.Empty);
      }


      using (Profile.Settings settings = new Profile.MPSettings())
      {
        playlistPlayer.RepeatPlaylist = settings.GetValueAsBool("movies", "repeat", true);
      }

      if (btnRepeatPlaylist != null)
      {
        btnRepeatPlaylist.Selected = playlistPlayer.RepeatPlaylist;
      }
    }
    private void SetMovieProperties(string path, string filename)
    {
      IMDBMovie info = new IMDBMovie();

      if (path == ".." || string.IsNullOrEmpty(path) || (!Directory.Exists(path) && !Util.Utils.IsVideo(filename)))
      {
        info.Reset(true);
        info.SetProperties(true, string.Empty);
        return;
      }

      if (Directory.Exists(path) && !Util.Utils.IsVideo(filename))
      {
        info.SetProperties(true, path);
        return;
      }

      try
      {
        VideoDatabase.GetMovieInfo(filename, ref info);

        // Get recording/nfo xml
        if (info.IsEmpty)
        {
          FetchMatroskaInfo(filename, false, ref info);

          if (info.IsEmpty)
          {
            FetchMovieNfo(path, filename, ref info);
          }
        }

        info.SetProperties(false, filename);
      }
      catch (Exception)
      {
      }
    }
    private void OnItemSelected(GUIListItem item, GUIControl parent)
    {
      GUIPropertyManager.SetProperty("#groupmovielist", string.Empty);
      
      if (handler.CurrentLevel > 0)
      {
        FilterDefinition defCurrent = (FilterDefinition)handler.View.Filters[handler.CurrentLevel - 1];
        string selectedValue = defCurrent.SelectedValue;

        if (Regex.Match(selectedValue, @"[\d]*").Success)
        {
          if (defCurrent.Where == "actor" || defCurrent.Where == "director")
          {
            selectedValue = VideoDatabase.GetActorNameById(Convert.ToInt32(defCurrent.SelectedValue));
          }

          if (defCurrent.Where == "genre")
          {
            selectedValue = VideoDatabase.GetGenreById(Convert.ToInt32(defCurrent.SelectedValue));
          }

          if (defCurrent.Where == "user groups")
          {
            selectedValue = VideoDatabase.GetUserGroupById(Convert.ToInt32(defCurrent.SelectedValue));
          }
        }
        GUIPropertyManager.SetProperty("#currentmodule",
                                       String.Format("{0}/{1} - {2}", GUILocalizeStrings.Get(100006),
                                                     handler.LocalizedCurrentView, selectedValue));
      }
      
      if (item.Label == "..")
      {
        IMDBMovie notMovie = new IMDBMovie();
        notMovie.SetProperties(true, string.Empty);
        IMDBActor notActor = new IMDBActor();
        notActor.SetProperties();
        return;
      }
      
      // Set current item if thumb thread is working (thread can still update thumbs while user changed
      // item) thus preventing sudden jump to initial selected item before thread start
      if (_setThumbs != null && _setThumbs.IsAlive)
      {
        currentSelectedItem = facadeLayout.SelectedListItemIndex;
      }

      IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
      
      if (movie == null)
      {
        movie = new IMDBMovie();
      }
      
      ArrayList files = new ArrayList();
      VideoDatabase.GetFilesForMovie(movie.ID, ref files);
      
      if (files.Count > 0)
      {
        movie.SetProperties(false, (string)files[0]);
      }
      else
      {
        movie.SetProperties(false, string.Empty);

        // Set title properties for other views (year, genres..)
        if (!string.IsNullOrEmpty(item.Label))
        {
          GUIPropertyManager.SetProperty("#title", item.Label);
          GUIPropertyManager.SetProperty("#groupmovielist", SetMovieListGroupedBy(item));
        }
      }
      
      IMDBActor actor = VideoDatabase.GetActorInfo(movie.ActorID);
      
      if (actor != null)
      {
        actor.SetProperties();
      }
      else
      {
        actor = new IMDBActor();
        actor.SetProperties();
      }

      if (movie.ID >= 0)
      {
        string titleExt = movie.Title + "{" + movie.ID + "}";
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
        
        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
      
      if (movie.Actor != string.Empty)
      {
        GUIPropertyManager.SetProperty("#title", movie.Actor);
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieActors, movie.ActorID.ToString());
        
        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
      
      // Random movieId by view (for FA) for selected groups
      string view = handler.CurrentLevelWhere;
      ArrayList mList = new ArrayList();
      GetItemViewHistory(view, mList);
    }
Beispiel #9
0
    protected override void LoadDirectory(string strNewDirectory)
    {
      GUIWaitCursor.Show();
      GUIListItem selectedItem = facadeLayout.SelectedListItem;
      if (selectedItem != null)
      {
        if (selectedItem.IsFolder && selectedItem.Label != "..")
        {
          m_history.Set(selectedItem.Label, currentFolder);
        }
      }
      currentFolder = strNewDirectory;

      GUIControl.ClearControl(GetID, facadeLayout.GetID);

      string objectCount = string.Empty;

      ArrayList itemlist = new ArrayList();
      ArrayList movies = ((VideoViewHandler)handler).Execute();

      if (handler.CurrentLevel > 0)
      {
        GUIListItem listItem = new GUIListItem("..");
        listItem.Path = string.Empty;
        listItem.IsFolder = true;
        Util.Utils.SetDefaultIcons(listItem);
        itemlist.Add(listItem);
      }

      foreach (IMDBMovie movie in movies)
      {
        GUIListItem item = new GUIListItem();
        item.Label = movie.Title;
        if (handler.CurrentLevel + 1 < handler.MaxLevels)
        {
          item.IsFolder = true;
        }
        else
        {
          item.IsFolder = false;
        }
       
        item.Path = movie.File;

        // Protected movies validation, checks item and if it is inside protected shares.
        // If item is inside PIN protected share, checks if user validate PIN with Unlock
        // command from context menu and returns "True" if all is ok and item will be visible
        // in movie list. Non-protected item will skip check and will be always visible.
        if (!string.IsNullOrEmpty(item.Path))
        {
          if(!CheckItem(item))
            continue;
        }
        //
        item.Duration = movie.RunTime * 60;
        item.AlbumInfoTag = movie;
        item.Year = movie.Year;
        item.DVDLabel = movie.DVDLabel;
        item.Rating = movie.Rating;
        item.IsPlayed = movie.Watched > 0 ? true : false;

        item.OnItemSelected += new GUIListItem.ItemSelectedHandler(item_OnItemSelected);

        itemlist.Add(item);
      }

      // Clear info for zero result
      if (itemlist.Count == 0)
      {
        GUIListItem item = new GUIListItem();
        item.Label = GUILocalizeStrings.Get(284);
        IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
        movie = new IMDBMovie();
        item.AlbumInfoTag = movie;
        movie.SetProperties(false);
        itemlist.Add(item);
      }

      int itemIndex = 0;

      foreach (GUIListItem item in itemlist)
      {
        facadeLayout.Add(item);
      }

      string selectedItemLabel = m_history.Get(currentFolder);
      if (string.IsNullOrEmpty(selectedItemLabel) && facadeLayout.SelectedListItem != null)
      {
        selectedItemLabel = facadeLayout.SelectedListItem.Label;
      }

      int itemCount = itemlist.Count;
      if (itemlist.Count > 0)
      {
        GUIListItem rootItem = (GUIListItem)itemlist[0];
        if (rootItem.Label == "..")
        {
          itemCount--;
        }
      }

      //set object count label
      GUIPropertyManager.SetProperty("#itemcount", Util.Utils.GetObjectCountLabel(itemCount));

      if (handler.CurrentLevel < handler.MaxLevels)
      {
        if (handler.CurrentLevelWhere.ToLower() == "genre")
        {
          SetGenreThumbs(itemlist);
        }
        else if (handler.CurrentLevelWhere.ToLower() == "actor")
        {
          SetActorThumbs(itemlist);
        }
        else if (handler.CurrentLevelWhere.ToLower() == "year")
        {
          SetYearThumbs(itemlist);
        }
        
        else
        {
          // Assign thumbnails also for the custom views. Bugfix for Mantis 0001471: 
          // Cover image thumbs missing in My Videos when view Selection is by "watched"
          SetIMDBThumbs(itemlist);
        }
      }
      else
      {
        SetIMDBThumbs(itemlist);
      }

      OnSort();

      SwitchLayout();
      UpdateButtonStates();

      // quite ugly to loop again to search the selected item...
      for (int i = 0; i < facadeLayout.Count; ++i)
      {
        GUIListItem item = facadeLayout[itemIndex];
        if (item.Label == selectedItemLabel)
        {
          GUIControl.SelectItemControl(GetID, facadeLayout.GetID, itemIndex);
          break;
        }
        itemIndex++;
      }
      if (currentSelectedItem >= 0)
      {
        GUIControl.SelectItemControl(GetID, facadeLayout.GetID, currentSelectedItem);
      }

      GUIWaitCursor.Hide();

      // 07.11.2010 Put in comment by Deda (it's redundant now-button Layout is already in focus state)
      //if (itemCount == 0)
      //{
      //  btnViews.Focus = true;
      //}
    }