/// <summary> /// Deletes all the connections and saves their data (the start and end port) /// so that they can be recreated if needed. /// </summary> /// <param name="inportConnections">A list of connections that will be destroyed</param> /// <param name="outportConnections"></param> private void SaveAndDeleteConnectors(IDictionary inportConnections, IDictionary outportConnections) { //----------------------------Inputs--------------------------------- foreach (var portModel in InPorts) { var portName = portModel.ToolTipContent; if (portModel.Connectors.Count != 0) { inportConnections.Add(portName, new List <PortModel>()); foreach (var connector in portModel.Connectors) { (inportConnections[portName] as List <PortModel>).Add(connector.Start); } } else { inportConnections.Add(portName, null); } } //Delete the connectors foreach (PortModel inport in InPorts) { inport.DestroyConnectors(); } //Clear out all the port models for (int i = InPorts.Count - 1; i >= 0; i--) { InPorts.RemoveAt(i); } //----------------------------Outputs--------------------------------- for (int i = 0; i < OutPorts.Count; i++) { PortModel portModel = OutPorts[i]; string portName = portModel.ToolTipContent; if (portModel.ToolTipContent.Equals(Formatting.TOOL_TIP_FOR_TEMP_VARIABLE)) { portName += i.ToString(CultureInfo.InvariantCulture); } if (portModel.Connectors.Count != 0) { outportConnections.Add(portName, new List <PortModel>()); foreach (ConnectorModel connector in portModel.Connectors) { (outportConnections[portName] as List <PortModel>).Add(connector.End); } } else { outportConnections.Add(portName, null); } } //Delete the connectors foreach (PortModel outport in OutPorts) { outport.DestroyConnectors(); } //Clear out all the port models for (int i = OutPorts.Count - 1; i >= 0; i--) { OutPorts.RemoveAt(i); } }
public Formula() { ArgumentLacing = LacingStrategy.Auto; OutPorts.Add(new PortModel(PortType.Output, this, new PortData("", Properties.Resources.FormulaPortDataResultToolTip))); RegisterAllPorts(); }
public TestNode() { InPorts.Add(new PortModel(PortType.Input, this, new PortData("input A", "This is input A."))); OutPorts.Add(new PortModel(PortType.Output, this, new PortData("output A", "This is output A."))); RegisterAllPorts(); }
protected PythonNodeBase() { OutPorts.Add(new PortModel(PortType.Output, this, new PortData("OUT", Properties.Resources.PythonNodePortDataOutputToolTip))); ArgumentLacing = LacingStrategy.Disabled; }
public void ConnectPort(ICore other, int selfEdge, int otherEdge) { InPorts.Connect(selfEdge, other.OutPorts, otherEdge); OutPorts.Connect(selfEdge, other.InPorts, otherEdge); }
protected override void DeserializeCore(XmlElement nodeElement, SaveContext context) { List <XmlNode> childNodes = nodeElement.ChildNodes.Cast <XmlNode>().ToList(); if (!Controller.IsInSyncWithNode(this)) { Controller.SyncNodeWithDefinition(this); OnNodeModified(); } else if (Controller.Definition == null || Controller.Definition.IsProxy) { 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, Properties.Resources.ToolTipOutput + (i + 1)), idx = i }); foreach (var dataAndIdx in data) { if (OutPorts.Count > dataAndIdx.idx) { OutPorts[dataAndIdx.idx] = new PortModel(PortType.Output, this, dataAndIdx.data); } else { OutPorts.Add(new PortModel(PortType.Output, this, 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, Properties.Resources.ToolTipInput + (i + 1)), idx = i }); foreach (var dataAndIdx in data) { if (InPorts.Count > dataAndIdx.idx) { InPorts[dataAndIdx.idx] = new PortModel(PortType.Input, this, dataAndIdx.data); } else { InPorts.Add(new PortModel(PortType.Input, this, dataAndIdx.data)); } } } #region Legacy output support else if (subNode.Name.Equals("Output")) { var data = new PortData(subNode.Attributes[0].Value, Properties.Resources.ToolTipFunctionOutput); if (OutPorts.Any()) { OutPorts[0] = new PortModel(PortType.Output, this, data); } else { OutPorts.Add(new PortModel(PortType.Output, this, data)); } } #endregion } RegisterAllPorts(); } base.DeserializeCore(nodeElement, context); //Base implementation must be called XmlNode nameNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Name")); if (nameNode != null && nameNode.Attributes != null) { Name = nameNode.Attributes["value"].Value; } XmlNode descNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Description")); if (descNode != null && descNode.Attributes != null) { Description = descNode.Attributes["value"].Value; } }
protected DSDropDownBase(string outputName) { OutPorts.Add(new PortModel(PortType.Output, this, new PortData(outputName, string.Format(Resources.DropDownPortDataResultToolTip, outputName)))); RegisterAllPorts(); PopulateItems(); }
/// <summary> /// Deletes all the connections and saves their data (the start and end port) /// so that they can be recreated if needed. /// </summary> /// <param name="portConnections">A list of connections that will be destroyed</param> private void SaveAndDeleteConnectors(OrderedDictionary inportConnections, OrderedDictionary outportConnections) { //----------------------------Inputs--------------------------------- for (int i = 0; i < InPorts.Count; i++) { PortModel portModel = InPorts[i]; string portName = portModel.ToolTipContent; if (portModel.Connectors.Count != 0) { inportConnections.Add(portName, new List <PortModel>()); foreach (ConnectorModel connector in portModel.Connectors) { (inportConnections[portName] as List <PortModel>).Add(connector.Start); Workspace.UndoRecorder.RecordDeletionForUndo(connector); } } else { inportConnections.Add(portName, null); } } //Delete the connectors foreach (PortModel inport in InPorts) { inport.DestroyConnectors(); } //Clear out all the port models for (int i = InPorts.Count - 1; i >= 0; i--) { InPorts.RemoveAt(i); } //----------------------------Outputs--------------------------------- for (int i = 0; i < OutPorts.Count; i++) { PortModel portModel = OutPorts[i]; string portName = portModel.ToolTipContent; if (portModel.ToolTipContent.Equals(Formatting.ToolTipForTempVariable)) { portName += i.ToString(CultureInfo.InvariantCulture); } if (portModel.Connectors.Count != 0) { outportConnections.Add(portName, new List <PortModel>()); foreach (ConnectorModel connector in portModel.Connectors) { (outportConnections[portName] as List <PortModel>).Add(connector.End); Workspace.UndoRecorder.RecordDeletionForUndo(connector); } } else { outportConnections.Add(portName, null); } } //Delete the connectors foreach (PortModel outport in OutPorts) { outport.DestroyConnectors(); } //Clear out all the port models for (int i = OutPorts.Count - 1; i >= 0; i--) { OutPorts.RemoveAt(i); } }
public NodeWithFailingASTOutput() { InPorts.Add(new PortModel(PortType.Input, this, new PortData("input", "dummy input"))); OutPorts.Add(new PortModel(PortType.Output, this, new PortData("result", "dummy result"))); RegisterAllPorts(); }
public ElementsOfType() { InPorts.Add(new PortModel(PortType.Input, this, new PortData("element class", Properties.Resources.PortDataElementTypeToolTip))); OutPorts.Add(new PortModel(PortType.Output, this, new PortData("elements", Properties.Resources.PortDataAllElementsInDocumentToolTip))); RegisterAllPorts(); }
public ByKeysAndValues() : base() { InPorts.Add(new PortModel(PortType.Input, this, new PortData("keys", Properties.Resources.JsonObject_Keys_Set))); InPorts.Add(new PortModel(PortType.Input, this, new PortData("values", Properties.Resources.JsonObject_Values_Set))); OutPorts.Add(new PortModel(PortType.Output, this, new PortData("jsonObject", Properties.Resources.JsonObject_Json_Get))); }
private void UpdatePaintVars(Graphics e) { if (paint_cellSizeChanged || !paint_initialized) { paint_cellSize = FlowGraph.Grid.CurrentCellSize; } if (paint_cellSizeChanged || !paint_initialized) { paint_portFont = new Font(PortFontFamily, 20); while (paint_portFont.GetHeight() > paint_cellSize.Height) { paint_portFont = new Font(PortFontFamily, paint_portFont.Size - 0.5f); } } if (paint_cellSizeChanged || paint_portsChanged || paint_locationChanged || !paint_initialized) { string longestInPortName = InPorts.Select(c => c.PortName).Aggregate("", (max, cur) => max.Length > cur.Length ? max : cur); string longestOutPortName = OutPorts.Select(c => c.PortName).Aggregate("", (max, cur) => max.Length > cur.Length ? max : cur); float portGripSize = paint_cellSize.Height / 3; paint_inPortSize = e.MeasureString(longestInPortName, paint_portFont); paint_outPortSize = e.MeasureString(longestOutPortName, paint_portFont); float nodeWidth = (float)Math.Ceiling((paint_inPortSize.Width + paint_outPortSize.Width + (portGripSize * 2)) / paint_cellSize.Width) * paint_cellSize.Width; float nodeHeight = ((InPorts.Count > OutPorts.Count ? InPorts.Count : OutPorts.Count) + 1) * paint_cellSize.Height; //add two for the header and footer paint_nodeSize = new SizeF(nodeWidth, nodeHeight); for (int i = 0; i < InPorts.Count; i++) { InPorts[i].PortBounds = new RectangleF(0 + portGripSize, (i + 1) * paint_cellSize.Height, paint_inPortSize.Width, paint_inPortSize.Height); } for (int i = 0; i < OutPorts.Count; i++) { float portTextOffset = e.MeasureString(OutPorts[i].PortName, paint_portFont).Width + portGripSize; OutPorts[i].PortBounds = new RectangleF(paint_nodeSize.Width - portTextOffset, (i + 1) * paint_cellSize.Height, paint_outPortSize.Width, paint_outPortSize.Height); } UpdateLinks(); } if (paint_cellSizeChanged || !paint_initialized) { paint_headerFont = new Font(PortFontFamily, 20); while (paint_headerFont.GetHeight() > paint_cellSize.Height || e.MeasureString(NodeHeaderText, paint_headerFont).Width > paint_nodeSize.Width) { paint_headerFont = new Font(PortFontFamily, paint_headerFont.Size - 0.5f); } } if (paint_cellSizeChanged || !paint_initialized) { paint_clip = new Rectangle(0, 0, (int)paint_nodeSize.Width, (int)paint_nodeSize.Height); } paint_initialized = true; paint_cellSizeChanged = false; paint_portsChanged = false; paint_locationChanged = false; }
public WebcamCapture() { OutPorts.Add(new PortModel(PortType.Output, this, new PortData("FileName", "Blablabla"))); RegisterAllPorts(); }
/// <summary> /// New <see cref="IfcReportDomain"/> custom node model. /// </summary> public IfcReportDomainComposingNodeModel() { OutPorts.Add(new PortModel(PortType.Output, this, new PortData("reportDomainType", "Reporting domain filter"))); RegisterAllPorts(); Items.AddRange(Enum.GetValues(typeof(IfcReportDomain)).Cast <IfcReportDomain>()); }
protected CombinatorNode(IEnumerable <PortModel> inPorts, IEnumerable <PortModel> outPorts) { InPorts.AddRange(inPorts); OutPorts.AddRange(outPorts); }