private void PrepareForZoomToArea(PowerPointSlide slideToPanFrom, PowerPointSlide slideToPanTo)
        {
            //Delete all shapes from slide excpet last magnified shape
            List<PowerPoint.Shape> shapes = _slide.Shapes.Cast<PowerPoint.Shape>().ToList();
            var matchingShapes = shapes.Where(current => (!current.Name.Contains("PPTLabsMagnifyAreaGroup")));
            foreach (PowerPoint.Shape s in matchingShapes)
                s.Delete();

            panShapeFrom = GetShapesWithPrefix("PPTLabsMagnifyAreaGroup")[0];
            panShapeTo = slideToPanTo.GetShapesWithPrefix("PPTLabsMagnifyAreaGroup")[0];

            //Add fade animation to existing shapes
            shapes = _slide.Shapes.Cast<PowerPoint.Shape>().ToList();
            matchingShapes = shapes.Where(current => (!(current.Equals(indicatorShape) || current.Equals(panShapeFrom))));
            foreach (PowerPoint.Shape s in matchingShapes)
            {
                DeleteShapeAnimations(s);
                PowerPoint.Effect effectFade = _slide.TimeLine.MainSequence.AddEffect(s, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious);
                effectFade.Exit = Office.MsoTriState.msoTrue;
                effectFade.Timing.Duration = 0.25f;
            }

            DeleteSlideNotes();
            DeleteSlideMedia();
            ManageSlideTransitions();
            indicatorShape = AddPowerPointLabsIndicator();
        }
Exemplo n.º 2
0
        public static void AddFrameMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape initialShape, PowerPoint.Shape finalShape, float duration)
        {
            float initialX = (initialShape.Left + (initialShape.Width) / 2);
            float initialY = (initialShape.Top + (initialShape.Height) / 2);
            float initialRotation = initialShape.Rotation;
            float initialWidth = initialShape.Width;
            float initialHeight = initialShape.Height;
            float initialFont = 0.0f;

            float finalX = (finalShape.Left + (finalShape.Width) / 2);
            float finalY = (finalShape.Top + (finalShape.Height) / 2);
            float finalRotation = finalShape.Rotation;
            float finalWidth = finalShape.Width;
            float finalHeight = finalShape.Height;
            float finalFont = 0.0f;

            if (initialShape.HasTextFrame == Office.MsoTriState.msoTrue && (initialShape.TextFrame.HasText == Office.MsoTriState.msoTriStateMixed || initialShape.TextFrame.HasText == Office.MsoTriState.msoTrue) && initialShape.TextFrame.TextRange.Font.Size != finalShape.TextFrame.TextRange.Font.Size)
            {
                finalFont = finalShape.TextFrame.TextRange.Font.Size;
                initialFont = initialShape.TextFrame.TextRange.Font.Size;
            }

            int numFrames = (int)(duration / 0.04f);
            numFrames = (numFrames > 30) ? 30 : numFrames;

            float incrementWidth = ((finalWidth / initialWidth) - 1.0f) / numFrames;
            float incrementHeight = ((finalHeight / initialHeight) - 1.0f) / numFrames;
            float incrementRotation = PowerPointLabsGlobals.GetMinimumRotation(initialRotation, finalRotation) / numFrames;
            float incrementLeft = (finalX - initialX) / numFrames;
            float incrementTop = (finalY - initialY) / numFrames;
            float incrementFont = (finalFont - initialFont) / numFrames;

            AddFrameAnimationEffects(animationSlide, initialShape, incrementLeft, incrementTop, incrementWidth, incrementHeight, incrementRotation, incrementFont, duration, numFrames);
        }
        private static List<PowerPoint.Shape> GetShapesFromLinesInText(PowerPointSlide currentSlide, Office.TextRange2 text, PowerPoint.Shape shape)
        {
            List<PowerPoint.Shape> shapesToAnimate = new List<PowerPoint.Shape>();

            foreach (Office.TextRange2 line in text.Lines)
            {
                PowerPoint.Shape highlightShape = currentSlide.Shapes.AddShape(
                    Office.MsoAutoShapeType.msoShapeRoundedRectangle,
                    line.BoundLeft,
                    line.BoundTop,
                    line.BoundWidth,
                    line.BoundHeight);

                highlightShape.Adjustments[1] = 0.25f;
                highlightShape.Fill.ForeColor.RGB = Utils.Graphics.ConvertColorToRgb(backgroundColor);
                highlightShape.Fill.Transparency = 0.50f;
                highlightShape.Line.Visible = Office.MsoTriState.msoFalse;
                Utils.Graphics.MoveZToJustBehind(highlightShape, shape);
                highlightShape.Name = "PPTLabsHighlightTextFragmentsShape" + Guid.NewGuid().ToString();
                highlightShape.Tags.Add("HighlightTextFragment", highlightShape.Name);
                highlightShape.Select(Office.MsoTriState.msoFalse);
                shapesToAnimate.Add(highlightShape);
            }

            return shapesToAnimate;
        }
        public void AddZoomToAreaAnimation(PowerPointSlide slideToPanFrom, PowerPointSlide slideToPanTo)
        {
            PrepareForZoomToArea(slideToPanFrom, slideToPanTo);
            DefaultMotionAnimation.AddZoomToAreaPanAnimation(this, panShapeFrom, panShapeTo, PowerPoint.MsoAnimTriggerType.msoAnimTriggerAfterPrevious);
            DefaultMotionAnimation.PreloadShape(this, panShapeFrom);

            indicatorShape.ZOrder(Office.MsoZOrderCmd.msoBringToFront);
        }
