コード例 #1
0
        /// <summary>
        /// Delete all specified photos.
        /// </summary>
        /// <param name="toDeleteList">Photo to delete.</param>
        /// <returns>Number of deleted photos.</returns>
        public static int DeletePhotos(List <Photo> toDeleteList)
        {
            PhotosDataSource db = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString());

            List <int> ids = new List <int>();

            foreach (Photo p in toDeleteList)
            {
                ids.Add(p.ID);
            }

            return(db.DeletePhotos(ids));
        }
コード例 #2
0
        /// <summary>
        /// Adds the photo.
        /// </summary>
        public static void AddPhoto()
        {
            string thumbnailPath    = ConfigurationManager.AppSettings["thumbnailDirectory"].ToString();
            string connectionString = ConnectionStringHelper.GetActualConnectionString();

            OpenFileDialog openImage = new OpenFileDialog();

            openImage.Filter = "Pliki obrazów (*.jpg, *.png, *.crt, *.tiff)|*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.crt;*.CRT;*.tiff;*.TIFF|Wszystkie pliki (*.*)|*.*";
            openImage.ShowDialog();

            if (openImage.CheckFileExists && !string.IsNullOrWhiteSpace(openImage.FileName))
            {
                string openedImageName = openImage.FileName;
                string fileName        = Path.GetFileName(openedImageName);
                string filePath        = openedImageName.Substring(0, openedImageName.Length - fileName.Length);
                string newFilePath     = ChangePath(filePath);

                Bitmap image = AForge.Imaging.Image.FromFile(openedImageName);

                int[] thumbnailSizes = GetThumbnailSize(image.Width, image.Height);

                int thumbnailWidth  = thumbnailSizes[0];
                int thumbnailHeight = thumbnailSizes[1];

                AForge.Imaging.Filters.ResizeBicubic filter = new AForge.Imaging.Filters.ResizeBicubic(thumbnailWidth, thumbnailHeight);
                Bitmap thumbnail = filter.Apply(image);

                string thumbnailFileName  = LookForFreeFilename(thumbnailPath, fileName);
                string thumbnailSavedPath = Path.Combine(thumbnailPath, thumbnailFileName);

                thumbnail.Save(thumbnailSavedPath);
                newFilePath = newFilePath + fileName;

                PhotosDataSource db          = new PhotosDataSource(connectionString);
                Photo            photoObject = new Photo();

                photoObject.FilePath      = newFilePath;
                photoObject.ThumbnailPath = thumbnailSavedPath;

                photoObject.Title       = fileName;
                photoObject.Description = string.Empty;

                photoObject.Archive   = null;
                photoObject.Attribute = null;

                db.AddPhoto(photoObject);
            }
        }
コード例 #3
0
        /// <summary>
        /// Get one photo.
        /// </summary>
        /// <param name="id">Photo ID.</param>
        /// <returns>One photo.</returns>
        public static Photo GetPhoto(int id)
        {
            PhotosDataSource db = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString());

            return(db.GetPhoto(id));
        }
コード例 #4
0
        /// <summary>
        /// Gets all tags for photo.
        /// </summary>
        /// <param name="photoID">Photo id.</param>
        /// <returns>Tag list.</returns>
        public static List <Tag> GetPhotosTags(int photoID)
        {
            PhotosDataSource photos = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString());

            return(photos.GetPhoto(photoID).Tags);
        }
コード例 #5
0
        /// <summary>
        /// Gets all photos.
        /// </summary>
        /// <returns>Photos list.</returns>
        public static List <Photo> GetAllPhotos()
        {
            PhotosDataSource db = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString());

            return(db.GetAllPhotos());
        }
コード例 #6
0
        /// <summary>
        /// Delete selected Photo.
        /// </summary>
        /// <param name="toDelete">Photo to delete.</param>
        /// <returns>Deleting photo operation state.</returns>
        public static bool DeletePhoto(Photo toDelete)
        {
            PhotosDataSource db = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString());

            return(db.DeletePhoto(toDelete.ID));
        }