/// <summary> /// Adds the tree node to link. /// </summary> /// <param name="sourceNode">The source node.</param> /// <param name="targetNode">The target node.</param> /// Created by SMK private void AddTreeNodeToLink(TreeNode sourceNode, TreeNode targetNode, bool mustGenFunclet) { #region Declare port position var sPort = GetSourcePort(sourceNode) as Port; if (sPort == null) { var sPoint = GetNodePoint(sourceNode); sPoint.X += Config.PORT_DELTA; sPort = new Port(sPoint, PortType.Output) { Name = sourceNode.Text, NodePath = sourceNode.FullPath }; } var tPoint = GetNodePoint(targetNode); tPoint.X -= (Config.PORT_D+ Config.PORT_DELTA); var tPort = new Port(tPoint, PortType.Input) { Name = targetNode.Text, NodePath = targetNode.FullPath }; #endregion #region Tree Design if (HasFunction(tPort)) { var existPort = GetTargetPort(targetNode) as Port; var existFunc = GetFunction(tPort); if (existFunc == null) { SizeF sizeF = Auxi_Geometry.RoundMeasureString(this, "Fx", fontFunctionHeader); int y = sPort.Y + (tPort.Y - sPort.Y) / 2; existFunc = new GraphNode(ComponentType.FunctionLink, "Fx", new Point(tPort.X - 100, y), sizeF); pnlTree.AddObjectGraphic(existFunc); var linkS = new LinkDot(sPort, existFunc.Ports[1], 4, false); var linkT = new LinkDot(existFunc.Ports[0], existPort, 4, true); linkS.Function = existFunc; linkT.Function = existFunc; if (existFunc.InputComponents == null) existFunc.InputComponents = new List<ComponentBase>(); existFunc.InputComponents.Add(linkS); pnlTree.AddObjectGraphic(linkS); pnlTree.AddObjectGraphic(linkT); } else { var linkS = new LinkDot(sPort, existFunc.Ports[1], 4, false); pnlTree.AddObjectGraphic(linkS); } GroupFunction((GraphNode)existFunc, existPort); } else { var link = new LinkDot(sPort, tPort, 4, true); pnlTree.AddObjectGraphic(link); //pnlTree.AddObjectGraphic(sPort); //pnlTree.AddObjectGraphic(tPort); } #endregion #region Funclet Design if (mustGenFunclet) AddFuncletDesign(sourceNode, targetNode); #endregion ChangeNodeIcon(sourceNode, 4); ChangeNodeIcon(targetNode, 4); }
/// <summary> /// Adds the funclet. /// </summary> /// <param name="sourceNode">The source node.</param> /// <param name="targetNode">The target node.</param> /// Created by SMK private void AddFuncletDesign(TreeNode sourceNode, TreeNode targetNode) { var existTarget = FindFuncletGraphicComponent(targetNode, false); if (existTarget == null) { SizeF sizefS = Auxi_Geometry.RoundMeasureString(this, sourceNode.Text, fontFunctionHeader); SizeF sizefT = Auxi_Geometry.RoundMeasureString(this, targetNode.Text, fontFunctionHeader); var sNode = new GraphNode(ComponentType.SourceNode, sourceNode.Text, new Point(10, 60), sizefS) { NodePath = sourceNode.FullPath }; var tNode = new GraphNode(ComponentType.TargetNode, targetNode.Text, new Point(550, 60), sizefT) { NodePath = targetNode.FullPath }; var link = new LinkDot(sNode.Ports[0], tNode.Ports[0], 4, true); AddFuncletGraphics(sNode, tNode, link); } else { // Serch Function for this existTarget var existFunction = FindFuncletGraphicComponent(targetNode, true) as Function; if (existFunction == null) { var existLd = pnlFunclet.GraphicalObjectList.Find(l => l is LinkDot) as LinkDot; //Port sPort = existLd List<string> portnames = new List<string>(); portnames.Add(existLd.StartPort.ParentComponent.Name);// portnames.Add(sourceNode.Text); existFunction = CreateFunction("concat", portnames); // Create new Graph Node SizeF sizefS = Auxi_Geometry.RoundMeasureString(this, sourceNode.Text, fontFunctionHeader); var newNode = new GraphNode(ComponentType.SourceNode, sourceNode.Text, new Point(10, 100), sizefS) { NodePath = sourceNode.FullPath }; // Create Link from Function to target node var outPort = existFunction.Ports.Find(p => p.PortType == PortType.Output) as Port; var ld = new LinkDot(outPort, existTarget.Ports[0], 4, true); outPort.IsConnected = true; existFunction.InputComponents.Add(newNode); existFunction.InputComponents.Add(existLd.StartPort.ParentComponent); // move the link from first source node to this function var portIn1 = existFunction.Ports.Find(p => p.PortType == PortType.Input && !p.IsConnected) as Port; existLd.ChangeEndPort(portIn1); portIn1.IsConnected = true; // Create Link from source Node to the new Function var portIn2 = existFunction.Ports.Find(p => p.PortType == PortType.Input && !p.IsConnected) as Port; var ld1 = new LinkDot(newNode.Ports[0], portIn2, 4, true); AddFuncletGraphics(newNode, existFunction, ld, ld1); } else { existFunction.NewPort(); // Create new Node SizeF sizefS = Auxi_Geometry.RoundMeasureString(this, sourceNode.Text, fontFunctionHeader); var newNode = new GraphNode(ComponentType.SourceNode, sourceNode.Text, new Point(10, 100 + 10 * existFunction.Ports.Count), sizefS) { NodePath = sourceNode.FullPath }; existFunction.InputComponents.Add(newNode); // Create Link from source Node to the new Function var newPort = existFunction.Ports.Find(p => p.PortType == PortType.Input && !p.IsConnected) as Port; var newLink = new LinkDot(newNode.Ports[0], newPort, 4, true); AddFuncletGraphics(newNode, newLink); } } DoGenXslt(true); }
/// <summary> /// Adds the link with attribute. /// </summary> /// <param name="nav">The nav.</param> /// <param name="tNode">The t node.</param> /// Created by SMK private void AddLinkWithAttribute(XPathNavigator nav, TreeNode tNode) { TreeNode sNode = null; string fncName = string.Empty; var lstArr = NodeUtils.GetFunctionList(nav.Value); int f_x = tabFunclet.Left; int f_y = tabFunclet.Top; int delta_x_f = 70; int delta_y_f = 20; int delta_x_n = 80; int delta_y_n = 40; int countF = 1; List<Function> lstInputInternal = new List<Function>(); if (lstArr.Count > 0) { Port linkPortF = null;// Port link for all function foreach (string item in lstArr) { fncName = string.Empty; int inF = item.IndexOf('('); if (inF > 0) { fncName = item.Substring(0, inF); if (fncName != string.Empty) { f_x += delta_x_f; f_y += delta_y_f; var agr = CommonUtility.GetTargetNodeName(item); var tmpFunc = CreateFunction(fncName, agr, f_x, f_y); int count = 2; int g_x = f_x - delta_x_n; int g_y = f_y - delta_y_f; string arr = string.Empty; //foreach (string arr in agr) for (int i = 0; i < agr.Count; i++) { arr = agr[i]; if (arr == string.Empty) { Port port = tmpFunc.Ports.Find(p => p.PortType == PortType.Input && !p.IsConnected); var fsub = lstInputInternal[0]; var outPort = fsub.Ports.Find(t => t.PortType == PortType.Output); LinkDot ld = CreateLinkDot(outPort, port); // Mark ports connected port.IsConnected = true; outPort.IsConnected = true; AddFuncletGraphics(ld); tmpFunc.InputComponents.Add(fsub); lstInputInternal.RemoveAt(0); continue; } var portFConnectIn = tmpFunc.Ports.Find(p => p.PortType == PortType.Input && !p.IsConnected); sNode = GetTreeNode(tvSource, arr); var isConstant = sNode == null || CommonUtility.IsConstantNode(sNode.FullPath); if (sNode != null) { if (portFConnectIn != null) { var input = CreateGraphNode(ComponentType.SourceNode, sNode.Text, sNode.FullPath, g_x, g_y); var ldIn = new LinkDot(input.Ports[0], portFConnectIn, 4, true); tmpFunc.InputComponents.Add(input); AddFuncletGraphics(ldIn, input); g_y += count * delta_y_n; g_x += count * delta_x_n; // Mark this port is connected portFConnectIn.SetPortStatus(true); input.Ports[0].SetPortStatus(true); ChangeNodeIcon(sNode, 4); ChangeNodeIcon(tNode, 4); AddTreeNodeToLink(sNode, tNode, false); } } else { var inputConstant = CreateGraphNode(ComponentType.Constant, arr, arr, g_x, g_y); var ldIn = new LinkDot(inputConstant.Ports[0], portFConnectIn, 4, true); tmpFunc.InputComponents.Add(inputConstant); AddFuncletGraphics(inputConstant, ldIn); g_y += count * delta_y_n; g_x += count * delta_x_n; // Mark this port is connected if (portFConnectIn != null) portFConnectIn.SetPortStatus(true); inputConstant.Ports[0].SetPortStatus(true); } } AddFuncletGraphics(tmpFunc); linkPortF = tmpFunc.Ports.Find(t => t.PortType == PortType.Output); lstInputInternal.Add(tmpFunc); } countF++; } } if (tNode != null) { var outPut = CreateGraphNode(ComponentType.SourceNode, tNode.Text, tNode.FullPath, f_x, f_y); AddFuncletGraphics(outPut); var newLd = CreateLinkDot(linkPortF, outPut.Ports[0]); AddFuncletGraphics(newLd); } nav.MoveToParent(); nav.MoveToParent(); } else { var strName = nav.Value.Substring(nav.Value.LastIndexOf("/") + 1); sNode = GetTreeNode(tvSource, strName); // add Link with two Graphic Node if (sNode != null && tNode != null) { mustGenXslt = true; AddTreeNodeToLink(sNode, tNode, false); var grpSour = CreateGraphNode(ComponentType.SourceNode, sNode.Text, sNode.FullPath, f_x, f_y); var grpTarg = CreateGraphNode(ComponentType.SourceNode, tNode.Text, tNode.FullPath, f_x + 200, f_y); var ldIn = new LinkDot(grpSour.Ports[0], grpTarg.Ports[0], 4, true); ChangeNodeIcon(sNode, 4); ChangeNodeIcon(tNode, 4); nav.MoveToParent(); nav.MoveToParent(); AddFuncletGraphics(grpSour, grpTarg, ldIn); if (!nav.MoveToNext()) return; } } }
/// <summary> /// Creates the link dot. /// </summary> /// <param name="startPort">The start port.</param> /// <param name="endPort">The end port.</param> /// <returns></returns> /// Created by SMK private LinkDot CreateLinkDot(Port startPort, Port endPort) { LinkDot ld = new LinkDot(startPort, endPort, 4, true); startPort.MarkPortConnected(true); endPort.MarkPortConnected(true); return ld; }