public static void DeleteStateGroup(SceneNode ownerNode, VisualStateGroupSceneNode nodeToRemove) { IList <VisualStateGroupSceneNode> stateGroups = VisualStateManagerSceneNode.GetStateGroups(ownerNode); stateGroups.Remove(nodeToRemove); if (stateGroups.Count != 0) { return; } ownerNode.ClearLocalValue(VisualStateManagerSceneNode.VisualStateGroupsProperty); }
public static void DeleteAnnotation(AnnotationSceneNode nodeToRemove) { SceneNode parent = nodeToRemove.Parent; IList <AnnotationSceneNode> annotations = AnnotationManagerSceneNode.GetAnnotations(parent); annotations.Remove(nodeToRemove); if (annotations.Count != 0) { return; } parent.ClearLocalValue(AnnotationManagerSceneNode.AnnotationsProperty); }
public static DataContextInfo FindDataContextPlacement(SceneNode sceneNode, IProperty targetProperty, DataSourceInfo dataSourceInfo) { DataContextInfo dataContextInfo = new DataContextEvaluator().Evaluate(sceneNode, (IPropertyId)targetProperty, true); if (!dataContextInfo.IsValid) { return((DataContextInfo)null); } if (dataContextInfo.Owner != null) { dataContextInfo.DataSourceMatch = dataContextInfo.DataSource.CompareSources(dataSourceInfo); if (dataContextInfo.DataSourceMatch == DataSourceMatchCriteria.Ignore) { using (sceneNode.ViewModel.CreateEditTransaction("", true)) { if (targetProperty != null) { sceneNode.ClearLocalValue((IPropertyId)targetProperty); } if (DataContextPlacementEvaluator.IsAnySourcelessBindings(sceneNode)) { return((DataContextInfo)null); } SceneNode sourcelessBindings = DataContextPlacementEvaluator.FindHighestDataContextLocationWithoutSourcelessBindings(dataContextInfo.GetOwnerSceneNode(sceneNode.ViewModel), sceneNode); if (sourcelessBindings == null) { dataContextInfo.Owner = (DocumentCompositeNode)null; dataContextInfo.Property = (IProperty)null; dataContextInfo.DataSourceMatch = DataSourceMatchCriteria.Ignore; } else { dataContextInfo.Owner = (DocumentCompositeNode)sourcelessBindings.DocumentNode; dataContextInfo.Property = DataContextHelper.GetDataContextProperty(dataContextInfo.Owner.Type); dataContextInfo.DataSourceMatch = DataSourceMatchCriteria.Any; } } } } else { SceneNode highestDataContextHost = DataContextPlacementEvaluator.GetHighestDataContextHost(sceneNode); if (highestDataContextHost == null) { return((DataContextInfo)null); } dataContextInfo = new DataContextInfo(); dataContextInfo.Owner = (DocumentCompositeNode)highestDataContextHost.DocumentNode; dataContextInfo.DataSourceMatch = DataSourceMatchCriteria.Any; } return(dataContextInfo); }
public static Dictionary <IPropertyId, SceneNode> StoreProperties(SceneNode sourceNode, IEnumerable <IPropertyId> propertyFilter, bool detachProperties) { Dictionary <IPropertyId, SceneNode> dictionary = new Dictionary <IPropertyId, SceneNode>(); List <IPropertyId> list = new List <IPropertyId>(); ReadOnlyCollection <IPropertyId> contentProperties = sourceNode.ContentProperties; DocumentCompositeNode documentCompositeNode = sourceNode.DocumentNode as DocumentCompositeNode; if (documentCompositeNode != null) { if (propertyFilter == null) { foreach (IPropertyId propertyId in (IEnumerable <IProperty>)documentCompositeNode.Properties.Keys) { list.Add(propertyId); } } else { foreach (IPropertyId propertyId in propertyFilter) { IProperty property = sourceNode.ProjectContext.ResolveProperty(propertyId); if (property != null && documentCompositeNode.Properties.Keys.Contains(property)) { list.Add((IPropertyId)property); } } } } foreach (IPropertyId propertyId in list) { if (!contentProperties.Contains(propertyId)) { DocumentNode node; using (sourceNode.ViewModel.ForceBaseValue()) node = sourceNode.GetLocalValueAsDocumentNode(propertyId).Node; if (node != null) { if (detachProperties) { DocumentNodeHelper.PreserveFormatting(node); sourceNode.ClearLocalValue(propertyId); } else { node = node.Clone(sourceNode.DocumentContext); } dictionary.Add(propertyId, sourceNode.ViewModel.GetSceneNode(node)); } } } return(dictionary); }
protected override void ModifyValue(PropertyReference propertyReference, object valueToSet, SceneNode.Modification modification, int index) { base.ModifyValue(propertyReference, valueToSet, modification, index); if (this.ViewModel.ActiveEditContext != null && propertyReference != null) { if (this.ViewModel.ActiveEditContext.OutOfPlaceOverriddenProperties == null) { this.ViewModel.ActiveEditContext.OutOfPlaceOverriddenProperties = (ICollection <IProperty>) new HashSet <IProperty>(); } if (!this.ViewModel.ActiveEditContext.OutOfPlaceOverriddenProperties.Contains((IProperty)propertyReference.FirstStep)) { this.ViewModel.ActiveEditContext.OutOfPlaceOverriddenProperties.Add((IProperty)propertyReference.FirstStep); } } if (this.ViewModel.AnimationEditor.IsCurrentlyAnimated((SceneNode)this, propertyReference, propertyReference.Count)) { return; } IViewObject viewTargetElement = this.ViewTargetElement; if (viewTargetElement == null) { return; } DocumentNode correspondingDocumentNode = this.ViewModel.DefaultView.GetCorrespondingDocumentNode(viewTargetElement, false); if (correspondingDocumentNode == null || correspondingDocumentNode == this.DocumentNode || (!correspondingDocumentNode.IsInDocument || correspondingDocumentNode.DocumentRoot != this.ViewModel.DocumentRoot)) { return; } SceneNode sceneNode = this.ViewModel.GetSceneNode(correspondingDocumentNode); ReferenceStep referenceStep = propertyReference[0]; if (sceneNode == null || referenceStep.MemberType == MemberType.DesignTimeProperty || (!referenceStep.TargetType.IsAssignableFrom(sceneNode.TargetType) || sceneNode.IsSet((IPropertyId)referenceStep) != PropertyState.Set)) { return; } sceneNode.ClearLocalValue((IPropertyId)referenceStep); }