API Reference
VisioLayoutExtensions
Layout and geometry helpers for Visio pages, shapes, and selections.
Inheritance
- Object
- VisioLayoutExtensions
Methods
public static VisioShapeSelection Align(VisioShapeSelection selection, VisioVerticalAlignment alignment) #VisioShapeSelectionAligns selected shapes horizontally inside the current selection bounds.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to align.
- alignment OfficeIMO.Visio.VisioHorizontalAlignment
- Horizontal alignment.
Align(OfficeIMO.Visio.VisioShapeSelection selection, OfficeIMO.Visio.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.
public static VisioPage CenterContent(VisioPage page) #VisioPageCenters top-level page shapes within the current page size.
Parameters
- page OfficeIMO.Visio.VisioPage
- Page to update.
public static VisioShapeSelection Distribute(VisioShapeSelection selection, VisioDistributionAxis axis) #VisioShapeSelectionDistributes selected shapes by center point along the requested axis.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to distribute.
- axis OfficeIMO.Visio.VisioDistributionAxis
- Distribution axis.
public static VisioShapeSelection DistributeHorizontally(VisioShapeSelection selection) #VisioShapeSelectionDistributes selected shapes horizontally by center point.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to distribute.
public static VisioShapeSelection DistributeVertically(VisioShapeSelection selection) #VisioShapeSelectionDistributes selected shapes vertically by center point.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to distribute.
public static VisioPage FitToContent(VisioPage page, Double margin = 0.5, Boolean resizePage = true) #VisioPageMoves 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 System.Double = 0.5
- Margin in inches around content.
- resizePage System.Boolean = true
- Whether to resize the page around the content.
public static VisioPage FitToContent(VisioPage page, Double horizontalMargin, Double verticalMargin, Boolean resizePage = true) #VisioPageMoves 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 System.Double
- Horizontal margin in inches.
- verticalMargin System.Double
- Vertical margin in inches.
- resizePage System.Boolean = true
- Whether to resize the page around the content.
public static VisioShapeBounds GetContentBounds(VisioPage page, Boolean includeGroupChildren = false, Boolean includeConnectors = true) #VisioShapeBoundsGets bounds of visible page content, including shapes, explicit connector routes, and connector label boxes.
Parameters
- page OfficeIMO.Visio.VisioPage
- Page to inspect.
- includeGroupChildren System.Boolean = false
- Whether nested group children should be included using their stored coordinates.
- includeConnectors System.Boolean = true
- Whether connector waypoints and label boxes should be included.
public static VisioShapeBounds GetShapeBounds(VisioShapeSelection selection) #VisioShapeBoundsGets the page-space bounds for a shape.
Parameters
- shape OfficeIMO.Visio.VisioShape
- Shape to inspect.
GetShapeBounds(System.Collections.Generic.IEnumerable{OfficeIMO.Visio.VisioShape} shapes) #Gets aggregate bounds for a shape sequence.
Parameters
- shapes System.Collections.Generic.IEnumerable{OfficeIMO.Visio.VisioShape}
- Shapes to inspect.
GetShapeBounds(OfficeIMO.Visio.VisioShapeSelection selection) #Gets the bounds of a shape selection.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to inspect.
public static VisioShapeSelection RelayoutAsGrid(VisioShapeSelection selection, Int32 columns = 0, Double horizontalSpacing = 0.5, Double verticalSpacing = 0.5, Boolean routeInternalConnectors = true) #VisioShapeSelectionRelays out selected shapes into a deterministic grid and optionally reroutes internal connectors.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to relayout.
- columns System.Int32 = 0
- Number of columns. When zero, OfficeIMO uses a near-square grid.
- horizontalSpacing System.Double = 0.5
- Horizontal spacing between columns in inches.
- verticalSpacing System.Double = 0.5
- Vertical spacing between rows in inches.
- routeInternalConnectors System.Boolean = true
- Whether connectors whose endpoints are both selected should be rerouted orthogonally.
public static VisioShapeSelection RelayoutAsGrid(VisioShapeSelection selection, VisioSelectionLayoutOptions options) #VisioShapeSelectionRelays 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.
public static VisioShapeSelection RelayoutAsHorizontalStack(VisioShapeSelection selection, Double spacing = 0.5, Boolean routeInternalConnectors = true) #VisioShapeSelectionRelays out selected shapes as a horizontal row and optionally reroutes internal connectors.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to relayout.
- spacing System.Double = 0.5
- Horizontal spacing between shapes in inches.
- routeInternalConnectors System.Boolean = true
- Whether connectors whose endpoints are both selected should be rerouted orthogonally.
public static VisioShapeSelection RelayoutAsVerticalStack(VisioShapeSelection selection, Double spacing = 0.5, Boolean routeInternalConnectors = true) #VisioShapeSelectionRelays out selected shapes as a vertical stack and optionally reroutes internal connectors.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to relayout.
- spacing System.Double = 0.5
- Vertical spacing between shapes in inches.
- routeInternalConnectors System.Boolean = true
- Whether connectors whose endpoints are both selected should be rerouted orthogonally.
public static VisioConnectorSelection ResizeLabelsToText(VisioConnectorSelection selection, Nullable<OfficeFontInfo> fontInfo = null, Double horizontalPadding = 0.12, Double verticalPadding = 0.06, Double minimumWidth = 0.45, Double minimumHeight = 0.22, Nullable<Double> maximumWidth = null) #VisioConnectorSelectionResizes selected connector label text boxes to fit their plain text using deterministic OfficeIMO.Drawing measurement.
Parameters
- selection OfficeIMO.Visio.VisioConnectorSelection
- Connector selection.
- fontInfo System.Nullable{OfficeIMO.Drawing.OfficeFontInfo} = null
- Font descriptor used for measurement. Uses connector text style, then Office default, when omitted.
- horizontalPadding System.Double = 0.12
- Horizontal padding in inches.
- verticalPadding System.Double = 0.06
- Vertical padding in inches.
- minimumWidth System.Double = 0.45
- Minimum resulting label width in inches.
- minimumHeight System.Double = 0.22
- Minimum resulting label height in inches.
- maximumWidth System.Nullable{System.Double} = null
- Optional maximum label width in inches. Text wraps by words when supplied.
public static VisioConnector ResizeLabelToText(VisioConnector connector, Nullable<OfficeFontInfo> fontInfo = null, Double horizontalPadding = 0.12, Double verticalPadding = 0.06, Double minimumWidth = 0.45, Double minimumHeight = 0.22, Nullable<Double> maximumWidth = null) #VisioConnectorResizes 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 System.Nullable{OfficeIMO.Drawing.OfficeFontInfo} = null
- Font descriptor used for measurement. Uses connector text style, then Office default, when omitted.
- horizontalPadding System.Double = 0.12
- Horizontal padding in inches.
- verticalPadding System.Double = 0.06
- Vertical padding in inches.
- minimumWidth System.Double = 0.45
- Minimum resulting label width in inches.
- minimumHeight System.Double = 0.22
- Minimum resulting label height in inches.
- maximumWidth System.Nullable{System.Double} = null
- Optional maximum label width in inches. Text wraps by words when supplied.
public static VisioShapeSelection ResizeToText(VisioShapeSelection selection, Nullable<OfficeFontInfo> fontInfo = null, Double horizontalPadding = 0.25, Double verticalPadding = 0.14, Double minimumWidth = 0.5, Double minimumHeight = 0.3) #VisioShapeSelectionResizes a shape to fit its plain text using deterministic OfficeIMO.Drawing measurement.
Parameters
- shape OfficeIMO.Visio.VisioShape
- Shape to resize.
- fontInfo System.Nullable{OfficeIMO.Drawing.OfficeFontInfo} = null
- Font descriptor used for measurement. Uses Office default when omitted.
- horizontalPadding System.Double = 0.25
- Horizontal padding in inches.
- verticalPadding System.Double = 0.14
- Vertical padding in inches.
- minimumWidth System.Double = 0.5
- Minimum resulting width in inches.
- minimumHeight System.Double = 0.3
- Minimum resulting height in inches.
ResizeToText(OfficeIMO.Visio.VisioShapeSelection selection, System.Nullable{OfficeIMO.Drawing.OfficeFontInfo} fontInfo, System.Double horizontalPadding, System.Double verticalPadding, System.Double minimumWidth, System.Double minimumHeight) #Resizes selected shapes to fit their plain text using deterministic OfficeIMO.Drawing measurement.
Parameters
- selection OfficeIMO.Visio.VisioShapeSelection
- Selection to resize.
- fontInfo System.Nullable{OfficeIMO.Drawing.OfficeFontInfo}
- Font descriptor used for measurement. Uses Office default when omitted.
- horizontalPadding System.Double
- Horizontal padding in inches.
- verticalPadding System.Double
- Vertical padding in inches.
- minimumWidth System.Double
- Minimum resulting width in inches.
- minimumHeight System.Double
- Minimum resulting height in inches.
public static VisioPage ResolveConnectorLabelOverlaps(VisioPage page, Double step = 0.18, Int32 maxAttempts = 12, Boolean avoidShapes = true, Boolean avoidLabels = true) #VisioPageMoves 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 System.Double = 0.18
- Search step in page units, expressed in inches.
- maxAttempts System.Int32 = 12
- Number of search rings to try around the current label position.
- avoidShapes System.Boolean = true
- Whether labels should avoid unrelated non-container shapes.
- avoidLabels System.Boolean = true
- Whether labels should avoid other connector labels.
public static VisioPage ResolveShapeOverlaps(VisioPage page, Double step = 0.25, Int32 maxAttempts = 24, Boolean includeContainers = false) #VisioPageMoves overlapping top-level shapes apart using a deterministic nearest-open-position search.
Parameters
- page OfficeIMO.Visio.VisioPage
- Page to update.
- step System.Double = 0.25
- Search step in inches.
- maxAttempts System.Int32 = 24
- Number of search rings to try around each overlapping shape.
- includeContainers System.Boolean = false
- Whether container and background surface shapes should be moved and treated as obstacles.