Ejemplo n.º 1
0
        public BaseFrameworkElement GetRelativeTargetElement(DocumentNodePath relativeEditingContainerPath)
        {
            if (relativeEditingContainerPath.ContainerNode != this.DocumentNode)
            {
                return((BaseFrameworkElement)null);
            }
            DocumentNodePath containerOwnerPath = relativeEditingContainerPath.GetContainerOwnerPath();

            if (containerOwnerPath == null)
            {
                return((BaseFrameworkElement)null);
            }
            SetterSceneNode setterSceneNode = this.ViewModel.GetSceneNode(containerOwnerPath.Node) as SetterSceneNode;

            if (setterSceneNode == null)
            {
                return(this.ViewModel.GetSceneNode(containerOwnerPath.Node) as BaseFrameworkElement);
            }
            IStoryboardContainer storyboardContainer = (IStoryboardContainer)this.ViewModel.GetSceneNode(containerOwnerPath.ContainerNode);
            SceneNode            sceneNode           = storyboardContainer.ResolveTargetName(setterSceneNode.Target);

            if (sceneNode == storyboardContainer)
            {
                return(storyboardContainer.TargetElement);
            }
            return(sceneNode as BaseFrameworkElement);
        }
Ejemplo n.º 2
0
        protected override void CreateAdorners()
        {
            GradientBrush     gradientBrush     = (GradientBrush)null;
            PropertyReference propertyReference = this.BrushPropertyReference;

            if (propertyReference != null)
            {
                gradientBrush = this.Element.GetComputedValueAsWpf(propertyReference) as GradientBrush;
                DocumentNodePath valueAsDocumentNode = this.Element.GetLocalValueAsDocumentNode(propertyReference);
                if (valueAsDocumentNode != null)
                {
                    this.Element.DesignerContext.GradientToolSelectionService.AdornedBrush = valueAsDocumentNode.Node;
                }
                else
                {
                    this.Element.DesignerContext.GradientToolSelectionService.AdornedBrush = (DocumentNode)null;
                }
            }
            if (gradientBrush == null)
            {
                return;
            }
            for (int index = 0; index < gradientBrush.GradientStops.Count; ++index)
            {
                this.AddAdorner((Adorner) new GradientStopAdorner((BrushTransformAdornerSet)this, index));
            }
        }
Ejemplo n.º 3
0
        public static DocumentNodePath ResolveNodePathForTemplateWithinExistingStyle(SceneElement targetElement, PropertyReference targetPropertyReference)
        {
            DocumentNodePath documentNodePath = ControlStylingOperations.ProvideStyleOrTemplateNodePath(targetElement, targetPropertyReference);

            if (documentNodePath != null)
            {
                SceneView defaultView = targetElement.ViewModel.DefaultView;
                ICollection <IViewObject> instantiatedElements = defaultView.GetInstantiatedElements(documentNodePath);
                if (instantiatedElements.Count <= 0)
                {
                    return(ControlStylingOperations.FindTemplateWithinStyle(documentNodePath, targetElement, ControlElement.TemplateProperty, (IPropertyId)targetPropertyReference[0]));
                }
                foreach (IViewObject viewObject in (IEnumerable <IViewObject>)instantiatedElements)
                {
                    if (PlatformTypes.Control.IsAssignableFrom((ITypeId)viewObject.GetIType((ITypeResolver)targetElement.ProjectContext)))
                    {
                        object platformObject = viewObject.GetValue(targetElement.ProjectContext.ResolveProperty(ControlElement.TemplateProperty));
                        if (platformObject != null)
                        {
                            IViewObject      instance = targetElement.ViewModel.ProjectContext.Platform.ViewObjectFactory.Instantiate(platformObject);
                            DocumentNodePath correspondingNodePath = defaultView.GetCorrespondingNodePath(instance, true);
                            if (correspondingNodePath != null && ControlStylingOperations.ShouldSetEditingContextToNodePath(correspondingNodePath, targetElement, targetPropertyReference[0]))
                            {
                                return(correspondingNodePath);
                            }
                        }
                    }
                }
            }
            return((DocumentNodePath)null);
        }
