Beispiel #1
0
        public void NotifyDeletePhoto(int index)
        {
            string photo = PhotoDB.GetPhoto(index).Serialize();
            MessageRecievedEventArgs messageRecievedEventArgs = new MessageRecievedEventArgs(MessageTypeEnum.P_DELETE, photo);

            NotifyPhotoChange?.Invoke(this, messageRecievedEventArgs);
        }
Beispiel #2
0
        private void AddPhoto(string photo_)
        {
            PhotoPackage photo = PhotoPackage.Deserialize(photo_);

            Settings.Instance.PicturesCounter++;
            PhotoDB.AddPhoto(photo);
        }
Beispiel #3
0
        private void AddPhotos(string photos_)
        {
            PhotoList photos = PhotoList.Deserialize(photos_);

            Settings.Instance.PicturesCounter = photos.Photos.Count;
            PhotoDB.AddPhotos(photos);
        }
Beispiel #4
0
    public static int Main(string[] args)
    {
        if (args.Length == 0)
        {
            System.Console.Error.WriteLine("Usage: cmd <mountpoint>");
            return(1);
        }

        ITDB itdb = new ITDB(args[0]);

        Console.WriteLine("Found Device: " + itdb.Device.Mountpoint);
        Console.WriteLine("\t{0} ({1}GB) - {2} - {3}",
                          itdb.Device.IpodInfo.GenerationString,
                          itdb.Device.IpodInfo.Capacity,
                          itdb.Device.IpodInfo.ModelString,
                          itdb.Device.IpodInfo.ModelNumber);
        Console.WriteLine("\tACPhPV: {0}, {1}, {2}, {3}, {4}",
                          itdb.Device.SupportsArtwork,
                          itdb.Device.SupportsChapterImage,
                          itdb.Device.SupportsPhoto,
                          itdb.Device.SupportsPodcast,
                          itdb.Device.SupportsVideo);
        Console.WriteLine("\tTrack Count: {0}", itdb.Tracks.Count);
        foreach (Track t in itdb.Tracks)
        {
            Console.WriteLine("\t\t{0}/{1}/{2}/{3}/{4}", t.Artist, t.Album, t.Title, t.RememberPlaybackPosition, t.TimeAdded);
        }
        Console.WriteLine("\tPlaylist Count: {0}", itdb.Playlists.Count);
        foreach (Playlist p in itdb.Playlists)
        {
            Console.Write("\t\t{0}", p.Name);
            if (p.IsMaster)
            {
                Console.WriteLine(" (Master)");
            }
            else
            {
                Console.WriteLine("");
            }
        }

        PhotoDB pdb = new PhotoDB(args[0]);

        Console.WriteLine("\tPhotos Count: {0}", pdb.Photos.Count);
        foreach (Artwork a in pdb.Photos)
        {
            Console.WriteLine("\t\t{0}", a.TimeCreated);
        }
        Console.WriteLine("\tPhotoAlbum Count: {0}", pdb.PhotoAlbums.Count);
        foreach (PhotoAlbum p in pdb.PhotoAlbums)
        {
            Console.WriteLine("\t\t{0}: {1}", p.Name, p.Photos.Count);
            foreach (Artwork a in p.Photos)
            {
                Console.WriteLine("\t\t\t{0}", a.TimeCreated);
            }
        }
        return(0);
    }
Beispiel #5
0
        /// <summary>
        /// Increment the count of the number of times the current photo has been viewed.
        /// </summary>
        public void IncrementViewed()
        {
            viewed++;

            PhotoDB db = new PhotoDB(token.DBConnection);

            db.IncrementViewedCount(this);
        }
Beispiel #6
0
        public static Photos GetPhotos(SessionToken token, PhotoDirectory obj)
        {
            PhotoDB odb     = new PhotoDB(token.DBConnection);
            Photos  photos  = odb.GetPhotos(token, obj);
            Photos  photos2 = (Photos)photos.Clone();

            FileInfo[] files = new DirectoryInfo(token.MapPath(obj.FullVirtualPath)).GetFiles("*.*");
            if (photos.Count != files.Length)
            {
                foreach (FileInfo info2 in files)
                {
                    string fullVirtualPath = GetVirtualPath(token, info2.FullName);
                    if (!photos.Contains(fullVirtualPath))
                    {
                        string   virtualPath = fullVirtualPath.Substring(0, (fullVirtualPath.Length - info2.Name.Length) - 1);
                        DateTime dateTaken   = DateTime.MinValue;
                        try
                        {
                            using (Image image = Image.FromFile(info2.FullName))
                            {
                                try
                                {
                                    dateTaken = ParseExifDateTime(image.GetPropertyItem(0x9003).Value);
                                }
                                catch (ArgumentException)
                                {
                                }
                            }
                            Photo photo = new Photo(token, info2.Name, virtualPath, dateTaken, info2.Length);
                            odb.Insert(obj, photo);
                            photos.Add(photo);
                        }
                        catch
                        {
                        }
                    }
                    photos2.Remove(fullVirtualPath);
                }
                foreach (Photo photo in photos2)
                {
                    ThumbnailUtilities.DeleteThumbnail(token.MapPath(photo.FullThumbnailVirtualPath));
                    odb.Delete(photo);
                    photos.Remove(photo);
                }
            }
            return(photos);
        }
