Example #1
0
        public Node createTextNode_wiring(string text, PointF pt, Node parent, bool isLineMark = false)
        {
            Node label = new Node();

            gMeasureString.PageUnit = GraphicsUnit.Pixel;
            Font ft = textFont_wiring;

            if (isLineMark)
            {
                ft = textFont_wiring_linemark;
            }
            label.FontFamily = new System.Windows.Media.FontFamily("Arial");
            label.FontSize   = 14;
            SizeF size = gMeasureString.MeasureString(text, ft);

            label.Fill = System.Windows.Media.Brushes.Transparent;
            label.Text = text;
            label.Size = new System.Windows.Size(size.Width + 15, size.Height);
            if (isLineMark)
            {
                label.Foreground = System.Windows.Media.Brushes.Red;
            }

            label.Stroke       = System.Windows.Media.Brushes.Transparent;
            label.Geometry     = new RectangleGeometry(new System.Windows.Rect(0, 0, 0, 0));
            label.IsSelectable = false;
            PointF parentLoc = convertSystemPointToDrawingPoint(parent.Location);
            PointF location  = UtilEMF.OffsetLocation(pt, parentLoc);

            if (parent is ng.WiringNodeCH)
            {
                location.X -= 60;
            }
            label.Location = convertPointFToWinPoint(location);
            parent.AddFlow.AddNode(label);
            return(label);
        }
Example #2
0
        public void DrawNode_wiring(Graphics g, WL.Node nd, string nodeTextFile, string name, JCHVRF.MyPipingBLL.NodeElement_Wiring item)
        {
            Font  textFont_wiring  = new Font("Arial", 8f, System.Drawing.FontStyle.Regular);
            Brush textBrush_wiring = new SolidBrush(Color.Black);
            Pen   pen = new Pen(Color.Black, 0.1f);

            if (nd is NextGenModel.MyNodeGround_Wiring)
            {
                pen = new Pen(Color.Black, 0.1f);
            }

            SizeF  ndSize     = new SizeF((float)nd.Size.Width, (float)nd.Size.Height);
            PointF ndLocation = new PointF((float)nd.Location.X, (float)nd.Location.Y);

            if (nd is NextGenModel.WiringNodeIn)
            {
                ndLocation = new PointF((float)nd.Location.X, (float)nd.Location.Y);
            }

            RectangleF rect = new RectangleF(ndLocation, ndSize);

            InitPointF(nodeTextFile);
            RelocatedNode(rect);

            if (ptStart.Count == ptEnd.Count)
            {
                for (int i = 0; i < ptStart.Count; ++i)
                {
                    g.DrawLine(pen, ptStart[i], ptEnd[i]);
                }
            }
            g.ResetTransform();

            if (item != null && item.PtCircles.Count >= item.UnitCount * 4)
            {
                pt.Point pt = UtilEMF.OffsetLocation(utilWiring.convertPointFToWinPoint(item.PtStr1), utilWiring.convertPointFToWinPoint(ndLocation));
                g.DrawString(item.Str1, textFont_wiring, textBrush_wiring, utilWiring.convertSystemPointToDrawingPoint(pt));

                for (int i = 0; i < item.UnitCount; ++i)
                {
                    RectangleF r1 = new RectangleF(item.PtCircles[i * 4], item.CircleSize);
                    RelocateLocation(ref r1, ndLocation);
                    RectangleF r2 = new RectangleF(item.PtCircles[i * 4 + 1], item.CircleSize);
                    RelocateLocation(ref r2, ndLocation);
                    RectangleF r3 = new RectangleF(item.PtCircles[i * 4 + 2], item.CircleSize);
                    RelocateLocation(ref r3, ndLocation);
                    RectangleF r4 = new RectangleF(item.PtCircles[i * 4 + 3], item.CircleSize);
                    RelocateLocation(ref r4, ndLocation);
                    g.DrawEllipse(pen, r1);
                    g.DrawEllipse(pen, r2);
                    g.DrawEllipse(pen, r3);
                    g.DrawEllipse(pen, r4);

                    pt.Point pt1 = UtilEMF.OffsetLocation(utilWiring.convertPointFToWinPoint(item.PtModelGroup[i]), utilWiring.convertPointFToWinPoint(ndLocation));

                    g.DrawString(item.ModelGroup[i], textFont_wiring, textBrush_wiring, utilWiring.convertSystemPointToDrawingPoint(pt1));      // YVOH200
                    pt.Point pt2 = UtilEMF.OffsetLocation(utilWiring.convertPointFToWinPoint(item.PtStrGroup1[i]), utilWiring.convertPointFToWinPoint(ndLocation));
                    if (i < 2)
                    {
                        g.DrawString(item.StrGroup1[i], textFont_wiring, textBrush_wiring, utilWiring.convertSystemPointToDrawingPoint(pt2));    // X Y | X Y
                    }
                    pt.Point pt3 = UtilEMF.OffsetLocation(utilWiring.convertPointFToWinPoint(item.PtStrGroup2[i]), utilWiring.convertPointFToWinPoint(ndLocation));
                    g.DrawString(item.StrGroup2[i], textFont_wiring, textBrush_wiring, utilWiring.convertSystemPointToDrawingPoint(pt3));        // L1L2L3N

                    pt.Point pt4 = UtilEMF.OffsetLocation(utilWiring.convertPointFToWinPoint(item.PtStrGroup3[i]), utilWiring.convertPointFToWinPoint(ndLocation));
                    if (item.UnitCount > 1)
                    {
                        g.DrawString(item.StrGroup3[i], textFont_wiring, textBrush_wiring, utilWiring.convertSystemPointToDrawingPoint(pt4));    // 19A 3Nph
                    }
                }
            }
        }
