diff options
Diffstat (limited to 'Software/Visual_Studio/SideChains/RealTimeGraphX/GraphInputComponentBase.cs')
| -rw-r--r-- | Software/Visual_Studio/SideChains/RealTimeGraphX/GraphInputComponentBase.cs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX/GraphInputComponentBase.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX/GraphInputComponentBase.cs new file mode 100644 index 000000000..4f1c52f12 --- /dev/null +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX/GraphInputComponentBase.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RealTimeGraphX.EventArguments; + +namespace RealTimeGraphX +{ + /// <summary> + /// Represents an <see cref="IGraphInputComponent{TIn}"/> base class. + /// </summary> + /// <typeparam name="TIn">The type of the in.</typeparam> + /// <seealso cref="RealTimeGraphX.IGraphInputComponent{TIn}" /> + public abstract class GraphInputComponentBase<TIn> : GraphObject, IGraphInputComponent<TIn> where TIn : IGraphComponent + { + /// <summary> + /// Occurs when the <see cref="P:RealTimeGraphX.IGraphInputComponent`1.Input" /> property has changed. + /// </summary> + public event EventHandler<InputChangedEventArgs<TIn>> InputChanged; + + private TIn _input; + /// <summary> + /// Gets the connected input <see cref="T:RealTimeGraphX.IGraphComponent" />. + /// </summary> + public TIn Input + { + get { return _input; } + private set + { + _input = value; + RaisePropertyChangedAuto(); + OnInputChanged(_input); + } + } + + /// <summary> + /// Raises the <see cref="InputChanged"/> event. + /// </summary> + /// <param name="input">The input.</param> + protected virtual void OnInputChanged(TIn input) + { + InputChanged?.Invoke(this, new InputChangedEventArgs<TIn>(input)); + } + + /// <summary> + /// Connects the specified component output to this component input. + /// </summary> + /// <param name="component">The component.</param> + /// <param name="fromInput">Specifies whether this call was made from a <see cref="TIn" /> component.</param> + public abstract void ConnectInput(TIn component, bool fromInput = false); + + /// <summary> + /// Disconnects this component input from the current connected <see cref="P:RealTimeGraphX.IGraphInputComponent`1.Input" /><see cref="T:RealTimeGraphX.IGraphComponent" />. + /// </summary> + /// <param name="fromInput">Specifies whether this call was made from a <see cref="TIn" /> component.</param> + public abstract void DisconnectInput(bool fromInput = false); + } +} |
