Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkDot"/> class.
 /// </summary>
 /// <param name="startPort">The start port.</param>
 /// <param name="endPort">The end port.</param>
 /// <param name="pn">The pn.</param>
 /// <param name="nPoints">The n points.</param>
 /// <param name="type">The type.</param>
 public LinkDot(Port startPort, Port endPort, Pen pn,int nPoints)
 {
     this.StartPort = startPort;
     this.EndPort = endPort;
     var _pts = GetPointArray(startPort, endPort, nPoints);
     if (_pts != null && _pts.Length > 1)
     {
         for (int i = 0; i < _pts.Length; i++)
         {
             pts.Add(_pts[i]);
         }
     }
     else
     {
         pts.Add(new Point(100, 100));
         pts.Add(new Point(200, 200));
     }
     pen = pn;
     sBrush = new SolidBrush(pn.Color);
 }
Exemple #2
0
        public override void InitPort()
        {
            // Add output port
            if (ListPort == null)
            {
                ListPort = new List<Port>();

                int port_y = area.Top + area.Height / 4;
                Port port = null;
                if (NodeType == VincaMapper.NodeType.Input || NodeType == VincaMapper.NodeType.Constant)
                {
                    port = new Port(this, area.Right + Config.PORT_DELTA, port_y, PortType.Output);
                }
                else
                {
                    port = new Port(this, area.Left - Config.PORT_DELTA - Config.PORT_WIDTH, port_y, PortType.Input);
                }
                ListPort.Add(port);
            }
        }
Exemple #3
0
 public bool ComparePort(Port p)
 {
     return (p.LinkPoint.X == this.LinkPoint.X && p.LinkPoint.Y == this.LinkPoint.Y && this.ID != p.ID);
 }
Exemple #4
0
 private LinkDot CreateLinkDot(Port startPort, Port endPort)
 {
     LinkDot ld = new LinkDot(startPort, endPort, penLinks, 4);
     startPort.MarkPortConnected(true);
     endPort.MarkPortConnected(true);
     return ld;
 }
Exemple #5
0
 private Function CreateFunction(string fname, List<string> agr, int f_x, int f_y, Port portLink)
 {
     var newFunction = (new Function(FunctionType.Default, fname, new Rectangle(f_x, f_y, Config.FUNCTION_WIDTH, Config.FUNCTION_HEIGHT), agr));
     if (portLink != null)
     {
         var portInput = newFunction.ListPort.Find(t => t.PortType == PortType.Input);
         LinkDot ld = CreateLinkDot(portLink, portInput);
         newFunction.MarkPortConnected(portInput);
         portLink.MarkPortConnected(true);
     }
     return newFunction;
 }
Exemple #6
0
        /// <summary>
        /// Moves the end dot.
        /// </summary>
        /// <param name="pt">The pt.</param>
        /// Created by SMK at  9:35 AM on 26/11/11 
        public void MoveWithPort(Port pt)
        {
            bool isMoveStartPort = StartPort.ID == pt.ID;
            if (pts.Count > 3)
            {
                if (isMoveStartPort)
                {
                    pts[1] = new Point(pt.LinkPoint.X + Config.DISTURN, pt.LinkPoint.Y);
                    pts[0] = pt.LinkPoint;
                }
                else
                {
                    pts[2] = new Point(pt.LinkPoint.X - Config.DISTURN, pt.LinkPoint.Y);
                    pts[3] = pt.LinkPoint;
                }

            }
            DefineCover();
        }
Exemple #7
0
 /// <summary>
 /// Marks the port connected.
 /// </summary>
 /// <param name="port">The port.</param>
 /// Created by khoaht at 9:58 AM on 11/30/2011
 public void MarkPortConnected(Port port)
 {
     if (this is Port)
     {
         ((Port)this).IsConnected = true;
     }
     else
     {
         ListPort.ForEach(p =>
         {
             if (p.ID == port.ID)
             {
                 p.IsConnected = true;
             }
         });
     }
 }