Exemplo n.º 5
0
        private static List<PowerPointSlide> AddMultiSlideZoomToArea(PowerPointSlide currentSlide, List<PowerPoint.Shape> shapesToZoom)
        {
            var addedSlides = new List<PowerPointSlide>();

            int shapeCount = 1;
            PowerPointSlide lastMagnifiedSlide = null;
            PowerPointMagnifyingSlide magnifyingSlide = null;
            PowerPointMagnifiedSlide magnifiedSlide = null;
            PowerPointMagnifiedPanSlide magnifiedPanSlide = null;
            PowerPointDeMagnifyingSlide deMagnifyingSlide = null;

            foreach (PowerPoint.Shape selectedShape in shapesToZoom)
            {
                magnifyingSlide = (PowerPointMagnifyingSlide)currentSlide.CreateZoomMagnifyingSlide();
                magnifyingSlide.AddZoomToAreaAnimation(selectedShape);

                magnifiedSlide = (PowerPointMagnifiedSlide)magnifyingSlide.CreateZoomMagnifiedSlide();
                magnifiedSlide.AddZoomToAreaAnimation(selectedShape);
                addedSlides.Add(magnifiedSlide);

                if (shapeCount != 1)
                {
                    magnifiedPanSlide = (PowerPointMagnifiedPanSlide)lastMagnifiedSlide.CreateZoomPanSlide();
                    magnifiedPanSlide.AddZoomToAreaAnimation(lastMagnifiedSlide, magnifiedSlide);
                    addedSlides.Add(magnifiedPanSlide);
                }

                if (shapeCount == shapesToZoom.Count)
                {
                    deMagnifyingSlide = (PowerPointDeMagnifyingSlide)magnifyingSlide.CreateZoomDeMagnifyingSlide();
                    deMagnifyingSlide.MoveTo(magnifyingSlide.Index + 2);
                    deMagnifyingSlide.AddZoomToAreaAnimation(selectedShape);
                    addedSlides.Add(deMagnifyingSlide);
                }

                selectedShape.Delete();

                if (shapeCount != 1)
                {
                    magnifyingSlide.Delete();
                    magnifiedSlide.MoveTo(magnifiedPanSlide.Index);
                    if (deMagnifyingSlide != null)
                        deMagnifyingSlide.MoveTo(magnifiedSlide.Index);
                    lastMagnifiedSlide = magnifiedSlide;
                }
                else
                {
                    addedSlides.Add(magnifyingSlide);
                    lastMagnifiedSlide = magnifiedSlide;
                }

                shapeCount++;
            }

            Graphics.SortByIndex(addedSlides);
            return addedSlides;
        }
        //Add highlight shape for paragraphs within selected shape which have bullets or with text selected by user
        private static bool AddNewShapesToAnimate(PowerPointSlide currentSlide, List<PowerPoint.Shape> shapesToUse, Office.TextRange2 selectedText)
        {
            bool anySelected = false;

            foreach (var sh in shapesToUse)
            {
                sh.Name = "HighlightBackgroundShape" + Guid.NewGuid();
            }

            if (userSelection == HighlightBackgroundSelection.kTextSelected)
            {
                foreach (var sh in shapesToUse)
                {
                    foreach (Office.TextRange2 paragraph in sh.TextFrame2.TextRange.Paragraphs)
                    {
                        if (paragraph.Start <= selectedText.Start + selectedText.Length
                            && selectedText.Start <= paragraph.Start + paragraph.Length - 1
                            && paragraph.TrimText().Length > 0)
                        {
                            GenerateHighlightShape(currentSlide, paragraph, sh);
                            anySelected = true;
                        }
                    }
                }
            }
            else
            {
                foreach (var sh in shapesToUse)
                {
                    bool anySelectedForShape = false;
                    foreach (Office.TextRange2 paragraph in sh.TextFrame2.TextRange.Paragraphs)
                    {
                        if (paragraph.ParagraphFormat.Bullet.Visible == Office.MsoTriState.msoTrue
                            && paragraph.TrimText().Length > 0)
                        {
                            GenerateHighlightShape(currentSlide, paragraph, sh);
                            anySelected = true;
                            anySelectedForShape = true;
                        }
                    }
                    if (anySelectedForShape)
                    {
                        continue;
                    }
                    foreach (Office.TextRange2 paragraph in sh.TextFrame2.TextRange.Paragraphs)
                    {
                        if (paragraph.TrimText().Length > 0)
                        {
                            GenerateHighlightShape(currentSlide, paragraph, sh);
                            anySelected = true;
                        }
                    }
                }
            }
            return anySelected;
        }
