public void AlignBoth() { var shapes = GetCurrentlySelectedShapes(); if (shapes.Count <= 1) { Error(TextCollection.DrawingsLabSelectAtLeastTwoShapes); return; } var dialog = new AlignmentDialogBoth(); if (dialog.ShowDialog() != true) { return; } if (dialog.DialogResult != true) { return; } Globals.ThisAddIn.Application.StartNewUndoEntry(); double sourceAnchorX = dialog.SourceAnchorVertical / 100; double targetAnchorX = dialog.TargetAnchorVertical / 100; double sourceAnchorY = dialog.SourceAnchorHorizontal / 100; double targetAnchorY = dialog.TargetAnchorHorizontal / 100; var targetShape = shapes.Last(); shapes.RemoveAt(shapes.Count - 1); double targetX = targetShape.Left + targetAnchorX * targetShape.Width; double targetY = targetShape.Top + (1 - targetAnchorY) * targetShape.Height; foreach (var shape in shapes) { shape.Left = (float)(targetX - sourceAnchorX * shape.Width); shape.Top = (float)(targetY - (1 - sourceAnchorY) * shape.Height); } }
public void AlignBothToSlide() { var shapes = GetCurrentlySelectedShapes(); if (shapes.Count <= 0) { Error(TextCollection.DrawingsLabSelectAtLeastOneShape); return; } var dialog = new AlignmentDialogBoth(); if (dialog.ShowDialog() != true) { return; } if (dialog.DialogResult != true) { return; } Globals.ThisAddIn.Application.StartNewUndoEntry(); double sourceAnchorX = dialog.SourceAnchorVertical / 100; double targetAnchorX = dialog.TargetAnchorVertical / 100; double sourceAnchorY = dialog.SourceAnchorHorizontal / 100; double targetAnchorY = dialog.TargetAnchorHorizontal / 100; double targetX = targetAnchorX * PowerPointPresentation.Current.SlideWidth; double targetY = (1 - targetAnchorY) * PowerPointPresentation.Current.SlideHeight; foreach (var shape in shapes) { shape.Left = (float)(targetX - sourceAnchorX * shape.Width); shape.Top = (float)(targetY - (1 - sourceAnchorY) * shape.Height); } }
public void AlignBothToSlide() { var shapes = GetCurrentlySelectedShapes(); if (shapes.Count <= 0) { Error(TextCollection.DrawingsLabSelectAtLeastOneShape); return; } var dialog = new AlignmentDialogBoth(); if (dialog.ShowDialog() != true) return; if (dialog.DialogResult != true) return; Globals.ThisAddIn.Application.StartNewUndoEntry(); double sourceAnchorX = dialog.SourceAnchorVertical / 100; double targetAnchorX = dialog.TargetAnchorVertical / 100; double sourceAnchorY = dialog.SourceAnchorHorizontal / 100; double targetAnchorY = dialog.TargetAnchorHorizontal / 100; double targetX = targetAnchorX * PowerPointPresentation.Current.SlideWidth; double targetY = (1 - targetAnchorY) * PowerPointPresentation.Current.SlideHeight; foreach (var shape in shapes) { shape.Left = (float)(targetX - sourceAnchorX * shape.Width); shape.Top = (float)(targetY - (1 - sourceAnchorY) * shape.Height); } }
public void AlignBoth() { var shapes = GetCurrentlySelectedShapes(); if (shapes.Count <= 1) { Error(TextCollection.DrawingsLabSelectAtLeastTwoShapes); return; } var dialog = new AlignmentDialogBoth(); if (dialog.ShowDialog() != true) return; if (dialog.DialogResult != true) return; Globals.ThisAddIn.Application.StartNewUndoEntry(); double sourceAnchorX = dialog.SourceAnchorVertical / 100; double targetAnchorX = dialog.TargetAnchorVertical / 100; double sourceAnchorY = dialog.SourceAnchorHorizontal / 100; double targetAnchorY = dialog.TargetAnchorHorizontal / 100; var targetShape = shapes.Last(); shapes.RemoveAt(shapes.Count - 1); double targetX = targetShape.Left + targetAnchorX * targetShape.Width; double targetY = targetShape.Top + (1 - targetAnchorY) * targetShape.Height; foreach (var shape in shapes) { shape.Left = (float)(targetX - sourceAnchorX * shape.Width); shape.Top = (float)(targetY - (1 - sourceAnchorY) * shape.Height); } }