private void ApplyImageDecorations(ImageDecoratorInvocationSource source)
 {
     if (ImagePropertyChanged != null)
     {
         ImagePropertyChanged(this, new ImagePropertyEvent(ImagePropertyType.Decorators, this.ImageInfo, source));
     }
 }
Example #2
0
 /// <summary>
 /// Applies changes to an image by firing the ImagePropertyChanged event.
 /// </summary>
 private void ApplyImageDecorations(ImagePropertyType propertyType, ImageDecoratorInvocationSource source)
 {
     if (ImagePropertyChanged != null)
     {
         OnImagePropertyChanged(new ImagePropertyEvent(propertyType, ImagePropertiesInfo, source));
     }
 }
        /// <summary>
        /// Writes a set of images based on the settings specified in a ImagePropertiesInfo object.
        /// </summary>
        /// <param name="imageInfo">the image properties</param>
        /// <param name="allowEnlargement">if true, generated images will be scaled larger than the source image (if the imageInfo sizes are larger) </param>
        public void WriteImages(ImagePropertiesInfo imageInfo, bool allowEnlargement, ImageDecoratorInvocationSource invocationSource, CreateFileCallback inlineFileCreator, CreateFileCallback linkedFileCreator, IEditorOptions clientOptions)
        {
            string inlinePrefix = imageInfo.LinkTarget == LinkTargetType.IMAGE ? "_thumb" : "";

            ImageFilter inlineFilter = ImageFilterDecoratorAdapter.CreateImageDecoratorsFilter(imageInfo, ImageEmbedType.Embedded, invocationSource, clientOptions);
            ImageFilter targetFilter = ImageFilterDecoratorAdapter.CreateImageDecoratorsFilter(imageInfo, ImageEmbedType.Linked, invocationSource, clientOptions);

            using (Bitmap inlineBitmap = new Bitmap(imageInfo.ImageSourceUri.LocalPath))
            {
                string imgPath = writeImage(inlineBitmap, imageInfo.ImageSourceUri.LocalPath, inlinePrefix, inlineFilter, inlineFileCreator);
                string inlineImgPath = new Uri(UrlHelper.CreateUrlFromPath(imgPath)).ToString();
                imageInfo.InlineImageUrl = inlineImgPath;
            }

            //Generate the link image
            //Warning! this imageInfo.LinkTarget check must be done after the inline image because the resize
            //         decorator will set the default link target for the image the first time it
            //         is applied.
            //imageInfo.LinkTarget = origLinkTarget;
            if (imageInfo.LinkTarget == LinkTargetType.IMAGE && !ImageDecoratorDirective.ShouldSuppressLinked)
            {
                using (Bitmap targetBitmap = new Bitmap(imageInfo.ImageSourceUri.LocalPath))
                {
                    string anchorPath = writeImage(targetBitmap, imageInfo.ImageSourceUri.LocalPath, "", targetFilter, linkedFileCreator);
                    string targetUrl = new Uri(UrlHelper.CreateUrlFromPath(anchorPath)).ToString();
                    imageInfo.LinkTargetUrl = targetUrl;
                }
            }
        }
        public void UpdateInlineImageSize(Size newSize, ImageDecoratorInvocationSource invocationSource)
        {
            ImagePropertiesInfo imagePropertiesInfo = (this as IImagePropertyEditingContext).ImagePropertiesInfo;

            imagePropertiesInfo.InlineImageSize = newSize;
            ImagePropertyChanged(this, new ImagePropertyEvent(ImagePropertyType.InlineSize, imagePropertiesInfo, invocationSource));
            RefreshImage();
        }
