/// By: Ryan Moe /// Edited Julian Nguyen /// <summary> /// THIS IS THREADED, call this instead of multiple calls to addnewPicture to /// prevent gui lockup. Adds multiple new photos to the databases and moves /// a copy of the picture to the library. Also writes all these changes to the disk /// </summary> /// <param name="guiCallback"></param> /// <param name="imageUserPath">List of photo paths on the disk</param> /// <param name="imageExtension">List of photo extensions</param> /// <param name="albumUID">The Album UID.</param> /// <param name="inAlbumImageName">NOTE: you can pass in NULL for the list for all default names, or you can have "" for a single element for a single default name.</param> /// <param name="updateCallback">The callback for the thread to send progress updates to.</param> /// <param name="updateAmount">The number of pictures to add BEFORE sending a progress update</param> public void addNewImages(addNewPictures_callback guiCallback, List<String> imageUserPath, List<String> imageExtension, Guid albumUID, List<String> inAlbumImageName, ProgressChangedEventHandler updateCallback, int updateAmount) { //TODO: JN: passing in a data class? _photoBombDatabase.addNewImages_backend(guiCallback, imageUserPath, imageExtension, albumUID, inAlbumImageName, updateCallback, updateAmount); }
/// By Julian Nguyen /// Edited: Julian Nguyen(5/7/13) /// <summary> /// This will take an image and grayscale it and then add it to the Database. /// </summary> /// <param name="guiCallback">The call back to the gui.</param> /// <param name="albumUID">The uid of the album.</param> /// <param name="imagePath">The path to the image.</param> public void addImageAsGrayscale(addNewPictures_callback guiCallback, Guid albumUID, String imagePath) { String pathOfnewGray = String.Empty; try { // Load the image into memory. Bitmap image = _imageManipulation.LoadImageNoLock(imagePath); // Grayscale the image in memory. Bitmap newGray = _imageManipulation.makeGrayscale(image); // Get a path for the image. pathOfnewGray = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".jpg"); // Save the image. newGray.Save(pathOfnewGray); } catch (Exception) { ErrorReport err = new ErrorReport(); err.reportStatus = ReportStatus.FAILURE; guiCallback(err, albumUID); } ErrorReport errReport = null; try { errReport = _photoBombDatabase.addNewImage(pathOfnewGray, ".jpg", albumUID); } catch { errReport = new ErrorReport(); errReport.reportStatus = ReportStatus.FAILURE; } try { File.Delete(pathOfnewGray); } catch { } guiCallback(errReport, albumUID); }
/************************************************************************************************************************** * Author: Alejandro Sosa **************************************************************************************************************************/ public void guiConvertToGreyscale(addNewPictures_callback guiGrayscaleCallback, ComplexPhotoData desiredImage, Guid albumGuid) { masterAndCommander.addImageAsGrayscale(guiGrayscaleCallback, albumGuid, desiredImage.fullPath); }
//By: Bill Sanders //Edited Last By: //Edited Last Date: 4/7/13 /// <summary> /// Adds a photo that already exists in one album to another album /// </summary> /// <param name="guiCallback"></param> /// <param name="photoList">A ComplexPhotoData object which contains all the information about a photo</param> /// <param name="albumUID">The unique ID of the album to copy the photo into</param> public void addExistingImagesToAlbum(addNewPictures_callback guiCallback, List<ComplexPhotoData> photoList, Guid albumUID) { ErrorReport errReport = null; errReport = _photoBombDatabase.addExistingImagesToAlbum_backend(photoList, albumUID); guiCallback(errReport, albumUID); }
/// By Ryan Moe /// Edited: Julian Nguyen(4/28/13) /// <summary> /// /// </summary> /// <param name="guiCallback"></param> /// <param name="photoUserPath"></param> /// <param name="photoExtension"></param> /// <param name="albumUID"></param> /// <param name="pictureNameInAlbum"></param> /// <param name="updateCallback"></param> /// <param name="updateAmount"></param> public void addNewImages_backend(addNewPictures_callback guiCallback, List<String> photoUserPath, List<String> photoExtension, Guid albumUID, List<String> pictureNameInAlbum, ProgressChangedEventHandler updateCallback, int updateAmount) { _addPhotosThread = new BackgroundWorker(); //transfer parameters into a data class to pass //into the photo thread. addPhotosThreadData data = new addPhotosThreadData(); data.errorReport = new ErrorReport(); data.guiCallback = guiCallback; data.photoUserPath = photoUserPath; data.photoExtension = photoExtension; data.albumUID = albumUID; data.pictureNameInAlbum = pictureNameInAlbum; data.updateAmount = updateAmount; //data.photoCollection = _photosCollection; //setup the worker. _addPhotosThread.WorkerReportsProgress = true; _addPhotosThread.WorkerSupportsCancellation = true; _addPhotosThread.DoWork += new DoWorkEventHandler(addPhotosThread_DoWork); _addPhotosThread.ProgressChanged += updateCallback; _addPhotosThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(addPhotosThread_RunWorkerCompleted); _addPhotosThread.RunWorkerAsync(data); }