1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Data model node - Properly recover when data model path validates

This commit is contained in:
Robert 2021-09-29 22:54:36 +02:00
parent 0058322936
commit eb9dd3b509
2 changed files with 17 additions and 2 deletions

View File

@ -7,10 +7,10 @@ using System.Runtime.CompilerServices;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Threading;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.Modules; using Artemis.Core.Modules;
using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services;
using Stylet;
namespace Artemis.UI.Shared.Controls namespace Artemis.UI.Shared.Controls
{ {
@ -282,9 +282,18 @@ namespace Artemis.UI.Shared.Controls
return; return;
if (e.OldValue is DataModelPath oldPath) if (e.OldValue is DataModelPath oldPath)
{
oldPath.PathInvalidated -= dataModelPicker.PathValidationChanged;
oldPath.PathValidated -= dataModelPicker.PathValidationChanged;
oldPath.Dispose(); oldPath.Dispose();
}
dataModelPicker.UpdateValueDisplay(); dataModelPicker.UpdateValueDisplay();
if (e.NewValue is DataModelPath newPath)
{
newPath.PathInvalidated += dataModelPicker.PathValidationChanged;
newPath.PathValidated += dataModelPicker.PathValidationChanged;
}
} }
private static void ShowFullPathPropertyCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void ShowFullPathPropertyCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
@ -318,6 +327,11 @@ namespace Artemis.UI.Shared.Controls
return; return;
} }
private void PathValidationChanged(object? sender, EventArgs e)
{
Dispatcher.Invoke(UpdateValueDisplay, DispatcherPriority.DataBind);
}
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
} }
} }

View File

@ -2,6 +2,7 @@
using Artemis.Core; using Artemis.Core;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
using Artemis.VisualScripting.Nodes.DataModel.CustomViewModels; using Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
using Stylet;
namespace Artemis.VisualScripting.Nodes.DataModel namespace Artemis.VisualScripting.Nodes.DataModel
{ {
@ -84,7 +85,7 @@ namespace Artemis.VisualScripting.Nodes.DataModel
private void DataModelPathOnPathValidated(object sender, EventArgs e) private void DataModelPathOnPathValidated(object sender, EventArgs e)
{ {
UpdateOutputPin(true); Execute.OnUIThread(() => UpdateOutputPin(true));
} }
/// <inheritdoc /> /// <inheritdoc />