Exemplo n.º 1
0
 /// <summary>
 /// Searches for the visual agenda image shape that corresponds to the given section index in the slide and returns it.
 /// </summary>
 private static Shape FindShapeCorrespondingToSection(PowerPointSlide inSlide, int sectionIndex)
 {
     return(inSlide.GetShape(AgendaShape.MeetsConditions(shape => shape.ShapePurpose == ShapePurpose.VisualAgendaImage &&
                                                         sectionIndex == shape.Section.Index)));
 }
        public static void AddHighlightBulletsText()
        {
            try
            {
                PowerPointSlide currentSlide = PowerPointCurrentPresentationInfo.CurrentSlide as PowerPointSlide;

                PowerPoint.ShapeRange selectedShapes = null;
                Office.TextRange2     selectedText   = null;

                //Get shapes to consider for animation
                List <PowerPoint.Shape> shapesToUse = null;
                switch (userSelection)
                {
                case HighlightTextSelection.kShapeSelected:
                    selectedShapes = Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange;
                    shapesToUse    = GetShapesToUse(currentSlide, selectedShapes);
                    break;

                case HighlightTextSelection.kTextSelected:
                    selectedShapes = Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange;
                    selectedText   = Globals.ThisAddIn.Application.ActiveWindow.Selection.TextRange2.TrimText();
                    shapesToUse    = GetShapesToUse(currentSlide, selectedShapes);
                    break;

                case HighlightTextSelection.kNoneSelected:
                    currentSlide.DeleteIndicator();
                    currentSlide.DeleteShapesWithPrefix("PPTLabsHighlightBackgroundShape");
                    shapesToUse = GetAllUsableShapesInSlide(currentSlide);
                    break;

                default:
                    break;
                }

                if (currentSlide.Name.Contains("PPTLabsHighlightBulletsSlide"))
                {
                    ProcessExistingHighlightSlide(currentSlide, shapesToUse);
                }

                if (shapesToUse == null || shapesToUse.Count == 0)
                {
                    return;
                }

                currentSlide.Name = "PPTLabsHighlightBulletsSlide" + DateTime.Now.ToString("yyyyMMddHHmmssffff");

                PowerPoint.Sequence sequence = currentSlide.TimeLine.MainSequence;
                bool isFirstShape            = IsFirstShape(currentSlide);

                foreach (PowerPoint.Shape sh in shapesToUse)
                {
                    if (!sh.Name.Contains("HighlightTextShape"))
                    {
                        sh.Name = "HighlightTextShape" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
                    }

                    //Add Font Appear effect for all paragraphs within shape
                    int currentIndex = sequence.Count;
                    sequence.AddEffect(sh, PowerPoint.MsoAnimEffect.msoAnimEffectChangeFontColor, PowerPoint.MsoAnimateByLevel.msoAnimateTextByFifthLevel, PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick);
                    List <PowerPoint.Effect> appearEffects = AsList(sequence, currentIndex + 1, sequence.Count + 1);

                    //Add Font Disappear effect for all paragraphs within shape
                    currentIndex = sequence.Count;
                    sequence.AddEffect(sh, PowerPoint.MsoAnimEffect.msoAnimEffectChangeFontColor, PowerPoint.MsoAnimateByLevel.msoAnimateTextByFifthLevel, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious);
                    List <PowerPoint.Effect> disappearEffects = AsList(sequence, currentIndex + 1, sequence.Count + 1);

                    //Remove effects for paragraphs without bullet points
                    List <int> markedForRemoval = GetParagraphsToRemove(sh, selectedText);
                    // assert appearEffects.Count == disappearEffects.Count;
                    // assert markedForRemoval.Count <= appearEffects.Count;
                    for (int i = markedForRemoval.Count - 1; i >= 0; --i)
                    {
                        // delete from back.
                        int index = markedForRemoval[i];
                        appearEffects[index].Delete();
                        appearEffects.RemoveAt(index);
                        disappearEffects[index].Delete();
                        disappearEffects.RemoveAt(index);
                    }

                    if (appearEffects.Count == 0)
                    {
                        continue;
                    }

                    RearrangeEffects(appearEffects, disappearEffects);
                    FormatAppearEffects(appearEffects, isFirstShape);
                    FormatDisappearEffects(disappearEffects);
                    isFirstShape = false;
                }

                if (currentSlide.HasAnimationForClick(clickNumber: 1))
                {
                    Globals.ThisAddIn.Application.CommandBars.ExecuteMso("AnimationPreview");
                }
                PowerPointPresentation.Current.AddAckSlide();
            }
            catch (Exception e)
            {
                Logger.LogException(e, "AddHighlightBulletsText");
                throw;
            }
        }
 /// <summary>
 /// Get shapes to use for animation.
 /// If user does not select anything: Select shapes which have bullet points
 /// If user selects some shapes: Keep shapes from user selection which have bullet points
 /// If user selects some text: Keep shapes used to store text
 /// </summary>
 private static List <PowerPoint.Shape> GetShapesToUse(PowerPointSlide currentSlide, PowerPoint.ShapeRange selectedShapes)
 {
     return(selectedShapes.Cast <PowerPoint.Shape>()
            .Where(HasText)
            .ToList());
 }
