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(); IEnumerable <PowerPoint.Shape> 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(); }
private static PowerPoint.Effect AddMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape animationShape, float initialX, float initialY, float finalX, float finalY, float duration, ref PowerPoint.MsoAnimTriggerType trigger) { if ((finalX != initialX) || (finalY != initialY)) { PowerPoint.Effect effectMotion = animationSlide.TimeLine.MainSequence.AddEffect(animationShape, PowerPoint.MsoAnimEffect.msoAnimEffectPathDown, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, trigger); PowerPoint.AnimationBehavior motion = effectMotion.Behaviors[1]; effectMotion.Timing.Duration = duration; trigger = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious; //Create VML path for the motion path //This path needs to be a curved path to allow the user to edit points float point1X = ((finalX - initialX) / 2f) / PowerPointPresentation.Current.SlideWidth; float point1Y = ((finalY - initialY) / 2f) / PowerPointPresentation.Current.SlideHeight; float point2X = (finalX - initialX) / PowerPointPresentation.Current.SlideWidth; float point2Y = (finalY - initialY) / PowerPointPresentation.Current.SlideHeight; motion.MotionEffect.Path = "M 0 0 C " + point1X.ToString(CultureInfo.InvariantCulture) + " " + point1Y.ToString(CultureInfo.InvariantCulture) + " " + point1X.ToString(CultureInfo.InvariantCulture) + " " + point1Y.ToString(CultureInfo.InvariantCulture) + " " + point2X.ToString(CultureInfo.InvariantCulture) + " " + point2Y.ToString(CultureInfo.InvariantCulture) + " E"; effectMotion.Timing.SmoothStart = Office.MsoTriState.msoFalse; effectMotion.Timing.SmoothEnd = Office.MsoTriState.msoFalse; return(effectMotion); } return(null); }
private void ManageNonMatchingShapes(PowerPoint.Shape shapeToZoom, PowerPoint.Shape indicatorShape) { foreach (PowerPoint.Shape sh in _slide.Shapes) { if (!sh.Equals(indicatorShape) && !sh.Equals(shapeToZoom)) { if (!HasExitAnimation(sh)) { DeleteShapeAnimations(sh); PowerPoint.Effect effectFade = _slide.TimeLine.MainSequence.AddEffect(sh, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); effectFade.Exit = Office.MsoTriState.msoTrue; effectFade.Timing.Duration = AutoAnimate.defaultDuration; //fadeFlag = true; } else { DeleteShapeAnimations(sh); PowerPoint.Effect effectDisappear = null; effectDisappear = _slide.TimeLine.MainSequence.AddEffect(sh, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); effectDisappear.Exit = Office.MsoTriState.msoTrue; effectDisappear.Timing.Duration = 0; } } } }
/// <summary> /// Preloads a shape within the slide to reduce lag. Call after the animations for the shape have been created. /// </summary> public static void PreloadShape(PowerPointSlide animationSlide, PowerPoint.Shape shape, bool addCoverImage = true) { // The cover image is used to cover the screen while the preloading happens behind the cover image. PowerPoint.Shape coverImage = null; if (addCoverImage) { coverImage = shape.Duplicate()[1]; coverImage.Left = shape.Left; coverImage.Top = shape.Top; animationSlide.RemoveAnimationsForShape(coverImage); } float originalWidth = shape.Width; float originalHeight = shape.Height; float originalLeft = shape.Left; float originalTop = shape.Top; // fit the shape exactly in the screen for preloading. float scaleRatio = Math.Min(PowerPointPresentation.Current.SlideWidth / shape.Width, PowerPointPresentation.Current.SlideHeight / shape.Height); animationSlide.RelocateShapeWithoutPath(shape, 0, 0, shape.Width * scaleRatio, shape.Height * scaleRatio); MsoAnimTriggerType trigger = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious; Effect effectMotion = AddMotionAnimation(animationSlide, shape, shape.Left, shape.Top, originalLeft + (originalWidth - shape.Width) / 2, originalTop + (originalHeight - shape.Height) / 2, 0, ref trigger); Effect effectResize = AddResizeAnimation(animationSlide, shape, shape.Width, shape.Height, originalWidth, originalHeight, 0, ref trigger); // Make "cover" image disappear after preload. PowerPoint.Effect effectDisappear = null; if (addCoverImage) { Sequence sequence = animationSlide.TimeLine.MainSequence; effectDisappear = sequence.AddEffect(coverImage, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); effectDisappear.Exit = Office.MsoTriState.msoTrue; effectDisappear.Timing.Duration = 0.01f; } int firstEffectIndex = animationSlide.IndexOfFirstEffect(shape); // Move the animations to just before the index of the first effect. if (effectDisappear != null) { effectDisappear.MoveTo(firstEffectIndex); } if (effectResize != null) { effectResize.MoveTo(firstEffectIndex); } if (effectMotion != null) { effectMotion.MoveTo(firstEffectIndex); } }
private void AddSliderEndEffect(Shape shape, PowerPoint.MsoAnimTriggerType trigger) { PowerPoint.Effect sliderEndEffect = this.GetCurrentSlide().TimeLine.MainSequence.AddEffect( shape, PowerPoint.MsoAnimEffect.msoAnimEffectDarken, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, trigger); sliderEndEffect.Timing.Duration = TimerLabConstants.ColorChangeDuration; }
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; }
private static PowerPoint.Effect AddRotationAnimation(PowerPointSlide animationSlide, PowerPoint.Shape animationShape, float initialRotation, float finalRotation, float duration, ref PowerPoint.MsoAnimTriggerType trigger) { if (finalRotation != initialRotation) { PowerPoint.Effect effectRotate = animationSlide.TimeLine.MainSequence.AddEffect(animationShape, PowerPoint.MsoAnimEffect.msoAnimEffectSpin, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, trigger); PowerPoint.AnimationBehavior rotate = effectRotate.Behaviors[1]; effectRotate.Timing.Duration = duration; effectRotate.EffectParameters.Amount = LegacyShapeUtil.GetMinimumRotation(initialRotation, finalRotation); trigger = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious; return(effectRotate); } return(null); }
private void AddProgressBarAnimation(int duration) { PowerPoint.Effect progressBarMotionEffect = this.GetCurrentSlide().TimeLine.MainSequence.AddEffect( progressBar, PowerPoint.MsoAnimEffect.msoAnimEffectGrowShrink, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick); progressBarMotionEffect.Timing.Duration = duration; progressBarMotionEffect.Timing.SmoothStart = Microsoft.Office.Core.MsoTriState.msoFalse; progressBarMotionEffect.Timing.SmoothEnd = Microsoft.Office.Core.MsoTriState.msoFalse; PowerPoint.AnimationBehavior shrinkBehavior = progressBarMotionEffect.Behaviors[1]; // Shrink width to 0 shrinkBehavior.ScaleEffect.ByX = 0f; shrinkBehavior.ScaleEffect.ByY = 100f; }
private void AddSliderMotionEffect(Shape shape, int duration, float timerWidth, float slideWidth, PowerPoint.MsoAnimTriggerType trigger) { PowerPoint.Effect sliderMotionEffect = this.GetCurrentSlide().TimeLine.MainSequence.AddEffect( shape, PowerPoint.MsoAnimEffect.msoAnimEffectPathRight, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, trigger); PowerPoint.AnimationBehavior motion = sliderMotionEffect.Behaviors[1]; float end = timerWidth / slideWidth; motion.MotionEffect.Path = "M 0 0 L " + end + " 0 E"; sliderMotionEffect.Timing.Duration = duration; sliderMotionEffect.Timing.SmoothStart = Microsoft.Office.Core.MsoTriState.msoFalse; sliderMotionEffect.Timing.SmoothEnd = Microsoft.Office.Core.MsoTriState.msoFalse; }
private static PowerPoint.Effect AddResizeAnimation(PowerPointSlide animationSlide, PowerPoint.Shape animationShape, float initialWidth, float initialHeight, float finalWidth, float finalHeight, float duration, ref PowerPoint.MsoAnimTriggerType trigger) { if ((finalWidth != initialWidth) || (finalHeight != initialHeight)) { animationShape.LockAspectRatio = Office.MsoTriState.msoFalse; PowerPoint.Effect effectResize = animationSlide.TimeLine.MainSequence.AddEffect(animationShape, PowerPoint.MsoAnimEffect.msoAnimEffectGrowShrink, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, trigger); PowerPoint.AnimationBehavior resize = effectResize.Behaviors[1]; effectResize.Timing.Duration = duration; resize.ScaleEffect.ByX = (finalWidth / initialWidth) * 100; resize.ScaleEffect.ByY = (finalHeight / initialHeight) * 100; trigger = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious; return(effectResize); } return(null); }
private void Application_SlideShowNextClick(PowerPoint.SlideShowWindow Wn, PowerPoint.Effect nEffect) { //throw new NotImplementedException(); // PowerPointスライドの「ノート」部分を取得する。 string note = Wn.View.Slide.NotesPage.Shapes.Placeholders[2].TextFrame.TextRange.Text; string noteT = note.Trim(); if (noteT != "") { oscSender.Connect(); Debug.WriteLine("つなげた"); oscSender.Send(new OscMessage("/scene", noteT)); //oscSender.Send(new OscMessage("/change", int.Parse(noteT))); Debug.WriteLine(noteT + ":"); this.oscSender.Close(); Debug.WriteLine("とじた"); } }
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; } }
//Set position, size and animations of the next slide copy private static void PrepareNextSlidePicture(PowerPointSlide currentSlide, PowerPoint.Shape selectedShape, ref PowerPoint.Shape nextSlidePicture) { nextSlidePicture.LockAspectRatio = Office.MsoTriState.msoTrue; if (selectedShape.Width > selectedShape.Height) { nextSlidePicture.Height = selectedShape.Height; } else { nextSlidePicture.Width = selectedShape.Width; } LegacyShapeUtil.CopyShapePosition(selectedShape, ref nextSlidePicture); selectedShape.Visible = Office.MsoTriState.msoFalse; nextSlidePicture.Name = "PPTZoomInShape" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); PowerPoint.Effect effectAppear = currentSlide.TimeLine.MainSequence.AddEffect(nextSlidePicture, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick); effectAppear.Timing.Duration = 0.50f; }
private void PrepareForZoomToArea(PowerPoint.Shape zoomShape) { MoveMotionAnimation(); //Delete zoom shapes and shapes with exit animations List <PowerPoint.Shape> shapes = _slide.Shapes.Cast <PowerPoint.Shape>().ToList(); IEnumerable <PowerPoint.Shape> matchingShapes = shapes.Where(current => (HasExitAnimation(current) || current.Equals(zoomShape))); foreach (PowerPoint.Shape s in matchingShapes) { s.Delete(); } float magnifyRatio = PowerPointPresentation.Current.SlideWidth / zoomShape.Width; AddZoomSlideCroppedPicture(magnifyRatio); DeleteSlideNotes(); DeleteSlideMedia(); ManageSlideTransitions(); indicatorShape = AddPowerPointLabsIndicator(); //Add fade out effect for non-zoom shapes shapes = _slide.Shapes.Cast <PowerPoint.Shape>().ToList(); matchingShapes = shapes.Where(current => (!(current.Equals(indicatorShape) || current.Equals(zoomSlideCroppedShapes)))); foreach (PowerPoint.Shape s in matchingShapes) { DeleteShapeAnimations(s); if (!ZoomLabSettings.BackgroundZoomChecked) { 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; } else { s.Visible = Office.MsoTriState.msoFalse; } } }
//Fade out non-matching shapes. If shape has exit animation, then delete it private void ManageNonMatchingShapes(int[] matchingShapeIDs, int indicatorShapeID) { foreach (PowerPoint.Shape sh in _slide.Shapes) { if (!matchingShapeIDs.Contains(sh.Id) && sh.Id != indicatorShapeID) { if (!HasExitAnimation(sh)) { DeleteShapeAnimations(sh); PowerPoint.Effect effectFade = _slide.TimeLine.MainSequence.AddEffect(sh, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); effectFade.Exit = Office.MsoTriState.msoTrue; effectFade.Timing.Duration = AnimationLabSettings.AnimationDuration; } else { DeleteShapeAnimations(sh); PowerPoint.Effect effectDisappear = null; effectDisappear = _slide.TimeLine.MainSequence.AddEffect(sh, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); effectDisappear.Exit = Office.MsoTriState.msoTrue; effectDisappear.Timing.Duration = 0; } } } }
public TildaAnimation(PowerPoint.Effect effect, TildaShape shape) { this.effect = effect; this.shape = shape; }
public void AddZoomToAreaAnimation(PowerPoint.Shape zoomShape) { PrepareForZoomToArea(zoomShape); if (!ZoomLabSettings.BackgroundZoomChecked) { //Zoom stored shape to fit slide zoomSlideCroppedShapes.LockAspectRatio = Office.MsoTriState.msoTrue; if (zoomSlideCroppedShapes.Width > zoomSlideCroppedShapes.Height) { zoomSlideCroppedShapes.Width = PowerPointPresentation.Current.SlideWidth; } else { zoomSlideCroppedShapes.Height = PowerPointPresentation.Current.SlideHeight; } zoomSlideCroppedShapes.Left = (PowerPointPresentation.Current.SlideWidth / 2) - (zoomSlideCroppedShapes.Width / 2); zoomSlideCroppedShapes.Top = (PowerPointPresentation.Current.SlideHeight / 2) - (zoomSlideCroppedShapes.Height / 2); DefaultMotionAnimation.AddDefaultMotionAnimation(this, zoomSlideCroppedShapes, zoomShape, 0.5f, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); //Add appear animations to existing shapes bool isFirst = true; PowerPoint.Effect effectFade = null; foreach (PowerPoint.Shape tmp in _slide.Shapes) { if (!(tmp.Equals(zoomSlideCroppedShapes) || tmp.Equals(indicatorShape))) { if (isFirst) { effectFade = _slide.TimeLine.MainSequence.AddEffect(tmp, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerAfterPrevious); } else { effectFade = _slide.TimeLine.MainSequence.AddEffect(tmp, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); } effectFade.Timing.Duration = 0.25f; isFirst = false; } } //Add fade out anmation to shape added by PPTLabs effectFade = _slide.TimeLine.MainSequence.AddEffect(zoomSlideCroppedShapes, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); effectFade.Exit = Office.MsoTriState.msoTrue; effectFade.Timing.Duration = 0.25f; } else { GetShapeToZoomWithBackground(zoomShape); PowerPoint.Effect lastDisappearEffect = DefaultMotionAnimation.AddZoomOutMotionAnimation(this, zoomSlideCroppedShapes, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); DefaultMotionAnimation.PreloadShape(this, zoomSlideCroppedShapes); //Add appear animations to existing shapes bool isFirst = true; PowerPoint.Effect effectFade = null; foreach (PowerPoint.Shape tmp in _slide.Shapes) { if (!(tmp.Equals(zoomSlideCroppedShapes) || tmp.Equals(indicatorShape)) && !(tmp.Name.Contains("PPTLabsMagnifyShape")) && !(tmp.Name.Contains("PPTLabsMagnifyArea"))) { tmp.Visible = Office.MsoTriState.msoTrue; if (isFirst) { effectFade = _slide.TimeLine.MainSequence.AddEffect(tmp, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerAfterPrevious); } else { effectFade = _slide.TimeLine.MainSequence.AddEffect(tmp, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious); } effectFade.Timing.Duration = 0.01f; isFirst = false; } } //Move last frame disappear animation to end lastDisappearEffect.MoveTo(_slide.TimeLine.MainSequence.Count); lastDisappearEffect.Timing.TriggerType = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious; lastDisappearEffect.Timing.TriggerDelayTime = 0.01f; } indicatorShape.ZOrder(Office.MsoZOrderCmd.msoBringToFront); }
//评分核心函数 public int check_Kernel(List<OfficeElement> ls) { int points = 0, i; int curPart = -1; //当前正在分析哪一部分的考点 for (i = 0; i < ls.Count; i++) { OfficeElement oe = ls[i]; #region 具体考点对象定位 if (oe.AttribName == "Root") continue; if (oe.AttribName == "Presentations") continue; if (oe.AttribName == "Slide") { #region 幻灯片定位 try { int slideId = int.Parse(oe.AttribValue); stuSld = stuPpt.Slides[slideId]; ansSld = ansPpt.Slides[slideId]; } catch { points = 0; break; } #endregion curPart = PART_SLIDE; continue; } if (oe.AttribName == "Background") { #region 幻灯片背景定位 try { stuBg = stuSld.Background; ansBg = ansSld.Background; } catch { points = 0; break; } #endregion curPart = PART_BACKGROUND; continue; } if (oe.AttribName == "Transition") { #region 过渡动画定位 try { stuTrans = stuSld.SlideShowTransition; ansTrans = ansSld.SlideShowTransition; } catch { points = 0; break; } #endregion curPart = PART_TRANSITION; continue; } if (oe.AttribName == "Effects") { continue; } if (oe.AttribName == "Effect") { #region 幻灯片动画定位 try { int effId = int.Parse(oe.AttribValue); stuEffect = stuSld.TimeLine.MainSequence[effId]; ansEffect = ansSld.TimeLine.MainSequence[effId]; } catch { points = 0; break; } #endregion curPart = PART_EFFECT; continue; } if (oe.AttribName == "Shape") { #region Shape定位 try { int shapeId = int.Parse(oe.AttribValue); stuShape = stuSld.Shapes[shapeId]; ansShape = ansSld.Shapes[shapeId]; } catch { points = 0; break; } #endregion curPart = PART_SHAPE; continue; } if (oe.AttribName == "Location") { curPart = PART_LOCATION; continue; } if (oe.AttribName == "Picture") { #region 图片属性定位 try { stuPf = stuShape.PictureFormat; ansPf = ansShape.PictureFormat; } catch { points = 0; break; } #endregion curPart = PART_PICTURE; continue; } if (oe.AttribName == "Run") { #region 文字部分定位 try { int runId = int.Parse(oe.AttribValue); stuTr = stuShape.TextFrame.TextRange.Runs(0, 100); ansTr = ansShape.TextFrame.TextRange.Runs(0, 100); } catch { points = 0; break; } #endregion curPart = PART_TEXTRANGE; continue; } if (oe.AttribName == "WordArt") { #region 艺术字定位 try { stuTf = stuShape.TextEffect; ansTf = ansShape.TextEffect; } catch { points = 0; break; } #endregion curPart = PART_WORDART; continue; } if (oe.AttribName == "ThreeD") { #region 三维属性定位 try { stu3d = stuShape.ThreeD; ans3d = ansShape.ThreeD; } catch { points = 0; break; } #endregion curPart = PART_3D; continue; } if (oe.AttribName == "Animation") { #region 自定义动画定位 try { stuAm = stuShape.AnimationSettings; ansAm = ansShape.AnimationSettings; } catch { points = 0; break; } #endregion curPart = PART_ANIMATION; continue; } if (oe.AttribName == "ClickAction") { #region 单击动作定位 try { stuAcs = stuShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseClick]; ansAcs = ansShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseClick]; } catch { points = 0; break; } #endregion curPart = PART_ACTION; continue; } if (oe.AttribName == "MoveAction") { #region 鼠标移动动作定位 try { stuAcs = stuShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseOver]; ansAcs = ansShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseOver]; } catch { points = 0; break; } #endregion curPart = PART_ACTION; continue; } #endregion #region 幻灯片判分 if (curPart == PART_SLIDE) { switch (oe.AttribName) { case "SlideName": if (stuSld.Name == ansSld.Name) points = int.Parse(oe.AttribValue); break; case "SlideIndex": if (stuSld.SlideIndex == ansSld.SlideIndex) points = int.Parse(oe.AttribValue); break; case "Layout": if (stuSld.Layout == ansSld.Layout) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 幻灯片背景判分 if (curPart == PART_BACKGROUND) { switch (oe.AttribName) { case "Fill": if (stuBg.Fill.Type.Equals(ansBg.Fill.Type)) points = int.Parse(oe.AttribValue); break; case "GradientType": if (stuBg.Fill.PresetGradientType == ansBg.Fill.PresetGradientType) points = int.Parse(oe.AttribValue); break; case "GradientStyle": if (stuBg.Fill.GradientStyle == ansBg.Fill.GradientStyle) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 幻灯片过渡动画判分 if (curPart == PART_TRANSITION) { switch (oe.AttribName) { case "AdvanceOnClick": if (stuTrans.AdvanceOnClick.Equals(ansTrans.AdvanceOnClick)) points = int.Parse(oe.AttribValue); break; case "AdvanceOnTime": if (stuTrans.AdvanceOnTime.Equals(ansTrans.AdvanceOnTime)) points = int.Parse(oe.AttribValue); break; case "AdvanceTime": if (stuTrans.AdvanceTime == ansTrans.AdvanceTime) points = int.Parse(oe.AttribValue); break; case "EntryEffect": if (stuTrans.EntryEffect.Equals(ansTrans.EntryEffect)) points = int.Parse(oe.AttribValue); break; case "Speed": if (stuTrans.Speed.Equals(ansTrans.Speed)) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 幻灯片动画判分 if (curPart == PART_EFFECT) { switch (oe.AttribName) { case "DisplayName": if (stuEffect.DisplayName == ansEffect.DisplayName) points = int.Parse(oe.AttribValue); break; case "EffectType": if (stuEffect.EffectType.Equals(ansEffect.EffectType)) points = int.Parse(oe.AttribValue); break; case "Exit": if (stuEffect.Exit.Equals(ansEffect.Exit)) points = int.Parse(oe.AttribValue); break; case "Index": if (stuEffect.Index == ansEffect.Index) points = int.Parse(oe.AttribValue); break; case "ShapeName": if (stuEffect.Shape.Name == ansEffect.Shape.Name) points = int.Parse(oe.AttribValue); break; case "Duration": if (stuEffect.Timing.Duration == ansEffect.Timing.Duration) points = int.Parse(oe.AttribValue); break; case "Paragraph": try { if (stuEffect.Paragraph == ansEffect.Paragraph) points = int.Parse(oe.AttribValue); } catch { points = 0; } break; case "TextRangeStart": try { if (stuEffect.TextRangeStart == ansEffect.TextRangeStart) points = int.Parse(oe.AttribValue); } catch { points = 0; } break; case "TextRangeLength": try { if (stuEffect.TextRangeLength == ansEffect.TextRangeLength) points = int.Parse(oe.AttribValue); } catch { points = 0; } break; } continue; } #endregion #region 幻灯片对象判分 if (curPart == PART_SHAPE) { continue; } #endregion #region 对象类型、定位判分 if (curPart == PART_LOCATION) { switch (oe.AttribName) { case "ShapeName": if (stuShape.Name == ansShape.Name) points = int.Parse(oe.AttribValue); break; case "Type": if (stuShape.Type == ansShape.Type) points = int.Parse(oe.AttribValue); break; case "Top": if (stuShape.Top == ansShape.Top) points = int.Parse(oe.AttribValue); break; case "Left": if (stuShape.Left == ansShape.Left) points = int.Parse(oe.AttribValue); break; case "Height": if (stuShape.Height == ansShape.Height) points = int.Parse(oe.AttribValue); break; case "Width": if (stuShape.Width == ansShape.Width) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 图片属性判分 if (curPart == PART_PICTURE) { switch (oe.AttribName) { case "CropLeft": if (stuPf.CropLeft == ansPf.CropLeft) points = int.Parse(oe.AttribValue); break; case "CropTop": if (stuPf.CropTop == ansPf.CropTop) points = int.Parse(oe.AttribValue); break; case "CropRight": if (stuPf.CropRight == ansPf.CropRight) points = int.Parse(oe.AttribValue); break; case "CropBottom": if (stuPf.CropBottom == ansPf.CropBottom) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 文本属性判分 if (curPart == PART_TEXTRANGE) { switch (oe.AttribName) { case "Text": if (stuTr.Text == ansTr.Text) points = int.Parse(oe.AttribValue); break; case "Bold": if (stuTr.Font.Bold == ansTr.Font.Bold) points = int.Parse(oe.AttribValue); break; case "Italic": if (stuTr.Font.Italic == ansTr.Font.Italic) points = int.Parse(oe.AttribValue); break; case "Underline": if (stuTr.Font.Underline == ansTr.Font.Underline) points = int.Parse(oe.AttribValue); break; case "FontName": if (stuTr.Font.Name == ansTr.Font.Name) points = int.Parse(oe.AttribValue); break; case "FontSize": if (stuTr.Font.Size == ansTr.Font.Size) points = int.Parse(oe.AttribValue); break; case "Shadow": if (stuTr.Font.Shadow == ansTr.Font.Shadow) points = int.Parse(oe.AttribValue); break; case "Superscript": if (stuTr.Font.Superscript == ansTr.Font.Superscript) points = int.Parse(oe.AttribValue); break; case "Subscript": if (stuTr.Font.Subscript == ansTr.Font.Subscript) points = int.Parse(oe.AttribValue); break; case "ForeColor": if (stuTr.Font.Color.RGB == ansTr.Font.Color.RGB) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 艺术字属性判分 if (curPart == PART_WORDART) { switch (oe.AttribName) { case "Text": if (stuTf.Text == ansTf.Text) points = int.Parse(oe.AttribValue); break; case "Bold": if (stuTf.FontBold == ansTf.FontBold) points = int.Parse(oe.AttribValue); break; case "Italic": if (stuTf.FontItalic == ansTf.FontItalic) points = int.Parse(oe.AttribValue); break; case "FontName": if (stuTf.FontName == ansTf.FontName) points = int.Parse(oe.AttribValue); break; case "FontSize": if (stuTf.FontSize == ansTf.FontSize) points = int.Parse(oe.AttribValue); break; case "Alignment": if (stuTf.Alignment.ToString() == ansTf.Alignment.ToString()) points = int.Parse(oe.AttribValue); break; case "PresetShape": if (stuTf.PresetShape.ToString() == ansTf.PresetShape.ToString()) points = int.Parse(oe.AttribValue); break; case "RotatedChars": if (stuTf.RotatedChars.ToString() == ansTf.RotatedChars.ToString()) points = int.Parse(oe.AttribValue); break; case "Tracking": if (stuTf.Tracking.ToString() == ansTf.Tracking.ToString()) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 三维属性判分 if (curPart == PART_3D) { switch (oe.AttribName) { case "ThreeDFormat": if (stu3d.PresetThreeDFormat == ans3d.PresetThreeDFormat) points = int.Parse(oe.AttribValue); break; case "LightingDirection": if (stu3d.PresetLightingDirection == ans3d.PresetLightingDirection) points = int.Parse(oe.AttribValue); break; case "LightingSoftness": if (stu3d.PresetLightingSoftness == ans3d.PresetLightingSoftness) points = int.Parse(oe.AttribValue); break; case "Material": if (stu3d.PresetMaterial == ans3d.PresetMaterial) points = int.Parse(oe.AttribValue); break; case "Depth": if (stu3d.Depth == ans3d.Depth) points = int.Parse(oe.AttribValue); break; case "ExtrusionDirection": if (stu3d.PresetExtrusionDirection == ans3d.PresetExtrusionDirection) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 自定义动画判分 if (curPart == PART_ANIMATION) { switch (oe.AttribName) { case "AnimationOrder": if (stuAm.AnimationOrder == ansAm.AnimationOrder) points = int.Parse(oe.AttribValue); break; case "EntryEffect": if (stuAm.EntryEffect == ansAm.EntryEffect) points = int.Parse(oe.AttribValue); break; case "AdvanceMode": if (stuAm.AdvanceMode == ansAm.AdvanceMode) points = int.Parse(oe.AttribValue); break; case "AdvanceTime": if (stuAm.AdvanceTime == ansAm.AdvanceTime) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 对象动作判分 if (curPart == PART_ACTION) { switch (oe.AttribName) { case "Action": if (stuAcs.Action == ansAcs.Action) points = int.Parse(oe.AttribValue); break; case "HyperlinkAddr": if (stuAcs.Hyperlink.Address == ansAcs.Hyperlink.Address) points = int.Parse(oe.AttribValue); break; case "HyperlinkSubAddr": if (stuAcs.Hyperlink.SubAddress == ansAcs.Hyperlink.SubAddress) points = int.Parse(oe.AttribValue); break; } continue; } #endregion } return points; }
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; } }