private void OnDeleteCluster(ClusterTreeNode clusterNode) { // avoid many intermediate updates myTransformationsObserver.ModuleChanged -= OnTransformationsChanged; var operation = new ChangeClusterAssignment(myPresentation); operation.Execute(t => t.HideCluster(clusterNode.Id)); // update tree { Root.Children.Remove(clusterNode); if (clusterNode.Id == SelectedCluster) { SelectedCluster = null; } foreach (var treeNode in clusterNode.Children) { myNodeToClusterCache.Remove(treeNode.Id); } } myTransformationsObserver.ModuleChanged += OnTransformationsChanged; }
private void OnAddNodesToCluster() { // avoid many intermediate updates myTransformationsObserver.ModuleChanged -= OnTransformationsChanged; var nodes = PreviewNodes .Cast <NodeWithCaption>() .Select(n => n.Node.Id) .ToList(); var operation = new ChangeClusterAssignment(myPresentation); operation.Execute(t => t.AddToCluster(nodes, SelectedCluster)); // update tree { var clusterNode = Root.Children.Single(n => n.Id == SelectedCluster); var captionModule = myPresentation.GetModule <ICaptionModule>(); var newTreeNodes = nodes .Select(n => new ClusterTreeNode(myPresentation) { Parent = clusterNode, Id = n, Caption = captionModule.Get(n).DisplayText, IsDropAllowed = false, ShowId = TreeShowId }); clusterNode.Children.AddRange(newTreeNodes); // register for notifications after tree is built to avoid intermediate states getting notified foreach (var node in newTreeNodes) { PropertyChangedEventManager.AddHandler(node, OnSelectionChanged, PropertySupport.ExtractPropertyName(() => node.IsSelected)); PropertyChangedEventManager.AddHandler(node, OnParentChanged, PropertySupport.ExtractPropertyName(() => node.Parent)); myNodeToClusterCache[node.Id] = clusterNode.Id; } } Filter = null; myTransformationsObserver.ModuleChanged += OnTransformationsChanged; }