예제 #1
0
        protected override void LoadSettings()
        {
            base.LoadSettings();
            using (Profile.Settings xmlreader = new Profile.MPSettings())
            {
                int defaultSort = (int)VideoSort.SortMethod.Name;
                if ((handler != null) && (handler.View != null) && (handler.View.Filters != null) &&
                    (handler.View.Filters.Count > 0))
                {
                    FilterDefinition def = (FilterDefinition)handler.View.Filters[0];
                    defaultSort = (int)GetSortMethod(def.DefaultSort);
                }


                currentSortMethod     = (VideoSort.SortMethod)xmlreader.GetValueAsInt(SerializeName, "sortmethod", defaultSort);
                currentSortMethodRoot =
                    (VideoSort.SortMethod)xmlreader.GetValueAsInt(SerializeName, "sortmethodroot", defaultSort);

                string playListFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                playListFolder += @"\My Playlists";

                m_strPlayListPath = xmlreader.GetValueAsString("movies", "playlists", playListFolder);
                m_strPlayListPath = Util.Utils.RemoveTrailingSlash(m_strPlayListPath);
            }
        }
예제 #2
0
 protected virtual bool AllowSortMethod(VideoSort.SortMethod method)
 {
     return(true);
 }
예제 #3
0
        protected override void OnShowSort()
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            // Sorry for all the fuss with dlg selected index but there is a huge problem with it beacuse
            // sort methods are in enums and they are not separate per view. Because some sort methods are not
            // valid for share view we have problem with enums and dlg item index. I sorted out this by two
            // variables maxCommonSortIndex and dbSortCount but they are need to implement manually on every new
            // sort added. If there is a better way to handle this (with not meesing too much in code :)) I will
            // appreciate fix.

            dlg.Reset();
            dlg.SetHeading(495);         // Sort options
            int maxCommonSortIndex = -1; // Inrease by 1 when adding new common sort label(sort valid in share and db views))
            int dbSortCount        = 0;  // increase by one when adding new database sort label

            // Watch for enums in VideoSort.cs - must be exactly as the enum order

            // Common sorts - group 1
            dlg.AddLocalizedString(365);  // 0 name
            maxCommonSortIndex++;
            dlg.AddLocalizedString(1309); // 1 nameall
            maxCommonSortIndex++;
            dlg.AddLocalizedString(104);  // 2 date created (date)
            maxCommonSortIndex++;
            dlg.AddLocalizedString(105);  // 3 size
            maxCommonSortIndex++;
            dlg.AddLocalizedString(527);  // 4 watched
            maxCommonSortIndex++;

            // Database sorts - group 2
            if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEO_TITLE)
            {
                dlg.AddLocalizedString(366); // 5 year
                dbSortCount++;
                dlg.AddLocalizedString(367); // 6 rating
                dbSortCount++;
            }

            // Share sorts - group 3
            if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS)
            {
                dlg.AddLocalizedString(430);  // 7 CD label
                dlg.AddLocalizedString(1221); // 8 date modified
                dlg.AddLocalizedString(1220); // 9 date created
            }

            // set the focus to currently used sort method

            // we need to correct index only if sort method enum is greater then max common sort index in share view
            if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS && // must be share view
                (int)CurrentSortMethod > maxCommonSortIndex)
            {
                dlg.SelectedLabel = (int)CurrentSortMethod - dbSortCount;
            }
            else
            {
                dlg.SelectedLabel = (int)CurrentSortMethod;
            }

            // show dialog and wait for result
            dlg.DoModal(GetID);
            if (dlg.SelectedId == -1)
            {
                return;
            }

            CurrentSortAsc = true;
            switch (dlg.SelectedId)
            {
            case 365:
                CurrentSortMethod = VideoSort.SortMethod.Name;
                break;

            case 1309:
                CurrentSortMethod = VideoSort.SortMethod.NameAll;
                break;

            case 104:
                CurrentSortMethod = VideoSort.SortMethod.Date;
                CurrentSortAsc    = false;
                break;

            case 1221:
                CurrentSortMethod = VideoSort.SortMethod.Modified;
                CurrentSortAsc    = false;
                break;

            case 1220:
                CurrentSortMethod = VideoSort.SortMethod.Created;
                CurrentSortAsc    = false;
                break;

            case 105:
                CurrentSortMethod = VideoSort.SortMethod.Size;
                break;

            case 366:
                CurrentSortMethod = VideoSort.SortMethod.Year;
                break;

            case 367:
                CurrentSortMethod = VideoSort.SortMethod.Rating;
                break;

            case 430:
                CurrentSortMethod = VideoSort.SortMethod.Label;
                break;

            case 527:
                CurrentSortMethod = VideoSort.SortMethod.Watched;
                break;

            default:
                CurrentSortMethod = VideoSort.SortMethod.Name;
                break;
            }

            OnSort();
            GUIControl.FocusControl(GetID, btnSortBy.GetID);
        }
    protected override void LoadSettings()
    {
      base.LoadSettings();
      using (Profile.Settings xmlreader = new Profile.MPSettings())
      {
        int defaultSort = (int)VideoSort.SortMethod.Name;
        if ((handler != null) && (handler.View != null) && (handler.View.Filters != null) &&
            (handler.View.Filters.Count > 0))
        {
          FilterDefinition def = (FilterDefinition)handler.View.Filters[0];
          defaultSort = (int)GetSortMethod(def.DefaultSort);
        }


        currentSortMethod = (VideoSort.SortMethod)xmlreader.GetValueAsInt(SerializeName, "sortmethod", defaultSort);
        currentSortMethodRoot =
          (VideoSort.SortMethod)xmlreader.GetValueAsInt(SerializeName, "sortmethodroot", defaultSort);

        string playListFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
        playListFolder += @"\My Playlists";

        m_strPlayListPath = xmlreader.GetValueAsString("movies", "playlists", playListFolder);
        m_strPlayListPath = Util.Utils.RemoveTrailingSlash(m_strPlayListPath);
      }
    }
    protected override void OnShowSort()
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(495); // Sort options

      // Watch for enums in VideoSort.cs
      dlg.AddLocalizedString(365); // name
      dlg.AddLocalizedString(104); // date created (date)
      dlg.AddLocalizedString(105); // size
      dlg.AddLocalizedString(366); // year
      dlg.AddLocalizedString(367); // rating
      dlg.AddLocalizedString(430); // label
      dlg.AddLocalizedString(527); // unwatched
      if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS)
      {
        dlg.AddLocalizedString(1221); // date modified
        dlg.AddLocalizedString(1220); // date created
      }

      // set the focus to currently used sort method
      dlg.SelectedLabel = (int)CurrentSortMethod;

      // show dialog and wait for result
      dlg.DoModal(GetID);
      if (dlg.SelectedId == -1)
      {
        return;
      }

      CurrentSortAsc = true;
      switch (dlg.SelectedId)
      {
        case 365:
          CurrentSortMethod = VideoSort.SortMethod.Name;
          break;
        case 104:
          CurrentSortMethod = VideoSort.SortMethod.Date;
          CurrentSortAsc = false;
          break;
        case 1221:
          CurrentSortMethod = VideoSort.SortMethod.Modified;
          CurrentSortAsc = false;
          break;
        case 1220:
          CurrentSortMethod = VideoSort.SortMethod.Created;
          CurrentSortAsc = false;
          break;
        case 105:
          CurrentSortMethod = VideoSort.SortMethod.Size;
          break;
        case 366:
          CurrentSortMethod = VideoSort.SortMethod.Year;
          break;
        case 367:
          CurrentSortMethod = VideoSort.SortMethod.Rating;
          break;
        case 430:
          CurrentSortMethod = VideoSort.SortMethod.Label;
          break;
        case 527:
          CurrentSortMethod = VideoSort.SortMethod.Unwatched;
          break;
        default:
          CurrentSortMethod = VideoSort.SortMethod.Name;
          break;
      }

      OnSort();
      GUIControl.FocusControl(GetID, btnSortBy.GetID);
    }