Example #5
0
 private ImageFilterDecoratorAdapter(ImagePropertiesInfo imageInfo, ImageEmbedType embedType, ImageDecoratorInvocationSource invocationSource, IEditorOptions editorOptions)
 {
     _decoratorsList   = imageInfo.ImageDecorators;
     _imageInfo        = imageInfo;
     _embedType        = embedType;
     _invocationSource = invocationSource;
     _editorOptions    = editorOptions;
 }
 private ImageFilterDecoratorAdapter(ImagePropertiesInfo imageInfo, ImageEmbedType embedType, ImageDecoratorInvocationSource invocationSource, IEditorOptions editorOptions)
 {
     _decoratorsList = imageInfo.ImageDecorators;
     _imageInfo = imageInfo;
     _embedType = embedType;
     _invocationSource = invocationSource;
     _editorOptions = editorOptions;
 }
        public void UpdateInlineImageSize(Size newSize, ImageDecoratorInvocationSource invocationSource)
        {
            if (!Visible)
            {
                //refresh the ImagePropertiesInfo object since it doesn't get refreshed automatically when
                //the form is hidden.
                ImagePropertyHandler.RefreshView();
            }

            ImagePropertiesInfo.InlineImageSize = newSize;
            ImagePropertyChanged(this, new ImagePropertyEvent(ImagePropertyType.InlineSize, ImagePropertiesInfo, invocationSource));
            RefreshImage();
        }
Example #8
0
        internal static void UpdateImageSource(ImagePropertiesInfo imgProperties, IHTMLElement imgElement, IBlogPostImageEditingContext editorContext, ImageInsertHandler imageInsertHandler, ImageDecoratorInvocationSource invocationSource)
        {
            ISupportingFile oldImageFile = null;

            try
            {
                oldImageFile = editorContext.SupportingFileService.GetFileByUri(new Uri((string)imgElement.getAttribute("src", 2)));
            }
            catch (UriFormatException) { }
            if (oldImageFile != null) //then this is a known supporting image file
            {
                using (new WaitCursor())
                {
                    BlogPostImageData imageData = BlogPostImageDataList.LookupImageDataByInlineUri(editorContext.ImageList, oldImageFile.FileUri);
                    if (imageData != null)
                    {
                        //Create a new ImageData object based on the image data attached to the current image src file.
                        BlogPostImageData newImageData = (BlogPostImageData)imageData.Clone();

                        //initialize some handlers for creating files based on the image's existing ISupportingFile objects
                        //This is necessary so that the new image files are recognized as being updates to an existing image
                        //which allows the updates to be re-uploaded back to the same location.
                        CreateImageFileHandler inlineFileCreator = new CreateImageFileHandler(editorContext.SupportingFileService,
                                                                                              newImageData.InlineImageFile != null ? newImageData.InlineImageFile.SupportingFile : null);
                        CreateImageFileHandler linkedFileCreator = new CreateImageFileHandler(editorContext.SupportingFileService,
                                                                                              newImageData.LinkedImageFile != null ? newImageData.LinkedImageFile.SupportingFile : null);

                        //re-write the image files on disk using the latest settings
                        imageInsertHandler.WriteImages(imgProperties, true, invocationSource, new CreateFileCallback(inlineFileCreator.CreateFileCallback), new CreateFileCallback(linkedFileCreator.CreateFileCallback), editorContext.EditorOptions);

                        //update the ImageData file references
                        Size imageSizeWithBorder = imgProperties.InlineImageSizeWithBorder;

                        //force a refresh of the image size values in the DOM by setting the new size attributes
                        imgElement.setAttribute("width", imageSizeWithBorder.Width, 0);
                        imgElement.setAttribute("height", imageSizeWithBorder.Height, 0);

                        newImageData.InlineImageFile.SupportingFile = inlineFileCreator.ImageSupportingFile;
                        newImageData.InlineImageFile.Height         = imageSizeWithBorder.Height;
                        newImageData.InlineImageFile.Width          = imageSizeWithBorder.Width;
                        if (imgProperties.LinkTarget == LinkTargetType.IMAGE)
                        {
                            newImageData.LinkedImageFile = new ImageFileData(linkedFileCreator.ImageSupportingFile, imgProperties.LinkTargetImageSize.Width, imgProperties.LinkTargetImageSize.Height, ImageFileRelationship.Linked);
                        }
                        else
                        {
                            newImageData.LinkedImageFile = null;
                        }

                        //assign the image decorators applied during WriteImages
                        //Note: this is a clone so the sidebar doesn't affect the decorator values for the newImageData image src file
                        newImageData.ImageDecoratorSettings = (BlogPostSettingsBag)imgProperties.ImageDecorators.SettingsBag.Clone();

                        //update the upload settings
                        newImageData.UploadInfo.ImageServiceId = imgProperties.UploadServiceId;

                        //save the new image data in the image list
                        editorContext.ImageList.AddImage(newImageData);
                    }
                    else
                    {
                        Debug.Fail("imageData could not be located");
                    }
                }
            }

            if (imgProperties.LinkTarget == LinkTargetType.NONE)
            {
                imgProperties.RemoveLinkTarget();
            }
        }