Exemplo n.º 7
0
        private static void PostFormatShapeOnCurrentSlide(PowerPointSlide currentSlide, PowerPoint.Shape spotShape)
        {
            //Format selected shape on current slide
            spotShape.Fill.ForeColor.RGB = 0xaaaaaa;
            spotShape.Fill.Transparency = 0.7f;
            spotShape.Line.Visible = Office.MsoTriState.msoTrue;
            spotShape.Line.ForeColor.RGB = 0x000000;

            Utils.Graphics.MakeShapeViewTimeInvisible(spotShape, currentSlide);
        }
 private static void InSlideAnimateSingleShape(PowerPointSlide currentSlide, PowerPoint.Shape shapeToAnimate)
 {
     PowerPoint.Effect appear = currentSlide.TimeLine.MainSequence.AddEffect(
         shapeToAnimate, 
         PowerPoint.MsoAnimEffect.msoAnimEffectAppear, 
         PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, 
         PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick);
     PowerPoint.Effect disappear = currentSlide.TimeLine.MainSequence.AddEffect(
         shapeToAnimate, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, 
         PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, 
         PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick);
     disappear.Exit = Office.MsoTriState.msoTrue;
 }
Exemplo n.º 9
0
 public static AgendaSlide Decode(PowerPointSlide slide)
 {
     if (slide == null) return null;
     try
     {
         return Decode(slide.Name);
     }
     catch (COMException e)
     {
         // sometims the shape is inaccessible (perhaps deleted. never occurred to me before.)
         // in this case, a COMException is thrown. so we return null.
         return null;
     }
 }
        //Use initial shape and final shape to calculate intial and final positions.
        //Add motion and resize animations to shapeToZoom
        public static void AddZoomToAreaMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape shapeToZoom, PowerPoint.Shape initialShape, PowerPoint.Shape finalShape, float duration, PowerPoint.MsoAnimTriggerType trigger)
        {
            float initialWidth = initialShape.Width;
            float finalWidth = finalShape.Width;
            float initialHeight = initialShape.Height;
            float finalHeight = finalShape.Height;

            float initialX = (initialShape.Left + (initialShape.Width) / 2) * (finalWidth / initialWidth);
            float finalX = (finalShape.Left + (finalShape.Width) / 2) * (finalWidth / initialWidth);
            float initialY = (initialShape.Top + (initialShape.Height) / 2) * (finalHeight / initialHeight);
            float finalY = (finalShape.Top + (finalShape.Height) / 2) * (finalHeight / initialHeight);

            AddMotionAnimation(animationSlide, shapeToZoom, initialX, initialY, finalX, finalY, duration, ref trigger);
            AddResizeAnimation(animationSlide, shapeToZoom, initialWidth, initialHeight, finalWidth, finalHeight, duration, ref trigger);
        }
        //Use shapeToZoom and reference shape to calculate intial and final positions
        //Add motion and resize animations to shapeToZoom
        public static void AddStepBackMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape shapeToZoom, PowerPoint.Shape referenceShape, float duration, PowerPoint.MsoAnimTriggerType trigger)
        {
            float initialX = (shapeToZoom.Left + (shapeToZoom.Width) / 2);
            float finalX = (referenceShape.Left + (referenceShape.Width) / 2);
            float initialY = (shapeToZoom.Top + (shapeToZoom.Height) / 2);
            float finalY = (referenceShape.Top + (referenceShape.Height) / 2);

            float initialWidth = shapeToZoom.Width;
            float finalWidth = referenceShape.Width;
            float initialHeight = shapeToZoom.Height;
            float finalHeight = referenceShape.Height;

            AddMotionAnimation(animationSlide, shapeToZoom, initialX, initialY, finalX, finalY, duration, ref trigger);
            AddResizeAnimation(animationSlide, shapeToZoom, initialWidth, initialHeight, finalWidth, finalHeight, duration, ref trigger);
        }
        //Use reference shape and slide dimensions to calculate intial and final positions
        //Add motion and resize animations to shapeToZoom
        public static void AddDrillDownMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape shapeToZoom, PowerPoint.Shape referenceShape, float duration, PowerPoint.MsoAnimTriggerType trigger)
        {
            float finalWidth = PowerPointPresentation.Current.SlideWidth;
            float initialWidth = referenceShape.Width;
            float finalHeight = PowerPointPresentation.Current.SlideHeight;
            float initialHeight = referenceShape.Height;

            float finalX = (PowerPointPresentation.Current.SlideWidth / 2) * (finalWidth / initialWidth);
            float initialX = (referenceShape.Left + (referenceShape.Width) / 2) * (finalWidth / initialWidth);
            float finalY = (PowerPointPresentation.Current.SlideHeight / 2) * (finalHeight / initialHeight);
            float initialY = (referenceShape.Top + (referenceShape.Height) / 2) * (finalHeight / initialHeight);

            AddMotionAnimation(animationSlide, shapeToZoom, initialX, initialY, finalX, finalY, duration, ref trigger);
            AddResizeAnimation(animationSlide, shapeToZoom, initialWidth, initialHeight, finalWidth, finalHeight, duration, ref trigger);
        }
        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();
        }
        private static Shape AddCaptionBoxToSlide(string caption, PowerPointSlide s)
        {
            float slideWidth = PowerPointPresentation.Current.SlideWidth;
            float slideHeight = PowerPointPresentation.Current.SlideHeight;
            
            Shape textBox = s.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, slideHeight - 100,
                slideWidth, 100);
            textBox.TextFrame.AutoSize = PpAutoSize.ppAutoSizeShapeToFitText;
            textBox.TextFrame.TextRange.Text = caption;
            textBox.TextFrame.WordWrap = MsoTriState.msoTrue;
            textBox.TextEffect.Alignment = MsoTextEffectAlignment.msoTextEffectAlignmentCentered;
            textBox.TextFrame.TextRange.Font.Size = 12;
            textBox.Fill.BackColor.RGB = 0;
            textBox.Fill.Transparency = 0.2f;
            textBox.TextFrame.TextRange.Font.Color.RGB = 0xffffff;

            textBox.Top = slideHeight - textBox.Height;
            return textBox;
        }