예제 #6
0
    protected override void OnShowSort()
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }

      // Sorry for all the fuss with dlg selected index but there is a huge problem with it beacuse
      // sort methods are in enums and they are not separate per view. Because some sort methods are not
      // valid for share view we have problem with enums and dlg item index. I sorted out this by two
      // variables maxCommonSortIndex and dbSortCount but they are need to implement manually on every new
      // sort added. If there is a better way to handle this (with not meesing too much in code :)) I will
      // appreciate fix.
      
      dlg.Reset();
      dlg.SetHeading(495); // Sort options
      int maxCommonSortIndex = -1; // Inrease by 1 when adding new common sort label(sort valid in share and db views))
      int dbSortCount = 0; // increase by one when adding new database sort label
      
      // Watch for enums in VideoSort.cs - must be exactly as the enum order

      // Common sorts - group 1
      dlg.AddLocalizedString(365); // 0 name
      maxCommonSortIndex++;
      dlg.AddLocalizedString(1309); // 1 nameall
      maxCommonSortIndex++;
      dlg.AddLocalizedString(1999); // 2 Name with Duration
      maxCommonSortIndex++;
      dlg.AddLocalizedString(104); // 3 date created (date)
      maxCommonSortIndex++;
      dlg.AddLocalizedString(105); // 4 size
      maxCommonSortIndex++;
      dlg.AddLocalizedString(527); // 5 watched
      maxCommonSortIndex++;
      
      // Database sorts - group 2
      if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEO_TITLE)
      {
        dlg.AddLocalizedString(366); // 6 year
        dbSortCount++;
        dlg.AddLocalizedString(367); // 7 rating
        dbSortCount++;
      }

      // Share sorts - group 3
      if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS)
      {
        dlg.AddLocalizedString(430);  // 8 CD label
        dlg.AddLocalizedString(1221); // 9 date modified
        dlg.AddLocalizedString(1220); // 10 date created
      }
      
      // set the focus to currently used sort method

      // we need to correct index only if sort method enum is greater then max common sort index in share view
      if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS  // must be share view
          && (int)CurrentSortMethod > maxCommonSortIndex) 
      {
        dlg.SelectedLabel = (int)CurrentSortMethod - dbSortCount;
      }
      else
      {
        dlg.SelectedLabel = (int)CurrentSortMethod;
      }

      // show dialog and wait for result
      dlg.DoModal(GetID);
      if (dlg.SelectedId == -1)
      {
        return;
      }

      CurrentSortAsc = true;
      switch (dlg.SelectedId)
      {
        case 365:
          CurrentSortMethod = VideoSort.SortMethod.Name;
          break;
        case 1309:
          CurrentSortMethod = VideoSort.SortMethod.NameAll;
          break;
        case 104:
          CurrentSortMethod = VideoSort.SortMethod.Date;
          CurrentSortAsc = false;
          break;
        case 1221:
          CurrentSortMethod = VideoSort.SortMethod.Modified;
          CurrentSortAsc = false;
          break;
        case 1220:
          CurrentSortMethod = VideoSort.SortMethod.Created;
          CurrentSortAsc = false;
          break;
        case 105:
          CurrentSortMethod = VideoSort.SortMethod.Size;
          break;
        case 366:
          CurrentSortMethod = VideoSort.SortMethod.Year;
          break;
        case 367:
          CurrentSortMethod = VideoSort.SortMethod.Rating;
          break;
        case 430:
          CurrentSortMethod = VideoSort.SortMethod.Label;
          break;
        case 527:
          CurrentSortMethod = VideoSort.SortMethod.Watched;
          break;
        case 1999:
          CurrentSortMethod = VideoSort.SortMethod.Name_With_Duration;
          break;
        default:
          CurrentSortMethod = VideoSort.SortMethod.Name;
          break;
      }

      OnSort();
      GUIControl.FocusControl(GetID, btnSortBy.GetID);
    }
