void Application_SlideSelectionChanged(PowerPoint.SlideRange SldRange) { try { if (SldRange != null) { if (currentlyViewed == "add") { try { addDictionaries.showSlideNumber(SldRange.SlideID.ToString(), SldRange.SlideNumber.ToString()); } catch (System.AccessViolationException ex) { } } else if (currentlyViewed == "update") { updateDictionaries.showSlideNumber(SldRange.SlideID.ToString(), SldRange.SlideNumber.ToString()); } } } catch (AccessViolationException avEx) { } catch (Exception ex) { } }
/// <summary> /// For `preview` /// </summary> /// <param name="slide">the temp slide to produce preview image</param> /// <param name="contentSlide">the slide that contains content</param> /// <param name="slideWidth"></param> /// <param name="slideHeight"></param> /// <param name="source"></param> private EffectsDesigner(PowerPoint.Slide slide, PowerPoint.Slide contentSlide, float slideWidth, float slideHeight, ImageItem source) : base(slide) { ContentSlide = contentSlide; Setup(slideWidth, slideHeight, source); }
/// <summary> /// Get all the text from a given Ppt /// shape, delimited by _crlf. /// </summary> static string GetShapeText( Ppt.Shape shape ) { string s = null; if( _t == shape.HasTextFrame && _t == shape.TextFrame.HasText ) { s = shape.TextFrame.TextRange.Text.Trim(); string[] a = s.Split( new char[] { '\r', '\n' } ); s = string.Empty; foreach( string s2 in a ) { s += PrependLinefeed( s2.Trim() ); } s = s.Trim(); if( 0 == s.Length ) { s = null; } } return s; }
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; }
/** * Creates a new TildaShape Object from a powerpoint shape * @param PowerPoint.Shape */ public TildaShape(PowerPoint.Shape shape, int id = 0) { this.shape = shape; this.scaler = Settings.Scaler(); this.id = id; animations = new List<TildaAnimation>(); }
/// <summary> /// Clone an existing slide (make a copy) /// </summary> /// <param name="presentation">PPT.Presentation object instance</param> /// <param name="slide">PPT.Slide instance that is to be cloned</param> /// <param name="destination">Destination for the cloned slide</param> /// <param name="locationIndex">Optional index for the new slide (slide.Index)</param> /// <returns></returns> public PPT.SlideRange CloneSlide( PPT.Presentation presentation, PPT.Slide slide, Locations.Location destination, int locationIndex = 0) { PPT.SlideRange dupeSlide = slide.Duplicate(); switch (destination) { case Locations.Location.First: dupeSlide.MoveTo(1); break; case Locations.Location.Last: dupeSlide.MoveTo((presentation.Slides.Count)); break; case Locations.Location.Custom: dupeSlide.MoveTo(locationIndex); break; } return dupeSlide; }
private static bool VerifyIsShapeRangeValid(PowerPoint.ShapeRange shapeRange, bool handleError) { try { if (shapeRange.Count < 1) { ThrowErrorCode(ErrorCodeForSelectionCountZero); } if (!IsShapeForSelection(shapeRange)) { ThrowErrorCode(ErrorCodeForSelectionNonShape); } return true; } catch (Exception e) { if (handleError) { ProcessErrorMessage(e); return false; } throw; } }
public void AddZoomToAreaAnimation(PowerPoint.Shape zoomShape) { PrepareForZoomToArea(); //Create zoomed-in version of the part of the slide specified by zoom shape zoomSlideCroppedShapes.PictureFormat.CropLeft += zoomShape.Left; zoomSlideCroppedShapes.PictureFormat.CropTop += zoomShape.Top; zoomSlideCroppedShapes.PictureFormat.CropRight += (PowerPointPresentation.Current.SlideWidth - (zoomShape.Left + zoomShape.Width)); zoomSlideCroppedShapes.PictureFormat.CropBottom += (PowerPointPresentation.Current.SlideHeight - (zoomShape.Top + zoomShape.Height)); PowerPointLabsGlobals.CopyShapePosition(zoomShape, ref zoomSlideCroppedShapes); 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); zoomSlideCroppedShapes.PictureFormat.CropLeft = 0; zoomSlideCroppedShapes.PictureFormat.CropTop = 0; zoomSlideCroppedShapes.PictureFormat.CropRight = 0; zoomSlideCroppedShapes.PictureFormat.CropBottom = 0; indicatorShape.ZOrder(Office.MsoZOrderCmd.msoBringToFront); }
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> /// Update columns width to fit text (can only decrease size of columns!!) /// Looks like sometimes it doesn't work how it should. /// </summary> /// <param name="shape">Table shape</param> /// <param name="settings">Tabular settings (with information about columns)</param> /// <exception cref="ArgumentException"></exception> internal static void AutoFitColumn(PowerPoint.Shape shape, TabularSettings settings) { if (shape.HasTable != MsoTriState.msoTrue) throw new ArgumentException("Shape must have table."); PowerPoint.TextFrame2 frame; float width; for (int column = 1; column <= shape.Table.Columns.Count; column++) { if (settings.Columns[column - 1].alignment != 'p' || (settings.Columns[column - 1].alignment == 'p' && settings.Columns[column - 1].width == 0)) { width = 0.0f; for (int row = 1; row <= shape.Table.Rows.Count; row++) { frame = shape.Table.Cell(row, column).Shape.TextFrame2; width = Math.Max(width, frame.TextRange.BoundWidth + frame.MarginLeft + frame.MarginRight + 1); } } else { width = settings.Columns[column - 1].width; } shape.Table.Columns[column].Width = width; } }
public void AddAutoAnimation(PowerPoint.Shape[] currentSlideShapes, PowerPoint.Shape[] nextSlideSlideShapes, int[] matchingShapeIDs) { PowerPoint.Shape indicatorShape = AddPowerPointLabsIndicator(); ManageNonMatchingShapes(matchingShapeIDs, indicatorShape.Id); AnimateMatchingShapes(currentSlideShapes, nextSlideSlideShapes, matchingShapeIDs); indicatorShape.ZOrder(Office.MsoZOrderCmd.msoBringToFront); }
private void CropPicture(PowerPoint.Shape picShape) { try { if (picShape.Left < 0) { picShape.PictureFormat.Crop.ShapeLeft = 0; } if (picShape.Top < 0) { picShape.PictureFormat.Crop.ShapeTop = 0; } if (picShape.Left + picShape.Width > SlideWidth) { picShape.PictureFormat.Crop.ShapeWidth = SlideWidth - picShape.Left; } if (picShape.Top + picShape.Height > SlideHeight) { picShape.PictureFormat.Crop.ShapeHeight = SlideHeight - picShape.Top; } } catch (Exception e) { // some kind of picture cannot be cropped Logger.LogException(e, "CropPicture"); } }
public PowerPoint.Shape ApplyRectBannerEffect(BannerDirection direction, Position textPos, PowerPoint.Shape imageShape, string overlayColor, int transparency) { var tbInfo = new TextBoxes(Shapes.Range(), SlideWidth, SlideHeight) .GetTextBoxesInfo(); if (tbInfo == null) return null; TextBoxes.AddMargin(tbInfo); PowerPoint.Shape overlayShape; direction = HandleAutoDirection(direction, textPos); switch (direction) { case BannerDirection.Horizontal: overlayShape = ApplyOverlayEffect(overlayColor, transparency, 0, tbInfo.Top, SlideWidth, tbInfo.Height); break; // case BannerDirection.Vertical: default: overlayShape = ApplyOverlayEffect(overlayColor, transparency, tbInfo.Left, 0, tbInfo.Width, SlideHeight); break; } ChangeName(overlayShape, EffectName.Banner); overlayShape.ZOrder(MsoZOrderCmd.msoSendToBack); if (imageShape != null) { imageShape.ZOrder(MsoZOrderCmd.msoSendToBack); } return overlayShape; }
public static PowerPointSlide FromSlideFactory(PowerPoint.Slide slide) { if (slide == null) return null; return new PowerPointDeMagnifyingSlide(slide); }
public static new PowerPointSlide FromSlideFactory(PowerPoint.Slide slide) { if (slide == null) return null; return new PowerPointDrillDownSlide(slide); }
public static void AddTag(PowerPoint.Shape shape, string tagName, String value) { if (StringUtil.IsEmpty(shape.Tags[tagName]) && value != null) { shape.Tags.Add(tagName, value); } }
public static new PowerPointSlide FromSlideFactory(PowerPoint.Slide slide) { if (slide == null) return null; return new PowerPointMagnifiedSlide(slide); }
public static void Init(PowerPoint.Application application) { if (instance == null) { instance = new PPCopy(); instance.Visible = false; try { nextHandle = Native.SetClipboardViewer(instance.Handle); isSuccessful = Native.AddClipboardFormatListener(instance.Handle); //if fails to set up clipboardFormatListener, re-try 5 times for (int i = 0; i < 5; i++) { if (isSuccessful) break; isSuccessful = Native.AddClipboardFormatListener(instance.Handle); } handle = instance.Handle; application.WindowSelectionChange += (selection) => { selectedRange = selection; if (!isSuccessful) { isSuccessful = Native.AddClipboardFormatListener(instance.Handle); } }; } catch { //TODO: support win XP? } } }
public static PowerPointSlide FromSlideFactory(PowerPoint.Slide slide) { if (slide == null) return null; return new PowerPointAutoAnimateSlide(slide); }
/// <summary> /// Append text with current internal formatting to the end of shape. /// </summary> /// <param name="shape">Text shape</param> /// <param name="text">Appended text</param> public void AppendText(PowerPoint.Shape shape, string text) { if (shape.HasTextFrame != MsoTriState.msoTrue) throw new ArgumentException("Shape must contain text frame."); AppendText(shape.TextFrame2.TextRange, text); }
public void AddZoomToAreaAnimation(PowerPoint.Shape zoomShape) { PrepareForZoomToArea(zoomShape); PowerPoint.Shape shapeToZoom = null, referenceShape = null; if (!ZoomToArea.backgroundZoomChecked) { shapeToZoom = GetShapeToZoom(zoomShape); referenceShape = GetReferenceShape(shapeToZoom); DefaultMotionAnimation.AddDefaultMotionAnimation(this, shapeToZoom, referenceShape, 0.5f, PowerPoint.MsoAnimTriggerType.msoAnimTriggerAfterPrevious); } else { shapeToZoom = zoomSlideCroppedShapes.Duplicate()[1]; DeleteShapeAnimations(shapeToZoom); PowerPointLabsGlobals.CopyShapePosition(zoomSlideCroppedShapes, ref shapeToZoom); referenceShape = GetReferenceShape(zoomShape); DefaultMotionAnimation.AddZoomToAreaMotionAnimation(this, shapeToZoom, zoomShape, referenceShape, 0.5f, PowerPoint.MsoAnimTriggerType.msoAnimTriggerAfterPrevious); } shapeToZoom.Name = "PPTLabsMagnifyAreaSlide" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); referenceShape.Delete(); zoomSlideCroppedShapes.Visible = Office.MsoTriState.msoFalse; indicatorShape.ZOrder(Office.MsoZOrderCmd.msoBringToFront); }
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(); var matchingShapes = shapes.Where(current => (HasExitAnimation(current) || current.Equals(zoomShape))); foreach (PowerPoint.Shape s in matchingShapes) s.Delete(); AddZoomSlideCroppedPicture(); 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 (!ZoomToArea.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; } }
private void CopySlides(PowerPoint.Presentation sourcePresentation, PowerPoint.Presentation destPresentation) { PowerPoint.Slides sourceSlides = sourcePresentation.Slides; PowerPoint.Slides destSlides = destPresentation.Slides; for (int i = 1; i <= sourceSlides.Count; i++) { PowerPoint.Slide slide = sourceSlides[i]; slide.Copy(); if (destSlides.Count > 0) { PowerPoint.Slide destSlide = destSlides[destSlides.Count]; destSlide.Select(); Marshal.ReleaseComObject(destSlide); } PowerPoint.Application application = destSlides.Application; application.CommandBars.ExecuteMso("PasteSourceFormatting"); Application.DoEvents(); Marshal.ReleaseComObject(application); Marshal.ReleaseComObject(slide); } Marshal.ReleaseComObject(sourceSlides); Marshal.ReleaseComObject(destSlides); }
/// <summary> /// Adjust the visual width of the specified shapes to the resize factors of first /// selected shape's visual width. /// </summary> /// <param name="selectedShapes"></param> public void AdjustVisualWidthProportionally(PowerPoint.ShapeRange selectedShapes) { try { var referenceWidth = GetReferenceWidth(selectedShapes); if (referenceWidth <= 0 || AdjustProportionallyProportionList?.Count != selectedShapes.Count) return; for (int i = 1; i < AdjustProportionallyProportionList.Count; i++) { var newWidth = referenceWidth* (AdjustProportionallyProportionList[i] / AdjustProportionallyProportionList[0]); var shape = new PPShape(selectedShapes[i + 1]); var anchorPoint = GetVisualAnchorPoint(shape); shape.AbsoluteWidth = newWidth; AlignVisualShape(shape, anchorPoint); } AdjustProportionallyProportionList = null; } catch (Exception e) { Logger.LogException(e, "AdjustVisualWidthProportionally"); } }
private void CropPicture(PowerPoint.Shape picShape, float targetLeft, float targetTop, float targetWidth, float targetHeight) { picShape.PictureFormat.Crop.ShapeLeft = targetLeft; picShape.PictureFormat.Crop.ShapeTop = targetTop; picShape.PictureFormat.Crop.ShapeWidth = targetWidth; picShape.PictureFormat.Crop.ShapeHeight = targetHeight; }
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); }
public static new PowerPointSlide FromSlideFactory(PowerPoint.Slide slide) { if (slide == null) return null; return new PowerPointStepBackSlide(slide); }
public clsMediaListItem(MediaTypeEnum m, string filename, int MediaID, List<clsSlidePictureItem> slideImages, MOIP.Presentation xPres) { this.ID = MediaID; this.mediaType = m; this.filename = filename; this.SlideImages = slideImages; this.PPTPresentation = xPres; }
public void Preview(PowerPoint.ShapeRange selectedShapes, float referenceWidth, float referenceHeight, Action<PowerPoint.ShapeRange, float, float, bool> previewAction) { if (selectedShapes == null) return; _isPreview = true; this.StartNewUndoEntry(); previewAction.Invoke(selectedShapes, referenceWidth, referenceHeight, IsAspectRatioLocked); }
private void App_SlideShowNextSlide(PowerPoint.SlideShowWindow Wn) { var index = Wn.View.CurrentShowPosition; var slide = Wn.Presentation.Slides[index]; GoToSlidePage(slide); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { coverAddin = this; ppt = new PowerPoint(); ppt.start(); //DocumentBeforeDoubleClick(); coverThread = new Thread(new ThreadStart(messageLoop)); // Start the thread coverThread.Start(); }