Ejemplo n.º 4
0
        public void SetData(ViewNode target, DocumentNode innerSource, T data)
        {
            List <PersistentData <T> > persistentDatas;
            DocumentNodePath           correspondingNodePath = this.viewNodeManager.GetCorrespondingNodePath(target);
            PersistentData <T>         persistentDatum       = new PersistentData <T>(data, correspondingNodePath, innerSource);

            if (!this.dictionary.TryGetValue(target.DocumentNode, out persistentDatas))
            {
                persistentDatas = new List <PersistentData <T> >()
                {
                    persistentDatum
                };
                this.dictionary[target.DocumentNode] = persistentDatas;
                PersistentViewNodeDictionary <T> persistentViewNodeDictionary = this;
                persistentViewNodeDictionary.count = persistentViewNodeDictionary.count + 1;
                return;
            }
            for (int i = 0; i < persistentDatas.Count; i++)
            {
                if (PersistentViewNodeDictionary <T> .CompareNodePaths(persistentDatas[i].Target, correspondingNodePath))
                {
                    persistentDatas[i] = persistentDatum;
                    return;
                }
            }
            persistentDatas.Add(persistentDatum);
        }
Ejemplo n.º 5
0
        public PersistentData <T> GetData(ViewNode viewNode)
        {
            List <PersistentData <T> > persistentDatas;
            PersistentData <T>         persistentDatum;

            if (this.dictionary.TryGetValue(viewNode.DocumentNode, out persistentDatas))
            {
                DocumentNodePath correspondingNodePath = this.viewNodeManager.GetCorrespondingNodePath(viewNode);
                if (correspondingNodePath == null)
                {
                    return(null);
                }
                List <PersistentData <T> > .Enumerator enumerator = persistentDatas.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        PersistentData <T> current = enumerator.Current;
                        if (!PersistentViewNodeDictionary <T> .CompareNodePaths(current.Target, correspondingNodePath))
                        {
                            continue;
                        }
                        persistentDatum = current;
                        return(persistentDatum);
                    }
                    return(null);
                }
                finally
                {
                    ((IDisposable)enumerator).Dispose();
                }
                return(persistentDatum);
            }
            return(null);
        }
Ejemplo n.º 6
0
            private void Visit(DocumentNodePath basisPath, DocumentNodePath rootPath, DocumentNode current, XamlProjectSubscription.XamlDocumentSubscription.NodeChangeCallback callback)
            {
                foreach (DocumentNode newNode in this.searchPath(current))
                {
                    callback(basisPath, newNode);
                }
                if (!current.Type.IsExpression || current.Parent == null || !current.IsProperty)
                {
                    return;
                }
                DocumentNode documentNode = new ExpressionEvaluator((IDocumentRootResolver)this.ProjectSubscription.ProjectContext).EvaluateExpression(basisPath, current);

                if (documentNode == null || documentNode == current)
                {
                    return;
                }
                if (documentNode.DocumentRoot != this.DocumentRoot)
                {
                    callback(basisPath, current);
                }
                else
                {
                    DocumentNodePath pathInSubContainer = rootPath.GetPathInContainer(current).GetPathInSubContainer(current.SitePropertyKey, documentNode);
                    this.WalkDescendants(basisPath, pathInSubContainer, documentNode, callback);
                }
            }
