Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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;
            }
        }