Example #9
0
 private void UpdateImageSource(ImagePropertiesInfo imgProperties, ImageDecoratorInvocationSource invocationSource)
 {
     UpdateImageSource(imgProperties, ImgElement, _editorContext, _imageInsertHandler, invocationSource);
 }
 public ImagePropertyEvent(ImagePropertyType propertyType, ImagePropertiesInfo imgProperties, ImageDecoratorInvocationSource invocationSource)
 {
     PropertyType = propertyType;
     _imageProperties = imgProperties;
     InvocationSource = invocationSource;
 }
 public void UpdateInlineImageSize(Size newSize, ImageDecoratorInvocationSource invocationSource, HtmlEditorControl currentEditor)
 {
     ImagePropertiesInfo.InlineImageSize = newSize;
     ApplyImageDecorations(ImagePropertyType.InlineSize, invocationSource);
 }
        public void UpdateInlineImageSize(Size newSize, ImageDecoratorInvocationSource invocationSource)
        {
            if(!Visible)
            {
                //refresh the ImagePropertiesInfo object since it doesn't get refreshed automatically when
                //the form is hidden.
                ImagePropertyHandler.RefreshView();
            }

            ImagePropertiesInfo.InlineImageSize = newSize;
            ImagePropertyChanged(this, new ImagePropertyEvent(ImagePropertyType.InlineSize, ImagePropertiesInfo, invocationSource));
            RefreshImage();
        }
Example #13
0
 public void UpdateInlineImageSize(Size newSize, ImageDecoratorInvocationSource invocationSource, HtmlEditorControl currentEditor)
 {
     ImagePropertiesInfo.InlineImageSize = newSize;
     ApplyImageDecorations(ImagePropertyType.InlineSize, invocationSource);
 }
Example #14
0
        /// <summary>
        /// Writes a set of images based on the settings specified in a ImagePropertiesInfo object.
        /// </summary>
        /// <param name="imageInfo">the image properties</param>
        /// <param name="allowEnlargement">if true, generated images will be scaled larger than the source image (if the imageInfo sizes are larger) </param>
        public void WriteImages(ImagePropertiesInfo imageInfo, bool allowEnlargement, ImageDecoratorInvocationSource invocationSource, CreateFileCallback inlineFileCreator, CreateFileCallback linkedFileCreator, IEditorOptions clientOptions)
        {
            string inlinePrefix = imageInfo.LinkTarget == LinkTargetType.IMAGE ? "_thumb" : "";

            ImageFilter inlineFilter = ImageFilterDecoratorAdapter.CreateImageDecoratorsFilter(imageInfo, ImageEmbedType.Embedded, invocationSource, clientOptions);
            ImageFilter targetFilter = ImageFilterDecoratorAdapter.CreateImageDecoratorsFilter(imageInfo, ImageEmbedType.Linked, invocationSource, clientOptions);

            using (Bitmap inlineBitmap = new Bitmap(imageInfo.ImageSourceUri.LocalPath))
            {
                string imgPath       = writeImage(inlineBitmap, imageInfo.ImageSourceUri.LocalPath, inlinePrefix, inlineFilter, inlineFileCreator);
                string inlineImgPath = new Uri(UrlHelper.CreateUrlFromPath(imgPath)).ToString();
                imageInfo.InlineImageUrl = inlineImgPath;
            }

            //Generate the link image
            //Warning! this imageInfo.LinkTarget check must be done after the inline image because the resize
            //         decorator will set the default link target for the image the first time it
            //         is applied.
            //imageInfo.LinkTarget = origLinkTarget;
            if (imageInfo.LinkTarget == LinkTargetType.IMAGE && !ImageDecoratorDirective.ShouldSuppressLinked)
            {
                using (Bitmap targetBitmap = new Bitmap(imageInfo.ImageSourceUri.LocalPath))
                {
                    string anchorPath = writeImage(targetBitmap, imageInfo.ImageSourceUri.LocalPath, "", targetFilter, linkedFileCreator);
                    string targetUrl  = new Uri(UrlHelper.CreateUrlFromPath(anchorPath)).ToString();
                    imageInfo.LinkTargetUrl = targetUrl;
                }
            }
        }
 public static ImageFilter CreateImageDecoratorsFilter(ImagePropertiesInfo imageInfo, ImageEmbedType embedType, ImageDecoratorInvocationSource invocationSource, IEditorOptions editorOptions)
 {
     return new ImageFilter(new ImageFilterDecoratorAdapter(imageInfo, embedType, invocationSource, editorOptions).ApplyImageDecorators);
 }
 public void UpdateInlineImageSize(Size newSize, ImageDecoratorInvocationSource invocationSource)
 {
     ImagePropertiesInfo imagePropertiesInfo = (this as IImagePropertyEditingContext).ImagePropertiesInfo ;
     imagePropertiesInfo.InlineImageSize = newSize;
     ImagePropertyChanged(this, new ImagePropertyEvent(ImagePropertyType.InlineSize, imagePropertiesInfo, invocationSource));
     RefreshImage();
 }
