private void RecalculateBasisNode(int index) { SceneNodeSubscription <basisT, pathT> .BasisNodeHolder basisNodeHolder = this.basisNodeList.ValueAt(index); if ((int)this.currentViewModel.XamlDocument.ChangeStamp == (int)basisNodeHolder.lastRecalcChangeStamp) { return; } SceneNodeSubscription <basisT, pathT> .BasisNodeInfo basisNodeInfo = this.BasisNodeAt(index); DocumentNodeMarkerSortedList markerSortedList = basisNodeHolder.PathNodeList; basisNodeHolder.PathNodeList = SceneNode.GetMarkerList <SceneNode>(this.path.Query(basisNodeHolder.Node), true); foreach (DocumentNodeMarkerSortedListBase.IntersectionResult intersectionResult in markerSortedList.UnionIdentity((DocumentNodeMarkerSortedListBase)basisNodeHolder.PathNodeList)) { if (intersectionResult.RightHandSideIndex == -1) { this.RemovePathNode(basisNodeInfo, this.pathNodeList.FindPosition(markerSortedList.MarkerAt(intersectionResult.LeftHandSideIndex))); } else if (intersectionResult.LeftHandSideIndex == -1) { DocumentNodeMarker newMarker = basisNodeHolder.PathNodeList.MarkerAt(intersectionResult.RightHandSideIndex); this.AddPathNode(basisNodeInfo, newMarker); } } basisNodeHolder.lastRecalcChangeStamp = this.currentViewModel.XamlDocument.ChangeStamp; }
private void IncrementalRecalculateBasisNode(int index, DocumentNodeChangeList damage, uint documentChangeStamp) { SceneNodeSubscription <basisT, pathT> .BasisNodeHolder basisNodeHolder = this.basisNodeList.ValueAt(index); DocumentNodeMarker ancestor = this.basisNodeList.MarkerAt(index); if ((int)basisNodeHolder.lastRecalcChangeStamp == (int)documentChangeStamp) { return; } SceneNodeSubscription <basisT, pathT> .BasisNodeInfo basisNodeInfo = this.BasisNodeAt(index); if (damage.Count == 0) { this.RecalculateBasisNode(index); } foreach (int index1 in damage.FindDescendants(ancestor)) { DocumentNodeMarker documentNodeMarker = damage.MarkerAt(index1); if (documentNodeMarker.IsDeleted) { this.RemovePathNodes(basisNodeInfo, documentNodeMarker); basisNodeHolder.PathNodeList.RemoveSelfAndDescendants(documentNodeMarker); } else { foreach (SceneNode sceneNode in this.IncrementalTraverseWithSearchPath(basisNodeHolder.Node, documentNodeMarker)) { this.AddPathNode(basisNodeInfo, sceneNode.DocumentNode.Marker); basisNodeHolder.PathNodeList.Add(sceneNode.DocumentNode.Marker); } } } basisNodeHolder.lastRecalcChangeStamp = documentChangeStamp; }
private void SetBasisNodesWorker(SceneViewModel viewModel, DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .BasisNodeHolder> newBasisNodeList) { this.ValidateBasisNodeStateWithViewModel(viewModel); DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .BasisNodeHolder> markerSortedListOf = this.basisNodeList; this.basisNodeList = newBasisNodeList; foreach (DocumentNodeMarkerSortedListBase.IntersectionResult intersectionResult in markerSortedListOf.UnionIdentity((DocumentNodeMarkerSortedListBase)this.basisNodeList)) { if (intersectionResult.RightHandSideIndex == -1) { this.OnBasisNodeRemoved(markerSortedListOf.ValueAt(intersectionResult.LeftHandSideIndex)); this.CleanOutPathNodesForBasisNode(markerSortedListOf.ValueAt(intersectionResult.LeftHandSideIndex), -1); } else if (intersectionResult.LeftHandSideIndex == -1) { SceneNodeSubscription <basisT, pathT> .BasisNodeHolder holder = new SceneNodeSubscription <basisT, pathT> .BasisNodeHolder(this.currentViewModel.GetSceneNode(this.basisNodeList.MarkerAt(intersectionResult.RightHandSideIndex).Node), default(basisT)); this.basisNodeList.SetValueAt(intersectionResult.RightHandSideIndex, holder); this.FireBasisNodeInsertedHandler(holder); this.OnBasisNodeInserted(holder); this.RecalculateBasisNode(intersectionResult.RightHandSideIndex); } else { this.basisNodeList.SetValueAt(intersectionResult.RightHandSideIndex, markerSortedListOf.ValueAt(intersectionResult.LeftHandSideIndex)); } } }
private void RemoveBasisNode(int index) { SceneNodeSubscription <basisT, pathT> .BasisNodeHolder basisNodeHolder = this.basisNodeList.ValueAt(index); this.OnBasisNodeRemoved(basisNodeHolder); this.CleanOutPathNodesForBasisNode(basisNodeHolder, index); this.basisNodeList.RemoveAt(index); }
private void OnPathNodeContentChanged(SceneNodeSubscription <basisT, pathT> .PathNodeHolder holder, DocumentNodeMarker damageMarker, DocumentNodeChange damage) { ++this.pathNodesChangeStamp; if (this.PathNodeContentChanged == null) { return; } this.PathNodeContentChanged((object)this, holder.Node, holder.Content, damageMarker, damage); }
private void OnBasisNodeInserted(SceneNodeSubscription <basisT, pathT> .BasisNodeHolder holder) { ++this.basisNodesChangeStamp; if (this.BasisNodeInserted == null) { return; } this.BasisNodeInserted((object)this, holder.Node, holder.Content); }
private void OnPathNodeRemoved(SceneNodeSubscription <basisT, pathT> .BasisNodeInfo basisNodeInfo, SceneNodeSubscription <basisT, pathT> .PathNodeHolder holder) { ++this.pathNodesChangeStamp; if (this.PathNodeRemoved == null) { return; } this.PathNodeRemoved((object)this, basisNodeInfo.Node, basisNodeInfo.Info, holder.Node, holder.Content); }
public SceneNodeSubscription <basisT, pathT> .PathNodeInfo PathNodeAt(int index) { SceneNodeSubscription <basisT, pathT> .PathNodeHolder pathNodeHolder = this.pathNodeList.ValueAt(index); return(new SceneNodeSubscription <basisT, pathT> .PathNodeInfo() { Index = index, Info = pathNodeHolder.Content, Node = pathNodeHolder.Node }); }
private void FirePathNodeInsertedHandler(SceneNodeSubscription <basisT, pathT> .BasisNodeInfo basisNodeInfo, SceneNodeSubscription <basisT, pathT> .PathNodeHolder holder) { if (this.pathNodeInsertedHandler != null) { holder.Content = this.pathNodeInsertedHandler((object)this, basisNodeInfo.Node, basisNodeInfo.Info, holder.Node); } else { holder.Content = default(pathT); } }
private void FireBasisNodeInsertedHandler(SceneNodeSubscription <basisT, pathT> .BasisNodeHolder holder) { if (this.basisNodeInsertedHandler != null) { holder.Content = this.basisNodeInsertedHandler((object)this, holder.Node); } else { holder.Content = default(basisT); } }
private void RemovePathNode(SceneNodeSubscription <basisT, pathT> .BasisNodeInfo basisNodeInfo, int pathNodeListIndex) { SceneNodeSubscription <basisT, pathT> .PathNodeHolder holder = this.pathNodeList.ValueAt(pathNodeListIndex); --holder.ReferenceCount; if (holder.ReferenceCount != 0) { return; } this.pathNodeList.RemoveAt(pathNodeListIndex); this.OnPathNodeRemoved(basisNodeInfo, holder); }
public IEnumerable <SceneNodeSubscription <basisT, pathT> .PathNodeInfo> PathNodesFor(SceneNode basisNode) { SceneNodeSubscription <basisT, pathT> .BasisNodeHolder holder = this.basisNodeList.Find(basisNode.DocumentNode.Marker); if (holder != null) { foreach (DocumentNodeMarker marker in holder.PathNodeList.Markers) { int index = this.pathNodeList.FindPosition(marker); yield return(this.PathNodeAt(index)); } } }
private void CleanOutPathNodesForBasisNode(SceneNodeSubscription <basisT, pathT> .BasisNodeHolder basisNodeHolder, int basisNodeIndex) { SceneNodeSubscription <basisT, pathT> .BasisNodeInfo basisNodeInfo = new SceneNodeSubscription <basisT, pathT> .BasisNodeInfo() { Index = basisNodeIndex, Info = basisNodeHolder.Content, Node = basisNodeHolder.Node }; foreach (DocumentNodeMarker ancestor in basisNodeHolder.PathNodeList.Markers) { this.RemovePathNodes(basisNodeInfo, ancestor); } }
private void RemovePathNodes(SceneNodeSubscription <basisT, pathT> .BasisNodeInfo basisNodeInfo, DocumentNodeMarker ancestor) { foreach (int index in this.pathNodeList.FindSelfAndDescendants(ancestor)) { SceneNodeSubscription <basisT, pathT> .PathNodeHolder holder = this.pathNodeList.ValueAt(index); --holder.ReferenceCount; if (holder.ReferenceCount == 0) { this.OnPathNodeRemoved(basisNodeInfo, holder); } } this.pathNodeList.RemoveSelfAndDescendants(ancestor); }
public void InsertBasisNode(SceneNode newBasisNode) { this.ValidateBasisNodeStateWithViewModel(newBasisNode.ViewModel); if (newBasisNode == null || this.basisNodeList.FindPosition(newBasisNode.DocumentNode.Marker) >= 0) { return; } SceneNodeSubscription <basisT, pathT> .BasisNodeHolder holder = new SceneNodeSubscription <basisT, pathT> .BasisNodeHolder(newBasisNode, default(basisT)); int index = this.basisNodeList.Add(newBasisNode.DocumentNode.Marker, holder); this.FireBasisNodeInsertedHandler(holder); this.OnBasisNodeInserted(holder); this.RecalculateBasisNode(index); }
private void AddPathNode(SceneNodeSubscription <basisT, pathT> .BasisNodeInfo basisNodeInfo, DocumentNodeMarker newMarker) { SceneNodeSubscription <basisT, pathT> .PathNodeHolder pathNodeHolder = this.pathNodeList.Find(newMarker); if (pathNodeHolder != null) { ++pathNodeHolder.ReferenceCount; } else { SceneNodeSubscription <basisT, pathT> .PathNodeHolder holder = new SceneNodeSubscription <basisT, pathT> .PathNodeHolder(default(pathT), this.currentViewModel.GetSceneNode(newMarker.Node), 1); this.pathNodeList.Add(newMarker, holder); this.FirePathNodeInsertedHandler(basisNodeInfo, holder); this.OnPathNodeInserted(basisNodeInfo, holder); } }
public void SetPathNodeInsertedHandler(SceneNodeSubscription <basisT, pathT> .PathNodeInsertedHandler value) { this.pathNodeInsertedHandler = value; }