// ------------------------------------------------- AddSource public bool AddSource(string src, LinkDot link) { if (link.Points[link.DotNumber - 1].Equals(endPoint) == true) { link.MoveDot(link.DotNumber - 2, beforeEndPoint); if (dicLinkeds.ContainsKey(src) == false) { dicLinkeds.Add(src, link); //ToDo add function Function tmpConcat = (Function)FuncList.Find(fnc => fnc is Function); if (tmpConcat == null) { /* * Node1----------->|TTTTTTTTT| * | Concat |----------->Des Node * New Node ------->|_________| * * */ //tmpConcat = new GraphConcat(new Point(400, 50), new string[] { "Concat", "Value", "Value" }); tmpConcat = new Function(FunctionType.Default, new string[] { "Concat" }, new Rectangle(400, 50, Config.FUNCTION_WIDTH, Config.FUNCTION_HEIGHT)); tmpConcat.InputFunclets.Add(funcList[1]); GraphNode graphNodeSrc = new GraphNode(new Point(200, 50 + funcList.Count * 30), new string[] { src }) ; tmpConcat.InputFunclets.Add(graphNodeSrc); funcList.Add(graphNodeSrc); funcList.Add(tmpConcat); funcList[0].InputFunclets.Clear(); funcList[0].InputFunclets.Add(tmpConcat); } else { /* * Node1----------->|TTTTTTTTT| * | Concat |----------->Des Node * Node2----------->| | * .....----------->| | * Node N --------->|_________| * */ GraphNode graphNodeSrc = new GraphNode(new Point(200, 50 + funcList.Count * 30), new string[] { src }); tmpConcat.InputFunclets.Add(graphNodeSrc); //tmpConcat.AddArgument(); //funcList.Add(graphNodeSrc); } } return true; } return false; }
/// <summary> /// Adds the group node. /// </summary> /// <param name="src">The SRC.</param> /// <param name="link">The link.</param> /// <param name="pen">The pen.</param> /// <param name="nPoints">The n points.</param> /// <returns></returns> /// Created by khoaht at 4:00 PM on 11/30/2011 public List<LinkDot> AddGroupNode(string functionName, string src, LinkDot link, Pen pen, int nPoints) { List<LinkDot> lstLD = null; if (link.Points[link.DotNumber - 1].Equals(endPoint) == true) { lstLD = new List<LinkDot>(); if (src != string.Empty) link.MoveDot(link.DotNumber - 2, beforeEndPoint); if (dicLinkeds.ContainsKey(src) == false) { dicLinkeds.Add(src, link); Function tmpFunc = (Function)FuncList.Find(fnc => fnc is Function); if (tmpFunc == null) { // Create new Function tmpFunc = new Function(FunctionType.Default, functionName, new Rectangle(400, 50, Config.FUNCTION_WIDTH, Config.FUNCTION_HEIGHT)); // Indicate the inputs var nodeIn = funcList.Find(t => (t is GraphNode) && (((GraphNode)t).NodeType == NodeType.Input)); tmpFunc.InputFunclets.Add(nodeIn); foreach (var item in funcList) { if (item.ID != tmpFunc.ID) lstLD.Add(CreateLink(item, tmpFunc, pen, nPoints)); } GraphNode graphNodeSrc = new GraphNode(NodeType.Input, new Point(200, 50 + funcList.Count * 30), src); tmpFunc.InputFunclets.Add(graphNodeSrc); funcList.Add(graphNodeSrc); if (!funcList.Exists(t => t.ID == tmpFunc.ID)) { funcList.Add(tmpFunc); } lstLD.Add(CreateLink(graphNodeSrc, tmpFunc, pen, nPoints)); funcList[0].InputFunclets.Clear(); funcList[0].InputFunclets.Add(tmpFunc); } else { tmpFunc.RestPortConnected(); foreach (var item in funcList) { if (item.ID != tmpFunc.ID) lstLD.Add(CreateLink(item, tmpFunc, pen, nPoints)); } tmpFunc.NewPort(); GraphNode graphNodeSrc = new GraphNode(NodeType.Input, new Point(200, 50 + funcList.Count * 30), src); tmpFunc.InputFunclets.Add(graphNodeSrc); funcList.Add(graphNodeSrc); if (!funcList.Exists(t => t.ID == tmpFunc.ID)) { funcList.Add(tmpFunc); } lstLD.Add(CreateLink(graphNodeSrc, tmpFunc, pen, nPoints)); funcList[0].InputFunclets.Clear(); funcList[0].InputFunclets.Add(tmpFunc); } } } return lstLD; }
/// <summary> /// Adds the source. /// </summary> /// <param name="src">The SRC.</param> /// <param name="link">The link.</param> /// <returns></returns> public bool AddSource(string src, LinkDot link) { if (link.Points[link.DotNumber - 1].Equals(endPoint) == true) { link.MoveDot(link.DotNumber - 2, beforeEndPoint); if (dicLinkeds.ContainsKey(src) == false) { dicLinkeds.Add(src, link); Function tmpFunc = (Function)FuncList.Find(fnc => fnc is Function); if (tmpFunc == null) { tmpFunc = new Function(FunctionType.Default, "concat", new Rectangle(400, 50, Config.FUNCTION_WIDTH, Config.FUNCTION_HEIGHT)); tmpFunc.InputFunclets.Add(funcList[1]); GraphNode graphNodeSrc = new GraphNode(NodeType.Input, new Point(200, 50 + funcList.Count * 30), src); tmpFunc.InputFunclets.Add(graphNodeSrc); funcList.Add(graphNodeSrc); funcList.Add(tmpFunc); // AddLink(graphNodeSrc,tmpFunc); funcList[0].InputFunclets.Clear(); funcList[0].InputFunclets.Add(tmpFunc); } else { GraphNode graphNodeSrc = new GraphNode(NodeType.Input, new Point(200, 50 + funcList.Count * 30), src); tmpFunc.InputFunclets.Add(graphNodeSrc); } } return true; } return false; }