예제 #7
0
        protected virtual void SetLabels()
        {
            bool isShareView = false;

            if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS)
            {
                isShareView = true;
            }

            bool _stackedFolder = true;

            if (isShareView)
            {
                _currentFolder = GUIVideoFiles.GetCurrentFolder;
                object o;
                MediaPortal.Database.FolderSettings.GetFolderSetting(_currentFolder, "VideoFiles", typeof(GUIVideoFiles.MapSettings), out o);

                if (o != null)
                {
                    GUIVideoFiles.MapSettings mapSettings = o as GUIVideoFiles.MapSettings;

                    _stackedFolder = mapSettings.Stack;
                }
            }
            else
            {
                _currentFolder = GUIVideoTitle.GetCurrentView;
                object o;
                // MediaPortal.Database.FolderSettings.GetFolderSetting(_currentFolder, "VideoViews", typeof(GUIVideoTitle.MapSettings), out o);
                MediaPortal.Database.FolderSettings.GetViewSetting(_currentFolder, "VideoViews", typeof(GUIVideoTitle.MapSettings), out o);
                if (o != null)
                {
                    GUIVideoTitle.MapSettings mapSettings = o as GUIVideoTitle.MapSettings;
                    if (mapSettings != null)
                    {
                        CurrentSortMethod = (VideoSort.SortMethod)mapSettings.SortBy;
                        CurrentSortAsc    = mapSettings.SortAscending;
                    }
                }
            }

            for (int i = 0; i < facadeLayout.Count; ++i)
            {
                GUIListItem item  = facadeLayout[i];
                IMDBMovie   movie = item.AlbumInfoTag as IMDBMovie;

                if (movie != null && movie.ID > 0 && !isShareView &&
                    (!item.IsFolder || CurrentSortMethod == VideoSort.SortMethod.NameAll))
                {
                    if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll ||
                        CurrentSortMethod == VideoSort.SortMethod.Name_With_Duration)
                    {
                        if (item.IsFolder)
                        {
                            item.Label2 = string.Empty;
                        }
                        else
                        {
                            // Show real movie duration (from video file)
                            int mDuration = VideoDatabase.GetMovieDuration(movie.ID);

                            if (mDuration <= 0)
                            {
                                ArrayList mFiles = new ArrayList();
                                VideoDatabase.GetFilesForMovie(movie.ID, ref mFiles);
                                mDuration = GUIVideoFiles.MovieDuration(mFiles, true);

                                if (mDuration <= 0)
                                {
                                    item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60);
                                }
                                else
                                {
                                    item.Label2 = Util.Utils.SecondsToHMString(mDuration);
                                }
                            }
                            else
                            {
                                item.Label2 = Util.Utils.SecondsToHMString(mDuration);
                            }
                        }
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Year)
                    {
                        item.Label2 = movie.Year.ToString();
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Rating)
                    {
                        item.Label2 = movie.Rating.ToString();
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Label)
                    {
                        item.Label2 = movie.DVDLabel.ToString();
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Size)
                    {
                        if (item.FileInfo != null)
                        {
                            item.Label2 = Util.Utils.GetSize(item.FileInfo.Length);
                        }
                        else
                        {
                            item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60);
                        }
                    }
                    else if (!isShareView && CurrentSortMethod == VideoSort.SortMethod.Date)
                    {
                        string strDate = string.Empty;

                        if (!item.IsFolder && movie != null)
                        {
                            if (movie.DateAdded != "0001-01-01 00:00:00")
                            {
                                strDate = movie.DateAdded;
                            }
                            else
                            {
                                strDate = movie.LastUpdate;
                            }
                        }
                        item.Label2 = strDate;
                    }
                }
                else
                {
                    string strSize1 = string.Empty, strDate = string.Empty;

                    if (item.FileInfo != null && !item.IsFolder)
                    {
                        strSize1 = Util.Utils.GetSize(item.FileInfo.Length);
                    }

                    if (item.FileInfo != null && !item.IsFolder)
                    {
                        if (CurrentSortMethod == VideoSort.SortMethod.Modified)
                        {
                            strDate = item.FileInfo.ModificationTime.ToShortDateString() + " " +
                                      item.FileInfo.ModificationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                        }
                        else
                        {
                            strDate = item.FileInfo.CreationTime.ToShortDateString() + " " +
                                      item.FileInfo.CreationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                        }
                    }

                    if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll)
                    {
                        if (item.IsFolder)
                        {
                            item.Label2 = string.Empty;
                        }
                        else
                        {
                            item.Label2 = strSize1;
                        }
                    }

                    if (CurrentSortMethod == VideoSort.SortMethod.Name_With_Duration && !item.IsFolder && item.Label != "..")
                    {
                        if (_stackedFolder)
                        {
                            int newMovieId = VideoDatabase.GetMovieId(item.Path);
                            item.Duration = VideoDatabase.GetMovieDuration(newMovieId);
                        }
                        else
                        {
                            int fileID = VideoDatabase.GetFileId(item.Path);
                            item.Duration = VideoDatabase.GetVideoDuration(fileID);
                        }

                        if (item.Duration > 0)
                        {
                            item.Label2 = Util.Utils.SecondsToShortHMSString(item.Duration);
                        }
                        else
                        {
                            item.Label2 = string.Empty;
                        }
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Created || CurrentSortMethod == VideoSort.SortMethod.Date || CurrentSortMethod == VideoSort.SortMethod.Modified)
                    {
                        if (!isShareView && CurrentSortMethod == VideoSort.SortMethod.Date && string.IsNullOrWhiteSpace(strDate))
                        {
                            if (!item.IsFolder && movie != null)
                            {
                                if (movie.DateAdded != "0001-01-01 00:00:00")
                                {
                                    strDate = movie.DateAdded;
                                }
                                else
                                {
                                    strDate = movie.LastUpdate;
                                }
                            }
                        }
                        item.Label2 = strDate;
                    }
                    else
                    {
                        if (item.IsFolder)
                        {
                            item.Label2 = string.Empty;
                        }
                        else
                        {
                            item.Label2 = strSize1;
                        }
                    }
                }
            }
        }