Exemplo n.º 4
0
 public ELearningService(PowerPointSlide slide, List <ExplanationItem> selfExplanationItems)
 {
     _slide = slide;
     _selfExplanationItems = selfExplanationItems;
 }
Exemplo n.º 5
0
 private static List <PowerPoint.Shape> GetEditedShapesForZoomToArea(PowerPointSlide currentSlide, List <PowerPoint.Shape> zoomRectangles)
 {
     return(zoomRectangles.Select(zoomShape => GetBestFitShape(currentSlide, zoomShape)).ToList());
 }
        protected override ShapeRange ExecutePasteAction(string ribbonId, PowerPointPresentation presentation, PowerPointSlide slide,
                                                         ShapeRange selectedShapes, ShapeRange selectedChildShapes)
        {
            if (selectedShapes.Count <= 0)
            {
                MessageBox.Show(TextCollection.PasteLabText.ReplaceWithClipboardActionHandlerReminderText, TextCollection.CommonText.ErrorTitle);
                return(null);
            }

            ShapeRange pastingShapes = ClipboardUtil.PasteShapesFromClipboard(presentation, slide);

            if (pastingShapes == null)
            {
                Logger.Log("PasteLab: Could not paste clipboard contents.");
                MessageBox.Show(PasteLabText.ErrorPaste, PasteLabText.ErrorDialogTitle);
                return(null);
            }

            return(ReplaceWithClipboard.Execute(presentation, slide, selectedShapes, selectedChildShapes, pastingShapes));
        }
        protected override ShapeRange ExecutePasteAction(string ribbonId, PowerPointPresentation presentation, PowerPointSlide slide,
                                                         ShapeRange selectedShapes, ShapeRange selectedChildShapes)
        {
            PPMouse.Coordinates coordinates  = PPMouse.RightClickCoordinates;
            DocumentWindow      activeWindow = this.GetCurrentWindow();

            float positionX = 0;
            float positionY = 0;

            if (activeWindow.ActivePane.ViewType == PpViewType.ppViewSlide)
            {
                int xref = activeWindow.PointsToScreenPixelsX(100) - activeWindow.PointsToScreenPixelsX(0);
                int yref = activeWindow.PointsToScreenPixelsY(100) - activeWindow.PointsToScreenPixelsY(0);
                positionX = ((coordinates.X - activeWindow.PointsToScreenPixelsX(0)) / xref) * 100;
                positionY = ((coordinates.Y - activeWindow.PointsToScreenPixelsY(0)) / yref) * 100;
            }

            ShapeRange pastingShapes = ClipboardUtil.PasteShapesFromClipboard(presentation, slide);

            if (pastingShapes == null)
            {
                Logger.Log("PasteLab: Could not paste clipboard contents.");
                MessageBox.Show(PasteLabText.ErrorPaste, PasteLabText.ErrorDialogTitle);
                return(null);
            }

            return(PasteAtCursorPosition.Execute(presentation, slide, pastingShapes, positionX, positionY));
        }
