// ------------------------------------------------- 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; }
//public List<Function> FunctionList //{ // get { return functionList; } //} // ------------------------------------------------- public LinkNode(string src, string tar, LinkDot link) { dicLinkeds = new Dictionary<string, LinkDot>(); dicLinkeds.Add(src, link); TarPath = tar; endPoint = link.Points[link.DotNumber - 1]; beforeEndPoint = link.Points[link.DotNumber - 2]; //ToDo add function GraphNode graphNodeSrc = new GraphNode(new Point(200, 50), new string[] { src }); GraphNode graphNodeTar = new GraphNode(new Point(600, 50), new string[] { tar }); funcList.Add(graphNodeTar); funcList.Add(graphNodeSrc); graphNodeTar.InputFunclets.Add(graphNodeSrc); }
/// <summary> /// Gets the linked nodes by linked dots. /// </summary> /// <param name="link">The link.</param> /// <returns></returns> public LinkNode GetLinkedNodesByLinkedDots(LinkDot link) { return lstLinkedNodes.Find(obj => obj.ContainLinkedDots(link)); }
// ------------------------------------------------- ContainLinkedDots public bool ContainLinkedDots(LinkDot link) { return dicLinkeds.ContainsValue(link); }
// ------------------------------------------------- public static LinkDot FromRegistry(RegistryKey regkey, string name) { try { string[] strs = (string[])regkey.GetValue(name); if (strs != null && strs.Length >= 10) { Pen pn = Auxi_Convert.ToPen(strs, strs.Length - 6); Point[] points = new Point[(strs.Length - 6) / 2]; for (int i = 0; i < points.Length; i++) { points[i] = Auxi_Convert.ToPoint(strs, i * 2); } LinkDot ld = new LinkDot(points, pn); return (ld); } else { return (null); } } catch { return (null); } finally { } }
/// <summary> /// Adds the node. /// </summary> /// <param name="tnSrc">The tn SRC.</param> /// <param name="tnTar">The tn tar.</param> /// <returns></returns> /// Created by SMK at 7:09 AM on 30/11/11 public List<LinkDot> AddNode(string functionName, TreeNode tnSrc, TreeNode tnTar) { List<LinkDot> ret = null; //if ((tnSrc == null) || (tnTar == null) || (mover == null)) if ((tnTar == null) || (mover == null)) { return null; } StartNode = tnSrc; EndNode = tnTar; ret = new List<LinkDot>(); int deltaXpace = 100; int nPoints = 3; Point[] pts = new Point[nPoints]; Point pointAtTarg = tvLinkedTar.InPoint(tnTar); pts[0] = tvLinkedSrc.OutPoint(tnSrc ?? tnTar); pts[nPoints - 1] = pointAtTarg; if (nPoints == 3) { // Increa the space pointAtTarg.X -= deltaXpace; pts[1] = pointAtTarg; } LinkNode tmpLnkNds = lstLinkedNodes.Find(link => link.TarPath == tnTar.FullPath); string path = tnSrc != null ? tnSrc.FullPath : string.Empty; if (tmpLnkNds == null) { tmpLnkNds = new LinkNode(path, tnTar.FullPath, new LinkDot(pts, penLinks)); lstLinkedNodes.Add(tmpLnkNds); #region Get LinkDot for funclet design var obj = new LinkDot(tmpLnkNds.StartNode.ListPort[0], tmpLnkNds.EndNode.ListPort[0], penLinks, 4); ret.Add(obj); #endregion } else { ret = tmpLnkNds.AddGroupNode(functionName, path, new LinkDot(pts, penLinks, true), penLinks, 4); } if (tnSrc != null) mover.Add(tmpLnkNds.GetLinked(tnSrc.FullPath)); return ret; }
private void AddLinkWithAttribute(XPathNavigator nav, TreeNode tNode) { TreeNode sNode = null; string fncName = string.Empty; FunctionType fnc = NodeUtils.GetFunctionType(nav.Value); 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<Funclet> lstInputInternal = new List<Funclet>(); 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 = Utils.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.ListPort.Find(p => p.PortType == PortType.InputSub && !p.IsConnected); var fsub = lstInputInternal[0]; var outPort = fsub.ListPort.Find(t => t.PortType == PortType.Output); LinkDot ld = CreateLinkDot(outPort, port); // Mark ports connected port.MarkPortConnected(port.ID, true); outPort.MarkPortConnected(outPort.ID, true); lstFuncsLink.Add(ld); tmpFunc.InputFunclets.Add(fsub); lstInputInternal.RemoveAt(0); continue; } var portFConnectIn = tmpFunc.ListPort.Find(p => p.PortType == PortType.Input && !p.IsConnected); sNode = GetTreeNode(tvSourceXML, arr); var isConstant = sNode == null || Utils.IsConstantNode(sNode.FullPath); if (sNode != null) { if (portFConnectIn != null) { var input = CreateGraphNode(NodeType.Input, sNode.Text, sNode.FullPath, g_x, g_y); var ldIn = new LinkDot(input.ListPort[0], portFConnectIn, penLinks, 4); tmpFunc.InputFunclets.Add(input); lnkNdCurrentTar.FuncList.Add(input); lstFuncsLink.Add(ldIn); g_y += count * delta_y_n; g_x += count * delta_x_n; // Mark this port is connected tmpFunc.MarkPortConnected(portFConnectIn); input.MarkPortConnected(input.ID, true); linkTrees.AddLink(sNode, tNode); ChangeSourceNodeIcon(sNode); ChangeSourceNodeIcon(tNode); } } else { var inputConstant = CreateGraphNode(NodeType.Constant, arr, arr, g_x, g_y); var ldIn = new LinkDot(inputConstant.ListPort[0], portFConnectIn, penLinks, 4); tmpFunc.InputFunclets.Add(inputConstant); lnkNdCurrentTar.FuncList.Add(inputConstant); lstFuncsLink.Add(ldIn); g_y += count * delta_y_n; g_x += count * delta_x_n; // Mark this port is connected tmpFunc.MarkPortConnected(portFConnectIn); inputConstant.MarkPortConnected(inputConstant.ID, true); } } lnkNdCurrentTar.FuncList.Add(tmpFunc); linkPortF = tmpFunc.ListPort.Find(t => t.PortType == PortType.Output); lstInputInternal.Add(tmpFunc); } countF++; } } var outPut = CreateGraphNode(NodeType.Target, tNode.Text, tNode.FullPath, f_x + 80, f_y); lnkNdCurrentTar.FuncList.Add(outPut); lstFuncsLink.Add(CreateLinkDot(linkPortF, outPut.ListPort[0])); nav.MoveToParent(); nav.MoveToParent(); } else { var strName = nav.Value.Substring(nav.Value.LastIndexOf("/") + 1); sNode = GetTreeNode(tvSourceXML, strName); // add Link with two Graphic Node if (sNode != null && tNode != null) { var ld = linkTrees.AddNode(fnc.ToString(), sNode, tNode); if (ld != null) { ChangeSourceNodeIcon(sNode); ChangeTargetNodeIcon(tNode); lnkNdCurrentTar = linkTrees.GetLinkedNodesByTar(tNode.FullPath); lstFuncsLink.AddRange(ld); nav.MoveToParent(); nav.MoveToParent(); } isMappingChanged = true; if (!nav.MoveToNext()) return; } } }
private LinkDot CreateLinkDot(Port startPort, Port endPort) { LinkDot ld = new LinkDot(startPort, endPort, penLinks, 4); startPort.MarkPortConnected(true); endPort.MarkPortConnected(true); return ld; }
/// <summary> /// Handles the MouseDown event of the tabFunclet control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> /// Created by SMK at 2:15 PM on 27/11/11 private void tabFunclet_MouseDown(object sender, MouseEventArgs e) { ptMouse_Down = e.Location; moverOnTab.Catch(e.Location, e.Button); if (moverOnTab.CaughtSource is LinkDot) { currentLinkDot = moverOnTab.CaughtSource as LinkDot; tabFunclet.ContextMenuStrip = ctxLinkDot; ctxLinkDot.Left = ptMouse_Down.X; ctxLinkDot.Top = ptMouse_Down.Y; } #region ShowFunctionMenuTripContext if (e.Button == System.Windows.Forms.MouseButtons.Right) { ShowFunctionMenuTripContext(); } #endregion }
/// <summary> /// Handles the MouseUp event of the tabFunclet control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> /// Created by SMK at 2:19 PM on 27/11/11 private void tabFunclet_MouseUp(object sender, MouseEventArgs e) { ptMouse_Up = e.Location; double dist = Auxi_Geometry.Distance(ptMouse_Down, e.Location); //ContextMenuStrip = cmenuFunc; tabFunclet.ContextMenuStrip = null; int iWasCaught, iNode; NodeShape shape; if (moverOnTab.Release(out iWasCaught, out iNode, out shape)) { GraphicalObject grobj = moverOnTab[iWasCaught].Source; if (e.Button == MouseButtons.Left) { if (grobj is Function) { if (((Function)grobj).LeftClick(e.Location) == true) { UpdateFormGraphic(); } } if (grobj is Port) { var endPort = FindPortCandidate(ptMouse_Up); if (endPort != null && portLinkStart != null && endPort.PortType == PortType.Input && portLinkStart.PortType == PortType.Output) { var ld = new LinkDot(portLinkStart, endPort, penLinks, 4); lstFuncsLink.Add(ld); UpdateFormGraphic(); portLinkStart = null; var parentS = endPort.ParentFunlet; if (parentS is Function) { var obj = lnkNdDesign.FuncList.FindAll(t => t.ListPort.Exists(u => u.ID == grobj.ID)); if (obj != null) { endPort.ParentFunlet.InputFunclets.AddRange(obj); } } endPort.MarkPortConnected(endPort); BuildXSLInDesign(); } } if (grobj is LinkDot) { if (currentLinkDot != null) { var objLink = lstFuncsLink.Find(t => t.StartPort == currentLinkDot.StartPort); var endPort = FindPortCandidate(ptMouse_Up); if (objLink != null && endPort != null) { objLink.EndPort.MarkPortConnected(objLink.EndPort.ID, false); lstFuncsLink.Remove(currentLinkDot); var ld = new LinkDot(currentLinkDot.StartPort, endPort, penLinks, 4); lstFuncsLink.Add(ld); UpdateFormGraphic(); portLinkStart = null; var parentS = endPort.ParentFunlet; if (parentS is Function) { var obj = lnkNdDesign.FuncList.Find(t => t.ListPort.Exists(u => u.ID == grobj.ID)) as GraphNode; if (obj != null) endPort.ParentFunlet.InputFunclets.Add(obj); } endPort.MarkPortConnected(endPort); BuildXSLInDesign(); } } } } else if (e.Button == MouseButtons.Right) { if (grobj is Function) { OnMouseUpObject = grobj; PointAtMouseUp = e.Location; } if (grobj is Port) { OnMouseUpObject = grobj; PointAtMouseUp = e.Location; } if (grobj is GraphConcat) { OnMouseUpObject = grobj; PointAtMouseUp = e.Location; } else { tabFunclet.ContextMenuStrip = null; } } } isOnMovingHeadOfLine = false; isOnMovingTailOfLine = false; this.tabFunclet.ContextMenuStrip = ctxFunlet; MustPaint(); }
/// <summary> /// Shows the function menu trip context. /// </summary> /// Created by khoaht at 3:51 PM on 11/29/2011 private void ShowFunctionMenuTripContext() { Point p = ptMouse_Down; if (moverOnTab.CaughtSource is Function) { currentFnc = moverOnTab.CaughtSource as Function; tabFunclet.ContextMenuStrip = ctxFunction; ctxFunction.Left = p.X; ctxFunction.Top = p.Y; } else if (moverOnTab.CaughtSource is Port) { currentPort = moverOnTab.CaughtSource as Port; if (currentPort.PortType == PortType.Input) { tabFunclet.ContextMenuStrip = ctxPort; ctxPort.Left = p.X; ctxPort.Top = p.Y; } } else if (moverOnTab.CaughtSource is GraphNode) { currentNode = moverOnTab.CaughtSource as GraphNode; tabFunclet.ContextMenuStrip = ctxTripNode; ctxTripNode.Left = p.X; ctxTripNode.Top = p.Y; } else if (moverOnTab.CaughtSource is LinkDot) { currentLinkDot = moverOnTab.CaughtSource as LinkDot; tabFunclet.ContextMenuStrip = ctxLinkDot; ctxLinkDot.Left = p.X; ctxLinkDot.Top = p.Y; } }
/// <summary> /// Handles the MouseUp event of the pnlMapper control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> /// Created by khoaht at 5:04 PM on 11/25/2011 private void pnlMapper_MouseUp(object sender, MouseEventArgs e) { Cursor.Clip = Rectangle.Empty; ptMouse_Up = e.Location; double fDist = Auxi_Geometry.Distance(ptMouse_Down, ptMouse_Up); int iWasObject, iWasNode; NodeShape shapeWasCaught; if (mover.Release(out iWasObject, out iWasNode, out shapeWasCaught)) { GraphicalObject grobj = mover.WasCaughtSource; if (e.Button == MouseButtons.Right && fDist <= 3) { if (grobj is LinkDot) { ldPressed = grobj as LinkDot; if (shapeWasCaught == NodeShape.Circle) { iPressedDot = iWasNode + 1; } else { iPressedDot = -1; } linkTrees.ResetAppearanceOfLinks(); Pen pen = new Pen(Color.Chartreuse, 3); ldPressed.Pen = pen; pnlMapper.Invalidate(); //ContextMenuStrip = menuOnLinks; } } else if (e.Button == MouseButtons.Left) { if (grobj is LinkDot) { ldPressed = grobj as LinkDot; linkTrees.ResetAppearanceOfLinks(); Pen pen = new Pen(ldPressed.Pen.Color, 2); ldPressed.Pen = pen; lnkNdCurrentTar = linkTrees.GetLinkedNodesByLinkedDots(ldPressed); UpdateFormGraphic(); } } } bFormInMove = 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 link. /// </summary> /// <param name="graphNodeSrc">The graph node SRC.</param> /// <param name="tmpFunc">The TMP func.</param> private LinkDot CreateLink(Funclet Node, Funclet function, Pen pen, int nPoints) { LinkDot ret = null; Port startPort = Node.ListPort[0]; if (startPort.PortType == PortType.Input) { Port endPort = function.ListPort.Find(p => p.IsConnected == false && p.PortType == PortType.Output); ret = new LinkDot(endPort, startPort, pen, nPoints); function.MarkPortConnected(endPort); } else { Port port = function.ListPort.Find(t => t.PortType == PortType.Input && !t.IsConnected); ret = new LinkDot(startPort, port, pen, nPoints); function.MarkPortConnected(port); } return ret; }
/// <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; }