Esempio n. 1
0
 private static void FindReferencedResourcesInternal(DocumentNode root, Dictionary <DocumentNode, bool> visited, IList <DocumentCompositeNode> resources)
 {
     foreach (DocumentNode documentNode in root.SelectDescendantNodes(new Predicate <DocumentNode>(ResourceHelper.FilterResources)))
     {
         DocumentNode index = new ExpressionEvaluator((IDocumentRootResolver)null).EvaluateExpression(new DocumentNodePath(root.DocumentRoot.RootNode, documentNode), documentNode);
         if (index != null && !visited.ContainsKey(index) && !root.IsAncestorOf(index))
         {
             visited[index] = true;
             ResourceHelper.FindReferencedResourcesInternal(index, visited, resources);
             DocumentCompositeNode parent = index.Parent;
             resources.Add(parent);
         }
     }
 }
Esempio n. 2
0
 // Token: 0x060034A5 RID: 13477 RVA: 0x000EA538 File Offset: 0x000E8738
 internal void EstablishTreeRelationships()
 {
     for (int i = 0; i < this.Count; i++)
     {
         this.EntryAt(i).Index = i;
     }
     for (int i = 1; i < this.Count; i++)
     {
         DocumentNode documentNode  = this.EntryAt(i);
         DocumentNode documentNode2 = this.EntryAt(i - 1);
         if (documentNode2.ChildCount == 0)
         {
             documentNode2 = documentNode2.Parent;
             while (documentNode2 != null && !documentNode2.IsAncestorOf(documentNode))
             {
                 documentNode2 = documentNode2.Parent;
             }
         }
         documentNode.Parent = documentNode2;
     }
 }
Esempio n. 3
0
        public override void Execute()
        {
            SceneElement targetElement = this.TargetElement;

            if (targetElement is StyleNode)
            {
                this.useStyle = new bool?(false);
            }
            else
            {
                IList <DocumentCompositeNode> auxillaryResources1;
                DocumentNode documentNode1 = this.ProvideCurrentStyle(targetElement, this.Type, new PropertyReference((ReferenceStep)targetElement.ProjectContext.ResolveProperty(BaseFrameworkElement.StyleProperty)), false, out auxillaryResources1);
                IList <DocumentCompositeNode> auxillaryResources2;
                DocumentNode other = this.ProvideCurrentTemplate(targetElement, new PropertyReference(this.ActiveTemplateProperty), out auxillaryResources2);
                bool         flag  = false;
                if ((other == null || other.DocumentRoot == null) && documentNode1 != null)
                {
                    using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitEditCopyStyle, true))
                    {
                        if (auxillaryResources1 != null && auxillaryResources1.Count > 0)
                        {
                            ResourceSite resourceSite = new ResourceSite(targetElement.DocumentNode);
                            resourceSite.EnsureResourceCollection();
                            foreach (DocumentCompositeNode entryNode in (IEnumerable <DocumentCompositeNode>)auxillaryResources1)
                            {
                                DocumentNode resourceEntryKey = ResourceNodeHelper.GetResourceEntryKey(entryNode);
                                DocumentNode documentNode2    = entryNode.Properties[DictionaryEntryNode.ValueProperty];
                                if (resourceEntryKey != null && documentNode2 != null)
                                {
                                    DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.DictionaryEntry);
                                    dictionaryEntryNode.KeyNode = this.SceneViewModel.GetSceneNode(resourceEntryKey.Clone(this.SceneViewModel.Document.DocumentContext));
                                    dictionaryEntryNode.Value   = this.SceneViewModel.GetSceneNode(documentNode2.Clone(this.SceneViewModel.Document.DocumentContext));
                                    resourceSite.ResourcesDictionary.Children.Add(dictionaryEntryNode.DocumentNode);
                                }
                            }
                        }
                        documentNode1 = documentNode1.Clone(this.SceneViewModel.Document.DocumentContext);
                        DocumentCompositeNode documentCompositeNode = documentNode1 as DocumentCompositeNode;
                        if (documentCompositeNode != null && documentCompositeNode.NameProperty != null && documentCompositeNode.Properties.Contains(documentCompositeNode.NameProperty))
                        {
                            documentCompositeNode.ClearValue((IPropertyId)documentCompositeNode.NameProperty);
                        }
                        targetElement.SetValue(this.TargetPropertyReference, (object)documentNode1);
                        DocumentNodePath valueAsDocumentNode = targetElement.GetLocalValueAsDocumentNode(this.TargetPropertyReference);
                        documentNode1 = valueAsDocumentNode != null ? valueAsDocumentNode.Node : (DocumentNode)null;
                        editTransaction.Update();
                        object computedValue = targetElement.GetComputedValue(new PropertyReference(this.ActiveTemplateProperty));
                        if (computedValue != null)
                        {
                            DocumentNodePath correspondingNodePath = this.SceneView.GetCorrespondingNodePath(this.SceneViewModel.ProjectContext.Platform.ViewObjectFactory.Instantiate(computedValue), true);
                            if (correspondingNodePath != null)
                            {
                                flag  = valueAsDocumentNode.IsAncestorOf(correspondingNodePath);
                                other = correspondingNodePath != null ? correspondingNodePath.Node : other;
                            }
                        }
                        editTransaction.Cancel();
                    }
                }
                this.useStyle = new bool?(flag || other != null && documentNode1 != null && documentNode1.IsAncestorOf(other));
            }
            base.Execute();
            this.useStyle = new bool?();
        }