/// <summary> /// Creates the component. /// </summary> /// <param name="dropNode">The drop node.</param> /// <returns></returns> /// Created by SMK private ComponentBase CreateComponent(TreeNode dropNode, ComponentType type) { Point pt = pnlFunclet.PointToClient(currentPoint); var sizef = Auxi_Geometry.RoundMeasureString(this, dropNode.Text, Config.FONT_HEADER); var node = new GraphNode(type, dropNode.Text, pt, sizef) { NodePath = dropNode.FullPath }; return node; }
/// <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> /// Handles the Click event of the mnuItemAddConstant control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// Created by SMK private void mnuItemAddConstant_Click(object sender, EventArgs e) { using (var frm = new FrmConstant(this)) { frm.ShowDialog(); if (!string.IsNullOrEmpty(mStringConstant)) { var sizef = Auxi_Geometry.RoundMeasureString(this, mStringConstant, Config.FONT_HEADER); GraphNode fn = new GraphNode(ComponentType.Constant, mStringConstant, ptMouse_Up, sizef) { NodePath = this.mStringConstant }; AddFuncletGraphics(fn); } } }
/// <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> /// Groups the function. /// </summary> /// <param name="func">The func.</param> /// <param name="tPort">The t port.</param> /// Created by SMK private void GroupFunction(GraphNode obj, Port targetPort) { var linkDots = pnlTree.GraphicalObjectList.FindAll(l => l is LinkDot && ((LinkDot)l).EndPort == targetPort); foreach (ComponentBase item in linkDots) { LinkDot ld = item as LinkDot; if (ld.StartPort != obj.Ports[0]) { ld.MustDrawArrow = false; ld.ChangeEndPort(obj.Ports[1]); obj.InputComponents.Add(ld); } } }