Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }