Reputation: 2620
I have succeeded to reestablish the link between two activities after another one ( which existed before between them) was deleted.
if (containerAsFlowchart != null)
{
for (int i = 0; i < containerAsFlowchart.Nodes.Count; i++)
{
if (containerAsFlowchart.Nodes[i] is FlowStep)
{
FlowStep fs = containerAsFlowchart.Nodes[i] as FlowStep;
if (fs.Next == null)
{
if (i < containerAsFlowchart.Nodes.Count - 1)
{
fs.Next = (FlowNode)((containerAsFlowchart.Nodes[i + 1] as FlowStep));
}
}
}
}
}
Al works fine till now, but even if the connection is made back, I am not able to visualize it in the workflow designer. If I extend or collapse an activity, or any other operation which refreshes the workflow, that pretty arrow is back there but.. is there any way to do this programmatically, and trigger this repainting straight after I delete one activity ?
Upvotes: 1
Views: 1510
Reputation: 7486
For the changes to be visible on the designer you've to directly edit its ModelItem.
var modelItem = Designer.Context.Services.GetService<ModelService>().Root;
// Do changes through modelItem ...
For example, to change the DisplayName of the root activity:
modelItem.Properties["DisplayName"].Value = "New Name";
What ModelItem
does is to keep every part of the workflow in an agnostic model structure, from complex types down to a simple integer. That model is use by the designer itself to print the workflow to the screen among other things (read arguments, variables, etc.).
Use the debugger and watch the model to learn more.
Upvotes: 1