Esempio n. 1
0
 private void UnbindFromNode(ChainNode node)
 {
     node.TransferRequested -= HandleNodeTransferRequested;
     node.HasErrorChanged   -= HandleChildHasErrorChanged;
     node.DisabledChanged   -= HandleNodeDisabledChanged;
     node.Destroying        -= HandleNodeDestroying;
 }
Esempio n. 2
0
        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);
                }
            }
        }
Esempio n. 3
0
 public void UntargetNode(ChainNode nodeToUntarget)
 {
     foreach (var state in SelectionStatesEnumerable)
     {
         state.RemoveTarget(nodeToUntarget, false);
     }
 }
Esempio n. 4
0
 private void BindToNode(ChainNode node)
 {
     node.TransferRequested += HandleNodeTransferRequested;
     node.HasErrorChanged   += HandleChildHasErrorChanged;
     node.DisabledChanged   += HandleNodeDisabledChanged;
     node.Destroying        += HandleNodeDestroying;
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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();
            }
        }
Esempio n. 8
0
        [UsedImplicitly]    // Recursive...
        public bool HasDescendent(ChainNode possibleDescendent)
        {
            if (Router.UniqueTargets.Any(target => target.HasDescendent(possibleDescendent)))
            {
                return(true);
            }

            return(this == possibleDescendent);
        }
Esempio n. 9
0
        private void HandleRouterTargetRemoved(ChainNode target)
        {
            if (target.ImplicitlyDisabled)
            {
                target.ImplicitlyDisabled = false;
            }

            TargetsDirty();
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        private void HandleRouterTargetAdded(ChainNode target)
        {
            target.ImplicitlyDisabled = Disabled;

            TargetsDirty();
        }
Esempio n. 12
0
 private void HandleTargetUntargetRequested(ChainNode nodeToUntarget)
 {
     UntargetNode(nodeToUntarget);
 }
Esempio n. 13
0
 private void HandleNodeDestroying(ChainNode node)
 {
     RemoveNode(node, false);
 }