Exemplo n.º 15
0
        // before we embed we need to check if we have any old shape on the slide. If
        // we have, we need to delete it AFTER the new shape is inserted to preserve
        // the original timeline.
        public void EmbedOnSlide(PowerPointSlide slide, int clickNumber)
        {
            var isOnClick = clickNumber > 0;
            var shapeName = Name;

            if (slide != null)
            {
                // embed new shape using two-turn method. In the first turn, embed the shape, name it to
                // something special to distinguish from the old shape; in the second turn, delete the
                // old shape using timeline invariant deletion, and rename the new shape to the correct
                // name.
                try
                {
                    var audioShape = AudioHelper.InsertAudioFileOnSlide(slide, SaveName);
                    audioShape.Name = "#";
                    slide.RemoveAnimationsForShape(audioShape);

                    if (isOnClick)
                    {
                        slide.SetShapeAsClickTriggered(audioShape, clickNumber, MsoAnimEffect.msoAnimEffectMediaPlay);
                    }
                    else
                    {
                        slide.SetAudioAsAutoplay(audioShape);
                    }

                    // delete old shape
                    slide.DeleteShapesWithPrefixTimelineInvariant(Name);

                    audioShape.Name = shapeName;
                }
                catch (COMException)
                {
                    // Adding the file failed for one reason or another - probably cancelled by the user.
                }
            }
            else
            {
                MessageBox.Show("Slide selection error");
            }
        }
        private static void InSlideAnimateMultiShape(PowerPointSlide currentSlide, PowerPoint.ShapeRange shapesToAnimate)
        {
            for (int num = 1; num <= shapesToAnimate.Count - 1; num++)
            {
                PowerPoint.Shape shape1 = shapesToAnimate[num];
                PowerPoint.Shape shape2 = shapesToAnimate[num + 1];

                if (shape1 == null || shape2 == null)
                    return;

                if (!isHighlightTextFragments)
                {
                    AnimateMovementBetweenShapes(currentSlide, shape1, shape2);
                }

                if (isHighlightTextFragments)
                {
                    //Transition from shape1 to shape2 with movement
                    PowerPoint.Effect shape2Appear = currentSlide.TimeLine.MainSequence.AddEffect(
                        shape2,
                        PowerPoint.MsoAnimEffect.msoAnimEffectFade,
                        PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone,
                        PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick);
                }
                else
                {
                    //Transition from shape1 to shape2 with fade
                    PowerPoint.Effect shape2Appear = currentSlide.TimeLine.MainSequence.AddEffect(
                        shape2,
                        PowerPoint.MsoAnimEffect.msoAnimEffectAppear,
                        PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone,
                        PowerPoint.MsoAnimTriggerType.msoAnimTriggerAfterPrevious);
                }
                PowerPoint.Effect shape1Disappear = currentSlide.TimeLine.MainSequence.AddEffect(
                        shape1,
                        PowerPoint.MsoAnimEffect.msoAnimEffectFade,
                        PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone,
                        PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious);
                shape1Disappear.Exit = Office.MsoTriState.msoTrue;
            }
        }
        private static void EmbedCaptionsOnSlide(PowerPointSlide s)
        {
            String rawNotes = s.NotesPageText;

            if (String.IsNullOrWhiteSpace(rawNotes))
            {
                return;
            }

            var separatedNotes = SplitNotesByClicks(rawNotes);
            var captionCollection = ConvertSectionsToCaptions(separatedNotes);
            if (captionCollection.Count == 0)
            {
                return;
            }

            Shape previous = null;
            for (int i = 0; i < captionCollection.Count; i++)
            {
                String currentCaption = captionCollection[i];
                Shape captionBox = AddCaptionBoxToSlide(currentCaption, s);
                captionBox.Name = "PowerPointLabs Caption " + i;

                if (i == 0)
                {
                    s.SetShapeAsAutoplay(captionBox);
                }

                if (i != 0)
                {
                    s.ShowShapeAfterClick(captionBox, i);
                    s.HideShapeAfterClick(previous, i);
                }

                if (i == captionCollection.Count - 1)
                {
                    s.HideShapeAsLastClickIfNeeded(captionBox);
                }
                previous = captionBox;
            }
        }
        public static PowerPointSlide FromSlideFactory(Slide slide, bool includeIndicator = false)
        {
            if (slide == null)
            {
                return null;
            }

            PowerPointSlide powerPointSlide;
            if (slide.Name.Contains("PPTLabsSpotlight"))
                powerPointSlide = PowerPointSpotlightSlide.FromSlideFactory(slide);
            else if (PowerPointAckSlide.IsAckSlide(slide))
                powerPointSlide = PowerPointAckSlide.FromSlideFactory(slide);
            else
                powerPointSlide = new PowerPointSlide(slide);

            if (includeIndicator)
            {
                powerPointSlide.AddPowerPointLabsIndicator();
            }
            return powerPointSlide;
        }
