Ejemplo n.º 1
0
        /// <summary>
        /// Get the set of the leaf's elementIds that is under the argument node
        /// </summary>
        /// <param name="node"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private HashSet <ElementId> GetLeafsFromNode(TreeNode node, DataController data)
        {
            // Get the tokened string that outlines the path to take in the tree to reach to the current node
            List <string> pathTokens = GetNamePath(node, new List <string>());

            // From the data controller, call the function to get ALL the element ids by path
            HashSet <ElementId> elementIds = data.GetElementIdsByPath(pathTokens);

            // Interset the set with the elementIds we currently have
            elementIds.IntersectWith(curElementIds);

            return(elementIds);
        }
Ejemplo n.º 2
0
        private void ElementSelectionTreeView_AfterCheck(object sender, TreeViewEventArgs e)
        {
            if (e.Action == TreeViewAction.Unknown)
            {
                return;
            }

            this.haltIdlingHandler = true;

            // Step 1: Get node's full path
            // string fullPath = e.Node.FullPath;
            // Step 2: Tokenize the path by seperating out the '\'s
            // List<string> pathTokens = fullPath.Split('\\').ToList();
            List <string> pathTokens = selectionController.GetNamePath(e.Node);
            // Step 3: Get all elements that has that same path
            HashSet <ElementId> elementIds = dataController.GetElementIdsByPath(pathTokens);

            elementIds.IntersectWith(dataController.AllElements);
            // Step 4: Apply the change to the nodes with the corresponding elementIds
            selectionController.UpdateSelectionByElementId(elementIds, e.Node.Checked);
            //// Step 5: Update the counter to the tree itself
            //selectionController.UpdateSelectionCounter(dataController.ElementTree);

            selectionController.UpdateAffectedCounter(elementIds, dataController);
            // selectionController.UpdateNodeCounter(e.Node, dataController);

            if (e.Node.Checked)
            {
                // Step 5a: Add elementIds onto curSelection
                dataController.SelElementIds.UnionWith(elementIds);
            }
            else
            {
                // Step 5b: Remove elementIds from curSelection
                dataController.SelElementIds.ExceptWith(elementIds);
            }

            requestHandler.AddRequest(Request.SelectElementIds);

            this.haltIdlingHandler = false;
        }