Example #17
0
 public HtmlAlignDecoratorSettings(IProperties settings, IHTMLElement element, ImageDecoratorInvocationSource invocationSource)
 {
     _element          = element;
     Settings          = settings;
     _invocationSource = invocationSource;
 }
 private void ApplyImageDecorations(ImageDecoratorInvocationSource source)
 {
     if(ImagePropertyChanged != null)
     {
         ImagePropertyChanged(this, new ImagePropertyEvent(ImagePropertyType.Decorators, this.ImageInfo, source));
     }
 }
        public void UpdateImageLink(string newLink, string title, bool newWindow, string rel, ImageDecoratorInvocationSource invocationSource)
        {
            if (newLink == String.Empty)
            {
                ImagePropertiesInfo.LinkTarget = LinkTargetType.NONE;
            }
            else
            {
                if ((ImagePropertiesInfo.LinkTarget != LinkTargetType.IMAGE) || (ImagePropertiesInfo.LinkTargetUrl != newLink))
                {
                    ImagePropertiesInfo.LinkTarget = LinkTargetType.URL;
                    ImagePropertiesInfo.LinkTargetUrl = newLink;
                }
                ImagePropertiesInfo.UpdateImageLinkOptions(title, rel, newWindow);
            }

            ApplyImageDecorations(ImagePropertyType.Decorators, invocationSource);
        }
Example #20
0
 public ImagePropertyEvent(ImagePropertyType propertyType, ImagePropertiesInfo imgProperties, ImageDecoratorInvocationSource invocationSource)
 {
     PropertyType     = propertyType;
     _imageProperties = imgProperties;
     InvocationSource = invocationSource;
 }
 public HtmlAlignDecoratorSettings(IProperties settings, IHTMLElement element, ImageDecoratorInvocationSource invocationSource)
 {
     _element = element;
     Settings = settings;
     _invocationSource = invocationSource;
 }
Example #22
0
 public static ImageFilter CreateImageDecoratorsFilter(ImagePropertiesInfo imageInfo, ImageEmbedType embedType, ImageDecoratorInvocationSource invocationSource, IEditorOptions editorOptions)
 {
     return(new ImageFilter(new ImageFilterDecoratorAdapter(imageInfo, embedType, invocationSource, editorOptions).ApplyImageDecorators));
 }
