public void UpdateFolders(int CurrentSortMethod, bool CurrentSortAsc, int CurrentLayout) { string currentFolder = GUIVideoFiles.GetCurrentFolder; if (currentFolder == string.Empty) { currentFolder = "root"; } if (!OnResetFolderSettings()) { return; } Log.Debug("UpdateFolders: currentFolder {0}", currentFolder); ArrayList strPathList = new ArrayList(); FolderSettings.GetPath(GUIVideoFiles.GetCurrentFolder, ref strPathList, "VideoFiles"); for (int iRow = 0; iRow < strPathList.Count; iRow++) { object o; FolderSettings.GetFolderSetting(strPathList[iRow] as string, "VideoFiles", typeof(GUIVideoFiles.MapSettings), out o); Log.Debug("UpdateFolders: GetFolderSetting {0}", strPathList[iRow] as string); if (o != null) { GUIVideoFiles.MapSettings mapSettings = o as GUIVideoFiles.MapSettings; if (mapSettings == null) { mapSettings = new GUIVideoFiles.MapSettings(); } if (CurrentSortMethod != -1) { Log.Debug("UpdateFolders: old SortBy {0}, new SortBy {1}", mapSettings.SortBy, CurrentSortMethod); mapSettings.SortBy = CurrentSortMethod; mapSettings.SortAscending = CurrentSortAsc; } if (CurrentLayout != -1) { Log.Debug("UpdateFolders: old ViewAs {0}, new ViewAs {1}", mapSettings.ViewAs, CurrentLayout); mapSettings.ViewAs = CurrentLayout; } FolderSettings.AddFolderSetting(strPathList[iRow] as string, "VideoFiles", typeof(GUIVideoFiles.MapSettings), mapSettings); } } }
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; } } } } }