Example #1
0
 private void OnNodesChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         Children.Clear();
         nodeToUmlClassControl.Clear();
         umlClassControlToNode.Clear();
         NodeNames.Clear();
         return;
     }
     if (e.OldItems != null)
     {
         foreach (Node node in e.OldItems)
         {
             var umlClassControl = nodeToUmlClassControl[(UmlClass)node];
             Children.Remove(umlClassControl);
             nodeToUmlClassControl.Remove((UmlClass)node);
             umlClassControlToNode.Remove(umlClassControl);
             NodeNames.Remove(node.Name);
         }
     }
     if (e.NewItems != null)
     {
         foreach (Node node in e.NewItems)
         {
             AddNode(node);
             if (!NodeNames.Contains(node.Name))
             {
                 NodeNames.Add(node.Name);
             }
         }
     }
     OnFilterTextChanged(null, FilterText);
 }
Example #2
0
        /// <summary>
        ///     Attempts to remove all traces of a particular custom node from Dynamo, assuming the node is not in a loaded workspace.
        /// </summary>
        /// <param name="guid"></param>
        public void Remove(Guid guid)
        {
            if (loadedNodes.ContainsKey(guid))
            {
                loadedNodes.Remove(guid);
            }
            if (nodePaths.ContainsKey(guid))
            {
                nodePaths.Remove(guid);
            }
            if (NodeCategories.ContainsKey(guid))
            {
                NodeCategories.Remove(guid);
            }
            var nodeName = NodeNames.Where((x) => x.Value == guid).ToList();

            nodeName.ForEach((pair) =>
            {
                NodeNames.Remove(pair.Key);
                dynSettings.Controller.SearchViewModel.Remove(pair.Key);
            });
            dynSettings.Controller.SearchViewModel.SearchAndUpdateResults();
            dynSettings.Controller.FSchemeEnvironment.RemoveSymbol(guid.ToString());
        }