diff --git a/NodeNetworkToolkit/ContextMenu/AddNodeContextMenuViewModel.cs b/NodeNetworkToolkit/ContextMenu/AddNodeContextMenuViewModel.cs index c70503c..f4f7d93 100644 --- a/NodeNetworkToolkit/ContextMenu/AddNodeContextMenuViewModel.cs +++ b/NodeNetworkToolkit/ContextMenu/AddNodeContextMenuViewModel.cs @@ -10,6 +10,9 @@ namespace NodeNetwork.Toolkit.ContextMenu { + /// + /// A viewmodel for a context menu that allows users to add nodes to a network. + /// public class AddNodeContextMenuViewModel : SearchableContextMenuViewModel { static AddNodeContextMenuViewModel() @@ -18,6 +21,9 @@ static AddNodeContextMenuViewModel() } #region Network + /// + /// The network to which the nodes are to be added. + /// public NetworkViewModel Network { get => _network; @@ -26,16 +32,31 @@ public NetworkViewModel Network private NetworkViewModel _network; #endregion + /// + /// The format that is used to create labels for the menu entries based on the node name. + /// E.g. "Add {0}" + /// public string LabelFormat { get; } + /// + /// When adding a node to the network, + /// this function is used to determine the position at which it is placed. + /// public Func NodePositionFunc { get; set; } = (node) => new Point(); + /// + /// A callback that is called after a node is added to the network through this menu. + /// public Action OnNodeAdded { get; set; } = node => { }; - private ReactiveCommand CreateNode { get; } - + /// + /// An interaction that is used to open contextmenu views given a SearchableContextMenuViewModel. + /// Used in ShowAddNodeForPendingConnectionMenu to display this menu, and a menu for choosing an endpoint. + /// public Interaction OpenContextMenu { get; } = new Interaction(); + private ReactiveCommand CreateNode { get; } + public AddNodeContextMenuViewModel(string labelFormat = "{0}") { LabelFormat = labelFormat; @@ -50,6 +71,12 @@ public AddNodeContextMenuViewModel(string labelFormat = "{0}") }); } + /// + /// Adds a new node type to the list. + /// Every time a node is added to a network from this list, the factory function in the template + /// will be called to create a new instance of the viewmodel type. + /// + /// The template with the node type to add. public void AddNodeType(NodeTemplate template) { Commands.Add(new LabeledCommand @@ -165,6 +192,10 @@ public void ShowAddNodeForPendingConnectionMenu(PendingConnectionViewModel pendi OpenContextMenu.Handle(this).Subscribe(); } + /// + /// Given a set of node templates, return those which have an endpoint + /// that could be connected to the specified pending connection. + /// public static IEnumerable GetConnectableNodes(IEnumerable candidateNodeTemplates, PendingConnectionViewModel testCon) { foreach (var curNode in candidateNodeTemplates) @@ -181,6 +212,10 @@ public static IEnumerable GetConnectableNodes(IEnumerable + /// Given a node viewmodel, return the outputs which could be connected to the pending connection. + /// Assumes testCon.Input is set. + /// public static IEnumerable GetConnectableOutputs(NodeViewModel node, PendingConnectionViewModel testCon) { var validator = testCon.Input.ConnectionValidator; @@ -194,6 +229,10 @@ public static IEnumerable GetConnectableOutputs(NodeViewMod } } + /// + /// Given a node viewmodel, return the inputs which could be connected to the pending connection. + /// Assumes testCon.Output is set. + /// public static IEnumerable GetConnectableInputs(NodeViewModel node, PendingConnectionViewModel testCon) { foreach (var curInput in node.Inputs.Items) diff --git a/NodeNetworkToolkit/ContextMenu/SearchableContextMenuViewModel.cs b/NodeNetworkToolkit/ContextMenu/SearchableContextMenuViewModel.cs index 213bf62..4829c3a 100644 --- a/NodeNetworkToolkit/ContextMenu/SearchableContextMenuViewModel.cs +++ b/NodeNetworkToolkit/ContextMenu/SearchableContextMenuViewModel.cs @@ -7,6 +7,9 @@ namespace NodeNetwork.Toolkit.ContextMenu { + /// + /// A data type containing a command, parameter and display properties. + /// public class LabeledCommand : ReactiveObject { #region Label @@ -58,6 +61,9 @@ public object CommandParameter #endregion } + /// + /// A viewmodel for a context menu in which the entries can be filtered by the user based on a searchquery. + /// public class SearchableContextMenuViewModel : ReactiveObject { static SearchableContextMenuViewModel()