Exemplo n.º 1
0
        public void DrawTextToAllNodes(Node node, Node parent, ng.SystemVRF sysItem)
        {
            // RND
            if (sysItem.editrpt == false)
            {
                sysItem.IsExportToReport = true;
            }

            if (node is ng.MyNodeOut)
            {
                ng.MyNodeOut nodeOut = node as ng.MyNodeOut;
                DrawTextToAllNodes(nodeOut.ChildNode, nodeOut, sysItem);
                nodeOut.Stroke = System.Windows.Media.Brushes.RoyalBlue;
            }
            else if (node is ng.MyNodeYP)
            {
                ng.MyNodeYP nodeYP = node as ng.MyNodeYP;
                drawTextToOtherNode(node, parent, sysItem);

                foreach (Node item in nodeYP.ChildNodes)
                {
                    DrawTextToAllNodes(item, nodeYP, sysItem);
                }
            }
            else if (node is ng.MyNodeCH)
            {
                ng.MyNodeCH nodeCH = node as ng.MyNodeCH;
                drawTextToOtherNode(node, parent, sysItem);

                DrawTextToAllNodes(nodeCH.ChildNode, nodeCH, sysItem);
            }
            else if (node is ng.MyNodeMultiCH)
            {
                ng.MyNodeMultiCH nodeMCH = node as ng.MyNodeMultiCH;
                drawTextToOtherNode(node, parent, sysItem);

                foreach (Node item in nodeMCH.ChildNodes)
                {
                    DrawTextToAllNodes(item, nodeMCH, sysItem);
                }
            }
            else if (node is ng.MyNodeIn)
            {
                ng.MyNodeIn nodeIn = node as ng.MyNodeIn;
                drawTextToIDUNode(sysItem, nodeIn);
            }

            if (node is ng.MyNode)
            {
                ng.MyNode myNode = node as ng.MyNode;
                if (myNode != null && myNode.MyInLinks != null && myNode.MyInLinks.Count > 0)
                {
                    for (int i = 0; i < myNode.MyInLinks.Count; i++)
                    {
                        ng.MyLink myLink = myNode.MyInLinks[i] as ng.MyLink;
                        drawTextToLink(myLink, i, parent, node, isInch, sysItem);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void SetLinkTextLocationForSechmaA(ng.MyLink myLink, int linkIndex, Node parent, Node node, Node label1, bool isVertical)
        {
            PointF ptText, ptParent, ptNode;

            ptText = getLeftCenterPointF(node);
            PipingOrientation inlinkOrientation = CheckLinkOrientation(node, myLink);

            if (inlinkOrientation == PipingOrientation.Down)
            {
                ptParent = convertSystemPointToDrawingPoint(parent.Location);
                //ptParent = parent.Location;
                ptNode = getBottomCenterPointF(node);

                ptText.X = (float)(ptNode.X - label1.Size.Width);
                //ptText.X = ptNode.X - label1.Size.Width;
                ptText.Y = (float)((ptNode.Y + ptParent.Y - label1.Size.Height) / 2);
                //ptText.Y = (ptNode.Y + ptParent.Y - label1.Size.Height) / 2;
            }
            else if (inlinkOrientation == PipingOrientation.Up)
            {
                ptParent = getLeftBottomPointF(parent);
                ptNode   = getTopCenterPointF(node);

                ptText.X = (float)(ptNode.X - label1.Size.Width);
                ptText.Y = (float)((ptNode.Y + ptParent.Y - label1.Size.Height) / 2);
            }
            else if (inlinkOrientation == PipingOrientation.Left)
            {
                if (parent is ng.MyNodeOut)
                {
                    ptParent = getLeftBottomPointF(parent);
                }
                else if (parent is ng.MyNodeMultiCH)
                {
                    ptParent = convertSystemPointToDrawingPoint(myLink.Points[myLink.Points.Count - 2]);
                    //ptParent = myLink.Points[myLink.Points.Count - 2];
                }
                else
                {
                    ptParent = getRightBottomPointF(parent);
                }
                ptNode = getLeftCenterPointF(node);

                ptText.X = (float)((ptNode.X + ptParent.X - label1.Size.Width) / 2);
                ptText.Y = ptNode.Y;
            }
            else if (inlinkOrientation == PipingOrientation.Right)
            {
                ptParent = getLeftBottomPointF(parent);
                ptNode   = getRightCenterPointF(node);

                if (parent is ng.MyNodeMultiCH)
                {
                    ptParent = convertSystemPointToDrawingPoint(myLink.Points[myLink.Points.Count - 2]);
                    //ptParent = myLink.Points[myLink.Points.Count - 2];
                }

                ptText.X = (float)(ptNode.X + ptParent.X - label1.Size.Width) / 2;
                ptText.Y = ptNode.Y;
            }
            else if (inlinkOrientation == PipingOrientation.Unknown)
            {
                if (isVertical)
                {
                    if ((parent is ng.MyNodeYP) && (node is ng.MyNodeYP))
                    {
                        ptParent = getLeftBottomPointF(parent);
                        ptNode   = getRightCenterPointF(node);
                        ptText.Y = (float)((ptNode.Y + ptParent.Y) / 2 - node.Size.Height);
                        ptText.X = (float)(ptNode.X - (label1.Size.Width + 5));
                    }
                    else if ((parent is ng.MyNodeYP) && (node is ng.MyNodeCH))
                    {
                        ptParent = getCenterPointF(parent);
                        ptNode   = getCenterPointF(node);
                        ptText.X = (float)((ptNode.X + ptParent.X) / 2);
                        ptText.Y = (float)(ptNode.Y + Math.Abs((parent.Size.Height - 10)));
                    }
                    else
                    {
                        ptNode   = getBottomCenterPointF(node);
                        ptText.X = (float)(ptNode.X - label1.Size.Width);
                        ptText.Y = (float)(ptNode.Y + (node.Size.Height));
                    }
                }
                else
                {
                    ptNode   = getBottomCenterPointF(node);
                    ptText.X = (float)(ptNode.X + label1.Size.Width);
                    ptText.Y = (float)(ptNode.Y + (node.Size.Height));
                }
            }

            else
            {
                ptNode   = getBottomCenterPointF(node);
                ptText.X = (float)(ptNode.X - label1.Size.Width);
                ptText.Y = (float)(ptNode.Y + (node.Size.Height));
            }
            if (isVertical)
            {
                if (node is ng.MyNodeIn)
                {
                    if (inlinkOrientation == PipingOrientation.Right)
                    {
                        ptNode   = getRightCenterPointF(node);
                        ptText.X = ptNode.X + 20;
                        ptText.Y = ptNode.Y;
                    }
                    else
                    {
                        ptNode = getTopCenterPointF(node);
                        // ptNode = getLeftCenterPointF(node);
                        //ptText.X = (float)(ptNode.X + label1.Size.Width-80 + 20);
                        ptText.X = ptNode.X + 5;
                        ptText.Y = ptNode.Y - 35;
                    }
                }
                else if (node is ng.MyNodeCH)
                {
                    ptNode   = getTopCenterPointF(node);
                    ptText.X = ptNode.X + 5;
                    ptText.Y = ptNode.Y - 33;
                }
                else
                {
                    ptText.X += 5;
                    if (myLink.Org is ng.MyNodeOut)
                    {
                        ptText.Y -= 100;
                    }
                }
            }
            else
            {
                if (node is ng.MyNodeIn)
                {
                    ptNode   = getLeftCenterPointF(node);
                    ptParent = convertSystemPointToDrawingPoint(myLink.Points[0]);
                    ptText.X = ptText.X + 10;
                    //ptParent = myLink.Points[0];
                    //commented by SA

                    /* ptText.X = (float)(ptNode.X - (label1.Size.Width+40));
                     * ptText.Y = ptNode.Y;
                     * if (ptNode.Y < ptParent.Y)
                     * {
                     *   ptText.Y = (float)(ptNode.Y - label1.Size.Height);
                     * } *///end of comment
                }
                else if (node is ng.MyNodeYP)
                {
                    if (parent is ng.MyNodeMultiCH)
                    {
                        ptParent = convertSystemPointToDrawingPoint(myLink.Points[1]);
                        //ptParent = myLink.Points[1];
                        ptNode = convertSystemPointToDrawingPoint(myLink.Points[2]);
                        //ptNode = myLink.Points[2];
                        ptText.X = (float)(ptParent.X + label1.Size.Width);
                        ptText.Y = ptParent.Y;
                        if (ptNode.Y < ptParent.Y)
                        {
                            ptText.Y = (float)(ptParent.Y - label1.Size.Height);
                        }
                    }
                }
                else if (node is ng.MyNodeCH)
                {
                    ptText.X += 10;
                    ptText.Y -= 10;
                }
            }

            if (linkIndex == 1)
            {
                if (node is ng.MyNodeIn)
                {
                    if (parent is ng.MyNodeYP)
                    {
                        ptParent = getCenterPointF(parent);
                        ptNode   = getRightCenterPointF(node);
                        if (isVertical)
                        {
                            ptText.Y = (float)(ptParent.Y - label1.Size.Height - 2);
                        }
                        else
                        {
                            if (ptNode.Y < ptParent.Y)
                            {
                                ptText.X = ptParent.X + 5;
                                ptText.Y = (float)(ptParent.Y - label1.Size.Height - 25);
                            }
                            else
                            {
                                ptText.X = ptParent.X + 5;
                                ptText.Y = ptParent.Y + 15;
                            }
                        }
                    }
                }
            }
            ptText.X        = Math.Max(0, ptText.X);
            ptText.Y        = Math.Max(0, ptText.Y);
            label1.Location = convertPointFToWinPoint(ptText);
            //label1.Location = ptText;
        }
Exemplo n.º 3
0
        private void SetLinkTextLocationForBinaryTree(ng.MyLink myLink, int linkIndex, Node parent, Node node, Node label1, bool isVertical)
        {
            PointF ptText, ptParent, ptNode;

            ptText = getLeftCenterPointF(node);
            if (parent is ng.MyNodeOut)
            {
                ptParent = getLeftBottomPointF(parent);
            }
            else if (parent is ng.MyNodeCH)
            {
                if (isVertical)
                {
                    ptParent = getRightCenterPointF(parent);
                }
                else
                {
                    ptParent = getBottomCenterPointF(parent);
                }
            }
            else if (parent is ng.MyNodeMultiCH)
            {
                if (isVertical)
                {
                    ptParent = convertSystemPointToDrawingPoint(myLink.Points[2]);
                    //ptParent = myLink.Points[2];
                }
                else
                {
                    ptParent = getBottomCenterPointF(parent);
                }
            }
            else
            {
                ptParent = getCenterPointF(parent);
            }

            if (isVertical)
            {
                ptNode = getLeftCenterPointF(node);

                if (parent is ng.MyNodeOut)
                {
                    ptNode   = getRightTopPointF(node);
                    ptText.X = (float)(ptNode.X - label1.Size.Width - 55);
                    ptText.Y = ptNode.Y - 30;
                }
                else if (node is ng.MyNodeIn || node is ng.MyNodeCH)
                {
                    ptNode   = getTopCenterPointF(node);
                    ptText.X = ptNode.X + 5;
                    ptText.Y = ptNode.Y - 30;
                }
                else if (node is ng.MyNodeYP)
                {
                    ptText.X = (float)(((ptNode.X + ptParent.X - label1.Size.Width) / 2) - 20);
                    ptText.Y = ptNode.Y;
                }
                else
                {
                    ptText.X = (float)(((ptNode.X + ptParent.X - label1.Size.Width) / 2) - 20);
                    ptText.Y = ptNode.Y;
                }
            }
            else
            {
                ptNode = getTopCenterPointF(node);

                ptText.X = (float)(ptNode.X + label1.Size.Width);
                ptText.Y = (float)((ptNode.Y + ptParent.Y - label1.Size.Height) / 2);
            }

            if (linkIndex == 1)
            {
                if (parent is ng.MyNodeYP)
                {
                    if (node is ng.MyNodeIn)
                    {
                        ptParent = getCenterPointF(parent);
                        if (isVertical)
                        {
                            ptText.Y = (float)(ptParent.Y - label1.Size.Height - 2);
                        }
                        else
                        {
                            ptText.X = ptParent.X + 5;
                        }
                    }
                }
            }
            ptText.X        = Math.Max(0, ptText.X);
            ptText.Y        = Math.Max(0, ptText.Y);
            label1.Location = convertPointFToWinPoint(ptText);
            // label1.Location = ptText;
        }
Exemplo n.º 4
0
        private void drawTextToLink(ng.MyLink myLink, int linkIndex, Node parent, Node node, bool isInch, ng.SystemVRF sysItem)
        {
            if (myLink == null || parent == null || node == null)
            {
                return;
            }

            string p1 = "";   //Low Pressure Gas
            string p2 = "";   //High Pressure Gas
            string p3 = "";   //Liquid
            string p5 = "";

            if (sysItem.IsPipingOK)
            {
                string SpecL   = myLink.SpecL;
                string SpecG_h = myLink.SpecG_h;
                string SpecG_l = myLink.SpecG_l;
                if (!string.IsNullOrEmpty(SpecL) && !string.IsNullOrEmpty(SpecG_h))
                {
                    if (SpecG_l != null && SpecG_l != "-")
                    {
                        p1 = "φ" + SpecG_l + ut_pipeSize;
                    }
                    if (SpecG_h != null && SpecG_h != "-")
                    {
                        p2 = "φ" + SpecG_h + ut_pipeSize;
                    }
                    p3 = "φ" + SpecL + ut_pipeSize;

                    if (isInch)
                    {
                        _dal    = new PipingDAL(thisProject);
                        SpecL   = GetPipeSize_Inch(myLink.SpecL);
                        SpecG_h = GetPipeSize_Inch(myLink.SpecG_h);
                        SpecG_l = GetPipeSize_Inch(myLink.SpecG_l);

                        p1 = "";
                        p2 = "";
                        p3 = "";
                        if (SpecG_l != null && SpecG_l != "-")
                        {
                            p1 = SpecG_l + ut_pipeSize;
                        }
                        if (SpecG_h != null && SpecG_h != "-")
                        {
                            p2 = SpecG_h + ut_pipeSize;
                        }
                        p3 = SpecL + ut_pipeSize;
                    }
                }
            }

            if (sysItem.IsInputLengthManually)
            {
                p5 = Unit.ConvertToControl(myLink.Length, UnitType.LENGTH_M, ut_length).ToString("0.##") + ut_length;
            }

            bool isCoolingOnly;

            if (node is ng.MyNodeIn)
            {
                isCoolingOnly = (node as ng.MyNodeIn).IsCoolingonly;
            }
            else if (node is ng.MyNodeYP)
            {
                isCoolingOnly = (node as ng.MyNodeYP).IsCoolingonly;
            }
            else
            {
                isCoolingOnly = false;
            }

            float   width  = 0;
            float   height = 5;
            JCHNode label1 = new JCHNode();
            Caption Child1 = new Caption();

            if (!string.IsNullOrEmpty(p1))
            {
                if (string.IsNullOrEmpty(p2) && !isCoolingOnly)
                {
                    DrawPipeLableColor(label1, " ", node, 4);
                    Child1 = DrawPipeCaptionColor(Child1, p1, node, 4);
                }
                else
                {
                    DrawPipeLableColor(label1, " ", node, 1);
                    Child1 = DrawPipeCaptionColor(Child1, p1, node, 1);
                }
                height += 8;
            }

            JCHNode label2 = new JCHNode();
            Caption Child2 = new Caption();

            if (!string.IsNullOrEmpty(p2))
            {
                if (parent is ng.MyNodeMultiCH || parent is ng.MyNodeCH)
                {
                    DrawPipeLableColor(label2, " ", node, 4);
                    Child2 = DrawPipeCaptionColor(Child2, p2, node, 4);
                }
                else if (string.IsNullOrEmpty(p1))
                {
                    DrawPipeLableColor(label2, " ", node, 4);
                    Child2 = DrawPipeCaptionColor(Child2, p2, node, 4);
                }
                else
                {
                    if (parent is ng.MyNodeYP)
                    {
                        ng.MyNodeYP pNodeYp = parent as ng.MyNodeYP;
                        if (pNodeYp.ParentNode is ng.MyNodeMultiCH || pNodeYp.ParentNode is ng.MyNodeCH)
                        {
                            DrawPipeLableColor(label2, " ", node, 4);
                            Child2 = DrawPipeCaptionColor(Child2, p2, node, 4);
                        }
                        else
                        {
                            DrawPipeLableColor(label2, " ", node, 2);
                            Child2 = DrawPipeCaptionColor(Child2, p2, node, 2);
                        }
                    }
                    else
                    {
                        DrawPipeLableColor(label2, " ", node, 2);
                        Child2 = DrawPipeCaptionColor(Child2, p2, node, 2);
                    }
                }
                height += 8;
            }

            JCHNode label3 = new JCHNode();
            Caption Child3 = new Caption();

            if (!string.IsNullOrEmpty(p3))
            {
                DrawPipeLableColor(label3, " ", node, 3);
                Child3  = DrawPipeCaptionColor(Child3, p3, node, 3);
                height += 8;
            }
            JCHNode label5 = new JCHNode();
            Caption Child5 = new Caption();

            if (!string.IsNullOrEmpty(p5))
            {
                DrawPipeLableColor(label5, " ", node, 5);
                Child5  = DrawPipeCaptionColor(Child5, p5, node, 5);
                height += 8;
            }
            width       = Math.Max(Math.Max((float)label1.Size.Width, (float)label2.Size.Width), Math.Max((float)label3.Size.Width, (float)label5.Size.Width));
            label1.Size = convertSize(width, height);

            if (sysItem.PipingLayoutType == old.PipingLayoutTypes.BinaryTree)
            {
                SetLinkTextLocationForBinaryTree(myLink, linkIndex, parent, node, label1, sysItem.IsPipingVertical);//TODO
            }
            else if (sysItem.PipingLayoutType == old.PipingLayoutTypes.SchemaA)
            {
                SetLinkTextLocationForSechmaA(myLink, linkIndex, parent, node, label1, sysItem.IsPipingVertical);//TODO
            }
            else
            {
                SetLinkTextLocationForNormal(myLink, linkIndex, parent, node, label1, sysItem.IsPipingVertical);
            }

            System.Windows.Point pf = label1.Location;


            if (!string.IsNullOrEmpty(p1))
            {
                Child1.Location = pf;
                addFlowPiping.AddCaption(Child1);
                addFlowPiping.RemoveNode(label1);
                pf.Y += 8;
            }
            if (!string.IsNullOrEmpty(p2))
            {
                label2.Location = pf;
                Child2.Location = pf;
                addFlowPiping.AddCaption(Child2);
                addFlowPiping.RemoveNode(label2);
                pf.Y += 8;
            }
            if (!string.IsNullOrEmpty(p3))
            {
                label3.Location = pf;
                Child3.Location = pf;
                addFlowPiping.AddCaption(Child3);
                addFlowPiping.RemoveNode(label3);
                pf.Y += 8;
            }
            if (!string.IsNullOrEmpty(p5))
            {
                label5.Location = pf;
                Child5.Location = pf;
                addFlowPiping.AddCaption(Child5);
                addFlowPiping.RemoveNode(label5);
                pf.Y += 8;
            }
        }
Exemplo n.º 5
0
        private void SetLinkTextLocationForNormal(ng.MyLink myLink, int linkIndex, Node parent, Node node, Node label1, bool isVertical)
        {
            PointF ptText, ptParent, ptNode;

            ptText = getLeftCenterPointF(node);
            if (node is ng.MyNodeYP)
            {
                if (parent is ng.MyNodeOut)
                {
                    ptText.X = (float)((node.Location.X + parent.Location.X - label1.Size.Width) / 2);
                }
                else if (parent is ng.MyNodeMultiCH)
                {
                    PointF pt1 = convertSystemPointToDrawingPoint(myLink.Points[myLink.Points.Count - 2]);
                    PointF pt2 = convertSystemPointToDrawingPoint(myLink.Points[myLink.Points.Count - 1]);
                    ptText = new PointF(pt1.X + pt2.X - (float)(label1.Size.Width) / 2, pt2.Y);
                }
                else
                {
                    ptParent = getRightCenterPointF(parent);
                    ptNode   = getLeftCenterPointF(node);
                    if (ptParent.Y == ptText.Y)
                    {
                        ptText.X = (float)(((ptNode.X + ptParent.X - label1.Size.Width) / 2));
                    }
                    else
                    {
                        if (isVertical)
                        {
                            ptText.X = (float)(ptNode.X + label1.Size.Width);
                        }
                        else
                        {
                            ptText.X = (float)(ptNode.X - label1.Size.Width);
                        }

                        ptText.Y = (float)((ptNode.Y + ptParent.Y - label1.Size.Height) / 2);
                    }
                }
            }
            else if (node is ng.MyNodeCH || node is ng.MyNodeMultiCH)
            {
                if (isVertical)
                {
                    if (parent is ng.MyNodeOut)
                    {
                        ptText.X = (float)(ptText.X - label1.Size.Width);
                    }
                    else
                    {
                        ptNode   = getCenterPointF(node);
                        ptParent = getCenterPointF(parent);
                        ptText.X = (float)((ptNode.X + ptParent.X - label1.Size.Width) / 2);
                    }
                }
                else
                {
                    ptNode   = getTopCenterPointF(node);
                    ptText.X = (float)(ptNode.X - label1.Size.Width) - 40;
                    ptText.Y = (float)(ptNode.Y - label1.Size.Height);
                }
            }
            else if (node is ng.MyNodeIn)
            {
                if (isVertical)
                {
                    ptText.X = (float)(node.Location.X - (label1.Size.Height / 2) - 35);
                    ptText.Y = (float)(node.Location.Y + (node.Size.Width / 2));
                }
                else
                {
                    //ptText.X = (float)(ptText.X - label1.Size.Width);
                    ptText.X = (float)(node.Location.X + (node.Size.Width / 2));
                    ptText.Y = (float)(node.Location.Y - (node.Size.Height / 2) + 10);
                }

                if (linkIndex == 1)
                {
                    ptParent = getCenterPointF(parent);
                    if (isVertical)
                    {
                        ptText.Y = (float)(ptParent.Y - label1.Size.Height - 2);
                    }
                    else
                    {
                        ptText.X = ptParent.X + 5;
                        ptText.Y = ptParent.Y + 15;
                    }
                }
            }
            ptText.X        = Math.Max(0, ptText.X);
            ptText.Y        = Math.Max(0, ptText.Y);
            label1.Location = convertPointFToWinPoint(ptText);
        }