static void watcher_ImagesUploaded(object Sender, ImageUploadEventArgs args) { DateTime time = args.Images[0].CaptureTime; string msg = string.Format("camID={0} count={1} time={2}", args.CameraID, args.Images.Length, time); System.Diagnostics.Debug.WriteLine(msg); }
protected void ProcessUploadSuccess() { string sourceImageClientFileName = this._SourceImageClientFileName; if (this.HasImage) { // Unload the current image this.UnloadImage(false); } // Delete old files if (File.Exists(this.TemporarySourceImageFilePath)) { File.Delete(this.TemporarySourceImageFilePath); } if (this._ImageUploadPreProcessingFilter == null) { // Just copy the source image File.Copy(this.UploadFilePath, this.TemporarySourceImageFilePath, true); } try { if (this._ImageUploadPreProcessingFilter != null) { // Pre-process the just uploaded image using (LoadedImage sourceImage = ImageArchiver.LoadImage(this.UploadFilePath)) { // Use PNG to preserve transparency FormatEncoderParams format = new PngFormatEncoderParams(); using (System.Drawing.Image tempImage = this._ImageUploadPreProcessingFilter.GetProcessedImage(sourceImage, sourceImage.Resolution, format)) { ImageArchiver.SaveImageToFileSystem(tempImage, this.TemporarySourceImageFilePath, format); // Optimization: save server resources... this.popupPictureTrimmer1.SetLoadImageData_ImageSize(tempImage.Size); this.popupPictureTrimmer1.SetLoadImageData_ImageResolution(sourceImage.Resolution); this.popupPictureTrimmer1.SetLoadImageData_ImageFormatId(sourceImage.FormatId); } } } // Load the image in the PictureTrimmer control this.popupPictureTrimmer1.LoadImageFromFileSystem(this.TemporarySourceImageFilePath, this._OutputResolution, this.CropConstraint); } catch (InvalidImageSizeException ex) { // Invalid image size ex.ToString(); // Display the invalid image size message this.SetCurrentStatusMessage(this.StatusMessage_InvalidImageSize, true); // EVENT: Upload error (invalid image size) this.OnUploadError(EventArgs.Empty); } catch { // Invalid image // Display the invalid image message this.SetCurrentStatusMessage(this.StatusMessage_InvalidImage, true); // EVENT: Upload error (invalid image) this.OnUploadError(EventArgs.Empty); } if (this.HasImage) { // Restore the source image client file name (changed in the UnloadImage method) this._SourceImageClientFileName = sourceImageClientFileName; // The new image has been uploaded this._ImageUploaded = true; this._ImageEdited = false; // Update the preview this._UpdatePreview = true; if (this.ImageUpload != null) { // EVENT: Image upload string pictureTrimmerTID = this.popupPictureTrimmer1.TemporaryFileId; ImageUploadEventArgs args = new ImageUploadEventArgs(this._OutputResolution, this.CropConstraint, this.PostProcessingFilter, this.PreviewFilter); this.OnImageUpload(args); if (this.HasImage) { if (this.popupPictureTrimmer1.TemporaryFileId != pictureTrimmerTID) { // The image has been reloeaded outside the control if (this.AutoOpenImageEditPopupAfterUpload) { // Open the image edit popup if necessary this.OpenImageEditPopup(); } // Exit !!! return; } } else { // The image has been unloaded, exit. return; } bool reloadImage = false; if (args.OutputResolutionChanged) { this._OutputResolution = args.OutputResolution; reloadImage = true; } if (args.CropConstraintChanged) { this._CropConstraint = args.CropConstraint; reloadImage = true; } if (args.PostProcessingFilterChanged) { this._PostProcessingFilter = args.PostProcessingFilter; // No need to reload if only the post processing filter has changed // AND - the updatePreview is surely already TRUE } if (args.PreviewFilterChanged) { this._PreviewFilter = args.PreviewFilter; // No need to reload if only the preview filter has changed // AND - the updatePreview is surely already TRUE } if (args.ReloadImageSet) { // Forced to reload the source image reloadImage = true; } if (reloadImage) { // Reload the image if (!args.ReloadImageSet) { // Standard reload, use the current source image size, resolutaion and format to save memory this.popupPictureTrimmer1.SetLoadImageData_ImageSize(this.SourceImageSize); this.popupPictureTrimmer1.SetLoadImageData_ImageResolution(this.SourceImageResolution); this.popupPictureTrimmer1.SetLoadImageData_ImageFormatId(this.SourceImageFormatId); } this.popupPictureTrimmer1.LoadImageFromFileSystem(this.TemporarySourceImageFilePath, this._OutputResolution, this.CropConstraint); } } // Invoke the OpenImageEditPopup after the event, so the eventhandler may change // the AutoOpenImageEditPopupAfterUpload property if (this.AutoOpenImageEditPopupAfterUpload) { // Open the image edit popup this.OpenImageEditPopup(); } } }
protected void OnImageUpload(ImageUploadEventArgs e) { if (this.ImageUpload != null) { this.ImageUpload(this, e); } }