private static PowerPoint.Shape GetStepBackWithBackgroundShapeToZoom(PowerPointSlide currentSlide, PowerPointSlide addedSlide, PowerPoint.Shape previousSlidePicture, out PowerPoint.Shape backgroundShape) { currentSlide.Copy(); PowerPoint.Shape currentSlideCopy = addedSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1]; ShapeUtil.FitShapeToSlide(ref currentSlideCopy); currentSlideCopy.Name = "PPTZoomOutShape" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); previousSlidePicture.Copy(); PowerPoint.Shape previousSlidePictureCopy = addedSlide.Shapes.Paste()[1]; Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(addedSlide.Index); // Scale everything up by this ratio. float ratio = PowerPointPresentation.Current.SlideWidth / previousSlidePictureCopy.Width; currentSlideCopy.Width *= ratio; currentSlideCopy.Height *= ratio; currentSlideCopy.Left = -ratio * previousSlidePictureCopy.Left; currentSlideCopy.Top = -ratio * previousSlidePictureCopy.Top; // for some reason height is locked to width, so we only need to change width here. previousSlidePictureCopy.Width *= ratio; previousSlidePictureCopy.Left = 0; previousSlidePictureCopy.Top = 0; backgroundShape = currentSlideCopy; return(previousSlidePictureCopy); }
//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); Shape cropShape = zoomSlideCopy.Shapes.AddShape(Office.MsoAutoShapeType.msoShapeRectangle, 0, 0, PowerPointPresentation.Current.SlideWidth - 0.01f, PowerPointPresentation.Current.SlideHeight - 0.01f); cropShape.Select(); Selection sel = Globals.ThisAddIn.Application.ActiveWindow.Selection; Shape croppedShape = CropToShape.Crop(zoomSlideCopy, sel, magnifyRatio: magnifyRatio); zoomSlideCroppedShapes = GraphicsUtil.CutAndPaste(croppedShape, _slide); zoomSlideCroppedShapes.Name = "PPTLabsMagnifyAreaGroup" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); ShapeUtil.FitShapeToSlide(ref zoomSlideCroppedShapes); zoomSlideCopy.Delete(); }
public static void AddDrillDownAnimation(PowerPoint.Shape selectedShape, PowerPointSlide currentSlide, out PowerPointDrillDownSlide addedSlide, bool includeAckSlide = true, bool deletePreviouslyAdded = true) { try { if (currentSlide == null || currentSlide.Index == PowerPointPresentation.Current.SlideCount) { System.Windows.Forms.MessageBox.Show("No next slide is found. Please select the correct slide", "Unable to Add Animations"); addedSlide = null; return; } //Pick up the border and shadow style, to be applied to zoomed shape selectedShape.PickUp(); PrepareZoomShape(currentSlide, ref selectedShape); PowerPointSlide nextSlide = GetNextSlide(currentSlide, deletePreviouslyAdded); PowerPoint.Shape nextSlidePicture = null, shapeToZoom = null; currentSlide.HideIndicator(); if (ZoomLabSettings.BackgroundZoomChecked) { nextSlidePicture = GetNextSlidePictureWithBackground(currentSlide, nextSlide); nextSlidePicture.Apply(); PrepareNextSlidePicture(currentSlide, selectedShape, ref nextSlidePicture); addedSlide = (PowerPointDrillDownSlide)currentSlide.CreateDrillDownSlide(); addedSlide.DeleteAllShapes(); nextSlidePicture.Copy(); shapeToZoom = addedSlide.Shapes.Paste()[1]; addedSlide.DeleteShapeAnimations(shapeToZoom); currentSlide.Copy(); var backgroundShape = addedSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1]; backgroundShape.Apply(); ShapeUtil.FitShapeToSlide(ref backgroundShape); backgroundShape.ZOrder(Office.MsoZOrderCmd.msoSendBackward); backgroundShape.Name = "PPTZoomInShape" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); addedSlide.PrepareForDrillDown(); addedSlide.AddDrillDownAnimationBackground(backgroundShape, shapeToZoom, nextSlidePicture); } else { PowerPoint.Shape pictureOnNextSlide = null; nextSlidePicture = GetNextSlidePictureWithoutBackground(currentSlide, nextSlide, out pictureOnNextSlide); nextSlidePicture.Apply(); PrepareNextSlidePicture(currentSlide, selectedShape, ref nextSlidePicture); addedSlide = (PowerPointDrillDownSlide)currentSlide.CreateDrillDownSlide(); addedSlide.DeleteAllShapes(); nextSlidePicture.Copy(); shapeToZoom = addedSlide.Shapes.Paste()[1]; addedSlide.DeleteShapeAnimations(shapeToZoom); currentSlide.Copy(); var backgroundShape = addedSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1]; backgroundShape.Apply(); ShapeUtil.FitShapeToSlide(ref backgroundShape); backgroundShape.ZOrder(Office.MsoZOrderCmd.msoSendBackward); backgroundShape.Name = "PPTZoomInShape" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); addedSlide.PrepareForDrillDown(); addedSlide.AddDrillDownAnimationNoBackground(backgroundShape, shapeToZoom, pictureOnNextSlide); pictureOnNextSlide.Delete(); } currentSlide.ShowIndicator(); Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(addedSlide.Index); Globals.ThisAddIn.Application.CommandBars.ExecuteMso("AnimationPreview"); if (includeAckSlide) { PowerPointPresentation.Current.AddAckSlide(); } } catch (Exception e) { Logger.LogException(e, "AddDrillDownAnimation"); ErrorDialogBox.ShowDialog("Error when adding drill down animation", "An error occurred when adding drill down animation.", e); throw; } }
public static void AddDrillDownAnimation(PowerPoint.Shape selectedShape, PowerPointSlide currentSlide, out PowerPointDrillDownSlide addedSlide, bool includeAckSlide = true, bool deletePreviouslyAdded = true) { try { //SlideCount - 1 due to #RestoreClipboardAfterAction creating a temporary slide to store clipboard if (currentSlide == null || currentSlide.Index == PowerPointPresentation.Current.SlideCount - 1) { System.Windows.Forms.MessageBox.Show(TextCollection.ZoomLabText.ErrorInvalidNextSlide, TextCollection.ZoomLabText.ErrorUnableToAddAnimationsCaption); addedSlide = null; return; } //Pick up the border and shadow style, to be applied to zoomed shape selectedShape.PickUp(); PrepareZoomShape(currentSlide, ref selectedShape); PowerPointSlide nextSlide = GetNextSlide(currentSlide, deletePreviouslyAdded); PowerPoint.Shape nextSlidePicture = null, shapeToZoom = null; currentSlide.HideIndicator(); if (ZoomLabSettings.BackgroundZoomChecked) { nextSlidePicture = GetNextSlidePictureWithBackground(currentSlide, nextSlide); nextSlidePicture.Apply(); PrepareNextSlidePicture(currentSlide, selectedShape, ref nextSlidePicture); addedSlide = (PowerPointDrillDownSlide)currentSlide.CreateDrillDownSlide(); addedSlide.DeleteAllShapes(); shapeToZoom = addedSlide.Shapes.SafeCopyPlaceholder(nextSlidePicture); addedSlide.DeleteShapeAnimations(shapeToZoom); PowerPoint.Shape backgroundShape = GraphicsUtil.AddSlideAsShape(currentSlide, addedSlide); backgroundShape.Apply(); ShapeUtil.FitShapeToSlide(ref backgroundShape); backgroundShape.ZOrder(Office.MsoZOrderCmd.msoSendBackward); backgroundShape.Name = "PPTZoomInShape" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); addedSlide.PrepareForDrillDown(); addedSlide.AddDrillDownAnimationBackground(backgroundShape, shapeToZoom, nextSlidePicture); } else { PowerPoint.Shape pictureOnNextSlide = null; nextSlidePicture = GetNextSlidePictureWithoutBackground(currentSlide, nextSlide, out pictureOnNextSlide); nextSlidePicture.Apply(); PrepareNextSlidePicture(currentSlide, selectedShape, ref nextSlidePicture); addedSlide = (PowerPointDrillDownSlide)currentSlide.CreateDrillDownSlide(); addedSlide.DeleteAllShapes(); shapeToZoom = addedSlide.Shapes.SafeCopyPlaceholder(nextSlidePicture); addedSlide.DeleteShapeAnimations(shapeToZoom); PowerPoint.Shape backgroundShape = GraphicsUtil.AddSlideAsShape(currentSlide, addedSlide); backgroundShape.Apply(); ShapeUtil.FitShapeToSlide(ref backgroundShape); backgroundShape.ZOrder(Office.MsoZOrderCmd.msoSendBackward); backgroundShape.Name = "PPTZoomInShape" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); addedSlide.PrepareForDrillDown(); addedSlide.AddDrillDownAnimationNoBackground(backgroundShape, shapeToZoom, pictureOnNextSlide); pictureOnNextSlide.SafeDelete(); } currentSlide.ShowIndicator(); Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(addedSlide.Index); Globals.ThisAddIn.Application.CommandBars.ExecuteMso("AnimationPreview"); if (includeAckSlide) { PowerPointPresentation.Current.AddAckSlide(); } } catch (Exception e) { Logger.LogException(e, "AddDrillDownAnimation"); ErrorDialogBox.ShowDialog("Error when adding drill down animation", "An error occurred when adding drill down animation.", e); throw; } }