private bool TryComputePosition(TVertex vertex, out Point position) { position = default(Point); int count = 0; foreach (TVertex neighbor in Graph.GetNeighbors(vertex)) { if (VerticesControls.TryGetValue(neighbor, out VertexControl neighborControl)) { double x = GetX(neighborControl); double y = GetY(neighborControl); position.X += double.IsNaN(x) ? 0.0 : x; position.Y += double.IsNaN(y) ? 0.0 : y; ++count; } } if (count > 0) { position.X /= count; position.Y /= count; return(true); } return(false); }
/// <inheritdoc /> public void SemiHighlightVertex(TVertex vertex, object semiHighlightInfo) { _semiHighlightedVertices[vertex] = semiHighlightInfo; if (VerticesControls.TryGetValue(vertex, out VertexControl control)) { GraphElementBehaviour.SetIsSemiHighlighted(control, true); GraphElementBehaviour.SetSemiHighlightInfo(control, semiHighlightInfo); } }
/// <inheritdoc /> public void RemoveSemiHighlightFromVertex(TVertex vertex) { _semiHighlightedVertices.Remove(vertex); if (VerticesControls.TryGetValue(vertex, out VertexControl control)) { GraphElementBehaviour.SetIsSemiHighlighted(control, false); GraphElementBehaviour.SetSemiHighlightInfo(control, null); } }
public VertexControl GetVertexControl([NotNull] TVertex vertex) { return(VerticesControls.TryGetValue(vertex, out VertexControl control) ? control : null); }