Exemple #1
0
        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 OnCatastrophicUpdate()
        {
            DocumentNodeMarkerSortedListOf <DocumentNodePath> immediateBasisNodes = this.ImmediateBasisNodes;

            if (this.CatastrophicUpdate != null)
            {
                this.CatastrophicUpdate((object)this, EventArgs.Empty);
            }
            this.Clear();
            this.newBasisNodes = immediateBasisNodes;
        }
 public void Clear()
 {
     foreach (IDisposable disposable in this.watchers.Values)
     {
         disposable.Dispose();
     }
     this.watchers.Clear();
     this.chainUpdate.Clear();
     this.basisNodes.Clear();
     this.newBasisNodes = (DocumentNodeMarkerSortedListOf <DocumentNodePath>)null;
 }
 public XamlProjectSubscription(DesignerContext designerContext, IProjectContext projectContext, SearchPath sceneSearch, XamlProjectSubscription.DocumentNodeFilter documentSearch)
 {
     this.designerContext = designerContext;
     this.projectContext  = projectContext;
     this.sceneSearch     = sceneSearch;
     this.documentSearch  = documentSearch;
     this.watchers        = new Dictionary <XamlDocument, IXamlSubscription>();
     this.chainUpdate     = new Queue <XamlDocument>();
     this.basisNodes      = new DocumentNodeMarkerSortedListOf <DocumentNodePath>();
     this.designerContext.ViewService.ViewClosed += new ViewEventHandler(this.ViewService_ViewOpenedOrClosed);
     this.designerContext.ViewService.ViewOpened += new ViewEventHandler(this.ViewService_ViewOpenedOrClosed);
 }
        public MarkerBasedSceneNodeCollection(SceneViewModel viewModel, ICollection <T> otherList)
        {
            this.viewModel = viewModel;
            MarkerBasedSceneNodeCollection <T> sceneNodeCollection = otherList as MarkerBasedSceneNodeCollection <T>;

            if (sceneNodeCollection != null)
            {
                this.markers = new DocumentNodeMarkerSortedListOf <DocumentNode>(sceneNodeCollection.markers);
            }
            else
            {
                this.markers = new DocumentNodeMarkerSortedListOf <DocumentNode>();
                foreach (T node in (IEnumerable <T>)otherList)
                {
                    if ((object)node != null && this.IsElementValid(node))
                    {
                        this.markers.Add(node.DocumentNode.Marker, node.DocumentNode);
                    }
                }
            }
        }
 public void Update()
 {
     if (this.newBasisNodes != null)
     {
         foreach (DocumentNodeMarkerSortedListBase.IntersectionResult intersectionResult in this.basisNodes.UnionIdentity((DocumentNodeMarkerSortedListBase)this.newBasisNodes))
         {
             if (intersectionResult.LeftHandSideIndex == -1)
             {
                 DocumentNodePath nodePath = this.newBasisNodes.ValueAt(intersectionResult.RightHandSideIndex);
                 this.Register(nodePath.RootNode.DocumentRoot as XamlDocument, nodePath);
             }
             if (intersectionResult.RightHandSideIndex == -1)
             {
                 DocumentNodePath documentNodePath = this.basisNodes.ValueAt(intersectionResult.LeftHandSideIndex);
                 this.Unregister(documentNodePath.RootNode.DocumentRoot as XamlDocument, documentNodePath.Node);
             }
         }
     }
     this.basisNodes    = this.newBasisNodes;
     this.newBasisNodes = (DocumentNodeMarkerSortedListOf <DocumentNodePath>)null;
     this.UpdateInternal();
 }
 public MarkerBasedSceneNodeCollection(SceneViewModel viewModel, DocumentNodeMarkerSortedListOf <DocumentNode> other)
 {
     this.viewModel = viewModel;
     this.markers   = new DocumentNodeMarkerSortedListOf <DocumentNode>(other);
 }
 public void SetBasisNodes(DocumentNodeMarkerSortedListOf <DocumentNodePath> newBasisNodes)
 {
     this.newBasisNodes = newBasisNodes;
 }