Exemplo n.º 19
0
        public static void AddStepBackFrameMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape initialShape)
        {
            float initialX = (initialShape.Left + (initialShape.Width) / 2);
            float initialY = (initialShape.Top + (initialShape.Height) / 2);
            float initialWidth = initialShape.Width;
            float initialHeight = initialShape.Height;

            float finalX = PowerPointPresentation.Current.SlideWidth / 2;
            float finalY = PowerPointPresentation.Current.SlideHeight / 2;
            float finalWidth = PowerPointPresentation.Current.SlideWidth;
            float finalHeight = PowerPointPresentation.Current.SlideHeight;

            int numFrames = 10;
            float duration = numFrames * 0.04f;

            float incrementWidth = ((finalWidth / initialWidth) - 1.0f) / numFrames;
            float incrementHeight = ((finalHeight / initialHeight) - 1.0f) / numFrames;
            float incrementLeft = (finalX - initialX) / numFrames;
            float incrementTop = (finalY - initialY) / numFrames;

            AddFrameAnimationEffects(animationSlide, initialShape, incrementLeft, incrementTop, incrementWidth, incrementHeight, 0.0f, 0.0f, duration, numFrames);
        }
#pragma warning disable 0618
        #region Main Synchronisation Function
        /// <summary>
        /// Call the function like this for example:
        /// SynchroniseSlidesUsingTemplate(slideTracker, refSlide, () => new VisualAgendaTemplate());
        /// generateTemplate is a function that returns a newly created template.
        /// </summary>
        private static void SynchroniseSlidesUsingTemplate(SlideSelectionTracker slideTracker, PowerPointSlide refSlide, Func<AgendaTemplate> generateTemplate)
        {
            var sections = Sections;

            var deletedShapeNames = RetrieveTrackedDeletions(refSlide);

            refSlide.DeleteSlideNumberShapes();
            refSlide.MakeShapeNamesNonDefault();
            refSlide.MakeShapeNamesUnique(shape => !AgendaShape.IsAnyAgendaShape(shape) &&
                                                   !PowerPointSlide.IsTemplateSlideMarker(shape));

            ScrambleSlideSectionNames();
            foreach (var currentSection in sections)
            {
                var template = generateTemplate();
                ConfigureTemplate(currentSection, template);

                var templateTable = RebuildSectionUsingTemplate(slideTracker, currentSection, template);
                SynchroniseAllSlides(template, templateTable, refSlide, sections, deletedShapeNames, currentSection);
            }

            TrackShapesInSlide(refSlide);
        }
