I'm trying to create a flow diagram with a decision shape. No matter how much I've tried, I failed to set the anchor point for the decision shape. I always get A (in the attached image), while B is the desired output.
Following is the code snippet I use: var diagram = new Diagram();
ShapeNode n1 = diagram.Factory.CreateShapeNode(10, 10, 24, 14); ShapeNode n2 = diagram.Factory.CreateShapeNode(10, 10, 24, 14); ShapeNode n3 = diagram.Factory.CreateShapeNode(10, 10, 24, 14); ShapeNode n4 = diagram.Factory.CreateShapeNode(10, 10, 24, 14); ShapeNode n5 = diagram.Factory.CreateShapeNode(10, 10, 24, 14); n2.Shape.AnchorPattern = AnchorPattern.Decision1In3Out; n2.Shape = Shapes.Decision; n1.Shape = Shapes.Ellipse; n5.Shape = Shapes.Ellipse;
n1.Text = "Start"; n2.Text = "Hungry"; n3.Text = "Eat"; n4.Text = "Sleep"; n5.Text = "End";
n1.ResizeToFitText(FitSize.KeepRatio); n2.ResizeToFitText(FitSize.KeepRatio); n3.ResizeToFitText(FitSize.KeepRatio); n4.ResizeToFitText(FitSize.KeepRatio); n5.ResizeToFitText(FitSize.KeepRatio);
var l1 = diagram.Factory.CreateDiagramLink(n1, n2); var l2 = diagram.Factory.CreateDiagramLink(n2, n3); var l3 = diagram.Factory.CreateDiagramLink(n2, n4); var l4 = diagram.Factory.CreateDiagramLink(n3, n4); var l5 = diagram.Factory.CreateDiagramLink(n4, n5);
l2.Text = "Yes"; l3.Text = "No";
l3.OriginAnchor = 3; l3.AutoRoute = true;
var layout = new FlowchartLayout(); layout.Anchoring = Anchoring.Keep; layout.Arrange(diagram);
var visioExporter = new VisioExporter(); visioExporter.Export(diagram, "test.vdx");
|