Example #3
0
        private void DoDrawingWiring(ng.SystemVRF sysItem, ng.WiringNodeOut nodeOut, string imgDir)
        {
            Node textNode;

            drawing.Point  ptText        = new drawing.Point();
            drawing.PointF nodeOutPointF = new drawing.PointF();

            NodeElement_Wiring item_wiring = utilWiring.GetNodeElement_Wiring_ODU(sysItem.OutdoorItem, thisProject.BrandCode);

            nodeOut.Location = new Point(10f, UtilPiping.HeightForNodeText + UtilPiping.OutdoorOffset_Y_wiring + 36f);

            string imgFile = System.IO.Path.Combine(imgDir, item_wiring.KeyName + ".png");

            utilWiring.setNode_wiring(nodeOut, imgFile, addFlowWiring);

            drawing.PointF ptf1 = new drawing.PointF((float)(nodeOut.Location.X + 140), (float)(nodeOut.Location.Y + 20));
            drawing.PointF ptf2 = new drawing.PointF(ptf1.X + 74, ptf1.Y + 4);
            drawing.PointF ptf3 = new drawing.PointF(ptf2.X - 10, ptf2.Y);
            ptArrayList_ground.Add(new drawing.PointF[] { ptf1, ptf2, ptf3 });

            string text = "";

            ptText = item_wiring.PtNodeNames[0];

            text = sysItem.Name;
            utilWiring.createTextNode_wiring(text, ptText, nodeOut);
            if (item_wiring.UnitCount > 1)
            {
                text = sysItem.OutdoorItem.AuxModelName;
                utilWiring.createTextNode_wiring(text, item_wiring.PtNodeNames[1], nodeOut);
            }

            utilWiring.createTextNode_wiring(item_wiring.Str1, item_wiring.PtStr1, nodeOut);

            nodeOutPointF = utilWiring.convertSystemPointToDrawingPoint(nodeOut.Location);
            for (int i = 0; i < item_wiring.UnitCount; ++i)
            {
                ptf1 = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2L[i], nodeOutPointF);
                ptf2 = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2R[i], nodeOutPointF);
                ptArrayList_power.Add(new drawing.PointF[] { ptf1, ptf2 });

                if (i < item_wiring.ModelGroup.Length)
                {
                    utilWiring.createTextNode_wiring(item_wiring.ModelGroup[i], item_wiring.PtModelGroup[i], nodeOut);
                }
                if (item_wiring.ModelGroup.Length > 1 && i < item_wiring.StrGroup1.Length)
                {
                    utilWiring.createTextNode_wiring(item_wiring.StrGroup1[i], item_wiring.PtStrGroup1[i], nodeOut);
                }
                if (i < item_wiring.StrGroup2.Length)
                {
                    utilWiring.createTextNode_wiring(item_wiring.StrGroup2[i], item_wiring.PtStrGroup2[i], nodeOut);
                }
                if (i < item_wiring.StrGroup3.Length)
                {
                    utilWiring.createTextNode_wiring(item_wiring.StrGroup3[i], item_wiring.PtStrGroup3[i], nodeOut);
                }
                if (i < item_wiring.StrGroup4.Length)
                {
                    utilWiring.createTextNode_wiring(item_wiring.StrGroup4[i], item_wiring.PtStrGroup4[i], nodeOut, true);
                }
            }

            drawing.PointF ptf4 = new drawing.PointF(0, 0);
            drawing.PointF ptf5 = new drawing.PointF(0, 0);
            ptText    = item_wiring.PtNodeNames[0];
            ptText.Y += Convert.ToInt32(UtilPiping.HeightForNodeText / 2);


            List <ng.WiringNodeIn> sortNodeInList = getSortNodeInList(nodeOut);


            if (sortNodeInList == null)
            {
                return;
            }

            List <ng.WiringNodeIn> wiringNodeInList = new List <ng.WiringNodeIn>();

            DrawWiringNodes(nodeOut, sortNodeInList.ToList <ng.WiringNode>(), wiringNodeInList, imgDir, false);

            DrawWiringRemoteControllers(wiringNodeInList, imgDir);


            for (int i = 0; i < strArrayList_powerType.Count; i++)
            {
                ptArrayList_power.Add(ptArrayList_mainpower[i]);

                ptf4     = ptArrayList_mainpower[i][1];
                text     = strArrayList_powerVoltage[i] + "/" + dArrayList_powerCurrent[i].ToString() + "A";
                textNode = utilWiring.createTextNode_wiring(text, new drawing.PointF(ptf4.X + 122, ptf4.Y + 2));
                addFlowWiring.AddNode(textNode);
                text     = strArrayList_powerType[i];
                textNode = utilWiring.createTextNode_wiring(text, new drawing.PointF(ptf4.X + 166, ptf4.Y - 12));
                addFlowWiring.AddNode(textNode);
            }

            DrawWiringLegend(nodeOut);

            foreach (drawing.PointF[] pt in ptArrayList)
            {
                Node nd1 = utilWiring.createLinePoint(pt[0]);
                addFlowWiring.AddNode(nd1);
                Node nd2 = utilWiring.createLinePoint(pt[pt.Length - 1]);
                addFlowWiring.AddNode(nd2);
                //Link lnk1 = utilWiring.createLine();
                Link lnk1 = utilWiring.createLine(nd1, nd2, "", addFlowWiring);
                //nd1.OutLinks.Add(lnk1, nd2);
                addFlowWiring.AddLink(lnk1);

                if (pt.Length > 2)
                {
                    var pt1 = utilWiring.convertPointFToWinPoint(pt[1]);
                    lnk1.AddPoint(pt1);
                }
            }

            foreach (drawing.PointF[] pt in ptArrayList_power)
            {
                Node nd1 = utilWiring.createLinePoint(pt[0]);
                //addFlowWiring.Nodes.Add(nd1);
                addFlowWiring.AddNode(nd1);
                Node nd2  = utilWiring.createLinePoint(pt[pt.Length - 1]);
                Link lnk1 = utilWiring.createLine(nd1, nd2, "", addFlowWiring);

                if (pt.Length > 2)
                {
                    lnk1.LineStyle = LineStyle.VH;
                }
                //lnk1.Jump = Jump.Arc;
                //lnk1.DrawWidth = 1;
                lnk1.StrokeThickness = 1;

                //lnk1.DrawColor = Color.Red;
                lnk1.Stroke = System.Windows.Media.Brushes.Red;
                //nd1.OutLinks.Add(lnk1, nd2);
                addFlowWiring.AddLink(lnk1);
            }

            foreach (drawing.PointF[] pt in ptArrayList_ground)
            {
                if (pt.Length > 2)
                {
                    ng.MyNodeGround_Wiring nodeground = new ng.MyNodeGround_Wiring();
                    nodeground.Location = new Point(pt[2].X, pt[2].Y);
                    imgFile             = System.IO.Path.Combine(imgDir, "Ground.png");
                    utilWiring.setNode_wiring(nodeground, imgFile, addFlowWiring);
                    //nodeground.DrawColor = Color.Transparent;
                }
                Node nd1 = utilWiring.createLinePoint(pt[0]);
                //addFlowWiring.Nodes.Add(nd1);
                addFlowWiring.AddNode(nd1);
                Node nd2  = utilWiring.createLinePoint(pt[1]);
                Link lnk1 = utilWiring.createLine(nd1, nd2, "", addFlowWiring);
                lnk1.DashStyle = DashStyles.Dash;
                //nd1.OutLinks.Add(lnk1, nd2);
                addFlowWiring.AddLink(lnk1);
            }
        }
