public Shape ApplyFrostedGlassBannerEffect(BannerDirection direction, Position textPos, Shape blurImage, string overlayColor, int transparency) { TextBoxInfo tbInfo = new TextBoxes(Shapes.Range(), SlideWidth, SlideHeight) .GetTextBoxesInfo(); if (tbInfo == null) { return(null); } TextBoxes.AddMargin(tbInfo); Shape overlayShape; Shape blurBanner = blurImage.Duplicate()[1]; blurBanner.Left = blurImage.Left; blurBanner.Top = blurImage.Top; direction = HandleAutoDirection(direction, textPos); switch (direction) { case BannerDirection.Horizontal: overlayShape = ApplyOverlayEffect(overlayColor, transparency, 0, tbInfo.Top, SlideWidth, tbInfo.Height); CropPicture(blurBanner, 0, tbInfo.Top, SlideWidth, tbInfo.Height); break; // case BannerDirection.Vertical: default: overlayShape = ApplyOverlayEffect(overlayColor, transparency, tbInfo.Left, 0, tbInfo.Width, SlideHeight); CropPicture(blurBanner, tbInfo.Left, 0, tbInfo.Width, SlideHeight); break; } ChangeName(overlayShape, EffectName.Banner); ChangeName(blurBanner, EffectName.Banner); overlayShape.ZOrder(MsoZOrderCmd.msoSendToBack); Utils.ShapeUtil.MoveZToJustBehind(blurBanner, overlayShape); Microsoft.Office.Interop.PowerPoint.ShapeRange range = Shapes.Range(new[] { blurBanner.Name, overlayShape.Name }); Shape resultShape = range.Group(); ChangeName(resultShape, EffectName.Banner); return(resultShape); }
public static Shape Crop(PowerPointSlide currentSlide, ShapeRange shapeRange, double magnifyRatio = 1.0, bool isInPlace = false, bool handleError = true) { try { bool hasManyShapes = shapeRange.Count > 1; Shape shape = hasManyShapes ? shapeRange.Group() : shapeRange[1]; float left = shape.Left; float top = shape.Top; shape.Cut(); shapeRange = currentSlide.Shapes.Paste(); shapeRange.Left = left; shapeRange.Top = top; if (hasManyShapes) { shapeRange = shapeRange.Ungroup(); } TakeScreenshotProxy(currentSlide, shapeRange); ShapeRange ungroupedRange = EffectsLabUtil.UngroupAllShapeRange(currentSlide, shapeRange); List <Shape> shapeList = new List <Shape>(); for (int i = 1; i <= ungroupedRange.Count; i++) { Shape filledShape = FillInShapeWithImage(currentSlide, SlidePicture, ungroupedRange[i], magnifyRatio, isInPlace); shapeList.Add(filledShape); } ShapeRange croppedRange = currentSlide.ToShapeRange(shapeList); Shape croppedShape = (croppedRange.Count == 1) ? croppedRange[1] : croppedRange.Group(); return(croppedShape); } catch (Exception e) { throw new CropLabException(e.Message); } }