mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Nodes - Reorganized code
This commit is contained in:
1 parent
69b881b044
commit
7c83d5345f
73 files changed
+1055
-738
No files matched your search
+20
@@ -0,0 +1,20 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:converters="clr-namespace:Artemis.VisualScripting.Converters"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Static.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Static.Screens.StaticNumericValueNodeCustomView"
|
||||
x:DataType="screens:StaticNumericValueNodeCustomViewModel">
|
||||
<UserControl.Resources>
|
||||
<converters:NumericConverter x:Key="NumericConverter" />
|
||||
</UserControl.Resources>
|
||||
<controls:NumberBox VerticalAlignment="Center" MinWidth="75" SimpleNumberFormat="F3" Classes="condensed">
|
||||
<Interaction.Behaviors>
|
||||
<behaviors:LostFocusNumberBoxBindingBehavior Value="{CompiledBinding CurrentValue, Converter={StaticResource NumericConverter}}"/>
|
||||
</Interaction.Behaviors>
|
||||
</controls:NumberBox>
|
||||
</UserControl>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens
|
||||
{
|
||||
public partial class StaticNumericValueNodeCustomView : ReactiveUserControl<StaticNumericValueNodeCustomViewModel>
|
||||
{
|
||||
public StaticNumericValueNodeCustomView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public class StaticNumericValueNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly StaticNumericValueNode _node;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
|
||||
public StaticNumericValueNodeCustomViewModel(StaticNumericValueNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
_nodeEditorService = nodeEditorService;
|
||||
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(CurrentValue));
|
||||
}
|
||||
|
||||
public Numeric? CurrentValue
|
||||
{
|
||||
get => _node.Storage;
|
||||
set => _nodeEditorService.ExecuteCommand(Script, new UpdateStorage<Numeric>(_node, value ?? new Numeric()));
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Static.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Static.Screens.StaticSKColorValueNodeCustomView"
|
||||
x:DataType="screens:StaticSKColorValueNodeCustomViewModel">
|
||||
<UserControl.Resources>
|
||||
<converters:SKColorToStringConverter x:Key="SKColorToStringConverter" />
|
||||
<converters:SKColorToColor2Converter x:Key="SKColorToColor2Converter" />
|
||||
</UserControl.Resources>
|
||||
<Grid Height="24" ColumnDefinitions="*" Width="110">
|
||||
<TextBox Classes="condensed"
|
||||
Watermark="#00000000"
|
||||
Padding="2 2 30 2">
|
||||
<Interaction.Behaviors>
|
||||
<behaviors:LostFocusTextBoxBindingBehavior Text="{CompiledBinding CurrentValue, Converter={StaticResource SKColorToStringConverter}}"/>
|
||||
</Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<controls:ColorPickerButton Classes="contained-color-picker-button"
|
||||
Color="{CompiledBinding CurrentValue, Converter={StaticResource SKColorToColor2Converter}}"
|
||||
ShowAcceptDismissButtons="False"
|
||||
FlyoutOpened="ColorPickerButton_OnFlyoutOpened"
|
||||
FlyoutClosed="ColorPickerButton_OnFlyoutClosed" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public class StaticSKColorValueNodeCustomView : ReactiveUserControl<StaticSKColorValueNodeCustomViewModel>
|
||||
{
|
||||
public StaticSKColorValueNodeCustomView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private void ColorPickerButton_OnFlyoutOpened(ColorPickerButton sender, EventArgs args)
|
||||
{
|
||||
ViewModel?.PauseUpdating();
|
||||
}
|
||||
|
||||
private void ColorPickerButton_OnFlyoutClosed(ColorPickerButton sender, EventArgs args)
|
||||
{
|
||||
ViewModel?.ResumeUpdating();
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public class StaticSKColorValueNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly StaticSKColorValueNode _node;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
private bool _applyChanges;
|
||||
private SKColor? _currentValue;
|
||||
|
||||
public StaticSKColorValueNodeCustomViewModel(StaticSKColorValueNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
_nodeEditorService = nodeEditorService;
|
||||
_applyChanges = true;
|
||||
|
||||
NodeModified += (_, _) => CurrentValue = _node.Storage;
|
||||
CurrentValue = _node.Storage;
|
||||
}
|
||||
|
||||
public SKColor? CurrentValue
|
||||
{
|
||||
get => _currentValue;
|
||||
set
|
||||
{
|
||||
if (_applyChanges && value != _node.Storage)
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateStorage<SKColor>(_node, value ?? SKColor.Empty));
|
||||
this.RaiseAndSetIfChanged(ref _currentValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void PauseUpdating()
|
||||
{
|
||||
_applyChanges = false;
|
||||
}
|
||||
|
||||
public void ResumeUpdating()
|
||||
{
|
||||
_applyChanges = true;
|
||||
|
||||
SKColor updatedValue = CurrentValue ?? SKColor.Empty;
|
||||
if (updatedValue != _node.Storage)
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateStorage<SKColor>(_node, updatedValue));
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Static.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Static.Screens.StaticStringValueNodeCustomView"
|
||||
x:DataType="screens:StaticStringValueNodeCustomViewModel">
|
||||
<TextBox VerticalAlignment="Center" MinWidth="75" Classes="condensed">
|
||||
<Interaction.Behaviors>
|
||||
<behaviors:LostFocusTextBoxBindingBehavior Text="{CompiledBinding CurrentValue}"/>
|
||||
</Interaction.Behaviors>
|
||||
</TextBox>
|
||||
</UserControl>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens
|
||||
{
|
||||
public partial class StaticStringValueNodeCustomView : ReactiveUserControl<StaticStringValueNodeCustomViewModel>
|
||||
{
|
||||
public StaticStringValueNodeCustomView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public class StaticStringValueNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly StaticStringValueNode _node;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
|
||||
public StaticStringValueNodeCustomViewModel(StaticStringValueNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
_nodeEditorService = nodeEditorService;
|
||||
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(CurrentValue));
|
||||
}
|
||||
|
||||
public string? CurrentValue
|
||||
{
|
||||
get => _node.Storage;
|
||||
set => _nodeEditorService.ExecuteCommand(Script, new UpdateStorage<string>(_node, value));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static;
|
||||
|
||||
[Node("Numeric-Value", "Outputs a configurable static numeric value.", "Static", OutputType = typeof(Numeric))]
|
||||
public class StaticNumericValueNode : Node<Numeric, StaticNumericValueNodeCustomViewModel>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public StaticNumericValueNode()
|
||||
: base("Numeric", "Outputs a configurable numeric value.")
|
||||
{
|
||||
Output = CreateOutputPin<Numeric>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public OutputPin<Numeric> Output { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static;
|
||||
|
||||
[Node("Color-Value", "Outputs a configurable color value.", "Static", InputType = typeof(SKColor), OutputType = typeof(SKColor))]
|
||||
public class StaticSKColorValueNode : Node<SKColor, StaticSKColorValueNodeCustomViewModel>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public StaticSKColorValueNode()
|
||||
: base("Color", "Outputs a configurable color value.")
|
||||
{
|
||||
Output = CreateOutputPin<SKColor>();
|
||||
Storage = new SKColor(255, 0, 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public OutputPin<SKColor> Output { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static;
|
||||
|
||||
[Node("String-Value", "Outputs a configurable static string value.", "Static", OutputType = typeof(string))]
|
||||
public class StaticStringValueNode : Node<string, StaticStringValueNodeCustomViewModel>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public StaticStringValueNode()
|
||||
: base("String", "Outputs a configurable string value.")
|
||||
{
|
||||
Output = CreateOutputPin<string>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public OutputPin<string> Output { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user