Nodes - Changed storage to be based on generics

Nodes - Added XML docs to most types
This commit is contained in:
Robert committed 2021-09-24 23:05:16 +02:00
1 parent 8413b8d6db
commit c1dab91c16
28 files changed
+522 -347

No files matched your search

@@ -1,38 +1,11 @@
using System.ComponentModel;
using Artemis.VisualScripting.Nodes.CustomViewModels;
using SkiaSharp;
using Artemis.VisualScripting.Nodes.CustomViewModels;
namespace Artemis.VisualScripting.Nodes.Color.CustomViewModels
{
public class StaticSKColorValueNodeCustomViewModel : CustomNodeViewModel
{
private readonly StaticSKColorValueNode _node;
public StaticSKColorValueNodeCustomViewModel(StaticSKColorValueNode node) : base(node)
{
_node = node;
}
public SKColor Input
{
get => (SKColor) (_node.Storage ?? SKColor.Empty);
set => _node.Storage = value;
}
public override void OnActivate()
{
_node.PropertyChanged += NodeOnPropertyChanged;
}
public override void OnDeactivate()
{
_node.PropertyChanged -= NodeOnPropertyChanged;
}
private void NodeOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Node.Storage))
OnPropertyChanged(nameof(Input));
}
}
}
@@ -12,5 +12,5 @@
</UserControl.Resources>
<shared:ColorPicker VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Color="{Binding Input, Converter={StaticResource SKColorToColorConverter}}" />
Color="{Binding Node.Storage, Converter={StaticResource SKColorToColorConverter}}" />
</UserControl>
@@ -5,7 +5,7 @@ using SkiaSharp;
namespace Artemis.VisualScripting.Nodes.Color
{
[Node("Color-Value", "Outputs a configurable color value.", "Static", InputType = typeof(SKColor), OutputType = typeof(SKColor))]
public class StaticSKColorValueNode : Node<StaticSKColorValueNodeCustomViewModel>
public class StaticSKColorValueNode : Node<SKColor, StaticSKColorValueNodeCustomViewModel>
{
#region Constructors
@@ -27,17 +27,9 @@ namespace Artemis.VisualScripting.Nodes.Color
public override void Evaluate()
{
Output.Value = Storage as SKColor? ?? SKColor.Empty;
Output.Value = Storage;
}
public override void Initialize(INodeScript script)
{
if (Storage is string && SKColor.TryParse(Storage.ToString(), out SKColor parsed))
Storage = parsed;
else
Storage = SKColor.Empty;
}
#endregion
}
}