/// <summary> /// The class constructor for a built-in type that is already loaded. </summary> /// <param name="node">The local node</param> public LocalSearchElement(dynNode node) { this.Node = node; this._name = Node.NodeUI.NickName; this.Weight = 1; this.Keywords = String.Join(" ", node.NodeUI.Tags); this._type = "Node"; this._description = node.NodeUI.Description; }
/// <summary> /// dynElement constructor for use by workbench in creating dynElements /// </summary> /// <param name="settings"></param> /// <param name="nickName"></param> public dynNodeUI(dynNode logic) { InitializeComponent(); SetLacingTypeCmd = new DelegateCommand<string>(new Action<string>(SetLacingType), CanSetLacingType); nodeLogic = logic; ArgumentLacing = NodeLogic.ArgumentLacing; nodeLogic.ArgumentLacingUpdated += new Nodes.LacingTypeChangedHandler(nodeLogic_ArgumentLacingUpdated); //set the main grid's data context to //this element nickNameBlock.DataContext = this; elementRectangle.DataContext = this; topControl.DataContext = this; elementRectangle.DataContext = this; inPorts = new ObservableCollection<dynPort>(); outPorts = new ObservableCollection<dynPort>(); inPorts.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ports_collectionChanged); outPorts.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ports_collectionChanged); this.IsSelected = false; //Binding heightBinding = new Binding("PreferredHeight"); //topControl.SetBinding(UserControl.HeightProperty, heightBinding); State = ElementState.DEAD; //Fetch the element name from the custom attribute. var nameArray = nodeLogic.GetType().GetCustomAttributes(typeof(NodeNameAttribute), true); if (nameArray.Length > 0) { NodeNameAttribute elNameAttrib = nameArray[0] as NodeNameAttribute; if (elNameAttrib != null) { NickName = elNameAttrib.Name; } } else NickName = ""; //set the z index to 2 Canvas.SetZIndex(this, 1); }
private bool traverseAny(dynNode entry) { bool result; if (resultDict.TryGetValue(entry, out result)) return result; result = predicate(entry); resultDict[entry] = result; if (result) return result; if (entry is dynFunction) { var symbol = (entry as dynFunction).Symbol; if (!dynSettings.Controller.FunctionDict.ContainsKey(symbol)) { dynSettings.Bench.Log("WARNING -- No implementation found for node: " + symbol); entry.NodeUI.Error("Could not find .dyf definition file for this node."); return false; } result = dynSettings.Controller.FunctionDict[symbol] .GetTopMostNodes() .Any(ContinueTraversalUntilAny); } resultDict[entry] = result; if (result) return result; return entry.Inputs.Values.Any(x => x != null && traverseAny(x.Item2)); }
public bool TraverseUntilAny(dynNode entry) { inProgress = true; bool result = traverseAny(entry); resultDict.Clear(); inProgress = false; return result; }
public bool ContinueTraversalUntilAny(dynNode entry) { if (inProgress) return traverseAny(entry); else throw new Exception("ContinueTraversalUntilAny cannot be used except in a traversal predicate."); }
internal void ConnectOutput(int portData, int inputData, dynNode nodeLogic) { if (!Outputs.ContainsKey(portData)) Outputs[portData] = new HashSet<Tuple<int, dynNode>>(); Outputs[portData].Add(Tuple.Create(inputData, nodeLogic)); }
internal void ConnectInput(int inputData, int outputData, dynNode node) { Inputs[inputData] = Tuple.Create(outputData, node); CheckPortsForRecalc(); }
/// <summary> /// Adds a local DynNode to search /// </summary> /// <param name="dynNode">A Dynamo node object</param> public void Add(dynNode dynNode) { var searchEle = new LocalSearchElement(dynNode); // add category to search var cat = dynNode.Category; if (!string.IsNullOrEmpty(cat)) { if (!cat.StartsWith("Revit API")) { SearchDictionary.Add(searchEle, cat + "." + searchEle.Name); if (!NodeCategories.ContainsKey(cat)) { var nameEle = new CategorySearchElement(cat); NodeCategories.Add(cat, nameEle); SearchDictionary.Add(nameEle, cat); } } else { if (!NodeCategories.ContainsKey(cat)) { var nameEle = new CategorySearchElement(cat); NodeCategories.Add(cat, nameEle); RevitApiSearchElements.Add(nameEle); } } } NodeCategories[cat].NumElements++; // add node to search if ( (searchEle.Name.StartsWith("API_")) ) { RevitApiSearchElements.Add( searchEle ); } else { SearchDictionary.Add(searchEle, searchEle.Name); if (dynNode.NodeUI.Tags.Count > 0) { SearchDictionary.Add(searchEle, dynNode.NodeUI.Tags); } SearchDictionary.Add(searchEle, dynNode.NodeUI.Description); } }
internal void ShowElement(dynNode e) { if (dynamicRun) return; if (!Nodes.Contains(e)) { if (HomeSpace != null && HomeSpace.Nodes.Contains(e)) { //Show the homespace ViewHomeWorkspace(); } else { foreach (FunctionDefinition funcDef in this.CustomNodeLoader.GetLoadedDefinitions() ) { if (funcDef.Workspace.Nodes.Contains(e)) { ViewCustomNodeWorkspace(funcDef); break; } } } } Bench.CenterViewOnElement(e.NodeUI); }
internal void ShowElement(dynNode e) { if (dynamicRun) return; if (!this.Nodes.Contains(e)) { if (this.homeSpace != null && this.homeSpace.Nodes.Contains(e)) { //Show the homespace ViewHomeWorkspace(); } else { foreach (var funcPair in this.FunctionDict) { if (funcPair.Value.Nodes.Contains(e)) { DisplayFunction(funcPair.Key); break; } } } } Bench.CenterViewOnElement(e.NodeUI); }