Ejemplo n.º 7
0
        private SceneElement GetContainingTextElement(DocumentNodePath nodePath)
        {
            if (this.ActiveSceneViewModel == null || this.ActiveSceneViewModel.ActiveEditingContainer == null)
            {
                return((SceneElement)null);
            }
            DocumentNodePath editingContainer = this.ActiveSceneViewModel.GetAncestorInEditingContainer(nodePath, this.ActiveSceneViewModel.ActiveEditingContainer.DocumentNodePath, (DocumentNodePath)null);
            SceneElement     sceneElement     = (SceneElement)null;

            if (editingContainer != null)
            {
                sceneElement = this.ActiveSceneViewModel.GetSceneNode(editingContainer.Node) as SceneElement;
            }
            for (; sceneElement != null; sceneElement = sceneElement.ParentElement)
            {
                if (sceneElement.IsVisuallySelectable || sceneElement == this.ActiveSceneViewModel.ActiveEditingContainer)
                {
                    if (!TextEditProxyFactory.IsEditableElement(sceneElement))
                    {
                        sceneElement = (SceneElement)null;
                        break;
                    }
                    break;
                }
            }
            return(sceneElement);
        }
Ejemplo n.º 8
0
        private static bool CompareNodePaths(DocumentNodePath stored, DocumentNodePath fromViewNodeTree)
        {
            if (stored == fromViewNodeTree)
            {
                return(true);
            }
            if (stored.Count != fromViewNodeTree.Count && stored.Count + 1 != fromViewNodeTree.Count)
            {
                return(false);
            }
            int num  = 0;
            int num1 = 0;

            while (num < stored.Count && num1 < fromViewNodeTree.Count)
            {
                NodePathEntry item          = stored[num];
                NodePathEntry nodePathEntry = fromViewNodeTree[num1];
                if (!item.Equals(nodePathEntry))
                {
                    if (item.Container != nodePathEntry.Container || num1 + 1 >= fromViewNodeTree.Count || item.Target != fromViewNodeTree[num1 + 1].Target)
                    {
                        return(false);
                    }
                    num1++;
                }
                num1++;
                num++;
            }
            if (num != stored.Count)
            {
                return(false);
            }
            return(num1 == fromViewNodeTree.Count);
        }
Ejemplo n.º 9
0
        public override IProperty GetPropertyForChild(SceneNode child)
        {
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }
            if (!(this.DocumentNode is DocumentCompositeNode))
            {
                throw new InvalidOperationException(ExceptionStringTable.SceneNodeMustBeCompositeForLogicalChild);
            }
            IProperty        property         = (IProperty)null;
            DocumentNodePath documentNodePath = child.DocumentNodePath;

            if (documentNodePath.ContainerNode == documentNodePath.Node)
            {
                SetterSceneNode setterSceneNode = this.ViewModel.GetSceneNode(documentNodePath.ContainerOwner) as SetterSceneNode;
                if (setterSceneNode != null)
                {
                    property = (IProperty)setterSceneNode.Property;
                }
            }
            else
            {
                property = base.GetPropertyForChild(child);
            }
            return(property);
        }
