Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public static void DeletePhoto(PhotoPackage photo)
        {
            PhotoList photoList = Instance.photoList;

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

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

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

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

            photoList.Photos.AddRange(photoList_.Photos);
        }
Ejemplo n.º 7
0
 private PhotoDB()
 {
     photoList = new PhotoList();
 }