コード例 #1
0
ファイル: LinkNode.cs プロジェクト: huutruongqnvn/vnecoo01
        //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);
        }
コード例 #2
0
ファイル: LinkNode.cs プロジェクト: huutruongqnvn/vnecoo01
        // -------------------------------------------------        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;
        }
コード例 #3
0
ファイル: FrmItem.cs プロジェクト: huutruongqnvn/vnecoo01
        /// <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;
            }
        }
コード例 #4
0
ファイル: FrmItem.cs プロジェクト: huutruongqnvn/vnecoo01
        /// <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);
            }
        }
コード例 #5
0
ファイル: FrmItem.cs プロジェクト: huutruongqnvn/vnecoo01
        /// <summary>
        /// Handles the Click event of the mnuRemoveNode 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 4:29 PM on 11/29/2011
        private void mnuRemoveNode_Click(object sender, EventArgs e)
        {
            if (lnkNdCurrentTar != null)
                lnkNdCurrentTar.FuncList.Remove(currentNode);

            if (lnkNdDesign != null)
            {
                lnkNdDesign.FuncList.Remove(currentNode);
                UpdateLinkDot(currentNode);
            }
            UpdateFormGraphic();
            currentNode = null;
        }
コード例 #6
0
ファイル: FrmItem.cs プロジェクト: huutruongqnvn/vnecoo01
 /// <summary>
 /// Handles the Click event of the mnuRemoveLink 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 at  10:31 PM on 30/11/11 
 private void mnuRemoveLink_Click(object sender, EventArgs e)
 {
     UpdateLinkDotForPort(currentPort);
     UpdateFormGraphic();
     currentNode = null;
 }
コード例 #7
0
ファイル: FrmItem.cs プロジェクト: huutruongqnvn/vnecoo01
        /// <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();
                }
            }
        }
コード例 #8
0
ファイル: LinkNode.cs プロジェクト: huutruongqnvn/vnecoo01
        /// <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;
        }
コード例 #9
0
ファイル: LinkNode.cs プロジェクト: huutruongqnvn/vnecoo01
        /// <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;
        }