Ejemplo n.º 10
0
 public Breadcrumb(SceneViewModel activeViewModel, EditContext editContext, DocumentNodePath selectedElementPath, bool isGhosted)
 {
     this.activeViewModel     = activeViewModel;
     this.editContext         = editContext;
     this.selectedElementPath = this.IsActiveScope ? (DocumentNodePath)null : selectedElementPath;
     this.isGhosted           = isGhosted;
 }
        public override bool AllowPostponedResourceUpdate(IInstanceBuilderContext context, ViewNode viewNode, IProperty propertyKey, DocumentNodePath evaluatedResource)
        {
            if (viewNode.Type.Metadata.NameProperty == propertyKey)
            {
                return(false);
            }
            DocumentNodePath editingContainer = context.ViewNodeManager.EditingContainer;

            if (editingContainer != null && DependencyObjectInstanceBuilderBase <T> .IsEvaluatedResourceWithinNodePath(editingContainer, viewNode, propertyKey, evaluatedResource))
            {
                return(false);
            }
            if (context.IsSerializationScope && !PlatformTypes.UIElement.IsAssignableFrom(viewNode.Type))
            {
                return(false);
            }
            if (evaluatedResource.Node != null && PlatformTypes.Visual.IsAssignableFrom(evaluatedResource.Node.Type))
            {
                return(false);
            }
            DocumentCompositeNode node = evaluatedResource.Node as DocumentCompositeNode;

            if (node != null && node.PlatformMetadata.IsCapabilitySet(PlatformCapability.SupportNonSharedResources) && node.Properties[DesignTimeProperties.SharedProperty] != null && !node.GetValue <bool>(DesignTimeProperties.SharedProperty))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 12
0
 private static void FindAllReferencedResources(DocumentNode node, List <DocumentNode> foundResources, Stack <DocumentNodePath> resourceReferenceTree, ResourceHelper.PostOrderOperation postOrderOperation)
 {
     foreach (DocumentNode documentNode1 in node.SelectDescendantNodes(new Predicate <DocumentNode>(ResourceHelper.FilterResources)))
     {
         DocumentNodePath context1 = new DocumentNodePath(node.DocumentRoot.RootNode, documentNode1);
         resourceReferenceTree.Push(context1);
         DocumentNode documentNode2 = (DocumentNode)null;
         if (DocumentNodeUtilities.IsDynamicResource(documentNode1))
         {
             foreach (DocumentNodePath context2 in resourceReferenceTree)
             {
                 documentNode2 = new ExpressionEvaluator((IDocumentRootResolver)context2.Node.Context).EvaluateExpression(context2, documentNode1);
                 if (documentNode2 != null)
                 {
                     break;
                 }
             }
         }
         else
         {
             documentNode2 = new ExpressionEvaluator((IDocumentRootResolver)context1.Node.Context).EvaluateExpression(context1, documentNode1);
         }
         if (documentNode2 != null && !ResourceHelper.IsResourceCached(documentNode2, foundResources))
         {
             foundResources.Add(documentNode2);
             ResourceHelper.FindAllReferencedResources(documentNode2, foundResources, resourceReferenceTree, postOrderOperation);
             if (postOrderOperation != null)
             {
                 postOrderOperation(documentNode2);
             }
         }
         resourceReferenceTree.Pop();
     }
 }
Ejemplo n.º 13
0
        private static RawDataSourceInfoBase GetDataSourceInfoFromResourceReference(DocumentCompositeNode resourceReferenceNode)
        {
            if (resourceReferenceNode.DocumentRoot == null)
            {
                return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid);
            }
            DocumentNode          resourceKey        = ResourceNodeHelper.GetResourceKey(resourceReferenceNode);
            ResourceReferenceType resourceType       = ResourceNodeHelper.GetResourceType((DocumentNode)resourceReferenceNode);
            DocumentNodePath      nodePath           = new DocumentNodePath(resourceReferenceNode.DocumentRoot.RootNode, (DocumentNode)resourceReferenceNode);
            DocumentNode          sourceNode         = new ExpressionEvaluator((IDocumentRootResolver)resourceReferenceNode.Context).EvaluateResource(nodePath, resourceType, resourceKey);
            RawDataSourceInfoBase dataSourceInfoBase = (RawDataSourceInfoBase) new RawDataSourceInfo(sourceNode, (string)null);

            if (sourceNode != null && PlatformTypes.XmlDataProvider.IsAssignableFrom((ITypeId)sourceNode.Type))
            {
                DocumentNode node = ((DocumentCompositeNode)sourceNode).Properties[XmlDataProviderSceneNode.XPathProperty];
                if (node != null)
                {
                    string valueAsString = DocumentPrimitiveNode.GetValueAsString(node);
                    if (!string.IsNullOrEmpty(valueAsString))
                    {
                        dataSourceInfoBase.XmlPath = valueAsString;
                    }
                }
            }
            return(dataSourceInfoBase);
        }
