Ejemplo n.º 1
0
        public static bool CanEditInPlace(SceneElement targetElement, ReferenceStep targetProperty, DocumentNodePath template)
        {
            DocumentNodePath documentNodePath = targetElement.DocumentNodePath;
            SceneViewModel   viewModel        = targetElement.ViewModel.GetViewModel(template.Node.DocumentRoot, true);

            if (targetElement.IsViewObjectValid && (targetElement.IsInstantiatedElementVisible || PlatformTypes.Style.IsAssignableFrom((ITypeId)template.Node.Type) && (targetProperty.Equals((object)BaseFrameworkElement.StyleProperty) || targetProperty == StyleNode.BasedOnProperty)) && (viewModel == targetElement.ViewModel && documentNodePath.IsAncestorOf(template)))
            {
                if (viewModel.DefaultView.GetInstantiatedElements(template).Count > 0)
                {
                    return(true);
                }
                if (!viewModel.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf) && PlatformTypes.FrameworkTemplate.IsAssignableFrom((ITypeId)template.Node.Type))
                {
                    SceneNode valueAsSceneNode = viewModel.GetSceneNode(template.Node).GetLocalValueAsSceneNode(viewModel.ProjectContext.PlatformMetadata.KnownProperties.FrameworkTemplateVisualTree);
                    if (valueAsSceneNode != null)
                    {
                        IViewVisual viewVisual = targetElement.ViewTargetElement as IViewVisual;
                        if (viewVisual == null && ProjectNeutralTypes.DataGridColumn.IsAssignableFrom((ITypeId)targetElement.Type))
                        {
                            DataGridElement dataGridElement = targetElement.Parent as DataGridElement;
                            if (dataGridElement != null && targetElement.DocumentNode.IsChild && (targetElement.DocumentNode.Parent.IsProperty && DataGridElement.ColumnsProperty.Equals((object)targetElement.DocumentNode.Parent.SitePropertyKey)))
                            {
                                viewVisual = dataGridElement.ViewTargetElement as IViewVisual;
                            }
                        }
                        if (viewVisual != null)
                        {
                            DocumentNodePath pathInContainer = template.GetPathInContainer(valueAsSceneNode.DocumentNode);
                            foreach (IViewObject viewObject in (IEnumerable <IViewObject>)viewModel.DefaultView.GetInstantiatedElements(pathInContainer))
                            {
                                IViewVisual visual = viewObject as IViewVisual;
                                if (visual != null && viewVisual.IsAncestorOf(visual))
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
 internal static bool IsCommandProperty(SceneElement element, ReferenceStep referenceStep)
 {
     if (PlatformTypes.Style.IsAssignableFrom((ITypeId)referenceStep.PropertyType) && !referenceStep.Equals((object)BaseFrameworkElement.StyleProperty))
     {
         return(TypeHelper.IsPropertyWritable((ITypeResolver)element.ViewModel.ProjectContext, (IProperty)referenceStep, element.IsSubclassDefinition));
     }
     return(false);
 }
Ejemplo n.º 3
0
        protected override bool DoesPropertyMatchFilter(PropertyFilter filter, PropertyEntry property)
        {
            ReferenceStep lastStep = ((PropertyReferenceProperty)property).Reference.LastStep;

            if (lastStep.Equals((object)BaseFrameworkElement.WidthProperty) || lastStep.Equals((object)BaseFrameworkElement.HeightProperty) || (lastStep.Equals((object)PanelElement.ZIndexProperty) || lastStep.Equals((object)CanvasElement.CanvasZIndexProperty)) || (lastStep.Equals((object)ScrollViewerElement.HorizontalScrollBarVisibilityProperty) || lastStep.Equals((object)ScrollViewerElement.VerticalScrollBarVisibilityProperty)))
            {
                if (!this.IsTargetingFrameworkElement)
                {
                    return(false);
                }
            }
            else if (lastStep.Equals((object)GridElement.ColumnProperty) || lastStep.Equals((object)GridElement.ColumnSpanProperty) || (lastStep.Equals((object)GridElement.RowProperty) || lastStep.Equals((object)GridElement.RowSpanProperty)))
            {
                if (!this.IsGridVisible)
                {
                    return(false);
                }
            }
            else if (lastStep.Equals((object)CanvasElement.LeftProperty) || lastStep.Equals((object)CanvasElement.TopProperty))
            {
                if (!this.IsCanvasVisible)
                {
                    return(false);
                }
            }
            else if (lastStep.Equals((object)PanelElement.ZIndexProperty) || lastStep.Equals((object)CanvasElement.CanvasZIndexProperty))
            {
                if (!this.IsPanelVisible)
                {
                    return(false);
                }
            }
            else if (lastStep.Equals((object)DockPanelElement.DockProperty))
            {
                if (!this.IsDockVisible)
                {
                    return(false);
                }
            }
            else if (lastStep.Equals((object)LayoutPositionCategory.wrapPanelOrientationProperty))
            {
                if (!this.IsChildWrapVisible)
                {
                    return(false);
                }
            }
            else if (lastStep.Equals((object)LayoutPositionCategory.stackPanelOrientationProperty) && !this.IsChildStackVisible)
            {
                return(false);
            }
            return(base.DoesPropertyMatchFilter(filter, property));
        }
        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);
        }