Example #1
0
        public static PowerPoint.ShapeRange BlurSelected(Models.PowerPointSlide slide, PowerPoint.Selection selection, int percentage)
        {
            var shapeRange = selection.ShapeRange;

            if (selection.HasChildShapeRange)
            {
                shapeRange = selection.ChildShapeRange;
            }

            try
            {
                var hasManyShapes = shapeRange.Count > 1;
                var shape         = hasManyShapes ? shapeRange.Group() : shapeRange[1];
                var left          = shape.Left;
                var top           = shape.Top;
                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();
                }

                var ungroupedRange  = EffectsLabUtil.UngroupAllShapeRange(slide, shapeRange);
                var shapeGroupNames = ApplyBlurEffect(slide, BlurPicture, ungroupedRange);
                var 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);
            }
        }
Example #2
0
        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);
            }
        }