Exemplo 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 (ZoomLabSettings.BackgroundZoomChecked)
                {
                    previousSlidePicture = GetPreviousSlidePictureWithBackground(currentSlide, previousSlide);
                    previousSlidePicture.Apply();
                    PreparePreviousSlidePicture(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(addedSlide, previousSlide);
                    shapeToZoom.Apply();
                    shapeToZoom.Copy();
                    previousSlidePicture = currentSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
                    previousSlidePicture.Apply();
                    PreparePreviousSlidePicture(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)
            {
                Logger.LogException(e, "AddStepBackAnimation");
                ErrorDialogBox.ShowDialog("Error when adding step back animation", "An error occurred when adding step back animation.", e);
                throw;
            }
        }
Exemplo n.º 9
0
 private static void PrepareZoomShape(PowerPointSlide currentSlide, ref PowerPoint.Shape selectedShape)
 {
     currentSlide.DeleteShapeAnimations(selectedShape);
     RemoveTextFromShape(selectedShape);
     selectedShape.Rotation = 0;
 }
Exemplo n.º 10
0
        private static List <Shape> GetShapesInInteractiveSequenceWithAnimationsRemoved(PowerPointSlide currentSlide, Shape triggerShape, List <Shape> shapesToAnimate)
        {
            Sequences sequences = currentSlide.TimeLine.InteractiveSequences;
            // A set is used here so no duplicate shapes will be added
            ISet <Shape> shapesToAnimateSet = new HashSet <Shape>(shapesToAnimate);

            // Find the existing sequence that has the triggerShape
            for (int i = 1; i <= sequences.Count; i++)
            {
                Sequence sequence = sequences[i];
                // Iterate from the back because of deletion
                for (int j = sequence.Count; j >= 1; j--)
                {
                    Effect effect = sequence[j];
                    // A sequence is attached to a trigger shape. However we can only use the effect to find out
                    // what is the trigger shape, thus we break when the first effect's trigger shape is not
                    // what we are looking for and delete all effects from the sequence otherwise.
                    if (effect.Timing.TriggerShape == triggerShape)
                    {
                        shapesToAnimateSet.Add(effect.Shape);
                        effect.Delete();
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(new List <Shape>(shapesToAnimateSet));
        }
Exemplo n.º 11
0
        public static void AddStepBackAnimation(PowerPoint.Shape selectedShape, PowerPointSlide currentSlide)
        {
            PowerPointStepBackSlide addedSlide;

            AddStepBackAnimation(selectedShape, currentSlide, out addedSlide);
        }
        protected override ShapeRange ExecutePasteAction(string ribbonId, PowerPointPresentation presentation, PowerPointSlide slide,
                                                         ShapeRange selectedShapes, ShapeRange selectedChildShapes)
        {
            if (selectedShapes.Count <= 0)
            {
                Logger.Log("PasteIntoGroup failed. No valid shape is selected.");
                return(null);
            }

            if (selectedShapes.Count == 1 && !ShapeUtil.IsAGroup(selectedShapes[1]))
            {
                Logger.Log("PasteIntoGroup failed. Selection is only a single shape.");
                return(null);
            }

            ShapeRange pastingShapes = PasteShapesFromClipboard(slide);

            if (pastingShapes == null)
            {
                return(null);
            }

            return(PasteIntoGroup.Execute(presentation, slide, selectedShapes, pastingShapes));
        }
Exemplo n.º 13
0
 public static void MakeShapeViewTimeInvisible(ShapeRange shapeRange, PowerPointSlide curSlide)
 {
     MakeShapeViewTimeInvisible(shapeRange, curSlide.GetNativeSlide());
 }
Exemplo n.º 14
0
        private static void SyncBulletAgendaSlide(PowerPointSlide refSlide, List <AgendaSection> sections,
                                                  AgendaSection currentSection, List <string> deletedShapeNames, PowerPointSlide targetSlide)
        {
            SyncShapesFromReferenceSlide(refSlide, targetSlide, deletedShapeNames);

            var referenceContentShape = refSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape));
            var targetContentShape    = targetSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape));
            var bulletFormats         = BulletFormats.ExtractFormats(referenceContentShape);

            Graphics.SetText(targetContentShape, sections.Where(section => section.Index > 1)
                             .Select(section => section.Name));
            Graphics.SyncShape(referenceContentShape, targetContentShape, pickupTextContent: false,
                               pickupTextFormat: false);

            ApplyBulletFormats(targetContentShape.TextFrame2.TextRange, bulletFormats, currentSection);
            targetSlide.DeletePlaceholderShapes();
        }
Exemplo n.º 15
0
 private static Shape FindBeamShape(PowerPointSlide slide)
 {
     return(slide.Shapes.Cast <Shape>().FirstOrDefault(AgendaShape.IsBeamShape));
 }