Exemple #9
0
        public void ChainUpdate(SceneViewModel viewModel, DocumentNodeMarkerSortedListBase newBasisNodes, IEnumerable <SceneNode> bonusBasisNodes, DocumentNodeChangeList damage, uint damageChangeStamp)
        {
            this.ValidateBasisNodeStateWithViewModel(viewModel);
            if (this.currentViewModel == null)
            {
                return;
            }
            SearchScope searchScope = (SearchScope)6;
            SearchScope scope       = this.path.Scope;
            bool        flag1       = (scope & searchScope) != scope;
            bool        flag2       = false;

            if (this.path.NumberOfSteps == 1)
            {
                SearchStep searchStep = this.path.Step(0);
                if (searchStep.Axis == SearchAxis.DocumentDescendant && (searchStep.Predicate.AnalysisScope & (SearchScope)6) == searchStep.Predicate.AnalysisScope)
                {
                    flag2 = true;
                }
            }
            if (newBasisNodes != null || bonusBasisNodes != null)
            {
                DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .BasisNodeHolder> newBasisNodeList = new DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .BasisNodeHolder>(newBasisNodes.Count);
                if (newBasisNodes != null)
                {
                    for (int index = 0; index < newBasisNodes.Count; ++index)
                    {
                        newBasisNodeList.Add(newBasisNodes.MarkerAt(index), (SceneNodeSubscription <basisT, pathT> .BasisNodeHolder)null);
                    }
                }
                if (bonusBasisNodes != null)
                {
                    foreach (SceneNode sceneNode in bonusBasisNodes)
                    {
                        newBasisNodeList.Add(sceneNode.DocumentNode.Marker, (SceneNodeSubscription <basisT, pathT> .BasisNodeHolder)null);
                    }
                }
                this.SetBasisNodesWorker(viewModel, newBasisNodeList);
            }
            foreach (DocumentNodeMarkerSortedListBase.IntersectionResult intersectionResult in this.pathNodeList.Intersect((DocumentNodeMarkerSortedListBase)damage, DocumentNodeMarkerSortedListBase.Flags.Contains))
            {
                this.OnPathNodeContentChanged(this.pathNodeList.ValueAt(intersectionResult.LeftHandSideIndex), damage.MarkerAt(intersectionResult.RightHandSideIndex), damage.ValueAt(intersectionResult.RightHandSideIndex));
            }
            if (flag1)
            {
                this.Recalculate(viewModel);
            }
            else
            {
                for (int index = this.basisNodeList.Count - 1; index >= 0; --index)
                {
                    if (this.basisNodeList.MarkerAt(index).IsDeleted)
                    {
                        this.RemoveBasisNode(index);
                    }
                    else if (flag2)
                    {
                        this.IncrementalRecalculateBasisNode(index, damage, damageChangeStamp);
                    }
                    else
                    {
                        this.RecalculateBasisNode(index);
                    }
                }
            }
        }
Exemple #10
0
        public void SetBasisNodes(SceneViewModel viewModel, IEnumerable <SceneNode> basisNodes)
        {
            DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .BasisNodeHolder> newBasisNodeList = new DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .BasisNodeHolder>();

            foreach (SceneNode sceneNode in basisNodes)
            {
                if (sceneNode != null)
                {
                    newBasisNodeList.Add(sceneNode.DocumentNode.Marker, (SceneNodeSubscription <basisT, pathT> .BasisNodeHolder)null);
                }
            }
            this.SetBasisNodesWorker(viewModel, newBasisNodeList);
        }
Exemple #11
0
 public void SetSceneRootNodeAsTheBasisNode(SceneViewModel viewModel)
 {
     if (viewModel.RootNode == null)
     {
         this.ClearBasisNodes();
     }
     else
     {
         DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .BasisNodeHolder> newBasisNodeList = new DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .BasisNodeHolder>();
         newBasisNodeList.Add(viewModel.RootNode.DocumentNode.Marker, (SceneNodeSubscription <basisT, pathT> .BasisNodeHolder)null);
         this.SetBasisNodesWorker(viewModel, newBasisNodeList);
     }
 }
