From eb9dd3b509ba88bda15a876536d794f063ff4bfb Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 29 Sep 2021 22:54:36 +0200 Subject: [PATCH] Data model node - Properly recover when data model path validates --- .../Controls/DataModelPicker.xaml.cs | 16 +++++++++++++++- .../Nodes/DataModel/DataModelNode.cs | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DataModelPicker.xaml.cs b/src/Artemis.UI.Shared/Controls/DataModelPicker.xaml.cs index 306728c42..dc8b45f2e 100644 --- a/src/Artemis.UI.Shared/Controls/DataModelPicker.xaml.cs +++ b/src/Artemis.UI.Shared/Controls/DataModelPicker.xaml.cs @@ -7,10 +7,10 @@ using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Controls; using System.Windows.Media; +using System.Windows.Threading; using Artemis.Core; using Artemis.Core.Modules; using Artemis.UI.Shared.Services; -using Stylet; namespace Artemis.UI.Shared.Controls { @@ -282,9 +282,18 @@ namespace Artemis.UI.Shared.Controls return; if (e.OldValue is DataModelPath oldPath) + { + oldPath.PathInvalidated -= dataModelPicker.PathValidationChanged; + oldPath.PathValidated -= dataModelPicker.PathValidationChanged; oldPath.Dispose(); + } dataModelPicker.UpdateValueDisplay(); + if (e.NewValue is DataModelPath newPath) + { + newPath.PathInvalidated += dataModelPicker.PathValidationChanged; + newPath.PathValidated += dataModelPicker.PathValidationChanged; + } } private static void ShowFullPathPropertyCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) @@ -318,6 +327,11 @@ namespace Artemis.UI.Shared.Controls return; } + private void PathValidationChanged(object? sender, EventArgs e) + { + Dispatcher.Invoke(UpdateValueDisplay, DispatcherPriority.DataBind); + } + public event PropertyChangedEventHandler? PropertyChanged; } } \ No newline at end of file diff --git a/src/Artemis.VisualScripting/Nodes/DataModel/DataModelNode.cs b/src/Artemis.VisualScripting/Nodes/DataModel/DataModelNode.cs index d84334720..8b9b1ebbe 100644 --- a/src/Artemis.VisualScripting/Nodes/DataModel/DataModelNode.cs +++ b/src/Artemis.VisualScripting/Nodes/DataModel/DataModelNode.cs @@ -2,6 +2,7 @@ using Artemis.Core; using Artemis.Storage.Entities.Profile; using Artemis.VisualScripting.Nodes.DataModel.CustomViewModels; +using Stylet; namespace Artemis.VisualScripting.Nodes.DataModel { @@ -84,7 +85,7 @@ namespace Artemis.VisualScripting.Nodes.DataModel private void DataModelPathOnPathValidated(object sender, EventArgs e) { - UpdateOutputPin(true); + Execute.OnUIThread(() => UpdateOutputPin(true)); } ///