protected void AddGraph(PocGraphInfo graphInfo) { LayoutStates.Clear(); if (graphInfo == null) { return; } HighlightAlgorithm?.ResetHighlight(); RemoveAllGraphElement(); Children.Clear(); Dictionary <int, PocVertex> vertexControlsById = new Dictionary <int, PocVertex>(); foreach (VertexInfo <PocVertex> info in graphInfo.Verteces.OfType <VertexInfo <PocVertex> >()) { AddVertexControl(info); vertexControlsById.Add(info.ID, info.Vertex); } int i = 0; foreach (EdgeInfo <PocEdge> info in graphInfo.Edges.OfType <EdgeInfo <PocEdge> >()) { PocVertex source = vertexControlsById[info.SourceID]; PocVertex target = vertexControlsById[info.TargetID]; CreateEdgeControl(new PocEdge(i.ToString(), source, target)); i++; } }
private void OnRelayoutInduction(bool tryKeepControls) { if (HighlightAlgorithm != null) { HighlightAlgorithm.ResetHighlight(); } //recreate the graph elements RecreateGraphElements(tryKeepControls); //do the layout process again Relayout(); }
private void DoNotificationLayout() { lock (_notificationSyncRoot) { _lastNotificationTimestamp = DateTime.Now; } if (Worker != null) { return; } Worker = new BackgroundWorker(); Worker.DoWork += (s, e) => { var w = (BackgroundWorker)s; lock (_notificationSyncRoot) { while ((DateTime.Now - _lastNotificationTimestamp) < _notificationLayoutDelay) { Thread.Sleep(_notificationLayoutDelay); if (w.CancellationPending) { break; } } } }; Worker.RunWorkerCompleted += (s, e) => { Worker = null; OnMutation(); ContinueLayout(); if (HighlightAlgorithm != null) { HighlightAlgorithm.ResetHighlight(); } }; Worker.RunWorkerAsync(); }