Exemple #8
0
        /// <summary>
        /// News the port.
        /// </summary>
        /// Created by khoaht at 10:45 AM on 11/30/2011
        public void NewPort()
        {
            area.Height += Config.FUNCTION_HEIGHT_UNIT;
            int port_y = area.Bottom - area.Height / 4;
            //input port
            Port newPort = new Port(this, area.Left - Config.PORT_WIDTH - Config.PORT_DELTA, port_y, PortType.Input);
            ListPort.Add(newPort);

            var outp = ListPort.Find(t => t.PortType == PortType.Output);
            outp.Y += Config.FUNCTION_HEIGHT_UNIT / 2;
        }
Exemple #9
0
        /// <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;
            }
        }
Exemple #10
0
 private void PrintTrack(Port port)
 {
     Console.WriteLine("{0} - X({1}) | Y({2})", port.PortType, port.LinkPoint.X, port.LinkPoint.Y);
 }
Exemple #11
0
 /// <summary>
 /// Moves the link node.
 /// </summary>
 /// <param name="nodePort">The node port.</param>
 /// Created by khoaht at 3:03 PM on 11/29/2011
 private void MoveLinkNode(Port nodePort)
 {
     for (int i = 0; i < lstFuncsLink.Count; i++)
     {
         if (lstFuncsLink[i].StartPort == nodePort || lstFuncsLink[i].EndPort == nodePort)
         {
             lstFuncsLink[i].MoveWithPort(nodePort);
             break;
         }
     }
 }
Exemple #12
0
 private bool IsExistPort(Port port)
 {
     return lstFuncsLink.Exists(ld => ld.EndPort.Equals(port));
 }
Exemple #13
0
 /// <summary>
 /// Gets the point array.
 /// </summary>
 /// <param name="nPoints">The n points.</param>
 /// <param name="pPort">The p port.</param>
 /// <param name="cPort">The c port.</param>
 /// <returns></returns>
 /// Created by khoaht at 4:37 PM on 11/28/2011
 private Point[] GetPointArray(Port startPort, Port endPort, int nPoints)
 {
     Point[] pts = new Point[nPoints];
     pts[0] = startPort.LinkPoint;
     pts[nPoints - 1] = endPort.LinkPoint;
     if (nPoints == 3)
     {
         pts[1] = new Point(endPort.LinkPoint.X - Config.DISTURN, endPort.LinkPoint.Y);
     }
     return pts;
 }
Exemple #14
0
        public override void InitPort()
        {
            // Add output port
            if (ListPort == null)
            {
                ListPort = new List<Port>();

                int port_y = area.Top + area.Top / 16;

                // input port
                Port input = new Port(this,area.Left - Config.PORT_WIDTH - Config.PORT_DELTA, port_y, PortType.Input) ;
                ListPort.Add(input);

                //output port
                Port output = new Port(this, area.Right + Config.PORT_DELTA, port_y, PortType.Output);
                ListPort.Add(output);
            }
        }
Exemple #15
0
        /// <summary>
        /// Handles the MouseMove 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:16 PM on 27/11/11 
        private void tabFunclet_MouseMove(object sender, MouseEventArgs e)
        {
            if (moverOnTab.Move(e.Location))
            {
                TabPage page = sender as TabPage;

                if (page != null)
                {
                    if (moverOnTab.CaughtSource is Funclet)
                    {
                        Funclet fmove = moverOnTab.CaughtSource as Funclet;

                        if (fmove is GraphNode)
                        {
                            var nodePort = fmove.ListPort[0];
                            MoveLinkNode(nodePort);
                        }
                        else if (fmove is Function)
                        {
                            foreach (Port item in fmove.ListPort)
                            {
                                MoveLinkNode(item);
                            }
                        }
                        else if (fmove is Port)
                        {
                            portLinkStart = fmove as Port;
                        }

                    }

                    if (moverOnTab.CaughtSource is LinkDot)
                    {
                        LinkDot link = moverOnTab.CaughtSource as LinkDot;

                        //If mouse move and mouse button down at head of line
                        double dist = Auxi_Geometry.Distance(ptMouse_Down, link.Points[link.Points.Count - 1]);
                        if ((dist < 4) || (isOnMovingHeadOfLine == true))
                        {
                            link.MoveEndDot(e.Location);
                            isOnMovingHeadOfLine = true;
                        }

                        //If mouse move and mouse button down at begin of line
                        dist = Auxi_Geometry.Distance(ptMouse_Down, link.Points[0]);
                        if ((dist < 4) || (isOnMovingTailOfLine == true))
                        {
                            link.MoveDot(0, e.Location);
                            isOnMovingTailOfLine = true;
                        }
                    }

                }
            }
        }
