Esempio n. 1
0
        public static void AddZoomToArea()
        {
            if (!IsSelectingShapes()) return;

            try
            {
                var currentSlide = PowerPointCurrentPresentationInfo.CurrentSlide;
                DeleteExistingZoomToAreaSlides(currentSlide);
                currentSlide.Name = "PPTLabsZoomToAreaSlide" + DateTime.Now.ToString("yyyyMMddHHmmssffff");

                var selectedShapes = Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange;
                var zoomRectangles = ReplaceWithZoomRectangleImages(currentSlide, selectedShapes);

                MakeInvisible(zoomRectangles);
                List<PowerPoint.Shape> editedSelectedShapes = GetEditedShapesForZoomToArea(currentSlide, zoomRectangles);

                var addedSlides = AddMultiSlideZoomToArea(currentSlide, editedSelectedShapes);
                if (!multiSlideZoomChecked) Graphics.SquashSlides(addedSlides);

                MakeVisible(zoomRectangles);

                Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(currentSlide.Index);
                PowerPointPresentation.Current.AddAckSlide();

                // Always call ReleaseComObject and GC.Collect after shape deletion to prevent shape corruption after undo.
                System.Runtime.InteropServices.Marshal.ReleaseComObject(selectedShapes);
                GC.Collect();
            }
            catch (Exception e)
            {
                Logger.LogException(e, "AddZoomToArea");
                ErrorDialogWrapper.ShowDialog("Error when adding zoom to area", "An error occurred when adding zoom to area.", e);
                throw;
            }
        }
Esempio n. 2
0
 private void ResetThemePanel()
 {
     try
     {
         LoadThemePanel();
     }
     catch (Exception e)
     {
         ErrorDialogWrapper.ShowDialog("Theme Panel Reset Failed", e.Message, e);
     }
 }
Esempio n. 3
0
 public static void CleanPersistentFolder(ICollection <string> filesInUse)
 {
     try
     {
         Empty(new DirectoryInfo(AggregatedFolder), filesInUse);
     }
     catch (Exception e)
     {
         ErrorDialogWrapper.ShowDialog("Failed to remove unused images.", e.Message, e);
     }
 }
Esempio n. 4
0
 public Action FunctionWrapper(Action action)
 {
     return(() =>
     {
         try
         {
             action();
         }
         catch (Exception e)
         {
             ErrorDialogWrapper.ShowDialog("Unexpected error in drawings lab.", e.Message, e);
             throw e;
         }
         GC.Collect();
     });
 }
Esempio n. 5
0
 private static bool RetryInit()
 {
     TempFolder = BackupTempFolder;
     Empty(new DirectoryInfo(AggregatedBackupTempFolder));
     if (!Directory.Exists(TempFolder))
     {
         try
         {
             Directory.CreateDirectory(TempFolder);
         }
         catch (Exception e)
         {
             ErrorDialogWrapper.ShowDialog("Error", e.Message, e);
             return(false);
         }
     }
     _isInit = true;
     return(true);
 }
Esempio n. 6
0
 private void EmptyThemePanel()
 {
     try
     {
         if (PowerPointPresentation.Current.SlideCount > 0)
         {
             dataSource.ThemeColorOne   = Color.White;
             dataSource.ThemeColorTwo   = Color.White;
             dataSource.ThemeColorThree = Color.White;
             dataSource.ThemeColorFour  = Color.White;
             dataSource.ThemeColorFive  = Color.White;
             dataSource.ThemeColorSix   = Color.White;
             dataSource.ThemeColorSeven = Color.White;
             dataSource.ThemeColorEight = Color.White;
             dataSource.ThemeColorNine  = Color.White;
             dataSource.ThemeColorTen   = Color.White;
         }
     }
     catch (Exception e)
     {
         ErrorDialogWrapper.ShowDialog("Theme Panel Reset Failed", e.Message, e);
     }
 }
Esempio n. 7
0
        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 (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();
                    Utils.Graphics.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();
                    Utils.Graphics.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)
            {
                PowerPointLabsGlobals.LogException(e, "AddDrillDownAnimation");
                ErrorDialogWrapper.ShowDialog("Error when adding drill down animation", "An error occurred when adding drill down animation.", e);
                throw;
            }
        }
Esempio n. 8
0
        public static void AddStepBackAnimation(PowerPoint.Shape selectedShape, PowerPointSlide currentSlide,
                                                out PowerPointStepBackSlide addedSlide, bool includeAckSlide = true, bool deletePreviouslyAdded = true)
        {
            try
            {
                if (currentSlide == null || currentSlide.Index == 1)
                {
                    System.Windows.Forms.MessageBox.Show("No previous 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 previousSlide = GetPreviousSlide(currentSlide, deletePreviouslyAdded);

                PowerPoint.Shape previousSlidePicture = null, shapeToZoom = null;

                currentSlide.HideIndicator();
                if (backgroundZoomChecked)
                {
                    previousSlidePicture = GetPreviousSlidePictureWithBackground(currentSlide, previousSlide);
                    previousSlidePicture.Apply();
                    PreparePreviousSlidePicture(currentSlide, selectedShape, ref previousSlidePicture);

                    addedSlide = (PowerPointStepBackSlide)previousSlide.CreateStepBackSlide();
                    addedSlide.DeleteAllShapes();

                    PowerPoint.Shape backgroundShape = null;
                    shapeToZoom = GetStepBackWithBackgroundShapeToZoom(currentSlide, addedSlide, previousSlidePicture, out backgroundShape);
                    shapeToZoom.Apply();

                    addedSlide.PrepareForStepBack();
                    addedSlide.AddStepBackAnimationBackground(shapeToZoom, backgroundShape, previousSlidePicture);
                }
                else
                {
                    addedSlide = (PowerPointStepBackSlide)previousSlide.CreateStepBackSlide();
                    addedSlide.DeleteAllShapes();

                    shapeToZoom = GetStepBackWithoutBackgroundShapeToZoom(currentSlide, addedSlide, previousSlide);
                    shapeToZoom.Apply();
                    shapeToZoom.Copy();
                    previousSlidePicture = currentSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
                    previousSlidePicture.Apply();
                    PreparePreviousSlidePicture(currentSlide, selectedShape, ref previousSlidePicture);

                    addedSlide.PrepareForStepBack();
                    addedSlide.AddStepBackAnimationNonBackground(shapeToZoom, previousSlidePicture);
                }
                currentSlide.ShowIndicator();

                currentSlide.Transition.EntryEffect = PowerPoint.PpEntryEffect.ppEffectFadeSmoothly;
                currentSlide.Transition.Duration    = 0.25f;
                Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(addedSlide.Index);
                Globals.ThisAddIn.Application.CommandBars.ExecuteMso("AnimationPreview");
                if (includeAckSlide)
                {
                    PowerPointPresentation.Current.AddAckSlide();
                }
            }
            catch (Exception e)
            {
                PowerPointLabsGlobals.LogException(e, "AddStepBackAnimation");
                ErrorDialogWrapper.ShowDialog("Error when adding step back animation", "An error occurred when adding step back animation.", e);
                throw;
            }
        }