Example #23
0
        public void UpdateImageLink(string newLink, string title, bool newWindow, string rel, ImageDecoratorInvocationSource invocationSource)
        {
            if (newLink == String.Empty)
            {
                ImagePropertiesInfo.LinkTarget = LinkTargetType.NONE;
            }
            else
            {
                if ((ImagePropertiesInfo.LinkTarget != LinkTargetType.IMAGE) || (ImagePropertiesInfo.LinkTargetUrl != newLink))
                {
                    ImagePropertiesInfo.LinkTarget    = LinkTargetType.URL;
                    ImagePropertiesInfo.LinkTargetUrl = newLink;
                }
                ImagePropertiesInfo.UpdateImageLinkOptions(title, rel, newWindow);
            }

            ApplyImageDecorations(ImagePropertyType.Decorators, invocationSource);
        }
        internal static void UpdateImageSource(ImagePropertiesInfo imgProperties, IHTMLElement imgElement, IBlogPostImageEditingContext editorContext, ImageInsertHandler imageInsertHandler, ImageDecoratorInvocationSource invocationSource)
        {
            ISupportingFile oldImageFile = null;
            try
            {
                oldImageFile = editorContext.SupportingFileService.GetFileByUri(new Uri((string)imgElement.getAttribute("src", 2)));
            }
            catch (UriFormatException) { }
            if (oldImageFile != null) //then this is a known supporting image file
            {
                using (new WaitCursor())
                {
                    BlogPostImageData imageData = BlogPostImageDataList.LookupImageDataByInlineUri(editorContext.ImageList, oldImageFile.FileUri);
                    if (imageData != null)
                    {
                        //Create a new ImageData object based on the image data attached to the current image src file.
                        BlogPostImageData newImageData = (BlogPostImageData)imageData.Clone();

                        //initialize some handlers for creating files based on the image's existing ISupportingFile objects
                        //This is necessary so that the new image files are recognized as being updates to an existing image
                        //which allows the updates to be re-uploaded back to the same location.
                        CreateImageFileHandler inlineFileCreator = new CreateImageFileHandler(editorContext.SupportingFileService,
                                                                                              newImageData.InlineImageFile != null ? newImageData.InlineImageFile.SupportingFile : null);
                        CreateImageFileHandler linkedFileCreator = new CreateImageFileHandler(editorContext.SupportingFileService,
                                                                                              newImageData.LinkedImageFile != null ? newImageData.LinkedImageFile.SupportingFile : null);

                        //re-write the image files on disk using the latest settings
                        imageInsertHandler.WriteImages(imgProperties, true, invocationSource, new CreateFileCallback(inlineFileCreator.CreateFileCallback), new CreateFileCallback(linkedFileCreator.CreateFileCallback), editorContext.EditorOptions);

                        //update the ImageData file references
                        Size imageSizeWithBorder = imgProperties.InlineImageSizeWithBorder;

                        //force a refresh of the image size values in the DOM by setting the new size attributes
                        imgElement.setAttribute("width", imageSizeWithBorder.Width, 0);
                        imgElement.setAttribute("height", imageSizeWithBorder.Height, 0);

                        newImageData.InlineImageFile.SupportingFile = inlineFileCreator.ImageSupportingFile;
                        newImageData.InlineImageFile.Height = imageSizeWithBorder.Height;
                        newImageData.InlineImageFile.Width = imageSizeWithBorder.Width;
                        if (imgProperties.LinkTarget == LinkTargetType.IMAGE)
                        {
                            newImageData.LinkedImageFile = new ImageFileData(linkedFileCreator.ImageSupportingFile, imgProperties.LinkTargetImageSize.Width, imgProperties.LinkTargetImageSize.Height, ImageFileRelationship.Linked);
                        }
                        else
                            newImageData.LinkedImageFile = null;

                        //assign the image decorators applied during WriteImages
                        //Note: this is a clone so the sidebar doesn't affect the decorator values for the newImageData image src file
                        newImageData.ImageDecoratorSettings = (BlogPostSettingsBag)imgProperties.ImageDecorators.SettingsBag.Clone();

                        //update the upload settings
                        newImageData.UploadInfo.ImageServiceId = imgProperties.UploadServiceId;

                        //save the new image data in the image list
                        editorContext.ImageList.AddImage(newImageData);
                    }
                    else
                        Debug.Fail("imageData could not be located");
                }
            }

            if (imgProperties.LinkTarget == LinkTargetType.NONE)
            {
                imgProperties.RemoveLinkTarget();
            }
        }
 private void UpdateImageSource(ImagePropertiesInfo imgProperties, ImageDecoratorInvocationSource invocationSource)
 {
     UpdateImageSource(imgProperties, ImgElement, _editorContext, _imageInsertHandler, invocationSource);
 }
 /// <summary>
 /// Applies changes to an image by firing the ImagePropertyChanged event.
 /// </summary>
 private void ApplyImageDecorations(ImagePropertyType propertyType, ImageDecoratorInvocationSource source)
 {
     if (ImagePropertyChanged != null)
         OnImagePropertyChanged(new ImagePropertyEvent(propertyType, ImagePropertiesInfo, source));
 }