Ejemplo n.º 14
0
        internal static bool EvaluateExpression(SceneViewModel parentViewModel, DocumentNodePath parentPath, IPropertyId parentPropertyKey, DocumentNodePath childPath)
        {
            bool flag = true;

            if (parentPropertyKey != null)
            {
                DocumentCompositeNode documentCompositeNode = parentPath.Node as DocumentCompositeNode;
                if (documentCompositeNode != null)
                {
                    DocumentNode expression = documentCompositeNode.Properties[parentPropertyKey];
                    if (expression != null && expression.Type.IsExpression)
                    {
                        expression = new ExpressionEvaluator(parentViewModel.DocumentRootResolver).EvaluateExpression(parentPath, expression);
                    }
                    else if (expression == null && documentCompositeNode.PlatformMetadata.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles) && BaseFrameworkElement.StyleProperty.Equals((object)parentPropertyKey))
                    {
                        ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator(parentViewModel.DocumentRootResolver);
                        DocumentNode        node = documentCompositeNode.Context.CreateNode(typeof(Type), (object)documentCompositeNode.Type.RuntimeType);
                        expression = expressionEvaluator.EvaluateResource(parentPath, node);
                    }
                    if (expression == null || expression != childPath.Node)
                    {
                        flag = false;
                    }
                }
            }
            return(flag);
        }
Ejemplo n.º 15
0
        private void UpdateAmbientValueFromSceneElement(SceneElement element, PropertyReference propertyReference)
        {
            bool strictTypeCheck = true;
            PropertyReference propertyReference1 = SceneNodeObjectSet.FilterProperty((SceneNode)element, propertyReference, strictTypeCheck);

            if (!element.IsViewObjectValid || propertyReference1 == null || propertyReference1.PlatformMetadata != element.Platform.Metadata)
            {
                return;
            }
            AmbientPropertyManager.AmbientPropertyValue ambientPropertyValue = this.GetAmbientPropertyValue(propertyReference1.FirstStep);
            if (ambientPropertyValue == null)
            {
                return;
            }
            using (element.ViewModel.ForceBaseValue())
            {
                if (element.IsSet(propertyReference1) == PropertyState.Unset)
                {
                    ambientPropertyValue.Value = null;
                }
                else
                {
                    DocumentNodePath valueAsDocumentNode = element.GetLocalValueAsDocumentNode(propertyReference1);
                    if (!this.HasValidValue(element.ViewModel, valueAsDocumentNode))
                    {
                        return;
                    }
                    ambientPropertyValue.Value = valueAsDocumentNode.Node;
                }
            }
        }
Ejemplo n.º 16
0
 private void WalkDescendants(DocumentNodePath basisPath, DocumentNodePath rootPath, DocumentNode currentNode, XamlProjectSubscription.XamlDocumentSubscription.NodeChangeCallback callback)
 {
     this.Visit(basisPath, rootPath, currentNode, callback);
     foreach (DocumentNode current in currentNode.DescendantNodes)
     {
         this.Visit(basisPath, rootPath, current, callback);
     }
 }
Ejemplo n.º 17
0
 private bool Register(XamlDocument document, DocumentNodePath nodePath)
 {
     if (document != null && this.GetWatcher(document).Register(nodePath) && !this.chainUpdate.Contains(document))
     {
         this.chainUpdate.Enqueue(document);
     }
     return(true);
 }
Ejemplo n.º 18
0
        protected override DocumentNodePath ProvideEditingContainer(SceneElement targetElement, PropertyReference targetProperty, DocumentNode resourceNode)
        {
            SceneViewModel   viewModel        = targetElement.ViewModel.GetViewModel(resourceNode.DocumentRoot, false);
            DocumentNodePath documentNodePath = targetElement.GetLocalValueAsDocumentNode(targetProperty) ?? new DocumentNodePath(resourceNode.DocumentRoot.RootNode, resourceNode);
            DocumentNode     documentNode     = (viewModel.GetSceneNode(resourceNode) as StyleNode).GetLocalValueAsSceneNode(ControlElement.TemplateProperty).DocumentNode;

            return(documentNodePath.GetPathInContainer((DocumentNode)documentNode.Parent).GetPathInSubContainer(documentNode.SitePropertyKey, documentNode));
        }
        protected override bool IsResourceInUse(LocalResourceModel resourceModel)
        {
            DocumentNodePath valueAsDocumentNode = this.TargetElement.GetLocalValueAsDocumentNode(new PropertyReference(this.GetTargetProperty((ITypeId)resourceModel.ResourceNode.Type)));

            if (valueAsDocumentNode != null)
            {
                return(valueAsDocumentNode.Node == resourceModel.ResourceNode);
            }
            return(false);
        }
