Beispiel #1
0
        /// <summary>
        /// Adds the link.
        /// </summary>
        /// <param name="tnSrc">The tn SRC.</param>
        /// <param name="tnTar">The tn tar.</param>
        /// <returns></returns>
        /// Created by khoaht at 9:22 AM on 11/30/2011
        public bool AddLink(TreeNode tnSrc, TreeNode tnTar)
        {
            if ((tnSrc == null) || (tnTar == null) || (mover == null))
            {
                return false;
            }
            StartNode = tnSrc;
            StartNode = tnTar;
            int deltaXpace = 100;
            int nPoints = 3;
            Point[] pts = new Point[nPoints];
            Point pointAtTarg = tvLinkedTar.InPoint(tnTar);

            pts[0] = tvLinkedSrc.OutPoint(tnSrc);
            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);

            if (tmpLnkNds == null)
            {
                tmpLnkNds = new LinkNode(tnSrc.FullPath, tnTar.FullPath, new LinkDot(pts, penLinks));
                lstLinkedNodes.Add(tmpLnkNds);
            }
            else
            {
                tmpLnkNds.AddSource(tnSrc.FullPath, new LinkDot(pts, penLinks, true));
            }

            mover.Add(tmpLnkNds.GetLinked(tnSrc.FullPath));

            return true;
        }
Beispiel #2
0
        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;
                }
            }
        }
Beispiel #3
0
        /// <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;
        }
Beispiel #4
0
        /// <summary>
        /// Handles the DragDrop event of the tabFunclet control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.DragEventArgs"/> instance containing the event data.</param>
        /// Created by SMK at  12:31 AM on 29/11/11 
        private void tabFunclet_DragDrop(object sender, DragEventArgs e)
        {
            try
            {

                if (lnkNdDesign == null)
                    lnkNdDesign = new LinkNode();
                int y = tabFunclet.Height - (FrmMain.Instance.Top + FrmMain.Instance.Height - e.Y);
                int x = tabFunclet.Width - (FrmMain.Instance.Left + FrmMain.Instance.Width - e.X);

                Point pnt = new Point(x, y);
                //Check that there is a TreeNode being dragged
                if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true) == false)
                    return;

                //Get the TreeNode being dragged
                TreeNode dropNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
                GraphNode node = null;
                if (dropNode.TreeView.Name.Equals("tvTargetXML"))
                {
                    node = new GraphNode(NodeType.Target, pnt, dropNode.Text) { NodePath = dropNode.FullPath };
                    if (lnkNdDesign.FuncList.FindIndex(t => t.FunctionName == node.NodePath) < 0)
                        lnkNdDesign.FuncList.Add(node);
                }
                else
                {
                    node = new GraphNode(NodeType.Input, pnt, dropNode.Text) { NodePath = dropNode.FullPath };
                    lnkNdDesign.FuncList.Add(node);
                }
                UpdateFormGraphic();

            }
            catch (Exception ex)
            {
                Trace(ex.Message, 5);
                Trace(ex.StackTrace, 5);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Handles the DragDrop event of the tvTargetXML control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.DragEventArgs"/> instance containing the event data.</param>
        private void tvTargetXML_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                //Check that there is a TreeNode being dragged
                if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true) == false)
                    return;

                //Get the TreeView raising the event (incase multiple on form)
                TreeView selectedTreeview = (TreeView)sender;

                //Get the TreeNode being dragged
                TreeNode dropNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");

                var targetNode1 = (EVincaTree)sender;
                //The target node should be selected from the DragOver event
                TreeNode targetNode = selectedTreeview.SelectedNode;
                bool useFunction = linkTrees.IsNodeMapped(targetNode.FullPath, true);
                var ld = linkTrees.AddNode("concat", dropNode, targetNode);
                if (ld != null)
                {
                    isMappingChanged = true;
                    ChangeSourceNodeIcon(dropNode);
                    ChangeTargetNodeIcon(targetNode);
                    lnkNdCurrentTar = linkTrees.GetLinkedNodesByTar(targetNode.FullPath);

                    #region Update on Design funclet
                    if (ld != null)
                    {
                        lnkNdDesign = lnkNdCurrentTar;
                        lstFuncsLink.AddRange(ld);

                        // Validate the LstFuncLisk
                        ValidateFuncLinkList(lstFuncsLink);
                    }
                    #endregion

                    UpdateFormGraphic();
                }
            }
            catch (Exception ex)
            {
                Trace(ex.Message, 5);
                Trace(ex.StackTrace, 5);
            }
        }
