When we use the auto-layout functionality in our application our diagram ends up upside down. The code we are using for adding shapes and connectors is below. Any ideas on how to make the layout start with our start block on top and then layout downward. I tried added the End block after the start and that did not fix it. Are there any other layouts we can try?
private
void
PopulateDiagram()
{
processingDiagram.Clear();
RadDiagramShape ppEnd =
new
RadDiagramShape()
{
Content =
"End"
,
Width = 100,
Height = 50,
Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.CloudShape)
};
processingDiagram.AddShape(ppEnd);
RadDiagramShape ppStart =
new
RadDiagramShape()
{
ContentTemplate = Resources[
"PreprocessingStartTemplate"
]
as
DataTemplate,
Width = 100,
Height = 50,
Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.CloudShape)
};
processingDiagram.AddShape(ppStart);
foreach
(PreprocessorSegment segment
in
SelectedEngine.PreprocessorSegments)
{
RadDiagramShape segmentStart =
new
RadDiagramShape()
{
Content = segment.Node,
Width = 100,
Height = 50,
Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.EllipseShape)
};
processingDiagram.AddShape(segmentStart);
RadDiagramConnection connection =
new
RadDiagramConnection()
{
Source = ppStart,
SourceConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Bottom,
Target = segmentStart,
TargetConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Top,
};
processingDiagram.AddConnection(connection);
List<
string
> unusedOutputs =
new
List<
string
>();
Dictionary<
string
, RadDiagramShape> outputShapes =
new
Dictionary<
string
, RadDiagramShape>();
Dictionary<PreprocessorAlgorithmInstance, RadDiagramShape> algShapes =
new
Dictionary<PreprocessorAlgorithmInstance, RadDiagramShape>();
foreach
(PreprocessorAlgorithmInstance alg
in
segment.Algorithms)
{
RadDiagramShape algShape =
new
RadDiagramShape()
{
Content = alg,
ContentTemplate = Resources[
"PreprocessingAlgorithmInstanceTemplate"
]
as
DataTemplate,
Width = 100,
Height = 50,
Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape)
};
unusedOutputs.Add(alg.Output);
outputShapes[alg.Output] = algShape;
algShapes[alg] = algShape;
processingDiagram.AddShape(algShape);
}
// Connections from Inputs to Outputs.
foreach
(PreprocessorAlgorithmInstance alg
in
segment.Algorithms)
{
foreach
(
string
input
in
alg.Inputs)
{
if
(outputShapes.ContainsKey(input))
{
RadDiagramConnection cn =
new
RadDiagramConnection()
{
Content = input,
Source = outputShapes[input],
SourceConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Bottom,
Target = algShapes[alg],
TargetConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Top,
TargetCapType = Telerik.Windows.Diagrams.Core.CapType.Arrow1Filled
};
processingDiagram.AddConnection(cn);
unusedOutputs.Remove(input);
}
else
{
RadDiagramConnection cn =
new
RadDiagramConnection()
{
Content = input,
Source = segmentStart,
SourceConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Bottom,
Target = algShapes[alg],
TargetConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Top,
TargetCapType = Telerik.Windows.Diagrams.Core.CapType.Arrow1Filled
};
processingDiagram.AddConnection(cn);
}
}
}
foreach
(
string
output
in
unusedOutputs)
{
RadDiagramConnection cn =
new
RadDiagramConnection()
{
Content = output,
Source = outputShapes[output],
SourceConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Bottom,
Target = ppEnd,
TargetConnectorPosition = Telerik.Windows.Diagrams.Core.ConnectorPosition.Top,
TargetCapType = Telerik.Windows.Diagrams.Core.CapType.Arrow1Filled
};
processingDiagram.AddConnection(cn);
}
}
processingDiagram.Layout();
}