Exemplo n.º 16
0
        //Return picture copy of next slide where shapes with exit animations have been deleted
        private static PowerPoint.Shape GetNextSlidePictureWithoutBackground(PowerPointSlide currentSlide, PowerPointSlide nextSlide, out PowerPoint.Shape pictureOnNextSlide)
        {
            Globals.ThisAddIn.Application.ActiveWindow.Selection.Unselect();
            Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(nextSlide.Index);

            List <PowerPoint.Shape> shapesOnNextSlide = new List <PowerPoint.Shape>();

            foreach (PowerPoint.Shape sh in nextSlide.Shapes)
            {
                if (!nextSlide.HasEntryAnimation(sh) && !ShapeUtil.IsHidden(sh))
                {
                    shapesOnNextSlide.Add(sh);
                }
            }

            var copiedShapes = new List <PowerPoint.Shape>();

            foreach (PowerPoint.Shape sh in shapesOnNextSlide)
            {
                sh.Copy();
                var shapeCopy = nextSlide.Shapes.Paste()[1];
                LegacyShapeUtil.CopyShapeAttributes(sh, ref shapeCopy);
                copiedShapes.Add(shapeCopy);
            }

            SelectAllShape(copiedShapes);
            PowerPoint.Selection sel        = Globals.ThisAddIn.Application.ActiveWindow.Selection;
            PowerPoint.Shape     shapeGroup = null;
            if (sel.ShapeRange.Count > 1)
            {
                shapeGroup = sel.ShapeRange.Group();
            }
            else
            {
                shapeGroup = sel.ShapeRange[1];
            }

            shapeGroup.Copy();
            pictureOnNextSlide = nextSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
            LegacyShapeUtil.CopyShapePosition(shapeGroup, ref pictureOnNextSlide);
            shapeGroup.Delete();

            pictureOnNextSlide.Copy();
            PowerPoint.Shape slidePicture = currentSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
            return(slidePicture);
        }
Exemplo n.º 17
0
 private static bool HasBeamShape(PowerPointSlide slide)
 {
     return(slide.Shapes.Cast <Shape>().Any(AgendaShape.IsBeamShape));
 }
Exemplo n.º 18
0
        public static void AddDrillDownAnimation(PowerPoint.Shape selectedShape, PowerPointSlide currentSlide)
        {
            PowerPointDrillDownSlide addedSlide;

            AddDrillDownAnimation(selectedShape, currentSlide, out addedSlide);
        }
Exemplo n.º 19
0
        protected override void ExecuteAction(string ribbonId)
        {
            if (AudioSettingService.selectedVoiceType == VoiceType.AzureVoice &&
                AzureAccount.GetInstance().IsEmpty())
            {
                MessageBox.Show("Invalid user account. Please log in again.");
                return;
            }

            //TODO: This needs to improved to stop using global variables
            this.StartNewUndoEntry();

            PowerPointSlide currentSlide = this.GetCurrentSlide();

            // If there are text in notes page for any of the selected slides
            if (this.GetCurrentPresentation().SelectedSlides.Any(slide => slide.NotesPageText.Trim() != ""))
            {
                ComputerVoiceRuntimeService.IsRemoveAudioEnabled = true;
                this.GetRibbonUi().RefreshRibbonControl("RemoveNarrationsButton");
            }

            try
            {
                ComputerVoiceRuntimeService.EmbedSelectedSlideNotes();
            }
            catch
            {
                MessageBox.Show("Failed to generate audio files.");
                return;
            }

            CustomTaskPane recorderPane = this.GetAddIn().GetActivePane(typeof(RecorderTaskPane));

            if (recorderPane == null)
            {
                return;
            }

            RecorderTaskPane recorder = recorderPane.Control as RecorderTaskPane;

            if (recorder == null)
            {
                return;
            }

            // initialize selected slides' audio
            List <string[]> allAudioFiles = ComputerVoiceRuntimeService.ExtractSlideNotes();

            recorder.InitializeAudioAndScript(this.GetCurrentPresentation().SelectedSlides.ToList(),
                                              allAudioFiles, true);

            // if current list is visible, update the pane immediately
            if (recorderPane.Visible)
            {
                recorder.UpdateLists(currentSlide.ID);
            }

            if (AudioSettingService.IsPreviewEnabled)
            {
                ComputerVoiceRuntimeService.PreviewAnimations();
            }
        }
