Ejemplo n.º 1
0
 /// <summary>
 /// Inits the port.
 /// </summary>
 /// Created by khoaht at 10:45 AM on 11/30/2011
 public override void InitPort()
 {
     if (Ports == null)
         Ports = new List<Port>();
     // Add Input
     int space = 3 * Config.PORT_D / 4;
     int y = area.Top + Config.PORT_D / 2;
     for (int i = 0; i < nPorts; i++)
     {
         Port newPort = new Port(this, area.Left - Config.PORT_WIDTH - Config.PORT_DELTA, y, PortType.Input);
         Ports.Add(newPort);
         y += (i + 1) * space + Config.PORT_D;
     }
     int out_y = area.Top + area.Height / 2 - Config.PORT_D / 2;
     Port outPort = new Port(this, area.Right + Config.PORT_DELTA, out_y, PortType.Output);
     Ports.Add(outPort);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// News the port.
        /// </summary>
        public void NewPort()
        {
            area.Height += 2 * Config.PORT_D;

            int y = area.Bottom - Config.PORT_D;
            Port newPort = new Port(this, area.Left - Config.PORT_WIDTH - Config.PORT_DELTA, y, PortType.Input);
            Ports.Add(newPort);

            var outPort = Ports.Find(p => p.PortType == PortType.Output);
            outPort.Y = area.Top + area.Height / 2 - Config.PORT_D / 2;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the tree node to link.
 /// </summary>
 /// <param name="portLinkStart">The port link start.</param>
 /// <param name="endPort">The end port.</param>
 /// Created by SMK
 private void AddTreeNodeToLink(Port portLinkStart, Port endPort)
 {
     if (endPort != null && portLinkStart != null)
     {
         var SNode = portLinkStart.ParentComponent as GraphNode;
         var TNode = endPort.ParentComponent as GraphNode;
         if (SNode != null && TNode != null)
         {
             var sourceNode = FindNode(tvSource.Nodes[0], SNode.Name) as TreeNode;
             var targetNode = FindNode(tvTarget.Nodes[0], TNode.Name) as TreeNode;
             if (sourceNode != null && targetNode != null)
             {
                 AddTreeNodeToLink(sourceNode, targetNode, false);
             }
         }
         else
         {
             var targetPort = pnlFunclet.GraphicalObjectList.Find(p => p is GraphNode && p.ComponentType == ComponentType.TargetNode && p.Ports[0].IsConnected);
             var lstSource = pnlFunclet.GraphicalObjectList.FindAll(n => n.ComponentType == ComponentType.SourceNode && n.Ports[0].IsConnected);
             if (lstSource != null && targetPort != null)
             {
                 var targetNode = FindNode(tvTarget.Nodes[0], targetPort.Name) as TreeNode;
                 foreach (ComponentBase item in lstSource)
                 {
                     var obj = item as GraphNode;
                     var sourceNode = FindNode(tvSource.Nodes[0], obj.Name) as TreeNode;
                     if (sourceNode != null && targetNode != null)
                     {
                         AddTreeNodeToLink(sourceNode, targetNode, false);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Compares the port.
 /// </summary>
 /// <param name="p">The p.</param>
 /// <returns></returns>
 public bool ComparePort(Port p)
 {
     return (p.LinkPoint.X == this.LinkPoint.X && p.LinkPoint.Y == this.LinkPoint.Y && this.ID != p.ID);
 }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Determines whether the specified end port has function.
        /// </summary>
        /// <param name="endPort">The end port.</param>
        /// <returns>
        /// 	<c>true</c> if the specified end port has function; otherwise, <c>false</c>.
        /// </returns>
        /// Created by SMK
        private bool HasFunction(Port endPort)
        {
            var linkDots = pnlTree.GraphicalObjectList.FindAll(l => l is LinkDot);
            foreach (ComponentBase item in linkDots)
            {
                LinkDot ld = item as LinkDot;
                if (ld.EndPort.Name == endPort.Name)
                    return true;
            }

            return false;
        }
Ejemplo n.º 7
0
 /// <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);
         }
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Gets the function.
 /// </summary>
 /// <returns></returns>
 /// Created by SMK
 private ComponentBase GetFunction(Port endPort)
 {
     var linkDots = pnlTree.GraphicalObjectList.FindAll(l => l is LinkDot);
     foreach (ComponentBase item in linkDots)
     {
         LinkDot ld = item as LinkDot;
         if (ld.EndPort.Name == endPort.Name)
         {
             if (ld.Function == null)
                 continue;
             return ld.Function;
         }
     }
     return null;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates the link dot.
 /// </summary>
 /// <param name="startPort">The start port.</param>
 /// <param name="endPort">The end port.</param>
 /// <returns></returns>
 /// Created by SMK
 private LinkDot CreateLinkDot(Port startPort, Port endPort)
 {
     LinkDot ld = new LinkDot(startPort, endPort, 4, true);
     startPort.MarkPortConnected(true);
     endPort.MarkPortConnected(true);
     return ld;
 }