protected void OrderFiles(IEnumerable <T> files) { // ReSharper disable once PossibleMultipleEnumeration FileNames = GetFileNames(files).Where(FileIsImage).OrderBy(c => c).ToArray(); OrderedFileNames = PageOrderMode switch { MainViewModel.PageOrder.Natural => GetFileNames(files) .Where(FileIsImage) .OrderBy(ef => ef, new NaturalSortComparer()) .ToArray(), MainViewModel.PageOrder.Modified => OrderFilesByDateModified(files).Where(FileIsImage).ToArray(), MainViewModel.PageOrder.Ordinal => FileNames.ToArray(), _ => throw new ArgumentOutOfRangeException() }; OrderedShortNames = OrderedFileNames.Select(fn => GetShortName(this is FolderContainer ? ContainerPath : null, fn)).ToArray(); foreach (var pageTag in Item.PageTags) { var index = Array.IndexOf(OrderedShortNames, pageTag.FileName); pageTag.Page = index == -1 ? -1 : index + 1; } }
public string GetFileName() => FileNames == null ? FileName : FileNames.ToArray()[_random.Next(0, FileNames.Count())];