#pragma warning disable 0618
        //Use initial shape and final shape to calculate intial and final positions
        //Add motion, resize and rotation animations to shape
        public static void AddDefaultMotionAnimation(
            PowerPointSlide animationSlide, 
            PowerPoint.Shape initialShape, 
            PowerPoint.Shape finalShape, 
            float duration,
            PowerPoint.MsoAnimTriggerType trigger)
        {
            float initialX = (initialShape.Left + (initialShape.Width) / 2);
            float initialY = (initialShape.Top + (initialShape.Height) / 2);
            float initialRotation = initialShape.Rotation;
            float initialWidth = initialShape.Width;
            float initialHeight = initialShape.Height;

            float finalX = (finalShape.Left + (finalShape.Width) / 2);
            float finalY = (finalShape.Top + (finalShape.Height) / 2);
            float finalRotation = finalShape.Rotation;
            float finalWidth = finalShape.Width;
            float finalHeight = finalShape.Height;

            AddMotionAnimation(animationSlide, initialShape, initialX, initialY, finalX, finalY, duration, ref trigger);
            AddResizeAnimation(animationSlide, initialShape, initialWidth, initialHeight, finalWidth, finalHeight, duration, ref trigger);
            AddRotationAnimation(animationSlide, initialShape, initialRotation, finalRotation, duration, ref trigger);
        }
 private static void RemoveCaptionsFromSlide(PowerPointSlide slide)
 {
     if (slide != null)
     {
         slide.DeleteShapesWithPrefixTimelineInvariant("PowerPointLabs Caption ");
     }
 }
