public SelectorTreeNodeCollectionEnumerator(StylesheetTreeNodeCollection owner)
 {
     if (owner.nodes != null)
     {
         this.ownerEnumerator = owner.nodes.GetEnumerator();
     }
     else
     {
         this.ownerEnumerator = null;
     }
 }
        public StylesheetTreeNode(StylesheetTree ownerTree, IElementSelector selector)
        {
            this.ownerTree = ownerTree;
            this.selector  = selector;
            this.nodes     = new StylesheetTreeNodeCollection(this);
            int selectorKey = 0;

            //Generally RootNode registers with
            if (selector != null)
            {
                selectorKey = selector.Key;
            }
            ownerTree.RegisterNodeWithKey(selectorKey, this);
        }
        public void DetachElements()
        {
            if (this.mappedElements != null)
            {
                if (this.propertySettingGroups != null)
                {
                    foreach (NodeElementEntry elementEntry in this.mappedElements.Values)
                    {
                        this.ManagePropetyChangeSubscription(elementEntry, false);

                        for (int i = 0; i < this.propertySettingGroups.Count; i++)
                        {
                            foreach (IPropertySetting setting in this.propertySettingGroups[i].PropertySettings.EnumeratePropertySettingsForElement(elementEntry.Element))
                            {
                                setting.UnapplyValue(elementEntry.Element);

                                if (setting is AnimatedPropertySetting)
                                {
                                    elementEntry.Element.ResetValue(setting.Property, ValueResetFlags.Style);
                                }
                            }
                        }
                    }

                    this.propertySettingGroups.Clear();
                    this.propertySettingGroups = null;
                }

                this.mappedElements.Clear();
                this.mappedElements = null;
            }

            if (this.nodes != null)
            {
                foreach (StylesheetTreeNode node in this.nodes)
                {
                    node.DetachElements();
                }
                this.nodes.Clear();
                this.nodes = null;
            }

            this.ownerTree = null;
        }
        private StylesheetTreeNode AddNodeRecursive(PropertySettingGroup propertySettings, IElementSelector selector, StylesheetTreeNodeCollection parentNodeCollection)
        {
            if (selector.Key == 0)
            {
                return(null);
            }

            StylesheetTreeNode node = parentNodeCollection.FindSelectorNode(selector.Key);

            if (node == null)
            {
                node = new StylesheetTreeNode(this.ownerNode.OwnerTree, selector);
                parentNodeCollection.RegisterSelectorNode(node);
            }

            if (selector.ChildSelector != null)
            {
                this.AddNodeRecursive(propertySettings, selector.ChildSelector, node.Nodes);
            }
            else
            {
                node.PropertySettingGroups.Add(propertySettings);
            }

            return(node);
        }