Beispiel #7
0
    public static int Main(string[] args)
    {
        if (args.Length == 0) {
            System.Console.Error.WriteLine ("Usage: cmd <mountpoint>");
            return 1;
        }

        ITDB itdb   = new ITDB (args[0]);
        Console.WriteLine("Found Device: " + itdb.Device.Mountpoint);
        Console.WriteLine("\t{0} ({1}GB) - {2} - {3}",
                          itdb.Device.IpodInfo.GenerationString,
                          itdb.Device.IpodInfo.Capacity,
                          itdb.Device.IpodInfo.ModelString,
                          itdb.Device.IpodInfo.ModelNumber);
        Console.WriteLine("\tACPhPV: {0}, {1}, {2}, {3}, {4}",
                          itdb.Device.SupportsArtwork,
                          itdb.Device.SupportsChapterImage,
                          itdb.Device.SupportsPhoto,
                          itdb.Device.SupportsPodcast,
                          itdb.Device.SupportsVideo);
        Console.WriteLine("\tTrack Count: {0}", itdb.Tracks.Count);
        foreach (Track t in itdb.Tracks)
            Console.WriteLine("\t\t{0}/{1}/{2}/{3}/{4}", t.Artist, t.Album, t.Title, t.RememberPlaybackPosition, t.TimeAdded);
        Console.WriteLine("\tPlaylist Count: {0}", itdb.Playlists.Count);
        foreach (Playlist p in itdb.Playlists) {
            Console.Write("\t\t{0}", p.Name);
            if (p.IsMaster)
                Console.WriteLine(" (Master)");
            else
                Console.WriteLine("");
        }

        PhotoDB pdb = new PhotoDB(args[0]);
        Console.WriteLine("\tPhotos Count: {0}", pdb.Photos.Count);
        foreach (Artwork a in pdb.Photos)
            Console.WriteLine("\t\t{0}", a.TimeCreated);
        Console.WriteLine("\tPhotoAlbum Count: {0}", pdb.PhotoAlbums.Count);
        foreach (PhotoAlbum p in pdb.PhotoAlbums) {
            Console.WriteLine("\t\t{0}: {1}", p.Name, p.Photos.Count);
            foreach (Artwork a in p.Photos)
                Console.WriteLine("\t\t\t{0}", a.TimeCreated);
        }
        return 0;
    }
