Exemple #1
0
        public static void AddAnimationInSlide(bool isHighlightBullets = false, bool isHighlightTextFragments = false)
        {
            try
            {
                PowerPointSlide       currentSlide   = PowerPointCurrentPresentationInfo.CurrentSlide;
                PowerPoint.ShapeRange selectedShapes = Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange;

                currentSlide.RemoveAnimationsForShapes(selectedShapes.Cast <PowerPoint.Shape>().ToList());

                if (!isHighlightBullets && !isHighlightTextFragments)
                {
                    FormatInSlideAnimateShapes(selectedShapes, isHighlightTextFragments);
                }

                if (selectedShapes.Count == 1)
                {
                    InSlideAnimateSingleShape(currentSlide, selectedShapes[1]);
                }
                else
                {
                    InSlideAnimateMultiShape(currentSlide, selectedShapes, isHighlightTextFragments);
                }

                if (!isHighlightBullets && !isHighlightTextFragments)
                {
                    Globals.ThisAddIn.Application.CommandBars.ExecuteMso("AnimationPreview");
                    PowerPointPresentation.Current.AddAckSlide();
                }
            }
            catch (Exception e)
            {
                Logger.LogException(e, "AddAnimationInSlide");
                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 shapes)
        {
            List <PowerPoint.Shape> shapesToUse = shapes.Cast <PowerPoint.Shape>()
                                                  .Where(sh => !sh.Name.Contains("PPTLabsHighlightBackgroundShape") &&
                                                         HasText(sh))
                                                  .ToList();

            return(shapesToUse);
        }
        public static void SyncShapeRange(ShapeRange refShapeRange, ShapeRange candidateShapeRange)
        {
            // all names of identical shapes should be consistent
            if (refShapeRange.Count != candidateShapeRange.Count)
            {
                return;
            }

            foreach (object shape in candidateShapeRange)
            {
                Shape candidateShape = shape as Shape;
                Shape refShape       = refShapeRange.Cast <Shape>().FirstOrDefault(item => IsSameType(item, candidateShape) &&
                                                                                   IsSamePosition(item, candidateShape,
                                                                                                  false, 15) &&
                                                                                   IsSameSize(item, candidateShape));

                if (candidateShape == null || refShape == null)
                {
                    continue;
                }

                candidateShape.Name = refShape.Name;
            }
        }
Exemple #4
0
 /// <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());
 }
Exemple #5
0
        public static void SyncShapeRange(ShapeRange refShapeRange, ShapeRange candidateShapeRange)
        {
            // all names of identical shapes should be consistent
            if (refShapeRange.Count != candidateShapeRange.Count)
            {
                return;
            }

            foreach (var shape in candidateShapeRange)
            {
                var candidateShape = shape as Shape;
                var refShape = refShapeRange.Cast<Shape>().FirstOrDefault(item => IsSameType(item, candidateShape) &&
                                                                                  IsSamePosition(item, candidateShape,
                                                                                                 false, 15) &&
                                                                                  IsSameSize(item, candidateShape));

                if (candidateShape == null || refShape == null) continue;

                candidateShape.Name = refShape.Name;
            }
        }