protected override void ExecuteAction(string ribbonId) { this.StartNewUndoEntry(); var selectedShape = this.GetCurrentSelection().ShapeRange[1]; var pres = this.GetCurrentPresentation(); FitToSlide.FitToWidth(selectedShape, pres.SlideWidth, pres.SlideHeight); }
private void SetToAbsoluteWidthAspectRatio() { // Store the original position of the shape var originalTop = _shape.Top; var originalLeft = _shape.Left; _shape.LockAspectRatio = MsoTriState.msoFalse; FitToSlide.FitToWidth(_shape, _absoluteWidth, _absoluteHeight); _shape.LockAspectRatio = MsoTriState.msoTrue; _shape.Top = originalTop; _shape.Left = originalLeft; UpdateAbsoluteWidth(); UpdateAbsoluteHeight(); }
/// <summary> /// Fit the selected shapes with aspect ratio according to the set dimension type. /// </summary> /// <param name="selectedShapes"></param> /// <param name="dimension"></param> /// <param name="slideWidth"></param> /// <param name="slideHeight"></param> private void FitAspectRatioShapes(PowerPoint.ShapeRange selectedShapes, Dimension dimension, float slideWidth, float slideHeight) { try { for (int i = 1; i <= selectedShapes.Count; i++) { PowerPoint.Shape shape = selectedShapes[i]; System.Drawing.PointF anchorPoint = GetVisualAnchorPoint(new PPShape(shape, false)); if (dimension == Dimension.Height) { FitToSlide.FitToHeight(shape, slideWidth, slideHeight); PPShape ppShape = new PPShape(shape, false); AlignVisualShape(ppShape, anchorPoint); ppShape.VisualTop = 0; } else if (dimension == Dimension.Width) { FitToSlide.FitToWidth(shape, slideWidth, slideHeight); PPShape ppShape = new PPShape(shape, false); AlignVisualShape(ppShape, anchorPoint); ppShape.VisualLeft = 0; } else if (dimension == Dimension.HeightAndWidth) { FitToSlide.AutoFit(shape, slideWidth, slideHeight); } } } catch (Exception e) { Logger.LogException(e, "FitAspectRatioShapes"); } }