private void UnbindFromNode(ChainNode node) { node.TransferRequested -= HandleNodeTransferRequested; node.HasErrorChanged -= HandleChildHasErrorChanged; node.DisabledChanged -= HandleNodeDisabledChanged; node.Destroying -= HandleNodeDestroying; }
private void HandleStateTargetRemoved(SelectionState state, ChainNode target) { var isUniqueTarget = SelectionStates.SelectMany(s => s).Count(t => t == target) == 0; if (isUniqueTarget) { target.UntargetRequested -= HandleTargetUntargetRequested; target.Schema = MutableObject.Empty; UniqueTargetRemoved(target); if (!NodeParents.ContainsKey(target)) { Debug.LogWarning("Odd... removing entry from NodeParents despite entry being missing. Kay... "); } else { NodeParents.Remove(target); } } else { if (!NodeParents.ContainsKey(target)) { Debug.LogError("Crap... modifying entry in NodeParents despite entry being missing. That's a problem... "); } else { NodeParents[target].States.Remove(state); } } }
public void UntargetNode(ChainNode nodeToUntarget) { foreach (var state in SelectionStatesEnumerable) { state.RemoveTarget(nodeToUntarget, false); } }
private void BindToNode(ChainNode node) { node.TransferRequested += HandleNodeTransferRequested; node.HasErrorChanged += HandleChildHasErrorChanged; node.DisabledChanged += HandleNodeDisabledChanged; node.Destroying += HandleNodeDestroying; }
private void RemoveNode(ChainNode node, bool recurse, bool isTransfer = false) { if (!isTransfer) { node.RequestUntargeting(); } UnbindFromNode(node); if (recurse) { foreach (var target in node.Router.UniqueTargets) { RemoveNode(target, true, isTransfer); } } if (!isTransfer) { node.Router.UntargetAllTargets(); } Nodes.Remove(node); UpdateHasError(); NodeRemoved(node, isTransfer); }
private void HandleNodeTransferRequested(ChainNode nodeToTransfer, ChainGroup destinationGroup) { // TODO: Can make transfers recursive here? What does that mean if descendents are in another group already? RemoveNode(nodeToTransfer, recurse: false, isTransfer: true); destinationGroup.AddNode(nodeToTransfer, recurse: false, isTransfer: true); }
private void HandleStateTargetAdded(SelectionState stateWithNewTarget, ChainNode newTarget, List <UndoItem> returnUndos) { // Cache this before the next step... bool isNewTargetForThisRouter = SelectionStates.SelectMany(s => s).Count(t => t == newTarget) == 1; // If a state adds a new target, all the other states in the router which are from a different group or no group, which contain the new target, remove that target. if (returnUndos != null) { returnUndos.AddRange(SelectionStates.Where(s => s != stateWithNewTarget && (s.GroupId != stateWithNewTarget.GroupId || s.GroupId == "") && s.Contains(newTarget)) .Select(s => s.RemoveTarget(newTarget, true))); } else { foreach (var state in SelectionStates.Where(s => s != stateWithNewTarget && (s.GroupId != stateWithNewTarget.GroupId || s.GroupId == "") && s.Contains(newTarget))) { state.RemoveTarget(newTarget, false); } } if (isNewTargetForThisRouter) { // This won't target this router, we're not listening to it yet... newTarget.RequestUntargeting(); // Bind to this event AFTER requesting the untargeting... newTarget.UntargetRequested += HandleTargetUntargetRequested; UniqueTargetAdded(newTarget); if (NodeParents.ContainsKey(newTarget)) { Debug.LogWarning("Interesting... adding entry to NodeParents despite entry existing. Clearing... "); NodeParents.Remove(newTarget); } NodeParents[newTarget] = new NodeSelectionStatesPair() { Node = Owner }; NodeParents[newTarget].States.Add(stateWithNewTarget); } else { if (!NodeParents.ContainsKey(newTarget)) { Debug.LogError("Uhm... modifying entry in NodeParents despite entry being missing. Correcting... "); NodeParents[newTarget] = new NodeSelectionStatesPair() { Node = Owner }; } NodeParents[newTarget].States.Add(stateWithNewTarget); } if (SelectionStates.SelectMany(s => s).Count(t => t == newTarget) == 1) { OutputSchemaRefreshRequested(); } }
[UsedImplicitly] // Recursive... public bool HasDescendent(ChainNode possibleDescendent) { if (Router.UniqueTargets.Any(target => target.HasDescendent(possibleDescendent))) { return(true); } return(this == possibleDescendent); }
private void HandleRouterTargetRemoved(ChainNode target) { if (target.ImplicitlyDisabled) { target.ImplicitlyDisabled = false; } TargetsDirty(); }
public void AddNode(ChainNode node, bool recurse, bool isTransfer = false) { BindToNode(node); if (recurse) { foreach (var target in node.Router.UniqueTargets) { AddNode(target, true); } } Nodes.Add(node); UpdateHasError(); NodeAdded(node, isTransfer); }
private void HandleRouterTargetAdded(ChainNode target) { target.ImplicitlyDisabled = Disabled; TargetsDirty(); }
private void HandleTargetUntargetRequested(ChainNode nodeToUntarget) { UntargetNode(nodeToUntarget); }
private void HandleNodeDestroying(ChainNode node) { RemoveNode(node, false); }