public void ApplyStyle(ImageItem source, Slide contentSlide, float slideWidth, float slideHeight, StyleOptions option = null) { if (Globals.ThisAddIn != null) { Globals.ThisAddIn.Application.StartNewUndoEntry(); } if (option != null) { SetStyleOptions(option); } // try to use cropped/adjusted image to apply var fullsizeImage = source.FullSizeImageFile; source.FullSizeImageFile = source.CroppedImageFile ?? source.FullSizeImageFile; source.OriginalImageFile = fullsizeImage; var effectsHandler = new EffectsDesigner(contentSlide, slideWidth, slideHeight, source); ApplyStyle(effectsHandler, source, isActualSize: true); source.FullSizeImageFile = fullsizeImage; source.OriginalImageFile = null; }
public void Init() { _contentSlide = PpOperations.SelectSlide(1); _processingSlide = PpOperations.SelectSlide(2); _imgItem = new ImageItem { ImageFile = Img, Tooltip = "some tooltips" }; _designer = EffectsDesigner.CreateEffectsDesignerForApply(_contentSlide, Pres.PageSetup.SlideWidth, Pres.PageSetup.SlideHeight, _imgItem); }
public void TestInsertImageReference() { // constructor for producing preview image var ed = new EffectsDesigner( _processingSlide, _contentSlide, Pres.PageSetup.SlideWidth, Pres.PageSetup.SlideHeight, new ImageItem { ImageFile = "some images", Tooltip = "some tooltips" }); ed.ApplyImageReference(Link); Assert.IsTrue( PpOperations.GetNotesPageText(_processingSlide) .Contains(Link)); ed.ApplyImageReferenceInsertion(Link, "Calibri", "#000000"); var refShape = PpOperations.SelectShapesByPrefix( EffectsDesigner.ShapeNamePrefix + "_" + EffectName.ImageReference); Assert.IsTrue( refShape.TextFrame2.TextRange.Text.Contains(Link)); }
/// <summary> /// process how to handle a style based on the given source and style option /// </summary> /// <param name="designer"></param> /// <param name="source"></param> /// <param name="isActualSize"></param> private void ApplyStyle(EffectsDesigner designer, ImageItem source, bool isActualSize) { Shape imageShape; if (Option.IsUseSpecialEffectStyle) { imageShape = designer.ApplySpecialEffectEffect(Option.GetSpecialEffect(), isActualSize); } else // non-special-effect style, e.g. direct text style { imageShape = designer.ApplyBackgroundEffect(); } var resultShapes = new List<Shape>(); foreach (var styleWorker in WorkerFactory.StyleWorkers) { resultShapes.AddRange( styleWorker.Execute(Option, designer, source, imageShape)); } // Those workers executed at the beginning will have the output // put at the back. resultShapes.Reverse(); SendToBack(resultShapes.ToArray()); imageShape.ZOrder(MsoZOrderCmd.msoSendToBack); }
/// <summary> /// process how to handle a style based on the given source and style option /// </summary> /// <param name="designer"></param> /// <param name="source"></param> /// <param name="isActualSize"></param> private void ApplyStyle(EffectsDesigner designer, ImageItem source, bool isActualSize) { if (Options.IsUseBannerStyle && (Options.TextBoxPosition == 4/*left*/ || Options.TextBoxPosition == 5/*centered*/ || Options.TextBoxPosition == 6/*right*/)) { designer.ApplyTextWrapping(); } else if (Options.IsUseCircleStyle || Options.IsUseOutlineStyle) { designer.ApplyTextWrapping(); } else { designer.RecoverTextWrapping(); } ApplyTextEffect(designer); // store style options information into original image shape // return original image and cropped image var metaImages = designer.EmbedStyleOptionsInformation( source.OriginalImageFile, source.FullSizeImageFile, source.ContextLink, source.Rect, Options); Shape originalImage = null; Shape croppedImage = null; if (metaImages.Count == 2) { originalImage = metaImages[0]; croppedImage = metaImages[1]; } Shape imageShape; if (Options.IsUseSpecialEffectStyle) { imageShape = designer.ApplySpecialEffectEffect(Options.GetSpecialEffect(), isActualSize, Options.ImageOffset); } else // Direct Text style { imageShape = designer.ApplyBackgroundEffect(Options.ImageOffset); } Shape backgroundOverlayShape = null; if (Options.IsUseOverlayStyle) { backgroundOverlayShape = designer.ApplyOverlayEffect(Options.OverlayColor, Options.Transparency); } Shape blurImageShape = null; if (Options.IsUseBlurStyle) { blurImageShape = Options.IsUseSpecialEffectStyle ? designer.ApplyBlurEffect(source.SpecialEffectImageFile, Options.BlurDegree, Options.ImageOffset) : designer.ApplyBlurEffect(degree: Options.BlurDegree, offset: Options.ImageOffset); } Shape bannerOverlayShape = null; if (Options.IsUseBannerStyle) { bannerOverlayShape = ApplyBannerStyle(designer, imageShape); } if (Options.IsUseTextBoxStyle) { designer.ApplyTextboxEffect(Options.TextBoxColor, Options.TextBoxTransparency); } Shape outlineOverlayShape = null; if (Options.IsUseOutlineStyle) { outlineOverlayShape = designer.ApplyRectOutlineEffect(imageShape, Options.FontColor, 0); } Shape frameOverlayShape = null; if (Options.IsUseFrameStyle) { frameOverlayShape = designer.ApplyAlbumFrameEffect(Options.FrameColor, Options.FrameTransparency); } Shape circleOverlayShape = null; if (Options.IsUseCircleStyle) { circleOverlayShape = designer.ApplyCircleRingsEffect(Options.CircleColor, Options.CircleTransparency); } Shape triangleOverlayShape = null; if (Options.IsUseTriangleStyle) { triangleOverlayShape = designer.ApplyTriangleEffect(Options.TriangleColor, Options.FontColor, Options.TriangleTransparency); } SendToBack( triangleOverlayShape, circleOverlayShape, frameOverlayShape, outlineOverlayShape, bannerOverlayShape, backgroundOverlayShape, blurImageShape, imageShape, croppedImage, originalImage); designer.ApplyImageReference(source.ContextLink); if (Options.IsInsertReference) { designer.ApplyImageReferenceInsertion(source.ContextLink, Options.GetFontFamily(), Options.FontColor); } }
private void ApplyTextEffect(EffectsDesigner effectsDesigner) { if (Options.IsUseTextFormat) { effectsDesigner.ApplyTextEffect(Options.GetFontFamily(), Options.FontColor, Options.FontSizeIncrease); effectsDesigner.ApplyTextPositionAndAlignment(Options.GetTextBoxPosition(), Options.GetTextBoxAlignment()); } else { effectsDesigner.ApplyOriginalTextEffect(); effectsDesigner.ApplyTextPositionAndAlignment(Position.Original, Alignment.Auto); } }
private Shape ApplyBannerStyle(EffectsDesigner effectsDesigner, Shape imageShape) { return effectsDesigner.ApplyRectBannerEffect(Options.GetBannerDirection(), Options.GetTextBoxPosition(), imageShape, Options.BannerColor, Options.BannerTransparency); }
public void ApplyStyle(ImageItem source, Slide contentSlide, float slideWidth, float slideHeight, StyleOption option = null) { if (option != null) { SetStyleOptions(option); } // try to use cropped/adjusted image to apply source.BackupFullSizeImageFile = source.FullSizeImageFile; source.FullSizeImageFile = source.CroppedImageFile ?? source.FullSizeImageFile; var effectsHandler = new EffectsDesigner(contentSlide, slideWidth, slideHeight, source); GenerateStyle(effectsHandler, source, isActualSize: true); // recover the source back source.FullSizeImageFile = source.BackupFullSizeImageFile; }