//Stores slide-size crop of the current slide as a global variable
        private void AddZoomSlideCroppedPicture(float magnifyRatio = 1.0f)
        {
            PowerPointSlide zoomSlideCopy = this.Duplicate();

            Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(zoomSlideCopy.Index);

            PowerPoint.Shape cropShape = zoomSlideCopy.Shapes.AddShape(Office.MsoAutoShapeType.msoShapeRectangle, 0, 0, PowerPointPresentation.Current.SlideWidth - 0.01f, PowerPointPresentation.Current.SlideHeight - 0.01f);
            cropShape.Select();
            PowerPoint.Selection sel          = Globals.ThisAddIn.Application.ActiveWindow.Selection;
            PowerPoint.Shape     croppedShape = CropToShape.Crop(zoomSlideCopy, sel, magnifyRatio: magnifyRatio);
            croppedShape.Cut();

            zoomSlideCroppedShapes      = _slide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
            zoomSlideCroppedShapes.Name = "PPTLabsMagnifyAreaGroup" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
            Utils.ShapeUtil.FitShapeToSlide(ref zoomSlideCroppedShapes);
            zoomSlideCopy.Delete();
        }
Beispiel #2
0
        //Stores slide-size crop of the current slide as a global variable
        private void AddZoomSlideCroppedPicture(float magnifyRatio = 1.0f)
        {
            PowerPointSlide zoomSlideCopy = this.Duplicate();

            Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(zoomSlideCopy.Index);

            PowerPoint.Shape cropShape = zoomSlideCopy.Shapes.AddShape(Office.MsoAutoShapeType.msoShapeRectangle, 0, 0, PowerPointPresentation.Current.SlideWidth - 0.01f, PowerPointPresentation.Current.SlideHeight - 0.01f);
            cropShape.Select();
            PowerPoint.Selection sel          = Globals.ThisAddIn.Application.ActiveWindow.Selection;
            PowerPoint.Shape     croppedShape = CropToShape.Crop(zoomSlideCopy, sel, magnifyRatio: magnifyRatio);
            try
            {
                string tempFilePath = FileDir.GetTemporaryPngFilePath();
                Utils.GraphicsUtil.ExportShape(croppedShape, tempFilePath);
                zoomSlideCroppedShapes = _slide.Shapes.AddPicture2(tempFilePath,
                                                                   Office.MsoTriState.msoFalse,
                                                                   Office.MsoTriState.msoTrue,
                                                                   0,
                                                                   0);
                croppedShape.Delete();
                try
                {
                    FileDir.DeleteFile(tempFilePath);
                }
                catch (Exception)
                {
                    // If the file cannot be deleted, we continue without deletion.
                }
            }
            catch (Exception)
            {
                // Revert to normal copy and pasting if unable to create file.
                croppedShape.Cut();
                zoomSlideCroppedShapes = _slide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
            }

            zoomSlideCroppedShapes.Name = "PPTLabsMagnifyAreaGroup" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
            Utils.ShapeUtil.FitShapeToSlide(ref zoomSlideCroppedShapes);
            zoomSlideCopy.Delete();
        }
 private static void ManageSlidesForReload(PowerPointSlide currentSlide, PowerPointSlide nextSlide, PowerPointSlide animatedSlide)
 {
     animatedSlide.Delete();
     if (!GetMatchingShapeDetails(currentSlide, nextSlide))
     {
         System.Windows.Forms.MessageBox.Show("No matching Shapes were found on the next slide", "Animation Not Added");
         return;
     }
     AddCompleteAnimations(currentSlide, nextSlide);
 }
 public void DeleteSlideAndTrack(PowerPointSlide slide)
 {
     RemoveSlideWithName(slide.Name);
     slide.Delete();
 }
        private static PowerPointBgEffectSlide PrepareForeground(ShapeRange oriShapeRange, ShapeRange copyShapeRange,
                                                                 Slide refSlide, PowerPointSlide newSlide)
        {
            try
            {
                // crop in the original slide and put into clipboard
                var croppedShape = MakeFrontImage(oriShapeRange);

                croppedShape.Cut();

                // swap the uncropped shapes and cropped shapes
                var pastedCrop = newSlide.Shapes.Paste();

                // calibrate pasted shapes
                pastedCrop.Left -= 12;
                pastedCrop.Top -= 12;

                // ungroup front image if necessary
                if (pastedCrop[1].Type == Core.MsoShapeType.msoGroup)
                {
                    pastedCrop[1].Ungroup();
                }

                copyShapeRange.Cut();
                oriShapeRange = refSlide.Shapes.Paste();

                oriShapeRange.Fill.ForeColor.RGB = 0xaaaaaa;
                oriShapeRange.Fill.Transparency = 0.7f;
                oriShapeRange.Line.Visible = Core.MsoTriState.msoTrue;
                oriShapeRange.Line.ForeColor.RGB = 0x000000;

                Utils.Graphics.MakeShapeViewTimeInvisible(oriShapeRange, refSlide);

                oriShapeRange.Select();

                // finally add transition to the new slide
                newSlide.Transition.EntryEffect = PpEntryEffect.ppEffectFadeSmoothly;
                newSlide.Transition.Duration = 0.5f;

                return new PowerPointBgEffectSlide(newSlide.GetNativeSlide());
            }
            catch (Exception e)
            {
                var errorMessage = CropToShape.GetErrorMessageForErrorCode(e.Message);
                errorMessage = errorMessage.Replace("Crop To Shape", "Blur/Recolor Remainder");

                newSlide.Delete();

                throw new InvalidOperationException(errorMessage);
            }
        }