/// <summary> /// Performs custom actions after an attribute in the DOM node subtree changed</summary> /// <param name="sender">Sender (root DOM node)</param> /// <param name="e">Attribute change event args</param> protected override void OnAttributeChanged(object sender, AttributeEventArgs e) { if (Validating && !m_undoingOrRedoing) { if (e.DomNode.Parent.Is <Group>() && e.AttributeInfo == ElementLabelAttribute) { var subGraph = e.DomNode.Parent.Cast <Group>(); if (e.DomNode.Is <Element>()) { // the name of a sub-node has changed, needs to update group pin names that are not manually set SyncGroupPinNamesFromModuleName(subGraph, e.DomNode); } } else if (e.DomNode.Is <GroupPin>() && e.AttributeInfo == PinNameAttributeAttribute) { if (e.DomNode.Parent != null) { var subGraph = e.DomNode.Parent.Cast <Group>(); // ensure group pin names are unique at local level UniqueNamer uniqueName = new UniqueNamer(); GroupPin childGrpPin = e.DomNode.Cast <GroupPin>(); foreach (var grpPin in subGraph.InputGroupPins) { if (grpPin != childGrpPin) { uniqueName.Name((string)grpPin.Name); } } foreach (var grpPin in subGraph.OutputGroupPins) { if (grpPin != childGrpPin) { uniqueName.Name((string)grpPin.Name); } } string unique = uniqueName.Name((string)childGrpPin.Name); if (unique != childGrpPin.Name) { childGrpPin.Name.SetString(unique); } // Reset IsDefaultName. Ignore the suffix because there are typically multiple // circuit elements in a group and the child group pin doesn't know about // our unique namer. var defaultName = childGrpPin.DefaultName(childGrpPin.IsInputSide); string ourRoot; int ourSuffix; uniqueName.Parse(unique, out ourRoot, out ourSuffix); childGrpPin.IsDefaultName = defaultName == ourRoot; UpdateParentGroupPinName(childGrpPin.IsInputSide, childGrpPin); } } } base.OnAttributeChanged(sender, e); }
/// <summary> /// Performs custom actions after an attribute in the DOM node subtree changed</summary> /// <param name="sender">Sender (root DOM node)</param> /// <param name="e">Attribute change event args</param> protected override void OnAttributeChanged(object sender, AttributeEventArgs e) { if (Validating && !m_undoingOrRedoing) { if (e.DomNode.Parent.Is <Group>() && e.AttributeInfo == ElementLabelAttribute) { var subGraph = e.DomNode.Parent.Cast <Group>(); if (e.DomNode.Is <Element>()) { // the name of a sub-node has changed, needs to update group pin names that are not manually set SyncGroupPinNamesFromModuleName(subGraph, e.DomNode); } } else if (e.DomNode.Is <GroupPin>() && e.AttributeInfo == PinNameAttributeAttribute) { if (e.DomNode.Parent != null) { var subGraph = e.DomNode.Parent.Cast <Group>(); // ensure group pin names are unique at local level UniqueNamer uniqueName = new UniqueNamer(); GroupPin childGrpPin = e.DomNode.Cast <GroupPin>(); foreach (var pin in subGraph.Inputs) { var grpPin = pin.Cast <GroupPin>(); if (grpPin != childGrpPin) { uniqueName.Name(grpPin.Name); } } foreach (var pin in subGraph.Outputs) { var grpPin = pin.Cast <GroupPin>(); if (grpPin != childGrpPin) { uniqueName.Name(grpPin.Name); } } string unique = uniqueName.Name(childGrpPin.Name); if (unique != childGrpPin.Name) { childGrpPin.Name = unique; } // try to reset IsDefaultName childGrpPin.IsDefaultName = childGrpPin.Name == childGrpPin.DefaultName(childGrpPin.IsInputSide); UpdateParentGroupPinName(childGrpPin.IsInputSide, childGrpPin); } } } base.OnAttributeChanged(sender, e); }