SRC structs
Identifying cells
Visio has two ways of identifying a cell:
By name - for example "FillForegnd"
By a triple of indices - (a section index, a row index, and a cell index). We'll refer to this (s,r,c) pattern often
These (s,r,c) values are used a lot when working with the Visio ShapeSheet. VisioAutomation defines a special struct called SRC to store these values. The full name of the struct is VisioAutomation.ShapeSheet.SRC.
Create a SRC struct from literal numbers
Create a SRC struct from well known Indices from the Visio PIA
The SRC below to points the fill foreground color
Common Cell SRCs in VisioAuatomation
VisioAutomation comes with a class that has predefined values for many of these (s,r,c) values for cells.
The static class called VisioAutomation.ShapeSheet.SRCConstant contains hundreds of cells.
So to get the (s,r,c) value for FillPattern we just need to write this
Here are some commonly used ones:
Immutability
SRC values are immutable structs. Once created their value cannot be changed
Dealing with the same cell in Multiple rows
Often you may have a (s,r,c) value , and you need almost the same cell, but for a different row. use the SRC.ForRow method to construct a new (s,r,c) value from an existing one
Converting between cell names and (s,r,c) values
Suppose you have a cell name stored as a string - "PinX" for example - and now you need to get the (s,r,c) value. There are a static methods that will provide the conversion for you for many common cell that are referred to by names.
The first is ShapeSheetHelper.GetSRCFromName
If the cell name is not one the method handles, then an exception will be thrown.
So, as an alternative you can try the ShapeSheetHelperTryGetSRCFromName which returns a nullbable SRC value;
Converting between (s,r,c) values and cell names
There's no helper method in the library that will do this. It will be considered for a future version.
Last updated