Beispiel #8
0
        /// <summary>
        /// Returns the details of the photos contained within a directory.
        /// </summary>
        /// <param name="token">A reference to the current session token object.</param>
        /// <param name="obj">The directory whos photos we want to retrieve.</param>
        /// <returns>A collection of Photo objects.</returns>
        public static Photos GetPhotos(SessionToken token, PhotoDirectory obj)
        {
            PhotoDB db = new PhotoDB(token.DBConnection);

            Photos results = db.GetPhotos(token, obj);

            Photos originalResults = (Photos)results.Clone();

            // Get a list of directories from the root path from the file system
            DirectoryInfo dirInfo = new DirectoryInfo(token.MapPath(obj.FullVirtualPath));

            FileInfo[] fileInfos = dirInfo.GetFiles("*.jpg");

            // Only need to update the database if the number of files in the database are
            // different to those on the file system.
            // TODO: Currently won't detect changes in file names. Ideas to enable this
            //       and still be fast?
            if (results.Count != fileInfos.Length)
            {
                foreach (FileInfo file in fileInfos)
                {
                    string virtualPath = GetVirtualPath(token, file.FullName);

                    // Do we have a Photo for this directory already? If not then we need to
                    // add it to the database
                    if (!results.Contains(virtualPath))
                    {
                        string dirVirtualPath = virtualPath.Substring(0, virtualPath.Length - file.Name.Length - 1);

                        DateTime dateTaken = DateTime.MinValue;
                        using (Image image = Image.FromFile(file.FullName))
                        {
                            try
                            {
                                PropertyItem date = image.GetPropertyItem((int)KnownEXIFIDCodes.DateTimeOriginal);
                                dateTaken = ParseExifDateTime(date.Value);
                            }
                            catch (ArgumentException)
                            {
                                // image does not have a date value
                            }
                        }
                        Photo photo = new Photo(token, file.Name, dirVirtualPath, dateTaken, file.Length);

                        // insert this fire into the database
                        db.Insert(obj, photo);

                        results.Add(photo);
                    }

                    originalResults.Remove(virtualPath);
                }

                // Are there any Photo objects in the original result set that aren't in
                // the list of files from the file system? If so, delete 'em
                foreach (Photo photo in originalResults)
                {
                    // Delete the associated thumbnail
                    ThumbnailUtilities.DeleteThumbnail(token.MapPath(photo.FullThumbnailVirtualPath));

                    db.Delete(photo);
                    results.Remove(photo);
                }
            }

            return(results);
        }
 public ActionResult DeletePhoto()
 {
     return(RedirectToAction("DeletePhoto", "DeletePhoto", new { selectedPhoto = PhotoDB.GetIndex(model.selectedPhoto) }));
 }
 public ActionResult ViewPhoto(int selectedPhoto)
 {
     model.selectedPhoto = PhotoDB.GetPhoto(selectedPhoto);
     return(RedirectToAction("ViewPhotoView"));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PhotoSql"/> class.
 /// </summary>
 public PhotoSql()
 {
     photoDb          = new PhotoDB();
     photoDb.DbClient = new SqlServerClient();
 }
Beispiel #12
0
        /// <summary>
        /// Returns the details of the sub-directories contained within a given path.
        /// </summary>
        /// <param name="parent">The parent directory, or null it at the root.</param>
        /// <param name="token">A reference to the current directory browser session token object.</param>
        /// <param name="path">The physical path of the directory in question.</param>
        /// <returns>A collection of PhotoDirectory objects.</returns>
        public static PhotoDirectories GetDirectories(PhotoDirectory parent, SessionToken token, string path)
        {
            PhotoDirectoryDB db = new PhotoDirectoryDB(token.DBConnection);

            // If the directory doesn't exist then a directory must have been deleted
            if (!Directory.Exists(path))
            {
                // extract out the name and virtual path from the full physical path
                path = path.Substring(token.PhotosRootFullPath.Length,
                                      path.Length - token.PhotosRootFullPath.Length);
                string name        = path.Substring(path.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                string virtualPath = path.Substring(0, path.LastIndexOf(Path.DirectorySeparatorChar));

                db.Delete(name, virtualPath);

                return(new PhotoDirectories());
            }
            else
            {
                // Get a list of directories from the database
                PhotoDirectories results = db.GetDirectories(token, GetVirtualPath(token, path));

                PhotoDirectories originalResults = (PhotoDirectories)results.Clone();

                // Get a list of directories from the root path from the file system
                DirectoryInfo   dirInfo  = new DirectoryInfo(path);
                DirectoryInfo[] dirInfos = dirInfo.GetDirectories();

                // Only need to update the database if the number of directories in the database are
                // different to those on the file system.
                // TODO: Currently won't detect changes in directory names. Ideas to enable this
                //       as still be fast?
                if (originalResults.Count != dirInfos.Length)
                {
                    foreach (DirectoryInfo dir in dirInfos)
                    {
                        // Ignore thumbnail directories
                        if (!dir.Name.Equals(ThumbnailUtilities.ThumbnailDirectory))
                        {
                            string virtualPath = GetVirtualPath(token, dir.FullName);

                            // Do we have a PhotoDirectory for this directory already? If not then we need to
                            // add it to the database
                            if (!results.Contains(virtualPath))
                            {
                                string parentVirtualPath = virtualPath.Substring(0, virtualPath.Length - dir.Name.Length - 1);

                                PhotoDirectory photoDirectory = new PhotoDirectory(token, dir.Name, parentVirtualPath);

                                // insert this directory into the database
                                db.Insert(parent, photoDirectory);

                                results.Add(photoDirectory);
                            }

                            originalResults.Remove(virtualPath);
                        }
                    }

                    // Are there any PhotoDirectory objects in the original result set that aren't in
                    // the list of directories from the file system? If so, delete 'em
                    foreach (PhotoDirectory photoDirectory in originalResults)
                    {
                        db.Delete(photoDirectory);

                        PhotoDB photoDB = new PhotoDB(token.DBConnection);
                        photoDB.DeleteDirectoryPhotos(photoDirectory);

                        results.Remove(photoDirectory);
                    }
                }

                return(results);
            }
        }
Beispiel #13
0
 public void DeletePhoto(object sender, PhotoPackage photo)
 {
     PhotoDB.DeletePhoto(photo);
 }
 public ActionResult Delete()
 {
     return(RedirectToAction("DeleteConfirm", "Photos", new { toDelete = PhotoDB.GetIndex(model.selectedPhoto) }));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PhotoSql"/> class.
 /// </summary>
 public PhotoSql()
 {
     photoDb = new PhotoDB();
     photoDb.DbClient = new SqlServerClient();
 }