Exemplo n.º 23
0
        private static bool GetMatchingShapeDetails(PowerPointSlide currentSlide, PowerPointSlide nextSlide)
        {
            currentSlideShapes = new PowerPoint.Shape[currentSlide.Shapes.Count];
            nextSlideShapes = new PowerPoint.Shape[currentSlide.Shapes.Count];
            matchingShapeIDs = new int[currentSlide.Shapes.Count];

            int counter = 0;
            PowerPoint.Shape tempMatchingShape = null;
            bool flag = false;
            
            foreach (PowerPoint.Shape sh in currentSlide.Shapes)
            {
                tempMatchingShape = nextSlide.GetShapeWithSameIDAndName(sh);
                if (tempMatchingShape == null)
                    tempMatchingShape = nextSlide.GetShapeWithSameName(sh);
                
                if (tempMatchingShape != null)
                {
                    currentSlideShapes[counter] = sh;
                    nextSlideShapes[counter] = tempMatchingShape;
                    matchingShapeIDs[counter] = sh.Id;
                    counter++;
                    flag = true;
                }
            }

            return flag;
        }
Exemplo n.º 24
0
 private static void RenameCurrentSlide(PowerPointSlide currentSlide)
 {
     if (currentSlide.Name.StartsWith("PPSlideEnd") || currentSlide.Name.StartsWith("PPSlideMulti"))
     {
         currentSlide.Name = "PPSlideMulti" + GetSlideIdentifier();
     }
     else
     {
         currentSlide.Name = "PPSlideStart" + GetSlideIdentifier();
     }
 }
Exemplo n.º 25
0
        private static void PrepareNextSlide(PowerPointSlide nextSlide)
        {
            if (nextSlide.Transition.EntryEffect != PowerPoint.PpEntryEffect.ppEffectFade && nextSlide.Transition.EntryEffect != PowerPoint.PpEntryEffect.ppEffectFadeSmoothly)
                nextSlide.Transition.EntryEffect = PowerPoint.PpEntryEffect.ppEffectNone;

            if (nextSlide.Name.StartsWith("PPSlideStart") || nextSlide.Name.StartsWith("PPSlideMulti"))
            {
                nextSlide.Name = "PPSlideMulti" + GetSlideIdentifier();
            }
            else
            {
                nextSlide.Name = "PPSlideEnd" + GetSlideIdentifier();
            }
        }
Exemplo n.º 26
0
        private static void AddCompleteAnimations(PowerPointSlide currentSlide, PowerPointSlide nextSlide)
        {
            var addedSlide = currentSlide.CreateAutoAnimateSlide() as PowerPointAutoAnimateSlide;
            Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(addedSlide.Index);

            AboutForm progressForm = new AboutForm();
            progressForm.Visible = true;

            addedSlide.MoveMotionAnimation(); //Move shapes with motion animation already added
            addedSlide.PrepareForAutoAnimate();
            RenameCurrentSlide(currentSlide);
            PrepareNextSlide(nextSlide);
            addedSlide.AddAutoAnimation(currentSlideShapes, nextSlideShapes, matchingShapeIDs);
            Globals.ThisAddIn.Application.CommandBars.ExecuteMso("AnimationPreview");
            PowerPointPresentation.Current.AddAckSlide();

            progressForm.Close();
        }
Exemplo n.º 27
0
 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);
 }
        private void AddSlideThumbnail(PowerPointSlide slide, int pos = -1, bool isCurrentSlide = false)
        {
            if (slide == null) return;

            var thumbnailPath = TempPath.GetPath("slide-" + DateTime.Now.GetHashCode() + slide.Index);
            slide.GetNativeSlide().Export(thumbnailPath, "JPG", GetPreviewWidth(), PreviewHeight);

            ImageItem imageItem;
            if (isCurrentSlide)
            {
                imageItem = new ImageItem
                {
                    ImageFile = thumbnailPath,
                    Tooltip = "(Current) Slide " + slide.Index
                };
            }
            else
            {
                imageItem = new ImageItem
                {
                    ImageFile = thumbnailPath,
                    Tooltip = "Slide " + slide.Index
                };
            }
            
            Dispatcher.Invoke(new Action(() =>
            {
                if (pos == -1)
                {
                    SlideList.Add(imageItem);
                }
                else
                {
                    SlideList.Insert(pos, imageItem);
                }
            }));
        }
