Nodes - Added node type registration system

Nodes - Moved models and node logic into core
Nodes - Added node service that leverages DI
This commit is contained in:
Robert committed 2021-08-07 21:05:15 +02:00
1 parent 51541b4e6e
commit 7eadc58bee
57 files changed
+481 -259

No files matched your search

@@ -1,10 +1,9 @@
using System.Collections;
using Artemis.VisualScripting.Attributes;
using Artemis.VisualScripting.Model;
using Artemis.Core;
namespace Artemis.VisualScripting.Nodes
{
[UI("Greater than", "Checks if the first input is greater than the second.")]
[Node("Greater than", "Checks if the first input is greater than the second.")]
public class GreaterThanNode : Node
{
#region Properties & Fields
@@ -45,7 +44,7 @@ namespace Artemis.VisualScripting.Nodes
#endregion
}
[UI("Less than", "Checks if the first input is less than the second.")]
[Node("Less than", "Checks if the first input is less than the second.")]
public class LessThanNode : Node
{
#region Properties & Fields
@@ -86,7 +85,7 @@ namespace Artemis.VisualScripting.Nodes
#endregion
}
[UI("Equals", "Checks if the two inputs are equals.")]
[Node("Equals", "Checks if the two inputs are equals.")]
public class EqualsNode : Node
{
#region Properties & Fields
@@ -127,7 +126,7 @@ namespace Artemis.VisualScripting.Nodes
#endregion
}
[UI("Negate", "Negates the boolean.")]
[Node("Negate", "Negates the boolean.")]
public class NegateNode : Node
{
#region Properties & Fields
@@ -1,9 +1,8 @@
using Artemis.VisualScripting.Attributes;
using Artemis.VisualScripting.Model;
using Artemis.Core;
namespace Artemis.VisualScripting.Nodes
{
[UI("To String", "Converts the input to a string.")]
[Node("To String", "Converts the input to a string.")]
public class ConvertToStringNode : Node
{
#region Properties & Fields
@@ -35,7 +34,7 @@ namespace Artemis.VisualScripting.Nodes
#endregion
}
[UI("To Integer", "Converts the input to an integer.")]
[Node("To Integer", "Converts the input to an integer.")]
public class ConvertToIntegerNode : Node
{
#region Properties & Fields
@@ -70,7 +69,7 @@ namespace Artemis.VisualScripting.Nodes
#endregion
}
[UI("To Double", "Converts the input to a double.")]
[Node("To Double", "Converts the input to a double.")]
public class ConvertToDoubleNode : Node
{
#region Properties & Fields
@@ -0,0 +1,15 @@
using Stylet;
namespace Artemis.VisualScripting.Nodes.CustomViewModels
{
public class StaticDoubleValueNodeCustomViewModel : PropertyChangedBase
{
private double _input;
public double Input
{
get => _input;
set => SetAndNotify(ref _input, value);
}
}
}
@@ -0,0 +1,15 @@
using Stylet;
namespace Artemis.VisualScripting.Nodes.CustomViewModels
{
public class StaticIntegerValueNodeCustomViewModel : PropertyChangedBase
{
private int _input;
public int Input
{
get => _input;
set => SetAndNotify(ref _input, value);
}
}
}
@@ -0,0 +1,15 @@
using Stylet;
namespace Artemis.VisualScripting.Nodes.CustomViewModels
{
public class StaticStringValueNodeCustomViewModel : PropertyChangedBase
{
private string _input;
public string Input
{
get => _input;
set => SetAndNotify(ref _input, value);
}
}
}
@@ -0,0 +1,12 @@
<UserControl x:Class="Artemis.VisualScripting.Nodes.CustomViews.StaticDoubleValueNodeCustomView"
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.CustomViewModels"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<TextBox VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Text="{Binding Input}" />
</UserControl>
@@ -0,0 +1,12 @@
<UserControl x:Class="Artemis.VisualScripting.Nodes.CustomViews.StaticIntegerValueNodeCustomView"
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.CustomViewModels"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<TextBox VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Text="{Binding Input}" />
</UserControl>
@@ -0,0 +1,12 @@
<UserControl x:Class="Artemis.VisualScripting.Nodes.CustomViews.StaticStringValueNodeCustomView"
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.CustomViewModels"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<TextBox VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Text="{Binding Input}" />
</UserControl>
@@ -1,10 +1,9 @@
using System.Windows;
using Artemis.VisualScripting.Attributes;
using Artemis.VisualScripting.Model;
using Artemis.Core;
using Artemis.VisualScripting.Nodes.CustomViewModels;
namespace Artemis.VisualScripting.Nodes
{
[UI("Integer-Value", "Outputs an configurable integer value.")]
[Node("Integer-Value", "Outputs an configurable integer value.")]
public class StaticIntegerValueNode : Node
{
#region Properties & Fields
@@ -21,7 +20,7 @@ namespace Artemis.VisualScripting.Nodes
: base("Integer", "Outputs an configurable integer value.")
{
Output = CreateOutputPin<int>();
RegisterCustomView(Application.Current.FindResource("StaticValueCustomViewTemplate") as DataTemplate, _customViewModel);
RegisterCustomViewModel<StaticIntegerValueNodeCustomViewModel>();
}
#endregion
@@ -36,7 +35,7 @@ namespace Artemis.VisualScripting.Nodes
#endregion
}
[UI("Double-Value", "Outputs a configurable double value.")]
[Node("Double-Value", "Outputs a configurable double value.")]
public class StaticDoubleValueNode : Node
{
#region Properties & Fields
@@ -53,7 +52,7 @@ namespace Artemis.VisualScripting.Nodes
: base("Double", "Outputs a configurable double value.")
{
Output = CreateOutputPin<double>();
RegisterCustomView(Application.Current.FindResource("StaticValueCustomViewTemplate") as DataTemplate, _customViewModel);
RegisterCustomViewModel<StaticDoubleValueNodeCustomViewModel>();
}
#endregion
@@ -68,7 +67,7 @@ namespace Artemis.VisualScripting.Nodes
#endregion
}
[UI("String-Value", "Outputs a configurable string value.")]
[Node("String-Value", "Outputs a configurable string value.")]
public class StaticStringValueNode : Node
{
#region Properties & Fields
@@ -85,7 +84,7 @@ namespace Artemis.VisualScripting.Nodes
: base("String", "Outputs a configurable string value.")
{
Output = CreateOutputPin<string>();
RegisterCustomView(Application.Current.FindResource("StaticValueCustomViewTemplate") as DataTemplate, _customViewModel);
RegisterCustomViewModel<StaticStringValueNodeCustomViewModel>();
}
#endregion
@@ -102,20 +101,7 @@ namespace Artemis.VisualScripting.Nodes
#region CustomViewModels
public class StaticIntegerValueNodeCustomViewModel
{
public int Input { get; set; }
}
public class StaticDoubleValueNodeCustomViewModel
{
public double Input { get; set; }
}
public class StaticStringValueNodeCustomViewModel
{
public string Input { get; set; }
}
#endregion
}
@@ -1,10 +1,9 @@
using System.Linq;
using Artemis.VisualScripting.Attributes;
using Artemis.VisualScripting.Model;
using Artemis.Core;
namespace Artemis.VisualScripting.Nodes
{
[UI("Format", "Formats the input string.")]
[Node("Format", "Formats the input string.")]
public class StringFormatNode : Node
{
#region Properties & Fields
@@ -1,12 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:nodes="clr-namespace:Artemis.VisualScripting.Nodes">
<DataTemplate x:Key="StaticValueCustomViewTemplate"
DataType="{x:Type nodes:StaticIntegerValueNodeCustomViewModel}">
<TextBox VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Text="{Binding Input}" />
</DataTemplate>
</ResourceDictionary>
+3 -4
View File
@@ -1,10 +1,9 @@
using System.Linq;
using Artemis.VisualScripting.Attributes;
using Artemis.VisualScripting.Model;
using Artemis.Core;
namespace Artemis.VisualScripting.Nodes
{
[UI("Sum (Integer)", "Sums the connected integer values.")]
[Node("Sum (Integer)", "Sums the connected integer values.")]
public class SumIntegersNode : Node
{
#region Properties & Fields
@@ -36,7 +35,7 @@ namespace Artemis.VisualScripting.Nodes
#endregion
}
[UI("Sum (Double)", "Sums the connected double values.")]
[Node("Sum (Double)", "Sums the connected double values.")]
public class SumDoublesNode : Node
{
#region Properties & Fields