protected SelectionBase(PortData outPortData) : this() { OutPortData.Add(outPortData); RegisterAllPorts(); dynRevitSettings.Controller.RevitDocumentChanged += Controller_RevitDocumentChanged; }
public void SetPortData(PortData data) { portData = data; UsingDefaultValue = portData.DefaultValue != null; RaisePropertyChanged("DefaultValueEnabled"); RaisePropertyChanged("PortName"); RaisePropertyChanged("TooltipContent"); }
public PortModel(PortType portType, NodeModel owner, PortData data) { IsConnected = false; PortType = portType; Owner = owner; SetPortData(data); MarginThickness = new Thickness(0); Height = Math.Abs(data.Height) < 0.001 ? Configurations.PortHeightInPixels : data.Height; }
public PortModel(PortType portType, NodeModel owner, PortData data) { IsConnected = false; PortType = portType; Owner = owner; PortName = data.NickName; UsingDefaultValue = false; DefaultValueEnabled = false; MarginThickness = new Thickness(0); Height = Math.Abs(data.Height) < 0.001 ? Configurations.PortHeightInPixels : data.Height; }
public PortModel(PortType portType, NodeModel owner, PortData data) { IsConnected = false; PortType = portType; Owner = owner; SetPortData(data); if (PortType == Models.PortType.Input) { MarginThickness = new Thickness(0); } else { MarginThickness = new Thickness(0, data.VerticalMargin, 0, 0); } Height = Math.Abs(data.Height) < 0.001 ? Configurations.PortHeightInPixels : data.Height; }
public PortModel(PortType portType, NodeModel owner, PortData data) { IsConnected = false; PortType = portType; Owner = owner; PortName = data.NickName; UsingDefaultValue = false; DefaultValueEnabled = false; MarginThickness = new Thickness(0); if (data.Height == 0) { this.Height = Configurations.PortHeightInPixels; } else { this.Height = data.Height; } }
protected MultipleElementSelectionBase(PortData outData) { OutPortData.Add(outData); RegisterAllPorts(); dynSettings.Controller.DynamoViewModel.PropertyChanged += DynamoViewModel_PropertyChanged; CanSelect = true; }
protected ElementSelectionBase(PortData outPortData) : base(outPortData) { }
protected override void LoadNode(XmlNode nodeElement) { List<XmlNode> childNodes = nodeElement.ChildNodes.Cast<XmlNode>().ToList(); XmlNode nameNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Name")); if (nameNode != null && nameNode.Attributes != null) NickName = nameNode.Attributes[0].Value; XmlNode idNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("ID")); if (idNode != null && idNode.Attributes != null) { string id = idNode.Attributes[0].Value; Guid funcId; if (!Guid.TryParse(id, out funcId) && nodeElement.Attributes != null) funcId = GuidUtility.Create(GuidUtility.UrlNamespace, nodeElement.Attributes["nickname"].Value); if (!VerifyFuncId(ref funcId)) { LoadProxyCustomNode(funcId); } Definition = Workspace.DynamoModel.CustomNodeManager.GetFunctionDefinition(funcId); if (Definition.IsProxy) { Error("Cannot load custom node"); } } foreach (XmlNode subNode in childNodes) { if (subNode.Name.Equals("Outputs")) { var data = subNode.ChildNodes.Cast<XmlNode>() .Select( (outputNode, i) => new { data = new PortData(outputNode.Attributes[0].Value, "Output #" + (i + 1)), idx = i }); foreach (var dataAndIdx in data) { if (OutPortData.Count > dataAndIdx.idx) OutPortData[dataAndIdx.idx] = dataAndIdx.data; else OutPortData.Add(dataAndIdx.data); } } else if (subNode.Name.Equals("Inputs")) { var data = subNode.ChildNodes.Cast<XmlNode>() .Select( (inputNode, i) => new { data = new PortData(inputNode.Attributes[0].Value, "Input #" + (i + 1)), idx = i }); foreach (var dataAndIdx in data) { if (InPortData.Count > dataAndIdx.idx) InPortData[dataAndIdx.idx] = dataAndIdx.data; else InPortData.Add(dataAndIdx.data); } } #region Legacy output support else if (subNode.Name.Equals("Output")) { var data = new PortData(subNode.Attributes[0].Value, "function output"); if (OutPortData.Any()) OutPortData[0] = data; else OutPortData.Add(data); } #endregion } if (!IsInSyncWithDefinition()) { ResyncWithDefinition(); } else { RegisterAllPorts(); } //argument lacing on functions should be set to disabled //by default in the constructor, but for any workflow saved //before this was the case, we need to ensure it here. ArgumentLacing = LacingStrategy.Disabled; //if (Definition != null) // ResyncWithDefinition(); }
public PortModel(PortType portType, NodeModel owner, PortData data) { IsConnected = false; PortType = portType; Owner = owner; PortName = data.NickName; UsingDefaultValue = false; DefaultValueEnabled = false; MarginThickness = new Thickness(0); if (data.Height == 0) this.Height = Configurations.PortHeightInPixels; else this.Height = data.Height; }
protected override void DeserializeCore(XmlElement element, SaveContext context) { base.DeserializeCore(element, context); //Base implementation must be called if (context == SaveContext.Undo) { XmlElementHelper helper = new XmlElementHelper(element); NickName = helper.ReadString("functionName"); Symbol = helper.ReadString("functionId"); Guid funcId; if (!VerifySymbol(out funcId)) { LoadProxyCustomNode(funcId); return; } XmlNodeList inNodes = element.SelectNodes("functionInput"); XmlNodeList outNodes = element.SelectNodes("functionOutput"); int i = 0; foreach (XmlNode inputNode in inNodes) { string name = inputNode.Attributes[0].Value; var data = new PortData(name, "Input #" + (i + 1), typeof(object)); if (InPortData.Count > i) InPortData[i] = data; else InPortData.Add(data); i++; } i = 0; foreach (XmlNode outputNode in outNodes) { string name = outputNode.Attributes[0].Value; var data = new PortData(name, "Output #" + (i + 1), typeof(object)); if (OutPortData.Count > i) OutPortData[i] = data; else OutPortData.Add(data); i++; } //Added it the same way as LoadNode. But unsure of when 'Output' ChildNodes will //be added to element. As of now I dont think it is added during serialize #region Legacy output support foreach (XmlNode subNode in element.ChildNodes) { if (subNode.Name.Equals("Output")) { var data = new PortData( subNode.Attributes[0].Value, "function output", typeof(object)); if (OutPortData.Any()) OutPortData[0] = data; else OutPortData.Add(data); } } #endregion RegisterAllPorts(); Guid funId; try { funId = Guid.Parse(Symbol); } catch { funId = GuidUtility.Create(GuidUtility.UrlNamespace, NickName); Symbol = funId.ToString(); } Definition = dynSettings.Controller.CustomNodeManager.GetFunctionDefinition(funId); Description = helper.ReadString("functionDesc"); } }
public ScanList(WorkspaceModel workspace) : base(workspace) { reductorPort = new PortData( "reductor", "Reductor Function: accepts one item from each list being reduced, and the current accumulated value, result is the new accumulated value."); InPortData.Add(reductorPort); InPortData.Add(new PortData("seed", "Starting accumulated value, to be passed into the first call to the Reductor function.")); InPortData.Add(new PortData("list1", "List #1")); OutPortData.Add(new PortData("scanned", "Scanned lists")); RegisterAllPorts(); }
protected ReferenceSelectionBase(PortData outPortData) : base(outPortData) { }
/// <summary> /// Add a port to this node. If the port already exists, return that port. /// </summary> /// <param name="portType"></param> /// <param name="data"></param> /// <param name="index"></param> /// <returns></returns> public PortModel AddPort(PortType portType, PortData data, int index) { PortModel p; switch (portType) { case PortType.INPUT: if (inPorts.Count > index) { p = inPorts[index]; //update the name on the node //e.x. when the node is being re-registered during a custom //node save p.PortName = data.NickName; if (data.HasDefaultValue) { p.UsingDefaultValue = true; p.DefaultValueEnabled = true; } return p; } p = new PortModel(index, portType, this, data.NickName) { UsingDefaultValue = data.HasDefaultValue, DefaultValueEnabled = data.HasDefaultValue }; p.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args) { if (args.PropertyName == "UsingDefaultValue") RequiresRecalc = true; }; InPorts.Add(p); //register listeners on the port p.PortConnected += p_PortConnected; p.PortDisconnected += p_PortDisconnected; return p; case PortType.OUTPUT: if (outPorts.Count > index) { p = outPorts[index]; p.PortName = data.NickName; return p; } p = new PortModel(index, portType, this, data.NickName) { UsingDefaultValue = false }; OutPorts.Add(p); //register listeners on the port p.PortConnected += p_PortConnected; p.PortDisconnected += p_PortDisconnected; return p; } return null; }
protected override void LoadNode(XmlNode nodeElement) { foreach (XmlNode subNode in nodeElement.ChildNodes) { if (subNode.Name.Equals("Name")) { NickName = subNode.Attributes[0].Value; } } foreach (XmlNode subNode in nodeElement.ChildNodes) { if (subNode.Name.Equals("ID")) { Symbol = subNode.Attributes[0].Value; Guid funcId; if (!VerifySymbol(out funcId)) { LoadProxyCustomNode(funcId); return; } } } foreach (XmlNode subNode in nodeElement.ChildNodes) { if (subNode.Name.Equals("Outputs")) { int i = 0; foreach (XmlNode outputNode in subNode.ChildNodes) { var data = new PortData( outputNode.Attributes[0].Value, "Output #" + (i + 1), typeof(object)); if (OutPortData.Count > i) { OutPortData[i] = data; } else { OutPortData.Add(data); } i++; } } else if (subNode.Name.Equals("Inputs")) { int i = 0; foreach (XmlNode inputNode in subNode.ChildNodes) { var data = new PortData( inputNode.Attributes[0].Value, "Input #" + (i + 1), typeof(object)); if (InPortData.Count > i) { InPortData[i] = data; } else { InPortData.Add(data); } i++; } } #region Legacy output support else if (subNode.Name.Equals("Output")) { var data = new PortData( subNode.Attributes[0].Value, "function output", typeof(object)); if (OutPortData.Any()) OutPortData[0] = data; else OutPortData.Add(data); } #endregion } RegisterAllPorts(); //argument lacing on functions should be set to disabled //by default in the constructor, but for any workflow saved //before this was the case, we need to ensure it here. ArgumentLacing = LacingStrategy.Disabled; // we've found a custom node, we need to attempt to load its guid. // if it doesn't exist (i.e. its a legacy node), we need to assign it one // deterministically Guid funId; try { funId = Guid.Parse(Symbol); } catch (FormatException) { funId = GuidUtility.Create( GuidUtility.UrlNamespace, nodeElement.Attributes["nickname"].Value); Symbol = funId.ToString(); } Definition = dynSettings.Controller.CustomNodeManager.GetFunctionDefinition(funId); }
protected override void LoadNode(XmlNode nodeElement) { Controller.LoadNode(nodeElement); List<XmlNode> childNodes = nodeElement.ChildNodes.Cast<XmlNode>().ToList(); XmlNode nameNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Name")); if (nameNode != null && nameNode.Attributes != null) NickName = nameNode.Attributes[0].Value; foreach (XmlNode subNode in childNodes) { if (subNode.Name.Equals("Outputs")) { var data = subNode.ChildNodes.Cast<XmlNode>() .Select( (outputNode, i) => new { data = new PortData(outputNode.Attributes[0].Value, "Output #" + (i + 1)), idx = i }); foreach (var dataAndIdx in data) { if (OutPortData.Count > dataAndIdx.idx) OutPortData[dataAndIdx.idx] = dataAndIdx.data; else OutPortData.Add(dataAndIdx.data); } } else if (subNode.Name.Equals("Inputs")) { var data = subNode.ChildNodes.Cast<XmlNode>() .Select( (inputNode, i) => new { data = new PortData(inputNode.Attributes[0].Value, "Input #" + (i + 1)), idx = i }); foreach (var dataAndIdx in data) { if (InPortData.Count > dataAndIdx.idx) InPortData[dataAndIdx.idx] = dataAndIdx.data; else InPortData.Add(dataAndIdx.data); } } #region Legacy output support else if (subNode.Name.Equals("Output")) { var data = new PortData(subNode.Attributes[0].Value, "function output"); if (OutPortData.Any()) OutPortData[0] = data; else OutPortData.Add(data); } #endregion } if (!Controller.IsInSyncWithNode(this)) { Controller.SyncNodeWithDefinition(this); } else { RegisterAllPorts(); } //argument lacing on functions should be set to disabled //by default in the constructor, but for any workflow saved //before this was the case, we need to ensure it here. ArgumentLacing = LacingStrategy.Disabled; }
/// <summary> /// Add a port to this node. If the port already exists, return that port. /// </summary> /// <param name="portType"></param> /// <param name="data"></param> /// <param name="index"></param> /// <returns></returns> public PortModel AddPort(PortType portType, PortData data, int index) { PortModel p; switch (portType) { case PortType.Input: if (inPorts.Count > index) { p = inPorts[index]; p.SetPortData(data); } else { p = new PortModel(portType, this, data); p.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args) { if (args.PropertyName == "UsingDefaultValue") { OnNodeModified(); } }; //register listeners on the port p.PortConnected += PortConnected; p.PortDisconnected += PortDisconnected; InPorts.Add(p); } return p; case PortType.Output: if (outPorts.Count > index) { p = outPorts[index]; p.SetPortData(data); } else { p = new PortModel(portType, this, data); OutPorts.Add(p); //register listeners on the port p.PortConnected += PortConnected; p.PortDisconnected += PortDisconnected; } return p; } return null; }