예제 #8
0
        protected override void OnShowSort()
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }
            dlg.Reset();
            dlg.SetHeading(495); // Sort options

            // Watch for enums in VideoSort.cs
            dlg.AddLocalizedString(365); // name
            dlg.AddLocalizedString(104); // date created (date)
            dlg.AddLocalizedString(105); // size
            dlg.AddLocalizedString(366); // year
            dlg.AddLocalizedString(367); // rating
            dlg.AddLocalizedString(430); // label
            dlg.AddLocalizedString(527); // unwatched
            if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS)
            {
                dlg.AddLocalizedString(1221); // date modified
                dlg.AddLocalizedString(1220); // date created
            }

            // set the focus to currently used sort method
            dlg.SelectedLabel = (int)CurrentSortMethod;

            // show dialog and wait for result
            dlg.DoModal(GetID);
            if (dlg.SelectedId == -1)
            {
                return;
            }

            CurrentSortAsc = true;
            switch (dlg.SelectedId)
            {
            case 365:
                CurrentSortMethod = VideoSort.SortMethod.Name;
                break;

            case 104:
                CurrentSortMethod = VideoSort.SortMethod.Date;
                CurrentSortAsc    = false;
                break;

            case 1221:
                CurrentSortMethod = VideoSort.SortMethod.Modified;
                CurrentSortAsc    = false;
                break;

            case 1220:
                CurrentSortMethod = VideoSort.SortMethod.Created;
                CurrentSortAsc    = false;
                break;

            case 105:
                CurrentSortMethod = VideoSort.SortMethod.Size;
                break;

            case 366:
                CurrentSortMethod = VideoSort.SortMethod.Year;
                break;

            case 367:
                CurrentSortMethod = VideoSort.SortMethod.Rating;
                break;

            case 430:
                CurrentSortMethod = VideoSort.SortMethod.Label;
                break;

            case 527:
                CurrentSortMethod = VideoSort.SortMethod.Unwatched;
                break;

            default:
                CurrentSortMethod = VideoSort.SortMethod.Name;
                break;
            }

            OnSort();
            GUIControl.FocusControl(GetID, btnSortBy.GetID);
        }