internal void AttachElement(RadElement addedElement) { //try to process element hierarchy, starting from the root node MapElementContext context = new MapElementContext(addedElement); this.MapStyleNodesToElementHierarchy(context); if (context.unmappedElements.Count == 0) { return; } foreach (RadElement unmapped in context.unmappedElements) { ICollection <StylesheetTreeNode> ancestorMatches = this.FindAncestorMatchingNodes(addedElement, unmapped); if (ancestorMatches == null || ancestorMatches.Count == 0) { continue; } foreach (StylesheetTreeNode node in ancestorMatches) { this.NodeMapElement(node, unmapped, context); } } }
private void MapStyleNodesToElementHierarchy(MapElementContext context) { foreach (RadElement childElement in ElementHierarchyEnumerator.TraverseElements(context.attachElement)) { if (context.mappedElements.ContainsKey(childElement)) { continue; } if (!this.MapStyleNodesToElement(childElement, context)) { context.unmappedElements.Add(childElement); } } }
private bool MapStyleNodesToElement(RadElement element, MapElementContext context) { ICollection <StylesheetTreeNode> matchingNodes = this.rootNode.Nodes.FindNodes(element); if (matchingNodes == null || matchingNodes.Count == 0) { return(false); } foreach (StylesheetTreeNode childNode in matchingNodes) { this.NodeMapElement(childNode, element, context); } return(true); }
private void NodeMapElement(StylesheetTreeNode node, RadElement element, MapElementContext context) { if (node.Nodes == null) { return; } foreach (RadElement childElement in ElementHierarchyEnumerator.TraverseElements(element, false)) { ICollection <StylesheetTreeNode> matchingNodes = node.Nodes.FindNodes(childElement); foreach (StylesheetTreeNode childNode in matchingNodes) { NodeMapElement(childNode, childElement, context); } } node.AttachElement(element); if (context != null) { context.mappedElements[element] = null; } }