Nodes - Implemented saving/loading

Nodes - Added data model node
This commit is contained in:
Robert committed 2021-08-10 16:52:24 +02:00
1 parent 61d7f1e1fb
commit afc4bee7ac
29 files changed
+730 -157

No files matched your search

@@ -15,7 +15,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DocumentationFile>bin\Artemis.VisualScripting.xml</DocumentationFile>
<DocumentationFile></DocumentationFile>
<NoWarn></NoWarn>
<WarningLevel>5</WarningLevel>
</PropertyGroup>
@@ -42,6 +42,7 @@
<ItemGroup>
<ProjectReference Include="..\Artemis.Core\Artemis.Core.csproj" />
<ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj" />
</ItemGroup>
<ItemGroup>
@@ -383,7 +383,7 @@ namespace Artemis.VisualScripting.Editor.Controls
if (_creationBoxParent.ContextMenu != null)
_creationBoxParent.ContextMenu.IsOpen = false;
INode node = nodeData.CreateNode();
INode node = nodeData.CreateNode(null);
Script.AddNode(node);
InitializeNode(node, _lastRightClickLocation);
@@ -207,9 +207,18 @@
</StackPanel>
</Border>
<!-- TODO: Figure out how to only use this for CustomViewModelNode -->
<Border x:Name="BrdCustomView" Grid.Column="1">
<ContentControl s:View.Model="{Binding Node.CustomViewModel}"/>
<Border.Resources>
<DataTemplate DataType="{x:Type core:CustomViewModelNode}">
<ContentControl s:View.Model="{Binding BaseCustomViewModel}"/>
</DataTemplate>
<DataTemplate DataType="{x:Type core:Node}">
<Border />
</DataTemplate>
</Border.Resources>
<ContentControl Content="{Binding Node}" />
</Border>
<Border x:Name="BrdOutputPins" Grid.Column="2">
@@ -0,0 +1,42 @@
using Artemis.Core;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Input;
using Artemis.UI.Shared.Services;
using Stylet;
namespace Artemis.VisualScripting.Nodes.CustomViewModels
{
public class DataModelNodeCustomViewModel : CustomNodeViewModel
{
private readonly DataModelNode _node;
public DataModelNodeCustomViewModel(DataModelNode node, IDataModelUIService dataModelUIService) : base(node)
{
_node = node;
Execute.OnUIThreadSync(() =>
{
SelectionViewModel = dataModelUIService.GetDynamicSelectionViewModel(module: null);
SelectionViewModel.PropertySelected += SelectionViewModelOnPropertySelected;
});
}
public DataModelDynamicViewModel SelectionViewModel { get; set; }
private void SelectionViewModelOnPropertySelected(object? sender, DataModelInputDynamicEventArgs e)
{
_node.DataModelPath = SelectionViewModel.DataModelPath;
if (_node.DataModelPath != null)
{
_node.DataModelPath.Save();
_node.Storage = _node.DataModelPath.Entity;
}
else
{
_node.Storage = null;
}
_node.UpdateOutputPin();
}
}
}
@@ -1,15 +1,24 @@
using Stylet;
using Artemis.Core;
namespace Artemis.VisualScripting.Nodes.CustomViewModels
{
public class StaticDoubleValueNodeCustomViewModel : PropertyChangedBase
public class StaticDoubleValueNodeCustomViewModel : CustomNodeViewModel
{
private double _input;
private readonly StaticDoubleValueNode _node;
public StaticDoubleValueNodeCustomViewModel(StaticDoubleValueNode node) : base(node)
{
_node = node;
}
public double Input
{
get => _input;
set => SetAndNotify(ref _input, value);
get => (double) _node.Storage;
set
{
_node.Storage = value;
OnPropertyChanged(nameof(Input));
}
}
}
}
@@ -1,15 +1,24 @@
using Stylet;
using Artemis.Core;
namespace Artemis.VisualScripting.Nodes.CustomViewModels
{
public class StaticIntegerValueNodeCustomViewModel : PropertyChangedBase
public class StaticIntegerValueNodeCustomViewModel : CustomNodeViewModel
{
private int _input;
private readonly StaticIntegerValueNode _node;
public StaticIntegerValueNodeCustomViewModel(StaticIntegerValueNode node) : base(node)
{
_node = node;
}
public int Input
{
get => _input;
set => SetAndNotify(ref _input, value);
get => (int)(long) _node.Storage;
set
{
_node.Storage = value;
OnPropertyChanged(nameof(Input));
}
}
}
}
@@ -1,15 +1,24 @@
using Stylet;
using Artemis.Core;
namespace Artemis.VisualScripting.Nodes.CustomViewModels
{
public class StaticStringValueNodeCustomViewModel : PropertyChangedBase
public class StaticStringValueNodeCustomViewModel : CustomNodeViewModel
{
private string _input;
private readonly StaticStringValueNode _node;
public StaticStringValueNodeCustomViewModel(StaticStringValueNode node) : base(node)
{
_node = node;
}
public string Input
{
get => _input;
set => SetAndNotify(ref _input, value);
get => (string) _node.Storage;
set
{
_node.Storage = value;
OnPropertyChanged(nameof(Input));
}
}
}
}
@@ -0,0 +1,11 @@
<UserControl x:Class="Artemis.VisualScripting.Nodes.CustomViews.DataModelNodeCustomView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.VisualScripting.Nodes.CustomViews"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<ContentControl s:View.Model="{Binding SelectionViewModel}"></ContentControl>
</UserControl>
@@ -0,0 +1,48 @@
using System;
using System.Linq;
using Artemis.Core;
using Artemis.Storage.Entities.Profile;
using Artemis.VisualScripting.Nodes.CustomViewModels;
namespace Artemis.VisualScripting.Nodes
{
[Node("Data Model-Value", "Outputs a selectable data model value.")]
public class DataModelNode : Node<DataModelNodeCustomViewModel>
{
public DataModelNode() : base("Data Model", "Outputs a selectable data model value")
{
}
public OutputPin Output { get; private set; }
public DataModelPath DataModelPath { get; set; }
public override void Initialize()
{
if (Storage is not DataModelPathEntity pathEntity)
return;
DataModelPath = new DataModelPath(null, pathEntity);
CustomViewModel.SelectionViewModel.ChangeDataModelPath(DataModelPath);
UpdateOutputPin();
}
public override void Evaluate()
{
if (DataModelPath.IsValid && Output != null)
Output.Value = DataModelPath.GetValue()!;
}
public void UpdateOutputPin()
{
if (Pins.Contains(Output))
{
RemovePin(Output);
Output = null;
}
Type type = DataModelPath?.GetPropertyType();
if (type != null)
Output = CreateOutputPin(type);
}
}
}
@@ -26,9 +26,11 @@ namespace Artemis.VisualScripting.Nodes
public override void Evaluate()
{
Output.Value = CustomViewModel.Input;
Output.Value = (int) (Storage as long? ?? 0);
}
public override void Initialize() => Storage ??= 0;
#endregion
}
@@ -55,9 +57,11 @@ namespace Artemis.VisualScripting.Nodes
public override void Evaluate()
{
Output.Value = CustomViewModel.Input;
Output.Value = Storage as double? ?? 0.0;
}
public override void Initialize() => Storage ??= 0.0;
#endregion
}
@@ -84,9 +88,9 @@ namespace Artemis.VisualScripting.Nodes
public override void Evaluate()
{
Output.Value = CustomViewModel.Input;
Output.Value = Storage as string;
}
#endregion
}
@@ -57,6 +57,28 @@
"resolved": "5.0.10",
"contentHash": "x70WuqMDuP75dajqSLvO+AnI/BbwS6da+ukTO7rueV7VoXoQ5CRA9FV4r7cOS4OUr2NS1Up7LDIutjCxQycRvg=="
},
"MaterialDesignColors": {
"type": "Transitive",
"resolved": "2.0.1",
"contentHash": "Azl8nN23SD6QPE0PdsfpKiIqWTvH7rzXwgXPiFSEt91NFOrwB5cx3iq/sbINWMZunhXJ32+jVUHiV03B8eJbZw=="
},
"MaterialDesignExtensions": {
"type": "Transitive",
"resolved": "3.3.0",
"contentHash": "dlxWtdrMH8aHNib3dWJhNQ/nNiA2b/CNvr90w/5KB6erTisuTpyYVx2l2+UGCZvwhSX5mHTHQYHfjgAKbDrgjg==",
"dependencies": {
"MaterialDesignColors": "1.2.7",
"MaterialDesignThemes": "3.2.0"
}
},
"MaterialDesignThemes": {
"type": "Transitive",
"resolved": "4.1.0",
"contentHash": "WqrO9AbtdE4pLPtDk/C5BZRnkgWFwVGyUHWj7tRJrgnKl089DEobVXBCLeqp2mkgBeFHj4Xe3AfWyhmlnO6AZA==",
"dependencies": {
"MaterialDesignColors": "2.0.1"
}
},
"McMaster.NETCore.Plugins": {
"type": "Transitive",
"resolved": "1.4.0",
@@ -104,6 +126,11 @@
"Microsoft.NETCore.Platforms": "3.0.0"
}
},
"Microsoft.Xaml.Behaviors.Wpf": {
"type": "Transitive",
"resolved": "1.1.31",
"contentHash": "LZpuf82ACZWldmfMuv3CTUMDh3o0xo0uHUaybR5HgqVLDBJJ9RZLykplQ/bTJd0/VDt3EhD4iDgUgbdIUAM+Kg=="
},
"NETStandard.Library": {
"type": "Transitive",
"resolved": "1.6.1",
@@ -336,6 +363,11 @@
"System.Threading.Timer": "4.0.1"
}
},
"SharpVectors.Reloaded": {
"type": "Transitive",
"resolved": "1.7.5",
"contentHash": "v9U5sSMGFE2zCMbh42BYHkaRYkmwwhsKMGcNRdHAKqD1ryOf4mhqnJR0o07hwg5KIEmCI9bDdrgYSmiZWlL+eA=="
},
"SkiaSharp": {
"type": "Transitive",
"resolved": "2.80.2",
@@ -344,6 +376,23 @@
"System.Memory": "4.5.3"
}
},
"SkiaSharp.Views.Desktop.Common": {
"type": "Transitive",
"resolved": "2.80.2",
"contentHash": "0vBvweMysgl1wgjuTQUhdJMD5z5nBjtYqmnHPeX+qHfkc336Wj2L3jEqwmGb0YP+RV47gFGz0EzMAW6szZch9w==",
"dependencies": {
"SkiaSharp": "2.80.2"
}
},
"SkiaSharp.Views.WPF": {
"type": "Transitive",
"resolved": "2.80.2",
"contentHash": "Fzo2+MNwHDh9Cob8sk7OO26kp3bhofjXMwlEK8IncF1ehu9hi3sH9iQDJrue9a88VEJJ+yyLISPUFcmXlGHSyQ==",
"dependencies": {
"SkiaSharp": "2.80.2",
"SkiaSharp.Views.Desktop.Common": "2.80.2"
}
},
"System.AppContext": {
"type": "Transitive",
"resolved": "4.3.0",
@@ -1266,6 +1315,24 @@
"LiteDB": "5.0.10",
"Serilog": "2.10.0"
}
},
"artemis.ui.shared": {
"type": "Project",
"dependencies": {
"Artemis.Core": "1.0.0",
"Humanizer.Core": "2.11.10",
"MaterialDesignExtensions": "3.3.0",
"MaterialDesignThemes": "4.1.0",
"Microsoft.Xaml.Behaviors.Wpf": "1.1.31",
"Ninject": "3.3.4",
"Ninject.Extensions.Conventions": "3.3.0",
"SharpVectors.Reloaded": "1.7.5",
"SkiaSharp": "2.80.2",
"SkiaSharp.Views.WPF": "2.80.2",
"Stylet": "1.3.6",
"System.Buffers": "4.5.1",
"System.Numerics.Vectors": "4.5.0"
}
}
}
}