Пример #1
0
 internal void MoveItem(ResourceEntryItem resourceEntry, int destinationIndex)
 {
     using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(StringTable.UndoUnitMoveResource))
     {
         DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)resourceEntry.Resource.ResourceNode.SceneNode;
         int num = this.ResourceDictionaryNode.IndexOf(dictionaryEntryNode);
         if (num == -1)
         {
             return;
         }
         if (destinationIndex > num)
         {
             --destinationIndex;
         }
         if (!this.ResourceDictionaryNode.Remove(dictionaryEntryNode))
         {
             return;
         }
         if (destinationIndex >= 0 && destinationIndex < this.ResourceDictionaryNode.Count)
         {
             this.ResourceDictionaryNode.Insert(destinationIndex, dictionaryEntryNode);
         }
         else
         {
             this.ResourceDictionaryNode.Add(dictionaryEntryNode);
         }
         editTransaction.Commit();
     }
 }
Пример #2
0
        private bool CopyItem(ResourceEntryItem primaryResource, ResourceContainer destinationContainer, int destinationIndex, bool skipReferencedResourceCopy)
        {
            ResourceConflictResolution conflictResolution = ResourceConflictResolution.UseExisting;
            DocumentNode               node1              = primaryResource.Resource.ResourceNode.Clone(destinationContainer.ViewModel.Document.DocumentContext);
            DictionaryEntryNode        primaryResource1   = (DictionaryEntryNode)destinationContainer.ViewModel.GetSceneNode(node1);
            ResourceEvaluation         resourceEvaluation = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.EvaluateResource(primaryResource1, destinationContainer.Node);
            List <DictionaryEntryNode> list1              = new List <DictionaryEntryNode>();

            if (!skipReferencedResourceCopy)
            {
                List <DocumentNode> foundResources = new List <DocumentNode>();
                Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindAllReferencedResources(primaryResource.DocumentNode, foundResources, (Microsoft.Expression.DesignSurface.Utility.ResourceHelper.PostOrderOperation)null);
                foreach (DocumentNode documentNode in foundResources)
                {
                    DocumentNode node2 = documentNode.Parent.Clone(destinationContainer.ViewModel.Document.DocumentContext);
                    list1.Add((DictionaryEntryNode)destinationContainer.ViewModel.GetSceneNode(node2));
                }
            }
            IList <ResourceEvaluation> list2 = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.EvaluateResources((IList <DictionaryEntryNode>)list1, destinationContainer.Node);

            if (!Microsoft.Expression.DesignSurface.Utility.ResourceHelper.CheckEvaluationResults(list2, (ResourceEvaluationResult)7))
            {
                if (!Microsoft.Expression.DesignSurface.Utility.ResourceHelper.CheckEvaluationResult(resourceEvaluation, ResourceEvaluationResult.ConflictingResourceExists, ResourceEvaluationResult.IdenticalResourceExists))
                {
                    goto label_10;
                }
            }
            conflictResolution = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.PromptForResourceConflictResolution(ResourceConflictResolution.UseExisting | ResourceConflictResolution.RenameNew | ResourceConflictResolution.OverwriteOld);
            if (conflictResolution == ResourceConflictResolution.Undetermined)
            {
                return(false);
            }
label_10:
            using (SceneEditTransaction editTransaction = destinationContainer.ViewModel.CreateEditTransaction(StringTable.UndoUnitCopyResource))
            {
                int num = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.AddResources(list2, (IList <SceneNode>)null, conflictResolution, destinationContainer.Node, destinationIndex);
                Microsoft.Expression.DesignSurface.Utility.ResourceHelper.AddPrimaryResource(resourceEvaluation, (IList <SceneNode>)null, conflictResolution, destinationContainer.Node, destinationIndex + num);
                ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator(destinationContainer.ViewModel.DocumentRootResolver);
                SceneNode           keyNode             = primaryResource1.KeyNode;
                if (keyNode != null)
                {
                    DocumentNode documentNode = expressionEvaluator.EvaluateResource(destinationContainer.Node.DocumentNodePath, keyNode.DocumentNode);
                    foreach (DictionaryEntryNode dictionaryEntryNode in destinationContainer.ResourceDictionaryNode)
                    {
                        if (dictionaryEntryNode.Value.DocumentNode == documentNode)
                        {
                            this.ResourceManager.SelectedItems.SetSelection((ResourceEntryBase)this.ResourceManager.GetResourceItem(destinationContainer, dictionaryEntryNode.DocumentNode as DocumentCompositeNode));
                            editTransaction.Commit();
                            return(true);
                        }
                    }
                }
                else
                {
                    editTransaction.Commit();
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
 internal static ResourceEvaluation EvaluateResource(DictionaryEntryNode primaryResource, SceneNode destination)
 {
     return(ResourceHelper.EvaluateResourcesInternal((IList <DictionaryEntryNode>) new List <DictionaryEntryNode>()
     {
         primaryResource
     }, destination)[0]);
 }
Пример #4
0
        public static SceneNode CreateValueConverter(SceneViewModel viewModel)
        {
            AddValueConverterDialog valueConverterDialog = new AddValueConverterDialog(viewModel);
            bool?nullable = valueConverterDialog.ShowDialog();

            if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? true : false)) != 0)
            {
                Type   objectType = valueConverterDialog.ObjectType;
                string name       = valueConverterDialog.ValueConverterResourceKey;
                if (objectType != (Type)null)
                {
                    viewModel.ProjectContext.GetType(objectType);
                    SceneNode sceneNode = viewModel.CreateSceneNode(objectType);
                    SceneNode rootNode  = viewModel.RootNode;
                    if (rootNode != null)
                    {
                        Microsoft.Expression.DesignSurface.Utility.ResourceHelper.EnsureResourceDictionaryNode(rootNode);
                        ResourceDictionaryNode resourceDictionaryNode = ResourceManager.ProvideResourcesForElement(rootNode);
                        if (resourceDictionaryNode != null)
                        {
                            if (string.IsNullOrEmpty(name))
                            {
                                name = objectType.Name;
                            }
                            string uniqueResourceKey = resourceDictionaryNode.GetUniqueResourceKey(name);
                            DictionaryEntryNode dictionaryEntryNode = DictionaryEntryNode.Factory.Instantiate((object)uniqueResourceKey, sceneNode);
                            resourceDictionaryNode.Insert(0, dictionaryEntryNode);
                            return((SceneNode)dictionaryEntryNode);
                        }
                    }
                }
            }
            return((SceneNode)null);
        }
