Пример #1
0
        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;
        }
Пример #2
0
        private void BuildTree()
        {
            using (new Profile("BuildTree"))
            {
                Root.Children.Clear();

                SelectedCluster = null;

                var transformationModule = myPresentation.GetModule <ITransformationModule>();
                var captionModule        = myPresentation.GetModule <ICaptionModule>();

                foreach (var cluster in transformationModule.Graph.Clusters.OrderBy(c => c.Id))
                {
                    var clusterNode = new ClusterTreeNode(myPresentation)
                    {
                        Parent        = Root,
                        Id            = cluster.Id,
                        Caption       = captionModule.Get(cluster.Id).DisplayText,
                        IsDragAllowed = false
                    };
                    Root.Children.Add(clusterNode);

                    // we do not want to see the pseudo node added for folding but the full expanded list of nodes of this cluster
                    var folding = transformationModule.Items
                                  .OfType <ClusterFoldingTransformation>()
                                  .SingleOrDefault(f => f.Clusters.Contains(cluster.Id));

                    var nodes = folding == null ? cluster.Nodes : folding.GetNodes(cluster.Id);

                    clusterNode.Children.AddRange(nodes
                                                  .Select(n => new ClusterTreeNode(myPresentation)
                    {
                        Parent        = clusterNode,
                        Id            = n.Id,
                        Caption       = captionModule.Get(n.Id).DisplayText,
                        IsDropAllowed = false,
                        ShowId        = TreeShowId
                    }));
                }

                // register for notifications after tree is built to avoid intermediate states getting notified

                foreach (ClusterTreeNode cluster in Root.Children)
                {
                    PropertyChangedEventManager.AddHandler(cluster, OnSelectionChanged, PropertySupport.ExtractPropertyName(() => cluster.IsSelected));

                    foreach (ClusterTreeNode node in cluster.Children)
                    {
                        PropertyChangedEventManager.AddHandler(node, OnSelectionChanged, PropertySupport.ExtractPropertyName(() => node.IsSelected));
                        PropertyChangedEventManager.AddHandler(node, OnParentChanged, PropertySupport.ExtractPropertyName(() => node.Parent));
                    }
                }

                myNodeToClusterCache = null;
            }
        }
Пример #3
0
        public ClusterEditorModel()
        {
            AddButtonCaption         = "Add ...";
            AddNodesToClusterCommand = new DelegateCommand(OnAddNodesToCluster, () => SelectedCluster != null);
            MouseDownCommand         = new DelegateCommand <MouseButtonEventArgs>(OnMouseDown);

            Root = new ClusterTreeNode(null);
            Root.IsDragAllowed = false;
            Root.IsDropAllowed = false;

            AddClusterCommand    = new DelegateCommand <ClusterTreeNode>(OnAddCluster, n => n == Root);
            DeleteClusterCommand = new DelegateCommand <ClusterTreeNode>(OnDeleteCluster, n => n.Parent == Root);

            myDragDropBehavior = new DragDropBehavior(Root);
            DropCommand        = new DelegateCommand <NodeDropRequest>(myDragDropBehavior.ApplyDrop);
        }
Пример #4
0
        private void OnAddCluster(ClusterTreeNode parent)
        {
            // avoid many intermediate updates
            myTransformationsObserver.ModuleChanged -= OnTransformationsChanged;

            var newClusterId  = Guid.NewGuid().ToString();
            var captionModule = myPresentation.GetModule <ICaptionModule>();

            captionModule.Add(new Caption(newClusterId, "<new>"));

            new ChangeClusterAssignment(myPresentation)
            .Execute(t => t.AddCluster(newClusterId));

            // start new clusters folded
            new ChangeClusterFolding(myPresentation)
            .Execute(t => t.Toggle(newClusterId));

            // update tree
            {
                var clusterNode = new ClusterTreeNode(myPresentation)
                {
                    Parent        = Root,
                    Id            = newClusterId,
                    Caption       = captionModule.Get(newClusterId).DisplayText,
                    IsDragAllowed = false
                };
                Root.Children.Add(clusterNode);

                // register for notifications after tree is built to avoid intermediate states getting notified

                PropertyChangedEventManager.AddHandler(clusterNode, OnSelectionChanged, PropertySupport.ExtractPropertyName(() => clusterNode.IsSelected));

                // nothing ot update
                //myNodeClusterCache = null;
            }

            Root.Children.Single(n => n.Id == newClusterId).IsSelected = true;

            myTransformationsObserver.ModuleChanged += OnTransformationsChanged;
        }
        private void OnDeleteCluster(ClusterTreeNode clusterNode)
        {
            // avoid many intermediate updates
            myTransformationsObserver.ModuleChanged -= OnTransformationsChanged;

            myPresentation.DynamicClusters().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;
        }