From f8270e6408aa80728035c5dc1fdd1d7f38edbf7b Mon Sep 17 00:00:00 2001 From: Trivalik <3148279+trivalik@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:10:18 +0100 Subject: [PATCH] allow assign graphControl.Graph = null and reassign graph --- .../WpfGraphControl/AutomaticGraphLayoutControl.xaml.cs | 6 +----- GraphLayout/tools/WpfGraphControl/GraphViewer.cs | 5 ++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/GraphLayout/tools/WpfGraphControl/AutomaticGraphLayoutControl.xaml.cs b/GraphLayout/tools/WpfGraphControl/AutomaticGraphLayoutControl.xaml.cs index 0445d7a1..c26cefe7 100644 --- a/GraphLayout/tools/WpfGraphControl/AutomaticGraphLayoutControl.xaml.cs +++ b/GraphLayout/tools/WpfGraphControl/AutomaticGraphLayoutControl.xaml.cs @@ -15,12 +15,8 @@ public Graph Graph { public static readonly DependencyProperty GraphProperty = DependencyProperty.Register("Graph", typeof(Graph), typeof(AutomaticGraphLayoutControl), new PropertyMetadata(default(Graph), (d,e)=> ((AutomaticGraphLayoutControl)d)?.SetGraph())); - + private void SetGraph() { - if (Graph == null) { - dockPanel.Children.Clear(); - return; - } if (_graphViewer == null) { _graphViewer = new GraphViewer(); _graphViewer.BindToPanel(dockPanel); diff --git a/GraphLayout/tools/WpfGraphControl/GraphViewer.cs b/GraphLayout/tools/WpfGraphControl/GraphViewer.cs index 31b8aaf0..ad72471d 100644 --- a/GraphLayout/tools/WpfGraphControl/GraphViewer.cs +++ b/GraphLayout/tools/WpfGraphControl/GraphViewer.cs @@ -746,7 +746,10 @@ void ProcessGraphUnderLock() { CancelToken = new CancelToken(); - if (_drawingGraph == null) return; + if (_drawingGraph == null) { + ClearGraphViewer(); + return; + } HideCanvas(); ClearGraphViewer();