예제 #1
0
        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);
        }
예제 #2
0
        public static void DeletePhoto(PhotoPackage photo)
        {
            PhotoList photoList = Instance.photoList;

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

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

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

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

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