Ejemplo n.º 20
0
            private void OnNodeAdded(DocumentNodePath basis, DocumentNode newNode)
            {
                DocumentCompositeNode compositeNode = newNode as DocumentCompositeNode;

                if (compositeNode != null && compositeNode.Type.IsExpression)
                {
                    this.OnExpressionAdded(basis, compositeNode);
                }
                this.ProjectSubscription.OnDocumentNodeAdded((IXamlSubscription)this, newNode, basis);
            }
Ejemplo n.º 21
0
        private string GetPropertyName(DocumentNodePath documentNodePath)
        {
            SetterSceneNode setterSceneNode = this.Parent as SetterSceneNode;

            if (setterSceneNode != null && setterSceneNode.Property != null)
            {
                return(setterSceneNode.Property.Name);
            }
            return(this.GetPropertyNameHelper(documentNodePath) ?? this.TargetType.Name);
        }
Ejemplo n.º 22
0
            protected void OnExpressionRemoved(DocumentNodePath basisPath, DocumentCompositeNode compositeNode)
            {
                DocumentNode node = new ExpressionEvaluator((IDocumentRootResolver)this.ProjectSubscription.ProjectContext).EvaluateExpression(basisPath, (DocumentNode)compositeNode);

                if (node == null || node.DocumentRoot == this.DocumentRoot)
                {
                    return;
                }
                this.ProjectSubscription.Unregister(node.DocumentRoot as XamlDocument, node);
            }
Ejemplo n.º 23
0
        public bool IsResourceReachable(SceneNode sourceNode)
        {
            if (!PlatformTypes.PlatformsCompatible(sourceNode.Type.PlatformMetadata, this.ResourceNode.PlatformMetadata))
            {
                return(false);
            }
            DocumentNodePath documentNodePath = sourceNode.DocumentNodePath;

            return(new ExpressionEvaluator(sourceNode.ViewModel.DocumentRootResolver).EvaluateResource(documentNodePath, this.KeyNode) == this.ValueNode);
        }
Ejemplo n.º 24
0
        protected virtual bool IsResourceInUse(LocalResourceModel resourceModel)
        {
            DocumentNodePath valueAsDocumentNode = this.TargetElement.GetLocalValueAsDocumentNode(this.TargetPropertyReference);

            if (valueAsDocumentNode != null)
            {
                return(valueAsDocumentNode.Node == resourceModel.ResourceNode);
            }
            return(false);
        }
        public override string ToString()
        {
            string           str = this.nodePath.ContainerNode.Type.Name + ":" + this.nodePath.ToString() + "." + this.targetProperty.Name;
            DocumentNodePath containerOwnerPath = this.nodePath.GetContainerOwnerPath();

            if (containerOwnerPath != null)
            {
                str = containerOwnerPath.ToString() + "," + str;
            }
            return(str);
        }
Ejemplo n.º 26
0
        protected override bool InternalCanCreateInstance(ISceneInsertionPoint insertionPoint)
        {
            if (!this.IsInsertionPointValid(insertionPoint))
            {
                return(false);
            }
            SceneNode        sceneNode          = insertionPoint.SceneNode;
            DocumentNodePath documentNodePath   = sceneNode.DocumentNodePath;
            DocumentNode     nodeBeingLookedFor = new ExpressionEvaluator(sceneNode.ViewModel.DocumentRootResolver).EvaluateResource(documentNodePath, this.ResourceModel.KeyNode);

            return(!documentNodePath.Contains(nodeBeingLookedFor));
        }
