Exemplo n.º 1
0
        private bool FindAncestor(SceneNode child, out SceneNode ancestor, ref PropertyReference propertyReference, Predicate <SceneNode> predicate)
        {
            ancestor = child;
            if (predicate(ancestor))
            {
                return(true);
            }
            SceneNode sceneNode = child;

            while (sceneNode != null && !predicate(sceneNode))
            {
                sceneNode = sceneNode.Parent;
            }
            ancestor = sceneNode;
            if (ancestor == null || ancestor.DocumentNode.Marker == null || ancestor.DocumentNode.DocumentRoot != child.DocumentNode.DocumentRoot)
            {
                return(false);
            }
            Stack <ReferenceStep> input = DocumentNodeMarkerUtilities.PropertyReferencePath(child.DocumentNode.Marker, ancestor.DocumentNode.Marker);

            propertyReference = new PropertyReference(input).Append(propertyReference);
            return(true);
        }
Exemplo n.º 2
0
        private void FireSelectivePropertyChangedEvents(SceneUpdatePhaseEventArgs args)
        {
            SceneNode[] selectedNodes = this.designerContext.SelectionManager.SelectedNodes;
            DocumentNodeMarkerSortedList markerSortedList;

            if (selectedNodes == null)
            {
                markerSortedList = new DocumentNodeMarkerSortedList();
            }
            else
            {
                markerSortedList = new DocumentNodeMarkerSortedList(selectedNodes.Length);
                foreach (SceneNode sceneNode in selectedNodes)
                {
                    TextRangeElement          textRangeElement  = sceneNode as TextRangeElement;
                    BehaviorTriggerActionNode triggerActionNode = sceneNode as BehaviorTriggerActionNode;
                    if (textRangeElement != null)
                    {
                        this.FireAllPropertyChangedEvents(args);
                        return;
                    }
                    if (triggerActionNode != null && triggerActionNode.Parent != null)
                    {
                        markerSortedList.Add(triggerActionNode.Parent.DocumentNode.Marker);
                    }
                    markerSortedList.Add(sceneNode.DocumentNode.Marker);
                }
            }
            foreach (DocumentNodeChange documentNodeChange in args.DocumentChanges.DistinctChanges)
            {
                if (SceneView.HandleAnimationChanges(args.ViewModel, documentNodeChange, new SceneView.HandleAnimationChange(this.InvalidatePropertyFromAnimationChange)) == SceneView.AnimationChangeResult.InvalidateAll)
                {
                    this.FireAllPropertyChangedEvents(args);
                    return;
                }
            }
            if (this.designerContext.SelectionManager.SecondarySelectedNodes != null)
            {
                foreach (SceneNode sceneNode in this.designerContext.SelectionManager.SecondarySelectedNodes)
                {
                    if (sceneNode.DocumentNode.Marker != null)
                    {
                        markerSortedList.Add(sceneNode.DocumentNode.Marker);
                    }
                }
            }
            foreach (DocumentNodeMarkerSortedListBase.IntersectionResult intersectionResult in args.DocumentChanges.Intersect((DocumentNodeMarkerSortedListBase)markerSortedList, DocumentNodeMarkerSortedListBase.Flags.ContainedBy))
            {
                Stack <ReferenceStep> input = DocumentNodeMarkerUtilities.PropertyReferencePath(args.DocumentChanges.MarkerAt(intersectionResult.LeftHandSideIndex), markerSortedList.MarkerAt(intersectionResult.RightHandSideIndex));
                if (input.Count > 0)
                {
                    PropertyReference propertyReference1 = new PropertyReference(input);
                    this.AddPropertyReferenceToSortedList(propertyReference1, this.changedPropertyReferences);
                    if (PlatformTypes.Style.IsAssignableFrom(propertyReference1.FirstStep.DeclaringTypeId))
                    {
                        int startIndex;
                        for (startIndex = 0; startIndex < propertyReference1.Count; ++startIndex)
                        {
                            if (PlatformTypes.Setter.IsAssignableFrom(propertyReference1.ReferenceSteps[startIndex].DeclaringTypeId))
                            {
                                ++startIndex;
                                break;
                            }
                        }
                        foreach (SceneChange sceneChange in SceneChange.ChangesOfType <SceneChange>(args.DocumentChanges, args.ViewModel.RootNode))
                        {
                            PropertyReferenceSceneChange referenceSceneChange = sceneChange as PropertyReferenceSceneChange;
                            if (referenceSceneChange != null && referenceSceneChange.PropertyChanged != null)
                            {
                                PropertyReference propertyReference2 = referenceSceneChange.PropertyChanged.Subreference(0);
                                if (startIndex < propertyReference1.Count)
                                {
                                    propertyReference2 = propertyReference2.Append(propertyReference1.Subreference(startIndex));
                                }
                                this.AddPropertyReferenceToSortedList(propertyReference2, this.changedPropertyReferences);
                            }
                        }
                    }
                }
            }
            this.FireSelectivePropertyChangedEventsWorker(args.DirtyViewState);
        }