Exemplo n.º 20
0
        //Return picture copy of previous slide where shapes with exit animations have been deleted
        private static PowerPoint.Shape GetPreviousSlidePictureWithBackground(PowerPointSlide currentSlide, PowerPointSlide previousSlide)
        {
            PowerPointSlide         previousSlideCopy = previousSlide.Duplicate();
            List <PowerPoint.Shape> shapes            = previousSlideCopy.Shapes.Cast <PowerPoint.Shape>().ToList();
            var matchingShapes = shapes.Where(current => previousSlideCopy.HasExitAnimation(current));

            foreach (PowerPoint.Shape s in matchingShapes)
            {
                s.Delete();
            }

            previousSlideCopy.Copy();
            PowerPoint.Shape slidePicture = currentSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
            previousSlideCopy.Delete();
            return(slidePicture);
        }
Exemplo n.º 21
0
 public static void ExportSlide(PowerPointSlide slide, string exportPath, float magnifyRatio = 1.0f)
 {
     ExportSlide(slide.GetNativeSlide(), exportPath, magnifyRatio);
 }
Exemplo n.º 22
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 (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;
            }
        }
Exemplo n.º 23
0
 public void DeleteShapesForUnusedItem(PowerPointSlide slide, ExplanationItem selfExplanationClickItem)
 {
     CalloutService.DeleteCalloutShape(slide, selfExplanationClickItem.tagNo);
     CaptionService.DeleteCaptionShape(slide, selfExplanationClickItem.tagNo);
 }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 25
0
        internal static PowerPointBgEffectSlide GenerateEffectSlide(PowerPointSlide curSlide, Selection selection, bool generateOnRemainder)
        {
            PowerPointSlide dupSlide = null;

            try
            {
                ShapeRange shapeRange = selection.ShapeRange;
                if (selection.HasChildShapeRange)
                {
                    shapeRange = selection.ChildShapeRange;
                }

                if (shapeRange.Count != 0)
                {
                    dupSlide = curSlide.Duplicate();
                }

                shapeRange.Cut();

                PowerPointBgEffectSlide effectSlide = PowerPointBgEffectSlide.BgEffectFactory(curSlide.GetNativeSlide(), generateOnRemainder);

                if (dupSlide != null)
                {
                    if (generateOnRemainder)
                    {
                        dupSlide.Delete();
                    }
                    else
                    {
                        dupSlide.MoveTo(curSlide.Index);
                        curSlide.Delete();
                    }
                }

                return(effectSlide);
            }
            catch (InvalidOperationException e)
            {
                MessageBox.Show(e.Message);
                return(null);
            }
            catch (COMException)
            {
                if (dupSlide != null)
                {
                    dupSlide.Delete();
                }

                MessageBox.Show(TextCollection.EffectsLabText.ErrorSelectAtLeastOneShape);
                return(null);
            }
            catch (Exception e)
            {
                if (dupSlide != null)
                {
                    dupSlide.Delete();
                }

                ErrorDialogBox.ShowDialog(CommonText.ErrorTitle, e.Message, e);
                return(null);
            }
        }
Exemplo n.º 26
0
        private static PowerPoint.Shape GetStepBackWithoutBackgroundShapeToZoom(PowerPointSlide addedSlide, PowerPointSlide previousSlide)
        {
            Globals.ThisAddIn.Application.ActiveWindow.Selection.Unselect();
            Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(addedSlide.Index);

            var copiedShapes = new List <PowerPoint.Shape>();

            foreach (PowerPoint.Shape sh in previousSlide.Shapes)
            {
                if (!previousSlide.HasExitAnimation(sh) && !ShapeUtil.IsHidden(sh))
                {
                    sh.Copy();
                    PowerPoint.Shape shapeCopy = addedSlide.Shapes.Paste()[1];
                    LegacyShapeUtil.CopyShapeAttributes(sh, ref shapeCopy);
                    copiedShapes.Add(shapeCopy);
                }
            }

            SelectAllShape(copiedShapes);
            PowerPoint.Selection sel        = Globals.ThisAddIn.Application.ActiveWindow.Selection;
            PowerPoint.Shape     shapeGroup = null;
            if (sel.ShapeRange.Count > 1)
            {
                shapeGroup = sel.ShapeRange.Group();
            }
            else
            {
                shapeGroup = sel.ShapeRange[1];
            }

            shapeGroup.Copy();
            PowerPoint.Shape previousSlidePicture = addedSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
            LegacyShapeUtil.CopyShapePosition(shapeGroup, ref previousSlidePicture);
            previousSlidePicture.Name = "PPTZoomOutShape" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
            shapeGroup.Delete();

            return(previousSlidePicture);
        }
