mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Nodes editor - Fixed cables not connecting with dynamic pins in some cases
This commit is contained in:
1 parent
ddfdbee340
commit
7e39a64fdf
4 files changed
+69
-20
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Core.Events;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
@@ -58,6 +59,26 @@ public interface INode : INotifyPropertyChanged
|
||||
/// Called when the node resets
|
||||
/// </summary>
|
||||
event EventHandler Resetting;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a pin was added to the node
|
||||
/// </summary>
|
||||
event EventHandler<SingleValueEventArgs<IPin>> PinAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a pin was removed from the node
|
||||
/// </summary>
|
||||
event EventHandler<SingleValueEventArgs<IPin>> PinRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a pin collection was added to the node
|
||||
/// </summary>
|
||||
event EventHandler<SingleValueEventArgs<IPinCollection>> PinCollectionAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a pin was removed from the node
|
||||
/// </summary>
|
||||
event EventHandler<SingleValueEventArgs<IPinCollection>> PinCollectionRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the node was loaded from storage or newly created
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Events;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
|
||||
@@ -16,6 +17,18 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
/// <inheritdoc />
|
||||
public event EventHandler? Resetting;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<SingleValueEventArgs<IPin>>? PinAdded;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<SingleValueEventArgs<IPin>>? PinRemoved;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<SingleValueEventArgs<IPinCollection>>? PinCollectionAdded;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<SingleValueEventArgs<IPinCollection>>? PinCollectionRemoved;
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly List<OutputPin> _outputPinBucket = new();
|
||||
@@ -120,7 +133,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
{
|
||||
InputPin<T> pin = new(this, name);
|
||||
_pins.Add(pin);
|
||||
OnPropertyChanged(nameof(Pins));
|
||||
PinAdded?.Invoke(this, new SingleValueEventArgs<IPin>(pin));
|
||||
return pin;
|
||||
}
|
||||
|
||||
@@ -134,7 +147,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
{
|
||||
InputPin pin = new(this, type, name);
|
||||
_pins.Add(pin);
|
||||
OnPropertyChanged(nameof(Pins));
|
||||
PinAdded?.Invoke(this, new SingleValueEventArgs<IPin>(pin));
|
||||
return pin;
|
||||
}
|
||||
|
||||
@@ -148,7 +161,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
{
|
||||
OutputPin<T> pin = new(this, name);
|
||||
_pins.Add(pin);
|
||||
OnPropertyChanged(nameof(Pins));
|
||||
PinAdded?.Invoke(this, new SingleValueEventArgs<IPin>(pin));
|
||||
return pin;
|
||||
}
|
||||
|
||||
@@ -162,7 +175,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
{
|
||||
OutputPin pin = new(this, type, name);
|
||||
_pins.Add(pin);
|
||||
OnPropertyChanged(nameof(Pins));
|
||||
PinAdded?.Invoke(this, new SingleValueEventArgs<IPin>(pin));
|
||||
return pin;
|
||||
}
|
||||
|
||||
@@ -237,7 +250,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
if (isRemoved)
|
||||
{
|
||||
pin.DisconnectAll();
|
||||
OnPropertyChanged(nameof(Pins));
|
||||
PinRemoved?.Invoke(this, new SingleValueEventArgs<IPin>(pin));
|
||||
}
|
||||
|
||||
return isRemoved;
|
||||
@@ -255,7 +268,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
return;
|
||||
|
||||
_pins.Add(pin);
|
||||
OnPropertyChanged(nameof(Pins));
|
||||
PinAdded?.Invoke(this, new SingleValueEventArgs<IPin>(pin));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -269,7 +282,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
{
|
||||
InputPinCollection<T> pin = new(this, name, initialCount);
|
||||
_pinCollections.Add(pin);
|
||||
OnPropertyChanged(nameof(PinCollections));
|
||||
PinCollectionAdded?.Invoke(this, new SingleValueEventArgs<IPinCollection>(pin));
|
||||
return pin;
|
||||
}
|
||||
|
||||
@@ -284,7 +297,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
{
|
||||
InputPinCollection pin = new(this, type, name, initialCount);
|
||||
_pinCollections.Add(pin);
|
||||
OnPropertyChanged(nameof(PinCollections));
|
||||
PinCollectionAdded?.Invoke(this, new SingleValueEventArgs<IPinCollection>(pin));
|
||||
return pin;
|
||||
}
|
||||
|
||||
@@ -299,7 +312,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
{
|
||||
OutputPinCollection<T> pin = new(this, name, initialCount);
|
||||
_pinCollections.Add(pin);
|
||||
OnPropertyChanged(nameof(PinCollections));
|
||||
PinCollectionAdded?.Invoke(this, new SingleValueEventArgs<IPinCollection>(pin));
|
||||
return pin;
|
||||
}
|
||||
|
||||
@@ -316,7 +329,7 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
{
|
||||
foreach (IPin pin in pinCollection)
|
||||
pin.DisconnectAll();
|
||||
OnPropertyChanged(nameof(PinCollections));
|
||||
PinCollectionRemoved?.Invoke(this, new SingleValueEventArgs<IPinCollection>(pinCollection));
|
||||
}
|
||||
|
||||
return isRemoved;
|
||||
|
||||
Reference in new issue
Block a user