Пример #5
0
        private static DictionaryEntryNode ResolveResourceConflict(ResourceEvaluation resourceEvaluation, IList <SceneNode> elements, SceneNode destination, ResourceConflictResolution resolution)
        {
            DictionaryEntryNode originalResource    = resourceEvaluation.OriginalResource;
            DocumentNode        evaluatedResource   = resourceEvaluation.EvaluatedResource;
            DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)null;

            if (resolution == ResourceConflictResolution.RenameNew)
            {
                DocumentNode newKey = ResourceHelper.GenerateUniqueResourceKey(originalResource.Key.ToString(), destination);
                ResourceHelper.ChangeKey(elements, originalResource, originalResource.KeyNode.DocumentNode, newKey);
                dictionaryEntryNode = originalResource;
            }
            else if (resolution == ResourceConflictResolution.OverwriteOld)
            {
                DocumentCompositeNode parent = evaluatedResource.Parent;
                if (parent != null && typeof(DictionaryEntry).IsAssignableFrom(parent.TargetType))
                {
                    SceneViewModel viewModel = SceneViewModel.GetViewModel((ISceneViewHost)destination.ProjectContext.GetService(typeof(ISceneViewHost)), parent.DocumentRoot, false);
                    if (viewModel != null)
                    {
                        using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UndoResourceOverwrite))
                        {
                            ((DictionaryEntryNode)viewModel.GetSceneNode((DocumentNode)parent)).Value = viewModel.GetSceneNode(originalResource.Value.DocumentNode.Clone(viewModel.Document.DocumentContext));
                            editTransaction.Commit();
                        }
                    }
                }
                dictionaryEntryNode = (DictionaryEntryNode)null;
            }
            else if (resolution == ResourceConflictResolution.UseExisting)
            {
                dictionaryEntryNode = (DictionaryEntryNode)null;
            }
            return(dictionaryEntryNode);
        }
 public static bool IsResourceValueConverter(DictionaryEntryNode entry)
 {
     if (PlatformTypes.IValueConverter.IsAssignableFrom((ITypeId)entry.Value.Type))
     {
         return(entry.Key is string);
     }
     return(false);
 }
Пример #7
0
        private EditResourceModel BuildResourceModelFromPropertyReference()
        {
            bool isMixed;
            DocumentCompositeNode findMe                = (DocumentCompositeNode)this.editingProperty.GetLocalValueAsDocumentNode(false, out isMixed);
            ResourceManager       resourceManager       = this.editingProperty.SceneNodeObjectSet.DesignerContext.ResourceManager;
            DocumentCompositeNode documentCompositeNode = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.LookupResource(this.editingProperty.SceneNodeObjectSet.ViewModel, findMe);
            DictionaryEntryNode   resourceEntryNode     = (DictionaryEntryNode)(documentCompositeNode.DocumentRoot != findMe.DocumentRoot ? ((ISceneViewHost)this.editingProperty.SceneNodeObjectSet.ViewModel.ProjectContext.GetService(typeof(ISceneViewHost))).OpenView(documentCompositeNode.DocumentRoot, false).ViewModel : this.editingProperty.SceneNodeObjectSet.ViewModel).GetSceneNode((DocumentNode)documentCompositeNode);
            SceneNode             sceneNode             = resourceEntryNode.Value;

            return(new EditResourceModel(this.designerContext, resourceEntryNode, (IPropertyInspector)this));
        }
Пример #8
0
 internal static void AddResource(DictionaryEntryNode resourceToAdd, ResourceDictionaryNode destinationDictionary, int insertionIndex)
 {
     if (insertionIndex >= 0 && insertionIndex < destinationDictionary.Count)
     {
         destinationDictionary.Insert(insertionIndex, resourceToAdd);
     }
     else
     {
         destinationDictionary.Add(resourceToAdd);
     }
 }
        public static ValueConverterModel CreateValueConverterModel(SceneNode valueConverter)
        {
            DictionaryEntryNode dictionaryEntryNode = valueConverter as DictionaryEntryNode;

            if (dictionaryEntryNode != null && ValueConverterModelFactory.IsResourceValueConverter(dictionaryEntryNode))
            {
                return((ValueConverterModel) new ValueConverterResourceModel(dictionaryEntryNode));
            }
            if (PlatformTypes.IValueConverter.IsAssignableFrom((ITypeId)valueConverter.Type))
            {
                return((ValueConverterModel) new ValueConverterLocalModel(valueConverter));
            }
            return((ValueConverterModel)null);
        }
Пример #10
0
        private bool MoveItem(ResourceEntryItem resourceEntry, ResourceContainer destinationContainer, int destinationIndex, bool skipReferencedResourceCopy, ReferencesFoundModel referencesFoundModel, bool doReferenceFixup)
        {
            bool flag = this.CopyItem(resourceEntry, destinationContainer, destinationIndex, skipReferencedResourceCopy);

            if (flag)
            {
                if (doReferenceFixup && !new AsyncProcessDialog(referencesFoundModel.FixReferencesAsync(), resourceEntry.Container.ViewModel.DesignerContext.ExpressionInformationService).ShowDialog().GetValueOrDefault(false))
                {
                    return(false);
                }
                DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)resourceEntry.Container.ViewModel.GetSceneNode((DocumentNode)resourceEntry.Resource.ResourceNode);
                using (SceneEditTransaction editTransaction = resourceEntry.Container.ViewModel.CreateEditTransaction(StringTable.UndoUnitDeleteResource))
                {
                    resourceEntry.Container.ResourceDictionaryNode.Remove(dictionaryEntryNode);
                    editTransaction.Commit();
                }
            }
            return(flag);
        }
Пример #11
0
        internal static bool CopyResourcesToNewResourceSite(IList <DocumentCompositeNode> auxillaryResources, SceneViewModel resourcesHostViewModel, DocumentCompositeNode resourcesHostNode, DocumentCompositeNode insertedResourceNode, int indexInResourceSite)
        {
            if (auxillaryResources == null || auxillaryResources.Count <= 0)
            {
                return(true);
            }
            bool flag = true;
            ResourceConflictResolution conflictResolution = ResourceConflictResolution.Undetermined;
            SceneNode sceneNode = resourcesHostViewModel.GetSceneNode((DocumentNode)resourcesHostNode);
            List <DictionaryEntryNode> list1 = new List <DictionaryEntryNode>();
            List <SceneNode>           list2 = new List <SceneNode>();

            foreach (DocumentNode documentNode in (IEnumerable <DocumentCompositeNode>)auxillaryResources)
            {
                DocumentNode        node = documentNode.Clone(resourcesHostViewModel.Document.DocumentContext);
                DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)resourcesHostViewModel.GetSceneNode(node);
                list1.Add(dictionaryEntryNode);
                if (dictionaryEntryNode.Value != null)
                {
                    list2.Add(dictionaryEntryNode.Value);
                }
            }
            if (insertedResourceNode != null)
            {
                list2.Add(resourcesHostViewModel.GetSceneNode((DocumentNode)insertedResourceNode));
            }
            IList <ResourceEvaluation> list3 = ResourceHelper.EvaluateResources((IList <DictionaryEntryNode>)list1, sceneNode);

            if (ResourceHelper.CheckEvaluationResults(list3, ResourceEvaluationResult.ConflictingResourceExists, ResourceEvaluationResult.ConflictingResourceIsMasked))
            {
                conflictResolution = ResourceHelper.PromptForResourceConflictResolution(ResourceConflictResolution.RenameNew | ResourceConflictResolution.OverwriteOld);
                if (conflictResolution == ResourceConflictResolution.Undetermined)
                {
                    flag = false;
                }
            }
            if (flag)
            {
                ResourceHelper.EnsureResourceDictionaryNode(sceneNode);
                ResourceHelper.AddResources(list3, (IList <SceneNode>)list2, conflictResolution, sceneNode, indexInResourceSite);
            }
            return(flag);
        }
Пример #12
0
        internal static int AddResources(IList <ResourceEvaluation> referencedResources, IList <SceneNode> referringElements, ResourceConflictResolution conflictResolution, SceneNode destination, int insertionIndex)
        {
            SceneViewModel         viewModel             = destination.ViewModel;
            ResourceDictionaryNode destinationDictionary = ResourceHelper.EnsureResourceDictionaryNode(destination);
            int num = insertionIndex;

            foreach (ResourceEvaluation resourceEvaluation in (IEnumerable <ResourceEvaluation>)referencedResources)
            {
                DictionaryEntryNode resourceToAdd = (DictionaryEntryNode)null;
                switch (resourceEvaluation.ConflictType)
                {
                case ResourceEvaluationResult.NoExistingResource:
                    resourceToAdd = resourceEvaluation.OriginalResource;
                    goto case 1;

                case ResourceEvaluationResult.IdenticalResourceExists:
                case ResourceEvaluationResult.IdenticalResourceIsMasked:
                    if (resourceToAdd != null)
                    {
                        ResourceHelper.AddResource(resourceToAdd, destinationDictionary, insertionIndex);
                        ++insertionIndex;
                        continue;
                    }
                    continue;

                case ResourceEvaluationResult.ConflictingResourceExists:
                    resourceToAdd = ResourceHelper.ResolveResourceConflict(resourceEvaluation, referringElements, destination, conflictResolution);
                    goto case 1;

                case ResourceEvaluationResult.ConflictingResourceIsMasked:
                    resourceToAdd = ResourceHelper.ResolveResourceConflict(resourceEvaluation, referringElements, destination, conflictResolution);
                    goto case 1;

                default:
                    throw new InvalidEnumArgumentException("ConflictType", (int)resourceEvaluation.ConflictType, typeof(ResourceEvaluationResult));
                }
            }
            return(insertionIndex - num);
        }
Пример #13
0
        public EditResourceModel(DesignerContext designerContext, DictionaryEntryNode resourceEntryNode, IPropertyInspector transactionContext)
        {
            this.designerContext   = designerContext;
            this.resourceEntryNode = resourceEntryNode;
            object       key = resourceEntryNode.Key;
            DocumentNode expression;

            if ((expression = key as DocumentNode) != null)
            {
                this.keyString = XamlExpressionSerializer.GetStringFromExpression(expression, resourceEntryNode.DocumentNode);
            }
            else if ((this.keyString = key as string) == null)
            {
                this.keyString = key.ToString();
            }
            this.keyStringIsValid = true;
            ResourceEntryItem resource = (ResourceEntryItem)this.designerContext.ResourceManager.GetResourceItem((DocumentCompositeNode)resourceEntryNode.DocumentNode);

            this.resourceObjectSet = new ResourceValueObjectSet(resource, designerContext, transactionContext);
            this.standInProperty   = this.resourceObjectSet.CreateProperty(new PropertyReference((ReferenceStep)this.resourceObjectSet.ProjectContext.ResolveProperty(DictionaryEntryNode.ValueProperty)), TypeUtilities.GetAttributes(resource.EffectiveType));
            this.standInProperty.PropertyValue.PropertyValueException += new EventHandler <PropertyValueExceptionEventArgs>(this.OnPropertyValueException);
            this.standInProperty.PropertyValue.PropertyChanged        += new PropertyChangedEventHandler(this.OnValuePropertyChanged);
        }
Пример #14
0
 private static void ChangeKey(IList <SceneNode> elements, DictionaryEntryNode resource, DocumentNode oldKey, DocumentNode newKey)
 {
     resource.KeyNode = resource.ViewModel.GetSceneNode(newKey);
     if (elements == null)
     {
         return;
     }
     foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)elements)
     {
         foreach (DocumentNode expression in sceneNode.DocumentNode.SelectDescendantNodes(new Predicate <DocumentNode>(ResourceHelper.FilterResources)))
         {
             DocumentCompositeNode node = expression as DocumentCompositeNode;
             if (node != null)
             {
                 DocumentNode resourceKey = ResourceNodeHelper.GetResourceKey(node);
                 if (resourceKey != null && resourceKey.Equals(oldKey) && new ExpressionEvaluator((IDocumentRootResolver)null).EvaluateExpression(sceneNode.DocumentNodePath, expression) == null)
                 {
                     ResourceNodeHelper.SetResourceKey(node, newKey.Clone(sceneNode.DocumentContext));
                 }
             }
         }
     }
 }
Пример #15
0
        private void ResourcesSubscription_PathNodeChanged(object sender, SceneNode pathNode, object item, DocumentNodeMarker damageMarker, DocumentNodeChange damage)
        {
            if (!damage.IsPropertyChange)
            {
                return;
            }
            DictionaryEntryNode dictionaryEntryNode = pathNode as DictionaryEntryNode;

            if (dictionaryEntryNode == null)
            {
                return;
            }
            bool flag = DictionaryEntryNode.KeyProperty.Equals((object)damage.PropertyKey);

            if (!flag && damage.ParentNode != null && (damage.ParentNode == dictionaryEntryNode.Value.DocumentNode && this.ViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.NameSupportedAsKey)) && damage.PropertyKey == damage.ParentNode.NameProperty)
            {
                flag = true;
            }
            if (!flag)
            {
                return;
            }
            this.OnKeyChanged(pathNode.DocumentNode);
        }
Пример #16
0
        private void InteractiveRenameResource()
        {
            if (this.DocumentNode == null || this.DocumentNode.DocumentRoot == null || this.DocumentNode.DocumentRoot.DocumentContext == null)
            {
                return;
            }
            string key = this.currentName;

            this.currentName = (string)null;
            if (key == null || key.Equals(this.resource.Name))
            {
                this.OnKeyChanged();
            }
            else
            {
                SceneViewModel viewModel = this.Container.ViewModel;
                if (new ResourceSite(viewModel.Document.DocumentContext, this.Container.ResourcesCollection).FindResource((IDocumentRootResolver)null, key, (ICollection <DocumentCompositeNode>)null, (ICollection <IDocumentRoot>)null) != null)
                {
                    viewModel.DesignerContext.MessageDisplayService.ShowError(StringTable.CreateResourceKeyStringIssueDirectConflict);
                    this.OnKeyChanged();
                }
                else
                {
                    List <SceneNode>     list  = new List <SceneNode>();
                    ReferencesFoundModel model = (ReferencesFoundModel)null;
                    viewModel.FindInternalResourceReferences(this.resource.ResourceNode, (ICollection <SceneNode>)list);
                    ITypeId             type = (ITypeId)viewModel.RootNode.Type;
                    bool                flag = PlatformTypes.ResourceDictionary.IsAssignableFrom(type) || PlatformTypes.Application.IsAssignableFrom(type);
                    DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)viewModel.GetSceneNode((DocumentNode)this.resource.ResourceNode);
                    if (list.Count > 0 || flag)
                    {
                        model = new ReferencesFoundModel((SceneNode)dictionaryEntryNode, (ICollection <SceneNode>)list, ReferencesFoundModel.UseScenario.RenameResource);
                        bool valueOrDefault = new AsyncProcessDialog((AsyncProcess) new SerialAsyncProcess((IAsyncMechanism) new CurrentDispatcherAsyncMechanism(DispatcherPriority.Background), new AsyncProcess[2]
                        {
                            (AsyncProcess) new ExternalOpenSceneResourceReferenceAnalyzer(model),
                            (AsyncProcess) new ExternalClosedSceneResourceReferenceAnalyzer(model)
                        }), this.DesignerContext.ExpressionInformationService).ShowDialog().GetValueOrDefault(false);
                        if (valueOrDefault && model.ReferenceNames.Count > 0)
                        {
                            valueOrDefault = new ReferencesFoundDialog(model).ShowDialog().GetValueOrDefault(false);
                        }
                        if (!valueOrDefault)
                        {
                            this.OnKeyChanged();
                            return;
                        }
                    }
                    using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UndoUnitRenameResource))
                    {
                        if (model != null && model.SelectedUpdateMethod != ReferencesFoundModel.UpdateMethod.DontFix && model.ReferenceNames.Count > 0)
                        {
                            model.NewKey = (object)key;
                            new AsyncProcessDialog(model.FixReferencesAsync(), this.DesignerContext.ExpressionInformationService).ShowDialog();
                        }
                        dictionaryEntryNode.Key = (object)key;
                        editTransaction.Commit();
                    }
                    this.OnKeyChanged();
                }
            }
        }
 public ValueConverterResourceModel(DictionaryEntryNode valueConverter)
 {
     this.valueConverter = valueConverter;
 }
Пример #18
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?();
        }
Пример #19
0
 internal ResourceEvaluation(DictionaryEntryNode originalResource, DocumentNode evaluatedResource, ResourceEvaluationResult conflictType)
 {
     this.originalResource  = originalResource;
     this.evaluatedResource = evaluatedResource;
     this.conflictType      = conflictType;
 }