public static PowerPoint.Shape Crop(PowerPoint.ShapeRange shapeRange, float magnifyRatio = 1.0f, bool isInPlace = false, bool handleError = true) { try { if (!VerifyIsShapeRangeValid(shapeRange, handleError)) { return(null); } var hasManyShapes = shapeRange.Count > 1; var shape = hasManyShapes ? shapeRange.Group() : shapeRange[1]; var left = shape.Left; var top = shape.Top; shape.Cut(); shapeRange = PowerPointCurrentPresentationInfo.CurrentSlide.Shapes.Paste(); shapeRange.Left = left; shapeRange.Top = top; if (hasManyShapes) { shapeRange = shapeRange.Ungroup(); } SetMagnifyRatio(magnifyRatio); TakeScreenshotProxy(shapeRange); var ungroupedRange = UngroupAllForShapeRange(shapeRange); var shapeNames = new string[ungroupedRange.Count]; for (int i = 1; i <= ungroupedRange.Count; i++) { var filledShape = FillInShapeWithImage(SlidePicture, ungroupedRange[i], isInPlace); shapeNames[i - 1] = filledShape.Name; } var croppedRange = PowerPointCurrentPresentationInfo.CurrentSlide.Shapes.Range(shapeNames); var croppedShape = (croppedRange.Count == 1) ? croppedRange[1] : croppedRange.Group(); return(croppedShape); } catch (Exception e) { if (handleError) { ProcessErrorMessage(e); return(null); } throw; } }
public static PowerPoint.ShapeRange BlurSelected(Models.PowerPointSlide slide, PowerPoint.Selection selection, int percentage) { PowerPoint.ShapeRange shapeRange = ShapeUtil.GetShapeRange(selection); try { bool hasManyShapes = shapeRange.Count > 1; PowerPoint.Shape shape = hasManyShapes ? shapeRange.Group() : shapeRange[1]; float left = shape.Left; float top = shape.Top; PPLClipboard.Instance.LockAndRelease(() => { shapeRange.Cut(); Utils.GraphicsUtil.ExportSlide(slide, BlurPicture); BlurImage(BlurPicture, percentage); shapeRange = slide.Shapes.Paste(); }); shapeRange.Left = left; shapeRange.Top = top; if (hasManyShapes) { shapeRange = shapeRange.Ungroup(); } PowerPoint.ShapeRange ungroupedRange = EffectsLabUtil.UngroupAllShapeRange(slide, shapeRange); List <string> shapeGroupNames = ApplyBlurEffect(slide, BlurPicture, ungroupedRange); PowerPoint.ShapeRange range = slide.Shapes.Range(shapeGroupNames.ToArray()); return(range); } catch (Exception e) { ActionFramework.Common.Log.Logger.LogException(e, "BlurSelectedEffect"); EffectsLabUtil.ShowErrorMessageBox(e.Message, e); return(null); } }
public static PowerPoint.ShapeRange BlurSelected(Models.PowerPointSlide slide, PowerPoint.ShapeRange shapeRange, int percentage) { if (!IsValidShapeRange(shapeRange)) { return(null); } try { _slide = slide; var hasManyShapes = shapeRange.Count > 1; var shape = hasManyShapes ? shapeRange.Group() : shapeRange[1]; var left = shape.Left; var top = shape.Top; shapeRange.Cut(); Utils.Graphics.ExportSlide(_slide, BlurPicture); BlurImage(BlurPicture, percentage); shapeRange = slide.Shapes.Paste(); shapeRange.Left = left; shapeRange.Top = top; if (hasManyShapes) { shapeRange = shapeRange.Ungroup(); } var ungroupedRange = UngroupAllShapeRange(shapeRange); var shapeGroupNames = ApplyBlurEffect(BlurPicture, ungroupedRange); var range = _slide.Shapes.Range(shapeGroupNames.ToArray()); return(range); } catch (Exception e) { ActionFramework.Common.Log.Logger.LogException(e, "BlurSelectedEffect"); ShowErrorMessageBox(e.Message, e); return(null); } }