Exemplo n.º 27
0
 private static void TakeScreenshotProxy(PowerPointSlide currentSlide, ShapeRange shapeRange)
 {
     shapeRange.Visible = Office.MsoTriState.msoFalse;
     GraphicsUtil.ExportSlide(currentSlide, SlidePicture);
     shapeRange.Visible = Office.MsoTriState.msoTrue;
 }
Exemplo n.º 28
0
        protected override ShapeRange ExecutePasteAction(string ribbonId, PowerPointPresentation presentation, PowerPointSlide slide,
                                                         ShapeRange selectedShapes, ShapeRange selectedChildShapes)
        {
            PowerPointSlide tempSlide         = presentation.AddSlide(index: slide.Index);
            ShapeRange      tempPastingShapes = ClipboardUtil.PasteShapesFromClipboard(tempSlide);

            if (tempPastingShapes == null)
            {
                tempSlide.Delete();
                return(ClipboardUtil.PasteShapesFromClipboard(slide));
            }

            ShapeRange pastingShapes = slide.CopyShapesToSlide(tempPastingShapes);

            tempSlide.Delete();

            return(pastingShapes);
        }
Exemplo n.º 29
0
 public SlideSelectionTracker(List <PowerPointSlide> selectedSlides, PowerPointSlide userCurrentSlide)
 {
     UserCurrentSlide = userCurrentSlide;
     _selectedSlides  = selectedSlides;
 }
Exemplo n.º 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="targetSlide"></param>
        /// <param name="isLoadingWithDefaultPicture">when no style found, use default picture to preview style</param>
        /// <returns>is successfully loaded</returns>
        private bool LoadStyleAndImage(PowerPointSlide targetSlide, bool isLoadingWithDefaultPicture = true)
        {
            if (targetSlide == null)
            {
                return(false);
            }

            var isSuccessfullyLoaded = false;
            var originalShapeList    = targetSlide
                                       .GetShapesWithPrefix(ShapeNamePrefix + "_" + EffectName.Original_DO_NOT_REMOVE);
            var croppedShapeList = targetSlide
                                   .GetShapesWithPrefix(ShapeNamePrefix + "_" + EffectName.Cropped_DO_NOT_REMOVE);

            // if no original shape, show default picture
            if (originalShapeList.Count == 0 && isLoadingWithDefaultPicture)
            {
                // De-select the picture
                EnterDefaultPictureMode();

                UpdatePreviewImages(isEnteringPictureVariation: true);
                UpdatePreviewStageControls();
                isSuccessfullyLoaded = true;
            }
            else if (originalShapeList.Count > 0) // load the style
            {
                Logger.Log("Original shapes found.");
                var originalImageShape    = originalShapeList[0];
                var isImageStillInListBox = false;
                var styleName             = originalImageShape.Tags[Service.Effect.Tag.ReloadPrefix + "StyleName"];

                // if the image source is still in the listbox,
                // select it as source and also select the target style
                for (var i = 0; i < ImageSelectionListBox.Items.Count; i++)
                {
                    var imageItem = (ImageItem)ImageSelectionListBox.Items[i];
                    if (imageItem.FullSizeImageFile == originalImageShape.Tags[Service.Effect.Tag.ReloadOriginImg] ||
                        imageItem.ContextLink == originalImageShape.Tags[Service.Effect.Tag.ReloadImgContext])
                    {
                        isImageStillInListBox = true;
                        UpdatePictureDimensionsInfo(croppedShapeList, originalImageShape, imageItem);
                        ImageSelectionListBox.SelectedIndex = i;
                        // previewing is done async, need to use beginInvoke
                        // so that it's after previewing
                        OpenVariationFlyoutForReload(styleName, originalImageShape);
                        break;
                    }
                }

                // if image source is deleted already, need to re-generate images
                // and put into listbox
                if (!isImageStillInListBox)
                {
                    var imageItem = ExtractImageItem(originalImageShape, croppedShapeList);
                    ViewModel.ImageSelectionList.Add(imageItem);

                    ImageSelectionListBox.SelectedIndex = ImageSelectionListBox.Items.Count - 1;
                    OpenVariationFlyoutForReload(styleName, originalImageShape);
                }
                isSuccessfullyLoaded = true;
            }
            return(isSuccessfullyLoaded);
        }