Exemplo n.º 29
0
        private static void AddFrameAnimationEffects(PowerPointSlide animationSlide, PowerPoint.Shape initialShape, float incrementLeft, float incrementTop, float incrementWidth, float incrementHeight, float incrementRotation ,float incrementFont, float duration, int numFrames)
        {
            PowerPoint.Shape lastShape = initialShape;
            PowerPoint.Sequence sequence = animationSlide.TimeLine.MainSequence;
            for (int i = 1; i <= numFrames; i++)
            {
                PowerPoint.Shape dupShape = initialShape.Duplicate()[1];
                if (i != 1 && animationType != FrameMotionAnimationType.kZoomToAreaDeMagnify)
                    sequence[sequence.Count].Delete();

                if (animationType == FrameMotionAnimationType.kInSlideAnimate || animationType == FrameMotionAnimationType.kZoomToAreaPan || animationType == FrameMotionAnimationType.kZoomToAreaDeMagnify)
                    animationSlide.DeleteShapeAnimations(dupShape);

                if (animationType == FrameMotionAnimationType.kZoomToAreaPan)
                    dupShape.Name = "PPTLabsMagnifyPanAreaGroup" + DateTime.Now.ToString("yyyyMMddHHmmssffff");

                dupShape.LockAspectRatio = Office.MsoTriState.msoFalse;
                dupShape.Left = initialShape.Left;
                dupShape.Top = initialShape.Top;

                if (incrementWidth != 0.0f)
                    dupShape.ScaleWidth((1.0f + (incrementWidth * i)), Office.MsoTriState.msoFalse, Office.MsoScaleFrom.msoScaleFromMiddle);

                if (incrementHeight != 0.0f)
                    dupShape.ScaleHeight((1.0f + (incrementHeight * i)), Office.MsoTriState.msoFalse, Office.MsoScaleFrom.msoScaleFromMiddle);

                if (incrementRotation != 0.0f)
                    dupShape.Rotation += (incrementRotation * i);

                if (incrementLeft != 0.0f)
                    dupShape.Left += (incrementLeft * i);

                if (incrementTop != 0.0f)
                    dupShape.Top += (incrementTop * i);

                if (incrementFont != 0.0f)
                    dupShape.TextFrame.TextRange.Font.Size += (incrementFont * i);

                if (i == 1 && (animationType == FrameMotionAnimationType.kInSlideAnimate || animationType == FrameMotionAnimationType.kZoomToAreaPan))
                {
                    PowerPoint.Effect appear = sequence.AddEffect(dupShape, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick);
                }
                else
                {
                    PowerPoint.Effect appear = sequence.AddEffect(dupShape, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious);
                    appear.Timing.TriggerDelayTime = ((duration / numFrames) * i);
                }

                PowerPoint.Effect disappear = sequence.AddEffect(lastShape, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious);
                disappear.Exit = Office.MsoTriState.msoTrue;
                disappear.Timing.TriggerDelayTime = ((duration / numFrames) * i);

                lastShape = dupShape;
            }

            if (animationType == FrameMotionAnimationType.kInSlideAnimate || animationType == FrameMotionAnimationType.kZoomToAreaPan || animationType == FrameMotionAnimationType.kZoomToAreaDeMagnify)
            {
                PowerPoint.Effect disappearLast = sequence.AddEffect(lastShape, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerAfterPrevious);
                disappearLast.Exit = Office.MsoTriState.msoTrue;
                disappearLast.Timing.TriggerDelayTime = duration;
            }
        }
 public static bool IsCitationSlide(PowerPointSlide slide)
 {
     if (slide == null)
         return false;
     return slide.Name == PictureCitationSlideName;
 }
Exemplo n.º 31
0
 /// <summary>
 /// 1-indexed.
 /// </summary>
 public PowerPointSlide GetSlide(int index)
 {
     return(PowerPointSlide.FromSlideFactory(Presentation.Slides[index]));
 }