コード例 #1
0
ファイル: SortedPhoto.cs プロジェクト: DmitriyCE/Lab1
        public static void SortPhotoByLocation(string path)
        {
            var createDir = new CreateDirectory();
            var pathNew   = createDir.CreateDirectoryOfName(path, "PhotoSort_SortPhotoByGeoLocation");
            var dirinfo   = new DirectoryInfo(path);
            var massPhoto = dirinfo.GetFiles();
            var sortPhoto = new SortedPhoto();

            foreach (var photo in massPhoto)
            {
                var geolocation = InfoImage.GetLocationPhoto(photo);
                if (geolocation != null)
                {
                    var location = InfoImage.GetLocality(geolocation);
                    if (Directory.Exists(pathNew + $"\\{location}") == false)
                    {
                        sortPhoto.CreateDirectoryOfName(pathNew, location);
                    }
                    photo.CopyTo(pathNew + $"\\{location}\\{photo.Name}", true);
                }
                else
                {
                    if (Directory.Exists(pathNew + $"\\NoneGeolocation") == false)
                    {
                        sortPhoto.CreateDirectoryOfName(pathNew, "NoneGeolocation");
                    }
                    photo.CopyTo(pathNew + $"\\NoneGeolocation\\{photo.Name}", true);
                }
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            RenameImage.PhotoCopyCompleted          += (e) => { WriteLine(e.Message); };
            DataOnPhoto.PhotoDrawingCompleted       += (e) => { WriteLine(e.Message); };
            SortedPhoto.CopyingDirectoriesCompleted += (e) => { WriteLine(e.Message); };
            SortedPhoto.SotringByLocationCompleted  += (e) => { WriteLine(e.Message); };
            ApplicationInterface.AppFunc();
            while (true)
            {
                switch (ReadKey().Key)
                {
                case ConsoleKey.A:
                {
                    ApplicationInterface.RedrawAppFunc();
                    RenameImage.RenameImageByDataAsync(ApplicationInterface.PathRequest());
                    break;
                }

                case ConsoleKey.B:
                {
                    ApplicationInterface.RedrawAppFunc();
                    DataOnPhoto.DateOnTheImageAsync(ApplicationInterface.PathRequest());
                    break;
                }

                case ConsoleKey.C:
                {
                    ApplicationInterface.RedrawAppFunc();
                    SortedPhoto.SortPhotoByYearsAsync(ApplicationInterface.PathRequest());
                    break;
                }

                case ConsoleKey.D:
                {
                    ApplicationInterface.RedrawAppFunc();
                    SortedPhoto.SortPhotoByLocationAsync(ApplicationInterface.PathRequest());
                    break;
                }

                case ConsoleKey.Escape:
                {
                    return;
                }
                }
            }
        }
コード例 #3
0
ファイル: SortedPhoto.cs プロジェクト: DmitriyCE/Lab1
        public static void SortPhotoByYears(string path)
        {
            var createDir = new CreateDirectory();
            var pathNew   = createDir.CreateDirectoryOfName(path, "PhotoSort_SortPhotoByYear");
            var dirinfo   = new DirectoryInfo(path);
            var massPhoto = dirinfo.GetFiles();
            var sortPhoto = new SortedPhoto();

            foreach (var photo in massPhoto)
            {
                var datePhoto = InfoImage.ImageDate(photo).ToString("Y");
                if (Directory.Exists(pathNew + $"\\{datePhoto}") == false)
                {
                    sortPhoto.CreateDirectoryOfName(pathNew, datePhoto);
                }
                photo.CopyTo(pathNew + $"\\{datePhoto}\\{photo.Name}", true);
            }
        }