The Cross Functional Flowchart template is one of the solutions that has a backing addon. The addon puts up the ribbon controls and the writing to the various shapes in the solution. You can use the Event Monitor tool in the SDK to see what cells get changed, but sometimes it's better to let the addon handle the work, as it may be (as in this case) setting multiple cells.
For this solution you don't have to worry about the shape being selected it seems, so you just need to invoke the right addon with the right arguments.
An example might look like this:
void Main()
{
var vApp = MyExtensions.GetRunningVisio();
var vPag = vApp.ActivePage;
// Create selection based on master to get hold of the shape instance
Visio.Master cffMaster = vPag.Document.Masters.ItemU["CFF Container"];
Visio.Selection sel = vPag.CreateSelection(Visio.VisSelectionTypes.visSelTypeByMaster,
Visio.VisSelectMode.visSelModeSkipSuper,
cffMaster);
Visio.Shape cffShape = sel.Count > 0 ? sel[1] : null;
ToggleCffDirection(cffShape);
}
private void ToggleCffDirection(Visio.Shape cffShape)
{
if (cffShape is null)
throw new ArgumentNullException(nameof(cffShape));
if (cffShape.HasCategory("CFF Container"))
{
bool isRtl = cffShape.CellsU["User.RTL"].ResultIU != 0;
// Find the Cross Functional Flowchart addon based on its universal name
foreach (Visio.Addon addon in cffShape.Application.Addons)
{
if (addon.NameU.Equals("CFF", StringComparison.Ordinal))
{
if (isRtl)
{
addon.Run("/left_to_right");
}
else
{
addon.Run("/right_to_left");
}
break;
}
}
}
}
You might want to improve the code by finding the addon outside of the method and passing it in as an argument, but it depends on what you're doing in the rest of your code.