Example #1
0
        public void SortAllImage(FileSortMethod order)
        {
            if (order == FileSortMethod.None)
            {
                ReadFiles(Setting.TempProfile.Path.Value.ToArray(), false);
            }
            int grids = Setting.TempProfile.NumofMatrix.Grid;

            ImgContainerManager.ImagePool.Sort(order);
            var t = ImgContainerManager.ChangeCurrentIndex(0);
        }
Example #2
0
        /// <summary>
        /// ソート
        /// </summary>
        /// <param name="order"></param>
        public void Sort(FileSortMethod order)
        {
#if DEBUG
            Stopwatch sw = new Stopwatch();
            sw.Start();
#endif
            if (ImageFileContextList.Count < 1)
            {
                return;
            }

            switch (order)
            {
            case FileSortMethod.FileName:
                ImageFileContextList = ImageFileContextList.OrderBy(i => i.FilePath).ToList();
                break;

            case FileSortMethod.FileNameRev:
                ImageFileContextList = ImageFileContextList.OrderByDescending(i => i.FilePath).ToList();
                break;

            case FileSortMethod.FileNameNatural:
                ImageFileContextList = ImageFileContextList.OrderBy(i => i.FilePath, new NaturalStringComparer()).ToList();
                break;

            case FileSortMethod.FileNameNaturalRev:
                ImageFileContextList = ImageFileContextList.OrderByDescending(i => i.FilePath, new NaturalStringComparer()).ToList();
                break;

            case FileSortMethod.LastWriteTime:
                foreach (ImageFileContext ifc in ImageFileContextList)
                {
                    ifc.ReadLastWriteTime();
                }
                ImageFileContextList = ImageFileContextList.OrderBy(i => i.Info.LastWriteTime).ToList();
                break;

            case FileSortMethod.LastWriteTimeRev:
                foreach (ImageFileContext ifc in ImageFileContextList)
                {
                    ifc.ReadLastWriteTime();
                }
                ImageFileContextList = ImageFileContextList.OrderByDescending(i => i.Info.LastWriteTime).ToList();
                break;

            case FileSortMethod.DateTaken:
                foreach (ImageFileContext ifc in ImageFileContextList)
                {
                    ifc.ReadInfoForView();
                }
                ImageFileContextList = ImageFileContextList.OrderBy((i) => {
                    if (i.Info.ExifInfo == null || i.Info.ExifInfo.DateTaken == null)
                    {
                        return(new DateTimeOffset());
                    }
                    return(i.Info.ExifInfo.DateTaken);
                }).ToList();
                break;

            case FileSortMethod.DateTakenRev:
                foreach (ImageFileContext ifc in ImageFileContextList)
                {
                    ifc.ReadInfoForView();
                }
                ImageFileContextList = ImageFileContextList.OrderByDescending((i) => {
                    if (i.Info.ExifInfo == null || i.Info.ExifInfo.DateTaken == null)
                    {
                        return(new DateTimeOffset());
                    }
                    return(i.Info.ExifInfo.DateTaken);
                }).ToList();
                break;

            case FileSortMethod.Random:
                ImageFileContextList.Shuffle();
                break;

            case FileSortMethod.None:
                break;
            }
#if DEBUG
            sw.Stop();
            Debug.WriteLine("-----------------------------------------------------");
            Debug.WriteLine(" sort end    order: " + order + "  time: " + sw.Elapsed);
            Debug.WriteLine("-----------------------------------------------------");
#endif
        }