Ejemplo n.º 27
0
        public static bool PropertyIsExpression(SceneNode element, IPropertyId property)
        {
            DocumentNodePath documentNodePath = (DocumentNodePath)null;

            using (element.ViewModel.ForceBaseValue())
                documentNodePath = element.GetLocalValueAsDocumentNode(property);
            if (documentNodePath != null && documentNodePath.Node != null)
            {
                return(documentNodePath.Node.Type.IsExpression);
            }
            return(false);
        }
Ejemplo n.º 28
0
 private Breadcrumb FindBreadcrumb(SceneElement targetElement)
 {
     foreach (Breadcrumb breadcrumb in (Collection <Breadcrumb>) this.Trail)
     {
         DocumentNodePath selectedElementPath = breadcrumb.SelectedElementPath;
         if (selectedElementPath != null && selectedElementPath.Equals((object)targetElement.DocumentNodePath))
         {
             return(breadcrumb);
         }
     }
     return((Breadcrumb)null);
 }
Ejemplo n.º 29
0
        private static DocumentNodePath RecreatePath(DocumentNodePath path, IList <DocumentNode> containers, IList <DocumentNode> containerOwners, IList <IProperty> containerProperties, DocumentNode childNode)
        {
            DocumentNodePath documentNodePath = path;

            if (containers != null)
            {
                for (int index = 0; index < containers.Count; ++index)
                {
                    documentNodePath = documentNodePath.GetPathInContainer(containerOwners[index]).GetPathInSubContainer(containerProperties[index], containers[index]);
                }
            }
            return(documentNodePath.GetPathInContainer(childNode));
        }
Ejemplo n.º 30
0
        private static SceneNode SetActiveEditingContainerInternal(ControlStylingOperations.EditScope scope)
        {
            SceneViewModel viewModel = scope.TargetElement.ViewModel.GetViewModel(scope.Node.DocumentRoot, true);

            if (viewModel == null)
            {
                return((SceneNode)null);
            }
            SceneElement selectionToSet = (SceneElement)viewModel.GetSceneNode(scope.Node);

            if (selectionToSet.IsLocked)
            {
                using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitEditStyleTemplate, new object[1]
                {
                    (object)scope.TargetProperty.Name
                })))
                {
                    selectionToSet.IsLocked = false;
                    editTransaction.Commit();
                }
            }
            if (viewModel == scope.TargetElement.ViewModel && scope.EditInPlace)
            {
                if (scope.NodePath != null)
                {
                    viewModel.ActiveEditingContainerPath = scope.NodePath;
                }
            }
            else
            {
                IPropertyId ancestorPropertyKey = (IPropertyId)scope.TargetProperty;
                if (scope.NodePath != null)
                {
                    DocumentNodePath documentNodePath = scope.NodePath;
                    ancestorPropertyKey = (IPropertyId)documentNodePath.ContainerOwnerProperty;
                    while ((documentNodePath = documentNodePath.GetContainerOwnerPath()) != null && documentNodePath.Node != scope.TargetElement.DocumentNode)
                    {
                        ancestorPropertyKey = (IPropertyId)documentNodePath.ContainerOwnerProperty;
                    }
                }
                BaseFrameworkElement frameworkElement = scope.TargetElement as BaseFrameworkElement;
                Size preferredSize = frameworkElement == null || !frameworkElement.IsViewObjectValid || !ControlStylingOperations.DoesPropertyAffectRoot((IPropertyId)scope.TargetProperty) ? Size.Empty : frameworkElement.GetComputedBounds((Base2DElement)frameworkElement).Size;
                viewModel.SetViewRoot(scope.TargetElement.ViewModel.DefaultView, scope.TargetElement, ancestorPropertyKey, scope.Node, preferredSize);
                viewModel.DefaultView.EnsureDesignSurfaceVisible();
            }
            if (viewModel.IsEditable)
            {
                viewModel.ElementSelectionSet.SetSelection(selectionToSet);
            }
            return(viewModel.ActiveEditingContainer);
        }