//Return zoomed version of cropped slide picture to be used for zoom out animation
        private void GetShapeToZoomWithBackground(PowerPoint.Shape zoomShape)
        {
            PowerPoint.Shape referenceShape = GetReferenceShape(zoomShape);

            float finalWidthMagnify    = referenceShape.Width;
            float initialWidthMagnify  = zoomShape.Width;
            float finalHeightMagnify   = referenceShape.Height;
            float initialHeightMagnify = zoomShape.Height;

            zoomShape.Copy();
            PowerPoint.Shape zoomShapeCopy = _slide.Shapes.Paste()[1];
            LegacyShapeUtil.CopyShapeAttributes(zoomShape, ref zoomShapeCopy);

            Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(_slide.SlideIndex);
            zoomSlideCroppedShapes.Select();
            zoomShapeCopy.Visible = Office.MsoTriState.msoTrue;
            zoomShapeCopy.Select(Office.MsoTriState.msoFalse);
            PowerPoint.ShapeRange selection  = Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange;
            PowerPoint.Shape      groupShape = selection.Group();

            groupShape.Width  *= (finalWidthMagnify / initialWidthMagnify);
            groupShape.Height *= (finalHeightMagnify / initialHeightMagnify);
            groupShape.Ungroup();
            zoomSlideCroppedShapes.Left += (referenceShape.Left - zoomShapeCopy.Left);
            zoomSlideCroppedShapes.Top  += (referenceShape.Top - zoomShapeCopy.Top);
            zoomShapeCopy.Delete();
            referenceShape.Delete();
        }
        private static List <string> ApplyBlurEffectTextBox(Models.PowerPointSlide slide, string imageFile, PowerPoint.Shape textBox)
        {
            List <string> shapeNames = new List <string>();

            shapeNames.Add(textBox.Name);

            textBox.ZOrder(Office.MsoZOrderCmd.msoBringToFront);
            textBox.Fill.Visible = Office.MsoTriState.msoFalse;
            textBox.Line.Visible = Office.MsoTriState.msoFalse;

            PowerPoint.Shape blurShape = slide.Shapes.AddShape(Office.MsoAutoShapeType.msoShapeRectangle, textBox.Left, textBox.Top, textBox.Width,
                                                               textBox.Height);
            blurShape.Rotation = textBox.Rotation;
            Utils.ShapeUtil.MoveZToJustBehind(blurShape, textBox);
            CropToShape.FillInShapeWithImage(slide, imageFile, blurShape, isInPlace: true);
            shapeNames.Add(blurShape.Name);

            if (EffectsLabSettings.IsTintSelected)
            {
                PowerPoint.Shape overlayShape = GenerateOverlayShape(slide, blurShape);
                shapeNames.Add(overlayShape.Name);
            }

            // cannot group placeholders
            if (textBox.Type != Office.MsoShapeType.msoPlaceholder)
            {
                PowerPoint.ShapeRange subRange     = slide.Shapes.Range(shapeNames.ToArray());
                PowerPoint.Shape      groupedShape = subRange.Group();
                shapeNames.Clear();
                shapeNames.Add(groupedShape.Name);
            }

            return(shapeNames);
        }
Beispiel #3
0
        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;
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
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);
            }
        }
        private static string ApplyBlurEffectShape(Models.PowerPointSlide slide, string imageFile, PowerPoint.Shape shape)
        {
            List <string> shapeNames = new List <string>();

            shapeNames.Add(shape.Name);

            if (!string.IsNullOrWhiteSpace(shape.TextFrame2.TextRange.Text))
            {
                shape.ZOrder(Office.MsoZOrderCmd.msoBringToFront);

                PowerPoint.Shape textBox = EffectsLabUtil.DuplicateShapeInPlace(shape);
                textBox.Fill.Visible = Office.MsoTriState.msoFalse;
                textBox.Line.Visible = Office.MsoTriState.msoFalse;
                Utils.ShapeUtil.MoveZToJustInFront(textBox, shape);
                shapeNames.Add(textBox.Name);
            }

            shape.TextFrame2.DeleteText();
            CropToShape.FillInShapeWithImage(slide, imageFile, shape, isInPlace: true);

            if (EffectsLabSettings.IsTintSelected)
            {
                PowerPoint.Shape overlayShape = GenerateOverlayShape(slide, shape);
                shapeNames.Add(overlayShape.Name);
            }

            if (shapeNames.Count > 1)
            {
                PowerPoint.ShapeRange subRange     = slide.Shapes.Range(shapeNames.ToArray());
                PowerPoint.Shape      groupedShape = subRange.Group();

                return(groupedShape.Name);
            }

            return(shapeNames[0]);
        }
Beispiel #7
0
 private static PowerPoint.Shape GetShapeFromSelection(PowerPoint.ShapeRange shapeRange)
 {
     PowerPoint.Shape result = shapeRange.Count > 1 ? shapeRange.Group() : shapeRange[1];
     return(result);
 }
 private static PowerPoint.Shape GetShapeFromShapeRange(PowerPoint.ShapeRange shapeRange)
 {
     return(shapeRange.Count > 1 ? shapeRange.Group() : shapeRange[1]);
 }