Exemple #16
0
        /// <summary>
        /// Inits the port.
        /// </summary>
        /// Created by khoaht at 10:45 AM on 11/30/2011
        public override void InitPort()
        {
            // Add output port
            if (ListPort == null)
            {
                if (nPorts == 2)
                {
                    ListPort = new List<Port>();

                    int port_y = area.Top + area.Height / 4;

                    // input port
                    Port input = new Port(this, area.Left - Config.PORT_WIDTH - Config.PORT_DELTA, port_y, PortType.Input);
                    ListPort.Add(input);
                    //input port
                    port_y = area.Top + area.Height * 3 / 4;
                    Port input2 = new Port(this, area.Left - Config.PORT_WIDTH - Config.PORT_DELTA, port_y, PortType.Input);
                    ListPort.Add(input2);

                    //output port
                    int port_out_y = area.Top + area.Height / 2;
                    Port output = new Port(this, area.Right + Config.PORT_DELTA, port_out_y, PortType.Output);
                    ListPort.Add(output);
                }
                else if (nPorts >= 4)
                {

                    //output port
                    int port_out_y = area.Top + area.Height / 2;

                    Port output = new Port(this, area.Right + Config.PORT_DELTA, port_out_y, PortType.Output);
                    ListPort.Add(output);

                    int port_y = area.Top;
                    for (int i = 0; i < nPorts - 1; i++)
                    {
                        area.Height += 10 * i;

                        port_y += area.Height / 4;
                        //input port
                        Port newPort = new Port(this, area.Left - Config.PORT_WIDTH - Config.PORT_DELTA, port_y, PortType.Input);
                        ListPort.Add(newPort);

                        var outp = ListPort.Find(t => t.PortType == PortType.Output);
                        outp.Y = area.Top + area.Height / 2;
                    }
                }
            }
        }
Exemple #17
0
        /// <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();
        }
Exemple #18
0
        /// <summary>
        /// Inits the port with aggurment.
        /// </summary>
        /// <param name="lstPorts">The LST ports.</param>
        /// Created by khoaht at 10:04 AM on 11/30/2011
        private void InitPortWithAggurment(List<string> lstPorts)
        {
            // Add output port
            if (ListPort == null)
            {
                ListPort = new List<Port>();
                int port_y = area.Top + area.Height / 4;

                //output port
                int port_out_y = area.Top + area.Height / 2;
                Port output = new Port(this, area.Right + Config.PORT_DELTA, port_out_y, PortType.Output);
                ListPort.Add(output);
                area.Height += 10 * lstPorts.Count - 1;
                foreach (string item in lstPorts)
                {
                    PortType pt = item == string.Empty ? PortType.InputSub : PortType.Input;
                    port_y += area.Height / 4;
                    //input port
                    Port newPort = new Port(this, area.Left - Config.PORT_WIDTH - Config.PORT_DELTA, port_y, pt);
                    ListPort.Add(newPort);

                    var outp = ListPort.Find(t => t.PortType == PortType.Output);
                    outp.Y = area.Top + area.Height / 2;
                }
            }
        }
Exemple #19
0
 private void UpdateLinkDotForPort(Port delFunclet)
 {
     // Link source
     List<LinkDot> slst = new List<LinkDot>();
     foreach (LinkDot _item in lstFuncsLink)
     {
         if (_item.EndPort.ID != delFunclet.ID && delFunclet.PortType == PortType.Input)
         {
             slst.Add(_item);
         }
         else if (_item.StartPort.ID != delFunclet.ID && delFunclet.PortType == PortType.Output)
         {
             slst.Add(_item);
         }
     }
     lstFuncsLink = slst;
 }
Exemple #20
0
 public void SetPortLink(Port port)
 {
     LinkPorts.Add(port);
 }
Exemple #21
0
 /// <summary>
 /// Deletes the specified star port.
 /// </summary>
 /// <param name="starPort">The star port.</param>
 /// <param name="endPort">The end port.</param>
 /// Created by SMK at  10:30 PM on 30/11/11 
 public void Delete(Port starPort, Port endPort)
 {
     if (StartPort == starPort && EndPort == endPort)
     {
         this.RemoveItSelf();
     }
 }