public static MessageRecievedEventArgs GetAllPhotos()
        {
            MessageRecievedEventArgs message = new MessageRecievedEventArgs(MessageTypeEnum.P_SEND, "");
            Settings  settings = Settings.Instance;
            PhotoList photos   = new PhotoList();

            string[] thumbnailsPath;
            try
            {
                thumbnailsPath = Directory.GetFiles(settings.OutputPath + "\\Thumbnails", "*.*", SearchOption.AllDirectories);
            }
            catch (Exception)
            {
                return(message);
            }

            foreach (var thumbPath in thumbnailsPath)
            {
                Image image;
                Image imageThumb;

                int    index     = thumbPath.IndexOf("\\Thumbnails");
                string imagePath = (index < 0) ? thumbPath : thumbPath.Remove(index, "\\Thumbnails".Length);

                try
                {
                    image      = Image.FromFile(imagePath);
                    imageThumb = Image.FromFile(thumbPath);
                }
                catch (Exception)
                {
                    continue;
                }

                photos.Photos.Add(new PhotoPackage(imagePath, thumbPath, image, imageThumb));
            }

            message.Message = photos.Serialize();

            return(message);
        }
Exemple #2
0
        public static void DeletePhoto(PhotoPackage photo)
        {
            PhotoList photoList = Instance.photoList;

            photoList.Photos.RemoveAll(a => a.PhotoPath == photo.PhotoPath);
        }
Exemple #3
0
        public static PhotoPackage GetPhoto(int index)
        {
            PhotoList photoList = Instance.photoList;

            return(photoList.Photos[index]);
        }
Exemple #4
0
        public static int GetIndex(PhotoPackage photo)
        {
            PhotoList photoList = Instance.photoList;

            return(photoList.Photos.IndexOf(photo));
        }
Exemple #5
0
        public static void AddPhoto(PhotoPackage photo)
        {
            PhotoList photoList = Instance.photoList;

            photoList.Photos.Add(photo);
        }
Exemple #6
0
        public static void AddPhotos(PhotoList photoList_)
        {
            PhotoList photoList = Instance.photoList;

            photoList.Photos.AddRange(photoList_.Photos);
        }
Exemple #7
0
 private PhotoDB()
 {
     photoList = new PhotoList();
 }