mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Nodes - Added to float node
Nodes - Updated almost all custom VMs to stay in sync across multiple instances
This commit is contained in:
1 parent
ed33d8a148
commit
7933bf7ee9
8 files changed
+217
-65
No files matched your search
@@ -1,10 +1,9 @@
|
||||
using System.Windows;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
{
|
||||
public abstract class CustomNodeViewModel : PropertyChangedBase, IViewAware, ICustomNodeViewModel
|
||||
public abstract class CustomNodeViewModel : PropertyChangedBase, ICustomNodeViewModel
|
||||
{
|
||||
protected CustomNodeViewModel(INode node)
|
||||
{
|
||||
@@ -13,21 +12,17 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
|
||||
public INode Node { get; }
|
||||
|
||||
#region Implementation of IViewAware
|
||||
#region Implementation of ICustomNodeViewModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AttachView(UIElement view)
|
||||
{
|
||||
View = view;
|
||||
OnDisplay();
|
||||
}
|
||||
|
||||
protected virtual void OnDisplay()
|
||||
public virtual void OnActivate()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public UIElement View { get; private set; }
|
||||
public virtual void OnDeactivate()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
+13
-11
@@ -1,4 +1,5 @@
|
||||
using Artemis.Core;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Modules;
|
||||
using Stylet;
|
||||
|
||||
@@ -26,7 +27,6 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
set
|
||||
{
|
||||
_node.DataModelPath = value;
|
||||
OnPropertyChanged(nameof(DataModelPath));
|
||||
|
||||
if (_node.DataModelPath != null)
|
||||
{
|
||||
@@ -41,8 +41,8 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
_node.UpdateOutputPin();
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
if (Modules != null)
|
||||
return;
|
||||
@@ -52,17 +52,19 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
Modules.Add(scriptProfile.Configuration.Module);
|
||||
else if (_node.Script.Context is ProfileConfiguration profileConfiguration && profileConfiguration.Module != null)
|
||||
Modules.Add(profileConfiguration.Module);
|
||||
|
||||
_node.PropertyChanged += NodeOnPropertyChanged;
|
||||
}
|
||||
|
||||
#region Overrides of CustomNodeViewModel
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnDisplay()
|
||||
public override void OnDeactivate()
|
||||
{
|
||||
Initialize();
|
||||
base.OnDisplay();
|
||||
_node.PropertyChanged -= NodeOnPropertyChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
private void NodeOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(DataModelNode.DataModelPath))
|
||||
OnPropertyChanged(nameof(DataModelPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -66,15 +66,15 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
NotifyOfPropertyChange(nameof(SelectedLayerProperty));
|
||||
}
|
||||
|
||||
#region Overrides of CustomNodeViewModel
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnDisplay()
|
||||
public override void OnActivate()
|
||||
{
|
||||
GetProfileElements();
|
||||
GetLayerProperties();
|
||||
}
|
||||
|
||||
#endregion
|
||||
public override void OnDeactivate()
|
||||
{
|
||||
base.OnDeactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Artemis.Core;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
{
|
||||
@@ -13,12 +13,24 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
|
||||
public double Input
|
||||
{
|
||||
get => (double) _node.Storage;
|
||||
set
|
||||
{
|
||||
_node.Storage = value;
|
||||
get => (double) (_node.Storage ?? 0.0);
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +45,24 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
|
||||
public float Input
|
||||
{
|
||||
get => (float)_node.Storage;
|
||||
set
|
||||
{
|
||||
_node.Storage = value;
|
||||
get => (float) (_node.Storage ?? 0f);
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,17 +77,24 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
|
||||
public int Input
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_node.Storage is long longInput)
|
||||
return (int)longInput;
|
||||
return (int)_node.Storage;
|
||||
}
|
||||
set
|
||||
{
|
||||
_node.Storage = value;
|
||||
get => _node.Storage is long longInput ? (int) longInput : (int) (_node.Storage ?? 0);
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,12 +109,24 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
|
||||
public string Input
|
||||
{
|
||||
get => (string)_node.Storage;
|
||||
set
|
||||
{
|
||||
_node.Storage = value;
|
||||
get => (string) _node.Storage;
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user