Beispiel #6
0
        /// <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 khoaht at 11:32 AM on 12/1/2011
        private void mnuItemAddConstant_Click(object sender, EventArgs e)
        {
            if (lnkNdDesign == null)
                lnkNdDesign = new LinkNode();
            using (var frm = new AddAttribute(this))
            {
                frm.ShowDialog();

                if (!string.IsNullOrEmpty(currentConstantValue))
                {
                    GraphNode fn = new GraphNode(NodeType.Constant, ptMouse_Up, this.currentConstantValue);
                    lnkNdDesign.FuncList.Add(fn);
                    UpdateFormGraphic();
                }
            }
        }
Beispiel #7
0
        /// <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;
        }
Beispiel #8
0
 /// <summary>
 /// Maps as single node with funclet.
 /// </summary>
 /// <param name="xslDoc">The XSL doc.</param>
 /// <param name="lnkndCurrent">The LNKND current.</param>
 /// <returns></returns>
 private XmlNode MapAsSingleNodeWithFunclet(XmlDocument xslDoc, LinkNode lnkndCurrent)
 {
     XmlNode tempNode = default(XmlNode);
     XmlAttribute tempAttribute = default(XmlAttribute);
     //<xsl:value-of select=""" + mappedValue + """/>
     tempNode = xslDoc.CreateElement(_xslPrefix, "value-of", _xslNameSpaceURI);
     tempAttribute = xslDoc.CreateAttribute("select");
     tempAttribute.InnerText = BuildFuncletString(lnkndCurrent.FuncList[0].InputFunclets[0]);
     tempNode.Attributes.Append(tempAttribute);
     return tempNode;
 }
Beispiel #9
0
        /// <summary>
        /// Gens the XSLT in design.
        /// </summary>        
        public void BuildXSLInDesign()
        {
            // Check the design has a match
            bool IsMatch = false;

            xslDoc = new XmlDocument();
            Funclet ginput = lnkNdDesign.FuncList.Find(t => t.NodeType == NodeType.Target);
            IsMatch = ginput != null;

            if (IsMatch)
            {
                // Clear link tree first
                linkTrees.Clear();

                XmlNode rootNode = default(XmlNode);
                XmlNode mainNode = default(XmlNode);
                XmlNode graphicNode = default(XmlNode);
                XmlAttribute tempAttribute = default(XmlAttribute);
                //target XML
                XmlDocument targetXmlDoc = new XmlDocument();

                //Setting up NSManager
                XmlNamespaceManager nmManger = new XmlNamespaceManager(xslDoc.NameTable);
                nmManger.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");
                if (!string.IsNullOrEmpty(m_TargetXMLPrefix))
                {
                    //add target xml namepace to the current
                    nmManger.AddNamespace(m_TargetXMLPrefix, m_TargetXMLNameSpaceURI);
                }
                if (!string.IsNullOrEmpty(m_SourceXMLPrefix))
                {
                    //add target xml namepace to the current
                    nmManger.AddNamespace(m_SourceXMLPrefix, m_SourceXMLNameSpaceURI);
                }

                //<xsl:stylesheet
                mainNode = xslDoc.CreateElement(_xslPrefix, "stylesheet", _xslNameSpaceURI);
                tempAttribute = xslDoc.CreateAttribute("version");
                tempAttribute.InnerText = "1.0";
                mainNode.Attributes.Append(tempAttribute);
                if (!string.IsNullOrEmpty(m_SourceXMLPrefix) || !string.IsNullOrEmpty(m_SourceXMLPrefix))
                {
                    tempAttribute = xslDoc.CreateAttribute("xmlns:" + m_SourceXMLPrefix);
                    tempAttribute.InnerText = m_SourceXMLNameSpaceURI;
                    mainNode.Attributes.Append(tempAttribute);
                }

                if (!string.IsNullOrEmpty(m_TargetXMLPrefix) || !string.IsNullOrEmpty(m_TargetXMLPrefix))
                {
                    tempAttribute = xslDoc.CreateAttribute("xmlns:" + m_TargetXMLPrefix);
                    tempAttribute.InnerText = m_TargetXMLNameSpaceURI;
                    mainNode.Attributes.Append(tempAttribute);
                }

                rootNode = xslDoc.AppendChild(mainNode);
                //<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
                mainNode = xslDoc.CreateElement(_xslPrefix, "output", _xslNameSpaceURI);
                tempAttribute = xslDoc.CreateAttribute("method");
                tempAttribute.InnerText = "xml";
                mainNode.Attributes.Append(tempAttribute);
                tempAttribute = xslDoc.CreateAttribute("encoding");
                tempAttribute.InnerText = "UTF-8";
                mainNode.Attributes.Append(tempAttribute);
                tempAttribute = xslDoc.CreateAttribute("indent");
                tempAttribute.InnerText = "yes";
                mainNode.Attributes.Append(tempAttribute);

                //<xsl:template match="/mstns:Root">
                mainNode = xslDoc.CreateElement(_xslPrefix, "template", _xslNameSpaceURI);
                tempAttribute = xslDoc.CreateAttribute("match");
                tempAttribute.InnerText = "/";
                mainNode.Attributes.Append(tempAttribute);

                targetXmlDoc.Load(fileTargetPath);

                if (targetXmlDoc.DocumentElement != null)
                {
                    mainNode.InnerXml = targetXmlDoc.DocumentElement.OuterXml;
                    BuildXSLT(xslDoc, mainNode);
                    rootNode.AppendChild(mainNode);
                }

                // Block Graphic
                graphicNode = xslDoc.CreateElement("ExGraphics");

                string xmlFrag = XsltUtils.GetXmlFrag(lnkNdDesign.FuncList);
                graphicNode.InnerXml = xmlFrag;
               // xslDoc.AppendChild(graphicNode);
                //ENd

                lnkNdCurrentTar = lnkNdDesign;
                rTxtMetaData.Text = GetXmlString(xslDoc);
                TransformOutput();
            }
        }
