You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a custom layout algorithm by inheriting from IExternalLayout<TVertex, TEdge>
Make sure NeedVertexSizes returns true (otherwise VertexSizes will be null)
Put a breakpoint on Compute(...) and inspect the elements in VertexSizes (all are zero-sized)
Bug cause (assumption):
public Dictionary<TVertex, Size> GetVertexSizes()
{
//measure if needed and get all vertex sizes
Measure(new USize(double.PositiveInfinity, double.PositiveInfinity));
var vertexSizes = new Dictionary<TVertex, Size>(_vertexlist.Count(a => ((IGraphXVertex)a.Value.Vertex).SkipProcessing != ProcessingOptionEnum.Exclude));
//go through the vertex presenters and get the actual layoutpositions
foreach (var vc in VertexList.Where(vc => ((IGraphXVertex)vc.Value.Vertex).SkipProcessing != ProcessingOptionEnum.Exclude))
{
vertexSizes[vc.Key] = new Size(vc.Value.ActualWidth, vc.Value.ActualHeight);
}
return vertexSizes;
}
Note: ActualWidth and ActualHeight (If I am right) are determined in the Arrange/Render step
and vc.Value.DesiredSize.Width and vc.Value.DesiredSize.Height should be used instead.
Workaround:
public class MyExternalAlgorithm: IExternalLayout<DataVertex, DataEdge>, ILayoutEdgeRouting<DataEdge>
{
private MyGraph Graph { get; set; }
private void WorkaroundForZeroVertexSizes()
{
var vertexControls = GraphArea.GetAllVertexControls();
foreach (var vertexControl in vertexControls)
{
var vertex = vertexControl.Vertex as DataVertex;
VertexSizes[vertex] = new GraphX.Measure.Size()
{
Width = vertexControl.DesiredSize.Width,
Height = vertexControl.DesiredSize.Height
};
}
}
public void Compute(CancellationToken cancellationToken)
{
WorkaroundForZeroVertexSizes();
// Now VertexSizes should be properly assigned
}
public IDictionary<DataVertex, GraphX.Measure.Point> VertexPositions { get; set; }
public IDictionary<DataVertex, GraphX.Measure.Size> VertexSizes { get; set; }
public bool NeedVertexSizes
{
get { return true; }
}
public bool SupportsObjectFreeze
{
get { return false; }
}
public MyExternalAlgorithm(MyGraph graph)
{
Graph = graph;
}
}
The text was updated successfully, but these errors were encountered:
To reproduce:
Bug cause (assumption):
Note: ActualWidth and ActualHeight (If I am right) are determined in the Arrange/Render step
and vc.Value.DesiredSize.Width and vc.Value.DesiredSize.Height should be used instead.
Workaround:
The text was updated successfully, but these errors were encountered: