Esempio n. 1
0
 protected override DocumentNodePath ProvideEditingContainer(SceneElement targetElement, PropertyReference targetProperty, DocumentNode resourceNode)
 {
     if (this.UseStyle)
     {
         if (this.SceneView.IsEditable && targetElement.IsViewObjectValid && (this.SceneView.GetViewState((SceneNode)targetElement) & this.RequiredSelectionViewState) == this.RequiredSelectionViewState)
         {
             Type runtimeType = this.SceneViewModel.ProjectContext.ResolveType(PlatformTypes.FrameworkTemplate).RuntimeType;
             return(this.SceneView.GetCorrespondingNodePath(this.SceneViewModel.ProjectContext.Platform.ViewObjectFactory.Instantiate(targetElement.GetComputedValue((IPropertyId)this.ProvideTemplateProperty(SingleTargetCommandBase.GetTypeOfElement(targetElement)))), true));
         }
         SceneNode sceneNode = targetElement.GetLocalValueAsSceneNode(targetProperty);
         if (sceneNode == null && resourceNode != null && resourceNode.IsInDocument)
         {
             SceneViewModel viewModel = SceneViewModel.GetViewModel(this.ViewHost, resourceNode.DocumentRoot, false);
             if (viewModel != null)
             {
                 sceneNode = viewModel.GetSceneNode(resourceNode);
             }
         }
         if (sceneNode != null)
         {
             return(sceneNode.GetLocalValueAsDocumentNode((IPropertyId)this.ProvideTemplateProperty(SingleTargetCommandBase.GetTypeOfElement(targetElement))));
         }
     }
     return(targetElement.GetLocalValueAsDocumentNode(targetProperty));
 }
Esempio n. 2
0
 private static bool HasEditableContent(SceneElement sceneElement, IPropertyId propertyKey)
 {
     return(!(sceneElement.GetLocalValueAsSceneNode(propertyKey) is BaseFrameworkElement));
 }
        protected DocumentNode ProvideCurrentTemplate(SceneElement targetElement, PropertyReference targetPropertyReference, out IList <DocumentCompositeNode> auxillaryResources)
        {
            IPlatform platform = this.SceneViewModel.ProjectContext.Platform;
            FrameworkTemplateElement frameworkTemplateElement1 = (FrameworkTemplateElement)null;

            auxillaryResources = (IList <DocumentCompositeNode>)null;
            if (targetElement.IsSet(targetPropertyReference) == PropertyState.Set)
            {
                FrameworkTemplateElement frameworkTemplateElement2 = targetElement.GetLocalValueAsSceneNode(targetPropertyReference) as FrameworkTemplateElement;
                if (frameworkTemplateElement2 != null)
                {
                    frameworkTemplateElement1 = targetElement.ClonePropertyValueAsSceneNode(targetPropertyReference) as FrameworkTemplateElement;
                    if (frameworkTemplateElement1 != null)
                    {
                        auxillaryResources = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindReferencedResources(frameworkTemplateElement2.DocumentNode);
                    }
                }
            }
            if (frameworkTemplateElement1 == null)
            {
                object                computedValue          = targetElement.GetComputedValue(targetPropertyReference);
                DocumentNode          root                   = computedValue == null ? (DocumentNode)null : this.SceneView.GetCorrespondingDocumentNode(platform.ViewObjectFactory.Instantiate(computedValue), true);
                IPropertyId           targetProperty         = (IPropertyId)targetElement.Platform.Metadata.ResolveProperty(BaseFrameworkElement.StyleProperty);
                DocumentCompositeNode documentCompositeNode1 = targetElement.DocumentNode as DocumentCompositeNode;
                if (!targetElement.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf) && documentCompositeNode1 != null && (root == null && targetPropertyReference.ReferenceSteps.Count == 1))
                {
                    ITypeId       styleTargetType = (ITypeId)targetElement.Type;
                    DocumentNode  currentStyle    = (DocumentNode)null;
                    ReferenceStep referenceStep   = targetPropertyReference.ReferenceSteps[0];
                    object        defaultStyleKey = this.GetDefaultStyleKey(targetElement, styleTargetType, targetProperty);
                    if (defaultStyleKey != null)
                    {
                        bool isThemeStyle;
                        IList <DocumentCompositeNode> auxillaryResources1;
                        this.ResolveDefaultStyle(targetElement, defaultStyleKey, true, out currentStyle, out isThemeStyle, out auxillaryResources1);
                    }
                    DocumentCompositeNode documentCompositeNode2 = currentStyle as DocumentCompositeNode;
                    if (documentCompositeNode2 != null)
                    {
                        DocumentCompositeNode documentCompositeNode3 = documentCompositeNode2.Properties[StyleNode.SettersProperty] as DocumentCompositeNode;
                        if (documentCompositeNode3 != null)
                        {
                            foreach (DocumentNode documentNode1 in (IEnumerable <DocumentNode>)documentCompositeNode3.Children)
                            {
                                DocumentCompositeNode documentCompositeNode4 = documentNode1 as DocumentCompositeNode;
                                if (documentCompositeNode4 != null)
                                {
                                    IMemberId    memberId      = (IMemberId)DocumentPrimitiveNode.GetValueAsMember(documentCompositeNode4.Properties[SetterSceneNode.PropertyProperty]);
                                    DocumentNode documentNode2 = documentCompositeNode4.Properties[SetterSceneNode.ValueProperty];
                                    if (memberId != null && documentNode2 != null && referenceStep.Equals((object)memberId))
                                    {
                                        root = documentNode2;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                if (root != null)
                {
                    frameworkTemplateElement1 = this.SceneViewModel.GetSceneNode(root.Clone(this.SceneViewModel.Document.DocumentContext)) as FrameworkTemplateElement;
                    auxillaryResources        = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindReferencedResources(root);
                }
                else
                {
                    frameworkTemplateElement1 = this.SceneViewModel.CreateSceneNode(computedValue) as FrameworkTemplateElement;
                }
            }
            if (frameworkTemplateElement1 == null)
            {
                return((DocumentNode)null);
            }
            return(frameworkTemplateElement1.DocumentNode);
        }