Exemple #12
0
 public SceneNodeSubscription()
 {
     this.pathNodeList  = new DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .PathNodeHolder>();
     this.basisNodeList = new DocumentNodeMarkerSortedListOf <SceneNodeSubscription <basisT, pathT> .BasisNodeHolder>();
 }
Exemple #13
0
        public void Update(SceneViewModel targetViewModel, SceneViewModel.ViewStateBits viewStateBits)
        {
            bool flag1 = (viewStateBits & SceneViewModel.ViewStateBits.ElementSelection) != SceneViewModel.ViewStateBits.None;

            if (targetViewModel != null && !targetViewModel.Document.IsEditable)
            {
                targetViewModel = (SceneViewModel)null;
            }
            if (targetViewModel != this.lastViewModel)
            {
                if (this.subscription == null || targetViewModel == null || this.subscription.ProjectContext != targetViewModel.ProjectContext)
                {
                    if (this.subscription != null)
                    {
                        this.subscription.PathNodeInserted   -= new XamlProjectSubscription.DocumentNodeInsertedHandler(this.Subscription_PathNodeInserted);
                        this.subscription.PathNodeRemoved    -= new XamlProjectSubscription.DocumentNodeRemovedHandler(this.Subscription_PathNodeRemoved);
                        this.subscription.CatastrophicUpdate -= new EventHandler(this.Subscription_Refresh);
                        this.subscription.Dispose();
                        this.subscription = (XamlProjectSubscription)null;
                    }
                    if (targetViewModel != null)
                    {
                        this.subscription = new XamlProjectSubscription(this.ResourceManager.DesignerContext, targetViewModel.ProjectContext, new SearchPath(new SearchStep[2]
                        {
                            new SearchStep((SearchAxis) new DelegateAxis(new DelegateAxis.EnumerationHandler(this.FilterScopeEnumerator), SearchScope.NodeTreeSelf)),
                            new SearchStep((SearchAxis) new DelegateAxis(new DelegateAxis.EnumerationHandler(this.FilteredResourceEnumerator), SearchScope.NodeTreeDescendant))
                        }), new XamlProjectSubscription.DocumentNodeFilter(this.FilteredDocumentNodeEnumerator));
                        this.subscription.PathNodeInserted   += new XamlProjectSubscription.DocumentNodeInsertedHandler(this.Subscription_PathNodeInserted);
                        this.subscription.PathNodeRemoved    += new XamlProjectSubscription.DocumentNodeRemovedHandler(this.Subscription_PathNodeRemoved);
                        this.subscription.CatastrophicUpdate += new EventHandler(this.Subscription_Refresh);
                    }
                }
                else
                {
                    this.subscription.Clear();
                }
                this.ClearItems();
                this.lastViewModel = targetViewModel;
                this.lastSelection.Clear();
                flag1 = true;
            }
            if (this.lastViewModel == null || !flag1)
            {
                return;
            }
            DocumentNodeMarkerSortedListOf <DocumentNodePath> newBasisNodes = new DocumentNodeMarkerSortedListOf <DocumentNodePath>(this.Selection.Count);

            foreach (SceneNode sceneNode in this.Selection.Selection)
            {
                DocumentNodeMarker marker           = sceneNode.DocumentNode.Marker;
                DocumentNodePath   documentNodePath = this.lastSelection.Find(marker) ?? sceneNode.DocumentNodePath;
                newBasisNodes.Add(marker, documentNodePath);
            }
            bool flag2 = true;

            foreach (DocumentNodeMarker marker in this.lastSelection.Markers)
            {
                if (newBasisNodes.Find(marker) == null)
                {
                    flag2 = false;
                    break;
                }
            }
            if (!flag2)
            {
                this.subscription.Clear();
                this.ClearItems();
            }
            this.subscription.SetBasisNodes(newBasisNodes);
            this.lastSelection = newBasisNodes;
            this.subscription.Update();
            this.ResourceManager.SelectedItems.RemoveSelection((ResourceEntryBase)this);
            this.OnPropertyChanged("Name");
            this.OnPropertyChanged("Type");
            this.OnPropertyChanged("UniqueId");
            this.OnPropertyChanged("ToolTip");
        }