Exemplo n.º 1
0
 /// <summary>
 /// 文件提取器构造函数
 /// </summary>
 /// <param name="directory">搜寻文件的目录</param>
 /// <param name="compareMode">指定文件的比较方式,用于排序</param>
 /// <param name="sortMode">排序方式,升序或降序</param>
 public FileExtractor(string directory, FileCompareMode compareMode, FileSortMode sortMode)
 {
     this.directory = directory;
     if (!this.directory.EndsWith("\\"))
     {
         this.directory += "\\";
     }
     this.compareMode = compareMode;
     this.sortMode    = sortMode;
 }
Exemplo n.º 2
0
        protected DateTime GetFileDate(FileInfo fileInfo, FileSortMode fileSortMode)
        {
            DateTime retVal = DateTime.MinValue;

            switch (fileSortMode)
            {
            case FileSortMode.CreateDate:
                retVal = fileInfo.CreationTime;
                break;

            case FileSortMode.ModifyDate:
            case FileSortMode.FileName:
                retVal = fileInfo.LastWriteTime;
                break;

            case FileSortMode.RecordingDate:
                if (fileInfo.Extension.ToUpper() == ".JPG")
                {
                    //retVal = PictureHelper.GetTakePicDateTime(PictureHelper.GetExifProperties(fileInfo.FullName));
                    if (this.DicRecordDate.ContainsKey(fileInfo.FullName))
                    {
                        retVal = this.DicRecordDate[fileInfo.FullName];
                    }
                }
                break;

            case FileSortMode.DateInFileName:
                Regex reg   = new Regex(@"((19|20)\d{2})-?(0[1-9]|1[0-2])-?(0[1-9]|[1-2][0-9]|3[0-1])");
                Match match = reg.Match(fileInfo.Name);

                if (match.Success)
                {
                    DateTime.TryParseExact(match.Value, new[] { "yyyy-MM-dd", "yyyyMMdd" }, CultureInfo.CurrentUICulture, DateTimeStyles.None, out retVal);
                }

                break;
            }

            return(retVal);
        }
        public void Sort(FileSortMode fileSortMode)
        {
            switch (fileSortMode)
            {
            case FileSortMode.Name:
                controller.Sort(nameComparer);
                break;

            case FileSortMode.Date:
                controller.Sort(dateComparer);
                break;

            case FileSortMode.Random:
                controller.Sort(randomComparer);
                break;

            case FileSortMode.Path:
                controller.Sort(pathComparer);
                break;

            default:
                throw new ArgumentOutOfRangeException("fileSortMode");
            }
        }
 protected abstract void PlaylistSort(FileSortMode fileSortMode);
 protected override void PlaylistSort(FileSortMode fileSortMode)
 {
     this.window.PanelPlaylist.ListPlaylist.Sort(fileSortMode);
 }
        protected DateTime GetFileDate(FileInfo fileInfo, FileSortMode fileSortMode)
        {
            DateTime retVal = DateTime.MinValue;

            switch (fileSortMode) {
                case FileSortMode.CreateDate:
                    retVal = fileInfo.CreationTime;
                    break;
                case FileSortMode.ModifyDate:
                case FileSortMode.FileName:
                    retVal = fileInfo.LastWriteTime;
                    break;
                case FileSortMode.RecordingDate:
                    if (fileInfo.Extension.ToUpper() == ".JPG")
                        //retVal = PictureHelper.GetTakePicDateTime(PictureHelper.GetExifProperties(fileInfo.FullName));
                        if (this.DicRecordDate.ContainsKey(fileInfo.FullName))
                            retVal = this.DicRecordDate[fileInfo.FullName];
                    break;
                case FileSortMode.DateInFileName:
                    Regex reg = new Regex(@"((19|20)\d{2})-?(0[1-9]|1[0-2])-?(0[1-9]|[1-2][0-9]|3[0-1])");
                    Match match = reg.Match(fileInfo.Name);

                    if (match.Success)
                        DateTime.TryParseExact(match.Value, new[] {"yyyy-MM-dd", "yyyyMMdd"}, CultureInfo.CurrentUICulture, DateTimeStyles.None, out retVal);

                    break;
            }

            return retVal;
        }
Exemplo n.º 7
0
 public FileNameComparer(FileSortMode sortMode)
 {
     this.sortMode = sortMode;
 }
Exemplo n.º 8
0
 public CreationTimeComparer(FileSortMode sortMode)
 {
     this.sortMode = sortMode;
 }