From 2ce6afb909f34af7d78c20cfeb9f2d8311e91336 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Fri, 3 Oct 2025 01:55:11 +0300 Subject: Changed RealTimeGraphX to .NET 4.6.1 --- .../RealTimeGraphX/GraphCommand.cs | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphCommand.cs (limited to 'Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphCommand.cs') diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphCommand.cs b/Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphCommand.cs new file mode 100644 index 000000000..e16ecd675 --- /dev/null +++ b/Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphCommand.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Input; + +namespace RealTimeGraphX +{ + /// + /// Represents a graph relay command. + /// + /// + public class GraphCommand : ICommand + { + private Action _action; + private Func _canExecute; + + /// + /// Initializes a new instance of the class. + /// + /// The action. + /// The can execute. + public GraphCommand(Action action, Func canExecute) + { + _action = action; + _canExecute = canExecute; + } + + /// + /// Initializes a new instance of the class. + /// + /// The action. + public GraphCommand(Action action) : this(action, null) + { + + } + + /// + /// Defines the method that determines whether the command can execute in its current state. + /// + /// Data used by the command. If the command does not require data to be passed, this object can be set to null. + /// + /// true if this command can be executed; otherwise, false. + /// + public bool CanExecute(object parameter) + { + if (_canExecute != null) + { + return _canExecute(); + } + + return true; + } + + /// + /// Defines the method to be called when the command is invoked. + /// + /// Data used by the command. If the command does not require data to be passed, this object can be set to null. + public void Execute(object parameter) + { + _action(); + } + + /// + /// Raises the can execute changed event. + /// + public void RaiseCanExecuteChanged() + { + CanExecuteChanged?.Invoke(this, new EventArgs()); + } + + /// + /// Occurs when changes occur that affect whether or not the command should execute. + /// + /// + public event EventHandler CanExecuteChanged; + } +} -- cgit v1.3.1