VisioLayoutExtensions
OfficeIMO.Visio
Layout and geometry helpers for Visio pages, shapes, and selections.
Inheritance
- object
- VisioLayoutExtensions
Methods
public static VisioShapeSelection Align(VisioShapeSelection selection, VisioHorizontalAlignment alignment) #Aligns selected shapes horizontally inside the current selection bounds.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to align.
- alignment OfficeIMO.Visio.VisioHorizontalAlignment
- Horizontal alignment.
Returns
VisioShapeSelectionpublic static VisioShapeSelection Align(VisioShapeSelection selection, VisioVerticalAlignment alignment) #Aligns selected shapes vertically inside the current selection bounds.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to align.
- alignment OfficeIMO.Visio.VisioVerticalAlignment
- Vertical alignment.
Returns
VisioShapeSelectionpublic static VisioPage CenterContent(VisioPage page) #Centers top-level page shapes within the current page size.
Parameters
- page OfficeIMO.Visio.VisioPage
- Page to update.
Returns
VisioPagepublic static VisioShapeSelection Distribute(VisioShapeSelection selection, VisioDistributionAxis axis) #Distributes selected shapes by center point along the requested axis.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to distribute.
- axis OfficeIMO.Visio.VisioDistributionAxis
- Distribution axis.
Returns
VisioShapeSelectionpublic static VisioShapeSelection DistributeHorizontally(VisioShapeSelection selection) #Distributes selected shapes horizontally by center point.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to distribute.
Returns
VisioShapeSelectionpublic static VisioShapeSelection DistributeVertically(VisioShapeSelection selection) #Distributes selected shapes vertically by center point.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to distribute.
Returns
VisioShapeSelectionpublic static VisioPage FitToContent(VisioPage page, double margin = 0.5, bool resizePage = true) #Moves top-level page shapes so content starts at the requested margin and optionally resizes the page to fit.
Parameters
- page OfficeIMO.Visio.VisioPage
- Page to update.
- margin double = 0.5
- Margin in inches around content.
- resizePage bool = true
- Whether to resize the page around the content.
Returns
VisioPagepublic static VisioPage FitToContent(VisioPage page, VisioFitToContentOptions options) #Fits an imported page using explicit group-child, connector-route, translation, and resize policies. Rotation-aware shape bounds and connector label boxes are used.
Parameters
- page OfficeIMO.Visio.VisioPage
- options OfficeIMO.Visio.VisioFitToContentOptions
Returns
VisioPagepublic static VisioPage FitToContent(VisioPage page, double horizontalMargin, double verticalMargin, bool resizePage = true) #Moves top-level page shapes so content starts at the requested margins and optionally resizes the page to fit.
Parameters
- page OfficeIMO.Visio.VisioPage
- Page to update.
- horizontalMargin double
- Horizontal margin in inches.
- verticalMargin double
- Vertical margin in inches.
- resizePage bool = true
- Whether to resize the page around the content.
Returns
VisioPagepublic static VisioShapeBounds GetConnectorContentBounds(VisioConnector connector) #Gets connector route and label bounds in page inches.
Parameters
- connector OfficeIMO.Visio.VisioConnector
Returns
VisioShapeBoundspublic static VisioShapeBounds GetContentBounds(VisioPage page, bool includeGroupChildren = false, bool includeConnectors = true) #Gets bounds of visible page content, including shapes, explicit connector routes, and connector label boxes.
Parameters
- page OfficeIMO.Visio.VisioPage
- Page to inspect.
- includeGroupChildren bool = false
- Whether nested group children should be included using their stored coordinates.
- includeConnectors bool = true
- Whether connector waypoints and label boxes should be included.
Returns
VisioShapeBoundspublic static VisioShapeBounds GetLabelBounds(VisioConnector connector) #Gets the explicitly placed connector label bounds in page inches, or empty bounds when no label is placed.
Parameters
- connector OfficeIMO.Visio.VisioConnector
Returns
VisioShapeBoundspublic static VisioShapeBounds GetPageShapeBounds(VisioShape shape) #Gets rotation-aware bounds in page coordinates, including every parent-group transform for a nested shape.
Parameters
- shape OfficeIMO.Visio.VisioShape
Returns
VisioShapeBoundspublic static VisioShapeBounds GetShapeBounds(VisioShape shape) #Gets the page-space bounds for a shape.
Parameters
- shape OfficeIMO.Visio.VisioShape
- Shape to inspect.
Returns
VisioShapeBoundspublic static VisioShapeBounds GetShapeBounds(IEnumerable<VisioShape> shapes) #Gets aggregate bounds for a shape sequence.
Parameters
- shapes System.Collections.Generic.IEnumerable<OfficeIMO.Visio.VisioShape>
- Shapes to inspect.
Returns
VisioShapeBoundspublic static VisioShapeBounds GetShapeBounds(VisioShapeSelection selection) #Gets the bounds of a shape selection.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to inspect.
Returns
VisioShapeBoundspublic static VisioShapeSelection RelayoutAsGrid(VisioShapeSelection selection, int columns = 0, double horizontalSpacing = 0.5, double verticalSpacing = 0.5, bool routeInternalConnectors = true) #Relays out selected shapes into a deterministic grid and optionally reroutes internal connectors.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to relayout.
- columns int = 0
- Number of columns. When zero, OfficeIMO uses a near-square grid.
- horizontalSpacing double = 0.5
- Horizontal spacing between columns in inches.
- verticalSpacing double = 0.5
- Vertical spacing between rows in inches.
- routeInternalConnectors bool = true
- Whether connectors whose endpoints are both selected should be rerouted orthogonally.
Returns
VisioShapeSelectionpublic static VisioShapeSelection RelayoutAsGrid(VisioShapeSelection selection, VisioSelectionLayoutOptions? options) #Relays out selected shapes into a deterministic grid and optionally reroutes internal connectors.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to relayout.
- options OfficeIMO.Visio.VisioSelectionLayoutOptions?
- Layout options.
Returns
VisioShapeSelectionpublic static VisioShapeSelection RelayoutAsHorizontalStack(VisioShapeSelection selection, double spacing = 0.5, bool routeInternalConnectors = true) #Relays out selected shapes as a horizontal row and optionally reroutes internal connectors.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to relayout.
- spacing double = 0.5
- Horizontal spacing between shapes in inches.
- routeInternalConnectors bool = true
- Whether connectors whose endpoints are both selected should be rerouted orthogonally.
Returns
VisioShapeSelectionpublic static VisioShapeSelection RelayoutAsVerticalStack(VisioShapeSelection selection, double spacing = 0.5, bool routeInternalConnectors = true) #Relays out selected shapes as a vertical stack and optionally reroutes internal connectors.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to relayout.
- spacing double = 0.5
- Vertical spacing between shapes in inches.
- routeInternalConnectors bool = true
- Whether connectors whose endpoints are both selected should be rerouted orthogonally.
Returns
VisioShapeSelectionpublic static VisioConnectorSelection ResizeLabelsToText(VisioConnectorSelection selection, OfficeFontInfo? fontInfo = null, double horizontalPadding = 0.12, double verticalPadding = 0.06, double minimumWidth = 0.45, double minimumHeight = 0.22, double? maximumWidth = null) #Resizes selected connector label text boxes to fit their plain text using deterministic OfficeIMO.Drawing measurement.
Parameters
- selection OfficeIMO.Visio.VisioConnectorSelection
- Connector selection.
- fontInfo OfficeIMO.Drawing.OfficeFontInfo? = null
- Font descriptor used for measurement. Uses connector text style, then Office default, when omitted.
- horizontalPadding double = 0.12
- Horizontal padding in inches.
- verticalPadding double = 0.06
- Vertical padding in inches.
- minimumWidth double = 0.45
- Minimum resulting label width in inches.
- minimumHeight double = 0.22
- Minimum resulting label height in inches.
- maximumWidth double? = null
- Optional maximum label width in inches. Text wraps by words when supplied.
Returns
VisioConnectorSelectionpublic static VisioConnector ResizeLabelToText(VisioConnector connector, OfficeFontInfo? fontInfo = null, double horizontalPadding = 0.12, double verticalPadding = 0.06, double minimumWidth = 0.45, double minimumHeight = 0.22, double? maximumWidth = null) #Resizes a connector label text box to fit its plain text using deterministic OfficeIMO.Drawing measurement.
Parameters
- connector OfficeIMO.Visio.VisioConnector
- Connector whose label box should be resized.
- fontInfo OfficeIMO.Drawing.OfficeFontInfo? = null
- Font descriptor used for measurement. Uses connector text style, then Office default, when omitted.
- horizontalPadding double = 0.12
- Horizontal padding in inches.
- verticalPadding double = 0.06
- Vertical padding in inches.
- minimumWidth double = 0.45
- Minimum resulting label width in inches.
- minimumHeight double = 0.22
- Minimum resulting label height in inches.
- maximumWidth double? = null
- Optional maximum label width in inches. Text wraps by words when supplied.
Returns
VisioConnectorpublic static VisioShape ResizeToText(VisioShape shape, OfficeFontInfo? fontInfo = null, double horizontalPadding = 0.25, double verticalPadding = 0.14, double minimumWidth = 0.5, double minimumHeight = 0.3) #Resizes a shape to fit its plain text using deterministic OfficeIMO.Drawing measurement.
Parameters
- shape OfficeIMO.Visio.VisioShape
- Shape to resize.
- fontInfo OfficeIMO.Drawing.OfficeFontInfo? = null
- Font descriptor used for measurement. Uses Office default when omitted.
- horizontalPadding double = 0.25
- Horizontal padding in inches.
- verticalPadding double = 0.14
- Vertical padding in inches.
- minimumWidth double = 0.5
- Minimum resulting width in inches.
- minimumHeight double = 0.3
- Minimum resulting height in inches.
Returns
VisioShapepublic static VisioShapeSelection ResizeToText(VisioShapeSelection selection, OfficeFontInfo? fontInfo = null, double horizontalPadding = 0.25, double verticalPadding = 0.14, double minimumWidth = 0.5, double minimumHeight = 0.3) #Resizes selected shapes to fit their plain text using deterministic OfficeIMO.Drawing measurement.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to resize.
- fontInfo OfficeIMO.Drawing.OfficeFontInfo? = null
- Font descriptor used for measurement. Uses Office default when omitted.
- horizontalPadding double = 0.25
- Horizontal padding in inches.
- verticalPadding double = 0.14
- Vertical padding in inches.
- minimumWidth double = 0.5
- Minimum resulting width in inches.
- minimumHeight double = 0.3
- Minimum resulting height in inches.
Returns
VisioShapeSelectionpublic static VisioPage ResolveConnectorLabelOverlaps(VisioPage page, double step = 0.18, int maxAttempts = 12, bool avoidShapes = true, bool avoidLabels = true, bool preferEndpointZones = false, bool avoidConnectorPaths = true, double positionStep = 0.08, int maxPositionShifts = 4, int optimizationPasses = 1) #Moves connector label boxes away from page edges, unrelated shapes, and previously placed connector labels.
Parameters
- page OfficeIMO.Visio.VisioPage
- Page whose connector labels should be adjusted.
- step double = 0.18
- Search step in page units, expressed in inches.
- maxAttempts int = 12
- Number of search rings to try around the current label position.
- avoidShapes bool = true
- Whether labels should avoid unrelated non-container shapes.
- avoidLabels bool = true
- Whether labels should avoid other connector labels.
- preferEndpointZones bool = false
- Whether labels should prefer common endpoint zones and avoid unrelated background zones.
- avoidConnectorPaths bool = true
- Whether labels should avoid unrelated connector paths.
- positionStep double = 0.08
- Connector path-position search step, from 0.0 to 1.0.
- maxPositionShifts int = 4
- Number of positive and negative connector path-position shifts to try.
- optimizationPasses int = 1
- Number of whole-page label optimization passes to run after the initial placement sweep.
Returns
VisioPagepublic static VisioPage ResolveShapeOverlaps(VisioPage page, double step = 0.25, int maxAttempts = 24, bool includeContainers = false) #Moves overlapping top-level shapes apart using a deterministic nearest-open-position search.
Parameters
- page OfficeIMO.Visio.VisioPage
- Page to update.
- step double = 0.25
- Search step in inches.
- maxAttempts int = 24
- Number of search rings to try around each overlapping shape.
- includeContainers bool = false
- Whether container and background surface shapes should be moved and treated as obstacles.
Returns
VisioPage