/// <inheritdoc />
        protected override void Execute(TransactionItem item, IRuleExecuteContext context)
        {
            var beginLifetimeTunnelBoundsChange = item.AsBoundsChange <IBeginLifetimeTunnel>();

            if (beginLifetimeTunnelBoundsChange.IsValid)
            {
                IBeginLifetimeTunnel beginLifetimeTunnel = beginLifetimeTunnelBoundsChange.TargetElement;
                beginLifetimeTunnel.TerminateLifetimeTunnel.Top = beginLifetimeTunnel.Top;
            }
            var removedBorderNode = item.AsComponentRemove <BorderNode, Structure>();

            if (removedBorderNode != null)
            {
                Element toDelete                = null;
                var     beginLifetimeTunnel     = removedBorderNode as IBeginLifetimeTunnel;
                var     terminateLifetimeTunnel = removedBorderNode as ITerminateLifetimeTunnel;
                if (beginLifetimeTunnel != null)
                {
                    toDelete = (Element)beginLifetimeTunnel.TerminateLifetimeTunnel;
                }
                else if (terminateLifetimeTunnel != null)
                {
                    toDelete = (Element)terminateLifetimeTunnel.BeginLifetimeTunnel;
                }
                toDelete?.Delete();
            }
        }
 /// <inheritdoc/>
 protected override void OnBeginExecuteTransactionItems(IRuleExecuteContext context)
 {
     if (context.ShouldRunIntermediateRules)
     {
         HandleBorderNodeBoundsChanges(context.MergeItems <BoundsChangeMerger <BorderNode> >());
     }
     ProcessTransactionItems = false;
 }
Exemple #3
0
        protected override void Execute(TransactionItem item, IRuleExecuteContext context)
        {
            var dataItemDirection = item.AsPropertyChange <DataItem, ParameterCallDirection>(nameof(DataItem.CallDirection));

            if (dataItemDirection.IsValid)
            {
                DataItem dataItem = dataItemDirection.TargetElement;
                if (dataItemDirection.NewValue != ParameterCallDirection.None && dataItem.CallIndex == -1)
                {
                    int callIndex = 0;
                    var function  = (Function)dataItemDirection.TargetElement.Definition;
                    while (function.DataItems.Any(d => d.CallDirection != ParameterCallDirection.None && d.CallIndex == callIndex))
                    {
                        ++callIndex;
                    }
                    dataItem.CallIndex = callIndex;
                }
                else if (dataItemDirection.NewValue == ParameterCallDirection.None)
                {
                    dataItem.CallIndex = -1;
                }
            }
        }
        /// <inheritdoc/>
        protected override void ExecuteCore(TransactionItemCollection transactions, IRuleExecuteContext context)
        {
            // Look for the begin wiring tag which is set when a wiring operation is started from a terminal
            var startTag = context.Tags.GetFirstTag <StartWiringTerminalTransactionTag>();

            if (startTag != null)
            {
                // Make sure the source node terminal is an output terminal
                startTag.Terminal.ConnectedTerminal.Direction = Direction.Output;
            }
            // Look for the end wiring tag which is set when the wiring operation completes
            var endTag = context.Tags.GetFirstTag <EndWiringTransactionTag>();

            if (endTag != null)
            {
                // See if the wire was ended on a terminal
                var terminal = endTag.End as Terminal;
                if (terminal != null)
                {
                    // Make sure the terminal is set to be a input terminal
                    terminal.Direction = Direction.Input;
                }
            }
        }