Beispiel #10
0
        private void fn_Click(object sender, EventArgs e)
        {
            if (lnkNdDesign == null)
                lnkNdDesign = new LinkNode();

            var obj = sender as ToolStripMenuItem;
            var tmpFn = new Function(FunctionType.Default, obj.Text, new Rectangle(ptMouse_Up.X, ptMouse_Up.Y, Config.FUNCTION_WIDTH, Config.FUNCTION_HEIGHT), (int)obj.Tag);

            lnkNdDesign.FuncList.Add(tmpFn);
            UpdateFormGraphic();
        }
Beispiel #11
0
        /// <summary>
        /// Adds the attribute to link.
        /// </summary>
        /// <param name="nav">The nav.</param>
        /// <param name="tNode">The t node.</param>
        /// Created by SMK at  10:56 PM on 26/11/11 
        private void AddLinkWithAttribute(XPathNavigator nav, TreeNode tNode)
        {
            TreeNode sNode = null;
            FunctionType fnc = NodeUtils.GetFunctionType(nav.Value);
            if (fnc != FunctionType.None)
            {
                var tName = NodeUtils.GetTargetNodeName(nav.Value);
                foreach (string item in tName)
                {
                    sNode = GetTreeNode(tvSourceXML, item);

                    // Add two node to Links
                    if (sNode != null && tNode != null)
                    {
                        if (linkTrees.AddLink(sNode, tNode))
                        {
                            ChangeTargetNodeIcon(tNode);
                            ChangeTargetNodeIcon(sNode);
                            lnkNdCurrentTar = linkTrees.GetLinkedNodesByTar(tNode.FullPath);
                            isMappingChanged = true;
                        }
                    }
                }
                nav.MoveToParent();
                nav.MoveToParent();
            }
            else
            {
                var tName = nav.Value.Substring(nav.Value.LastIndexOf("/") + 1);
                sNode = GetTreeNode(tvSourceXML, tName);
                // Add two node to Links
                if (sNode != null && tNode != null)
                {
                    if (linkTrees.AddLink(sNode, tNode))
                    {
                        ChangeSourceNodeIcon(sNode);
                        ChangeTargetNodeIcon(tNode);
                        lnkNdCurrentTar = linkTrees.GetLinkedNodesByTar(tNode.FullPath);
                        nav.MoveToParent();
                        nav.MoveToParent();
                    }
                    isMappingChanged = true;
                    if (!nav.MoveToNext()) return;
                }
                nav.MoveToParent();
            }
        }
Beispiel #12
0
        /// <summary>
        /// Handles the DragDrop event of the tvTargetXML control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.DragEventArgs"/> instance containing the event data.</param>
        private void tvTargetXML_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                //Check that there is a TreeNode being dragged
                if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true) == false)
                    return;

                //Get the TreeView raising the event (incase multiple on form)
                TreeView selectedTreeview = (TreeView)sender;

                //Get the TreeNode being dragged
                TreeNode dropNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");

                var targetNode1 = (EVincaTree)sender;
                //The target node should be selected from the DragOver event
                TreeNode targetNode = selectedTreeview.SelectedNode;

                if (linkTrees.AddLink(dropNode, targetNode))
                {
                    isMappingChanged = true;
                    ChangeSourceNodeIcon(dropNode);
                    ChangeTargetNodeIcon(targetNode);
                    lnkNdCurrentTar = linkTrees.GetLinkedNodesByTar(targetNode.FullPath);
                    UpdateFormGraphic();
                }
            }
            catch (Exception ex)
            {
                Trace(ex.Message, 5);
                Trace(ex.StackTrace, 5);
            }
        }