Example #4
0
        private void DrawWiringNodes(Node parent, List <ng.WiringNode> nodes, List <ng.WiringNodeIn> myNodeInList, string imgDir, bool isHR)
        {
            bool   prevBrotherNodeIsIndoor = false;
            double sumCurrent = 0.0d;

            ng.WiringNodeIn    lastIn = null;
            drawing.PointF     ptf1, ptf2, ptf3, ptf4, ptf5, ptf6;
            NodeElement_Wiring item_wiring;
            string             imgFile;
            int lastYIndex = 0;
            int index1 = 0;

            drawing.PointF nodeCHPointF = new drawing.PointF();
            drawing.PointF nodeInPointF = new drawing.PointF();
            foreach (ng.WiringNode node in nodes)
            {
                if (node is ng.WiringNodeCH)
                {
                    prevBrotherNodeIsIndoor = false;

                    ng.WiringNodeCH nodeCH = node as ng.WiringNodeCH;
                    item_wiring = utilWiring.GetNodeElement_Wiring_CH(nodeCH.Model, nodeCH.PowerSupply, nodeCH.PowerLineType, nodeCH.PowerCurrent);

                    nodeCH.Location = utilWiring.getLocationChild_wiring(parent, node, index1, isHR);
                    nodeCH.Text     = item_wiring.ShortModel;

                    utilWiring.setNode_wiring(nodeCH, new Size(80, 52), addFlowWiring);

                    utilWiring.createTextNode_wiring("CH Unit", new drawing.PointF(86, -13), nodeCH);

                    DrawWiringNodes(nodeCH, nodeCH.ChildNodes, myNodeInList, imgDir, isHR);

                    double x = parent.Location.X + parent.Size.Width - 1;
                    double y = nodeCH.Location.Y + nodeCH.Size.Height - 2;
                    float  enlargedHeight = 0;
                    if (nodeCH.IsMultiCHBox && nodeCH.ChildNodes.Count > 1)
                    {
                        enlargedHeight = UtilPiping.VDistanceVertical_wiring * (nodeCH.ChildNodes.Count - 1);
                        nodeCH.Size    = new Size(nodeCH.Size.Width, nodeCH.Size.Height + enlargedHeight);
                    }

                    if (nodeCH.IsMultiCHBox)
                    {
                        int newBranchIndex = 0;
                        for (int i = 0; i < nodeCH.ChildNodes.Count; i++)
                        {
                            ng.WiringNodeIn wiringIn = nodeCH.ChildNodes[i] as ng.WiringNodeIn;
                            if (wiringIn != null && wiringIn.IsNewBranchOfParent)
                            {
                                utilWiring.createTextNode_wiring((newBranchIndex * 2 + 3) + " " + (newBranchIndex * 2 + 4)
                                                                 , new drawing.PointF(142, UtilPiping.VDistanceVertical_wiring * i), nodeCH);
                                newBranchIndex++;
                            }
                        }
                    }
                    else
                    {
                        utilWiring.createTextNode_wiring(item_wiring.StrGroup1[0], item_wiring.PtStr1, nodeCH);
                    }

                    utilWiring.createTextNode_wiring(item_wiring.Str1, new drawing.PointF(35, (float)(nodeCH.Size.Height - enlargedHeight - 14)), nodeCH);

                    if (index1 == 0)
                    {
                        ptf1 = new drawing.PointF((float)x, (float)y);
                        ptf2 = new drawing.PointF((float)(nodeCH.Location.X + 1), (float)y);
                        ptArrayList.Add(new drawing.PointF[] { ptf1, ptf2 });
                    }
                    else
                    {
                        x    = nodeCH.Location.X;
                        ptf1 = new drawing.PointF((float)x, (float)y);
                        ptf2 = new drawing.PointF((float)(x - 60), (float)y);
                        ptf3 = new drawing.PointF((float)(x - 60), (float)(y - 15));
                        ptf4 = new drawing.PointF((float)x, (float)(y - UtilityWiring.VDistanceVertical_wiring * (index1 - lastYIndex)));
                        ptArrayList.Add(new drawing.PointF[] { ptf1, ptf2, ptf3, ptf4 });
                    }

                    ptf1 = new drawing.PointF((float)(nodeCH.Location.X + 140 - 60), (float)(nodeCH.Location.Y + 20));
                    ptf2 = new drawing.PointF(ptf1.X + 74, ptf1.Y + 4);
                    ptf3 = new drawing.PointF(ptf2.X - 10, ptf2.Y);
                    ptArrayList_ground.Add(new drawing.PointF[] { ptf1, ptf2, ptf3 });

                    utilWiring.createTextNode_wiring(item_wiring.StrGroup2[0], item_wiring.PtStrGroup2[0], nodeCH);

                    utilWiring.createTextNode_wiring(item_wiring.StrGroup3[0], item_wiring.PtStrGroup3[0], nodeCH);

                    utilWiring.createTextNode_wiring(item_wiring.StrGroup4[0], item_wiring.PtStrGroup4[0], nodeCH, true);

                    nodeCHPointF = utilWiring.convertSystemPointToDrawingPoint(nodeCH.Location);
                    ptf4         = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2L[0], nodeCHPointF);
                    ptf5         = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2R[0], nodeCHPointF);
                    ptf4.X      -= 60;
                    ptf5.X      -= 60;
                    ptArrayList_power.Add(new drawing.PointF[] { ptf4, ptf5 });

                    lastYIndex = index1;
                    if (nodeCH.ChildNodes.Count > 1)
                    {
                        index1 += nodeCH.ChildNodes.Count - 1;
                    }
                    index1++;
                }
                else if (node is ng.WiringNodeIn)
                {
                    ng.WiringNodeIn nodeIn = node as ng.WiringNodeIn;
                    lastIn = nodeIn;
                    int  powerIndex = 0;
                    bool isNewPower = false;
                    item_wiring = utilWiring.GetNodeElement_Wiring_IDU(nodeIn.RoomIndoorItem.IndoorItem, thisProject.BrandCode, sysItem.OutdoorItem.Type, ref strArrayList_powerType, ref strArrayList_powerVoltage, ref dArrayList_powerCurrent, ref powerIndex, ref isNewPower);
                    double current = nodeIn.RoomIndoorItem.IndoorItem.RatedCurrent;
                    sumCurrent     += current;
                    nodeIn.Location = utilWiring.getLocationChild_wiring(parent, node, index1, isHR);
                    nodeIn.Text     = item_wiring.ShortModel;

                    imgFile = System.IO.Path.Combine(imgDir, item_wiring.KeyName + ".png");
                    utilWiring.setNode_wiring(nodeIn, imgFile, addFlowWiring);


                    string indoorName = nodeIn.RoomIndoorItem.IndoorName;

                    // DOUBT NEED TO CHECK LATER after FER as Room is not functional in FER

                    //if (!string.IsNullOrEmpty(nodeIn.RoomIndoorItem.RoomID))
                    //{
                    //    RoomLoadIndexBLL roomBill = new RoomLoadIndexBLL();
                    //    string floorRoomName = roomBill.getFloorRoomName(nodeIn.RoomIndoorItem, thisProject);
                    //    indoorName = floorRoomName + ":" + indoorName;
                    //}
                    //else
                    //{
                    //    if (!string.IsNullOrEmpty(nodeIn.RoomIndoorItem.DisplayRoom))
                    //    {
                    //        indoorName = nodeIn.RoomIndoorItem.DisplayRoom + ":" + indoorName;
                    //    }
                    //}

                    utilWiring.createTextNode_wiring(indoorName, new drawing.PointF(66, -13), nodeIn);
                    utilWiring.createTextNode_wiring(item_wiring.StrGroup3[0], item_wiring.PtStrGroup3[0], nodeIn);

                    utilWiring.createTextNode_wiring(item_wiring.Str1, item_wiring.PtStr1, nodeIn);
                    utilWiring.createTextNode_wiring(item_wiring.StrGroup1[0], item_wiring.PtStrGroup1[0], nodeIn);
                    utilWiring.createTextNode_wiring(item_wiring.StrGroup2[0], item_wiring.PtStrGroup2[0], nodeIn);
                    utilWiring.createTextNode_wiring(item_wiring.StrGroup4[0], item_wiring.PtStrGroup4[0], nodeIn, true);


                    double x1 = parent.Location.X + parent.Size.Width - 1;
                    double y1 = nodeIn.Location.Y + nodeIn.Size.Height - 2;
                    float  x  = (float)x1;
                    float  y  = (float)y1;
                    if (isHR && parent is ng.WiringNodeOut && !prevBrotherNodeIsIndoor)
                    {
                        x    = (float)nodeIn.Location.X;
                        ptf1 = new drawing.PointF(x, y);
                        ptf2 = new drawing.PointF(x - UtilPiping.HDistanceVertical_wiring - 60, y);
                        ptf3 = new drawing.PointF(x - UtilPiping.HDistanceVertical_wiring - 60, y - 15);
                        ptf4 = new drawing.PointF(x - UtilPiping.HDistanceVertical_wiring, y - UtilPiping.VDistanceVertical_wiring * (index1 - lastYIndex));
                        ptArrayList.Add(new drawing.PointF[] { ptf1, ptf2, ptf3, ptf4 });
                    }
                    else
                    {
                        if (index1 == 0 || nodeIn.IsNewBranchOfParent)
                        {
                            ptf1 = new drawing.PointF(x, y);
                            ptf2 = new drawing.PointF((float)(nodeIn.Location.X + 1), y);
                            ptArrayList.Add(new drawing.PointF[] { ptf1, ptf2 });
                        }
                        else
                        {
                            x    = (float)nodeIn.Location.X;
                            ptf1 = new drawing.PointF(x, y);
                            ptf2 = new drawing.PointF(x, y - 15);
                            ptf3 = new drawing.PointF(x + 60, y - UtilPiping.VDistanceVertical_wiring);
                            ptArrayList.Add(new drawing.PointF[] { ptf1, ptf2, ptf3 });
                        }
                    }

                    ptf1 = new drawing.PointF((float)(nodeIn.Location.X + 140), (float)(nodeIn.Location.Y + 20));
                    ptf2 = new drawing.PointF(ptf1.X + 74, ptf1.Y + 4);
                    ptf3 = new drawing.PointF(ptf2.X - 10, ptf2.Y);
                    ptArrayList_ground.Add(new drawing.PointF[] { ptf1, ptf2, ptf3 });

                    myNodeInList.Add(nodeIn);
                    nodeInPointF = utilWiring.convertSystemPointToDrawingPoint(nodeIn.Location);
                    ptf4         = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2L[0], nodeInPointF);
                    ptf5         = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2R[0], nodeInPointF);
                    ptf5.X      += (10f * powerIndex) + 55f;
                    ptArrayList_power.Add(new drawing.PointF[] { ptf4, ptf5 });

                    if (isNewPower)
                    {
                        ptf4 = new drawing.PointF(ptf5.X, (float)(nodeIn.Location.Y + (nodeIn.Size.Height / 2)));
                        ptf6 = new drawing.PointF(ptf5.X + 240, ptf4.Y);
                        ptArrayList_mainpower.Add(new drawing.PointF[] { ptf5, ptf4, ptf6 });
                    }
                    else
                    {
                        ptArrayList_mainpower[powerIndex][0] = ptf5;
                    }

                    prevBrotherNodeIsIndoor = true;
                    lastYIndex = index1;
                    index1++;
                }
            }
        }