Example #1
0
        private void DomNode_AttributeChanged(object sender, AttributeEventArgs e)
        {
            if (IsCircuitItem(e.DomNode, e.DomNode.Parent))
            {
                NotifyObjectChanged(e.DomNode); //required for Layers. http://tracker.ship.scea.com/jira/browse/WWSATF-1389

                // Editing the subgraph may cause changes in the parent graph, such as reordering group pins in a group needs
                // to change the pin indexes of the external edges in the parent graph.
                // Each circuit or group has its own local editing context, and the default TransactionContext implementation
                // only responds to these Dom changes from the adapted DomNode and below.
                // We need to catch changes up in the hierarchy too for proper undo/redo.
                var circuitValidator = DomNode.GetRoot().As <CircuitValidator>();
                if (circuitValidator != null)
                {
                    var transactionContext = circuitValidator.ActiveHistoryContext;
                    if (transactionContext != null && transactionContext != this)
                    {
                        if (transactionContext.DomNode.Ancestry.FirstOrDefault(x => x == e.DomNode.Parent) != null)
                        {
                            if (transactionContext.InTransaction)
                            {
                                transactionContext.AddOperation(new AttributeChangedOperation(e));
#if DEBUG_VERBOSE
                                var parent = transactionContext.DomNode.Ancestry.FirstOrDefault(x => x == e.DomNode.Parent);
                                Trace.TraceInformation("PARENT GRAPH {0} element  {1} -- Attribute {2} changed from  {3} to {4}",
                                                       CircuitUtil.GetDomNodeName(parent), CircuitUtil.GetDomNodeName(e.DomNode), e.AttributeInfo.Name, e.OldValue, e.NewValue);
#endif
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private void DomNode_ChildRemoved(object sender, ChildEventArgs e)
        {
            Dirty = true;
#if DEBUG_VERBOSE
            if (e.Parent == DomNode)
            {
                Trace.TraceInformation("{0} --  Removed {1}  from parent {2}", CircuitUtil.GetDomNodeName(DomNode),
                                       CircuitUtil.GetDomNodeName(e.Child), CircuitUtil.GetDomNodeName(e.Parent));
            }
#endif
        }
Example #3
0
        private void DomNode_AttributeChanged(object sender, AttributeEventArgs e)
        {
            Dirty = true;
 #if DEBUG_VERBOSE
            if (e.DomNode == DomNode || e.DomNode.Parent == DomNode)
            {
                Trace.TraceInformation("{0} element  {1} -- Attribute {2} changed from  {3} to {4}",
                                       CircuitUtil.GetDomNodeName(DomNode), CircuitUtil.GetDomNodeName(e.DomNode), e.AttributeInfo.Name, e.OldValue, e.NewValue);
            }
#endif
        }
Example #4
0
        private void DomNode_ChildInserted(object sender, ChildEventArgs e)
        {
            AddNode(e.Child);
            if (IsCircuitItem(e.Child, e.Parent))
            {
                if (e.Child.Is <Wire>())
                {
                    var connection = e.Child.Cast <Wire>();
                    if (connection.InputElement.Is <Group>())  // set dirty to force update group pin connectivity
                    {
                        connection.InputElement.Cast <Group>().Dirty = true;
                    }

                    if (connection.OutputElement.Is <Group>())
                    {
                        connection.OutputElement.Cast <Group>().Dirty = true;
                    }
                }

                OnObjectInserted(new ItemInsertedEventArgs <object>(e.Index, e.Child, e.Parent));

                var circuitValidator = DomNode.GetRoot().As <CircuitValidator>();
                if (circuitValidator != null)
                {
                    var transactionContext = circuitValidator.ActiveHistoryContext;
                    if (transactionContext != null && transactionContext != this)
                    {
                        if (transactionContext.DomNode.Ancestry.FirstOrDefault(x => x == e.Parent) != null)
                        {
                            if (transactionContext.InTransaction)
                            {
                                transactionContext.AddOperation(new ChildInsertedOperation(e));
#if DEBUG_VERBOSE
                                var parent = transactionContext.DomNode.Ancestry.FirstOrDefault(x => x == e.Parent);
                                Trace.TraceInformation("PARENT GRAPH {0} --  Added {1} to parent {2}",
                                                       CircuitUtil.GetDomNodeName(parent), CircuitUtil.GetDomNodeName(e.Child), CircuitUtil.GetDomNodeName(e.Parent));
#endif
                            }
                        }
                    }
                }
            }
        }