Exemple #1
0
 public ng.WiringNodeIn createNodeIn_wiring(old.RoomIndoor riItem)
 {
     ng.WiringNodeIn node = new ng.WiringNodeIn();
     node.Tooltip        = old.NodeType.IN.ToString();
     node.IsEditable     = false;
     node.Stroke         = System.Windows.Media.Brushes.Transparent;
     node.FontFamily     = new System.Windows.Media.FontFamily("Arial");
     node.FontSize       = 11;
     node.Geometry       = new RectangleGeometry(new System.Windows.Rect(0, 0, 0, 0));
     node.RoomIndoorItem = riItem;
     return(node);
 }
Exemple #2
0
        private ng.MyNodeRemoteControler_Wiring DrawWiringRCNode(ng.WiringNodeIn nodeIn, JCHVRF.Model.Accessory RC, int RCIndex, string imgDir)
        {
            ng.MyNodeRemoteControler_Wiring nodeRC = null;
            double x = nodeIn.Location.X + nodeIn.Size.Width + ((RCIndex + 1) * 82f) + 60f;
            double y = nodeIn.Location.Y - 32f;

            string model = "";

            if (RC.BrandCode == "Y")
            {
                model = RC.Model_York;
            }
            else
            {
                model = RC.Model_Hitachi;
            }
            if (model != "")
            {
                nodeRC          = new ng.MyNodeRemoteControler_Wiring();
                nodeRC.Location = new Point(x, y);
                string imgFile = System.IO.Path.Combine(imgDir, "RemoteControler.png");
                utilWiring.setNode_wiring(nodeRC, imgFile, addFlowWiring);

                //nodeRC.DrawColor = Color.Transparent;
                nodeRC.Stroke = Brushes.Transparent;

                drawing.PointF ptf = new drawing.PointF((float)nodeRC.Size.Width, 5);
                utilWiring.createTextNode_wiring(model, ptf, nodeRC);

                if (RC.IsShared)
                {
                    utilWiring.createTextNode_wiring("Shared", new drawing.PointF(ptf.X, ptf.Y + 15), nodeRC);
                }
            }
            return(nodeRC);
        }
Exemple #3
0
        private List <ng.WiringNodeIn> getSortNodeInList(Object objList)
        {
            List <ng.WiringNodeIn> myNodeList     = new List <ng.WiringNodeIn>();
            List <ng.WiringNodeIn> sortNodeInList = new List <ng.WiringNodeIn>();
            List <ng.WiringNodeIn> mainNodeInList = new List <ng.WiringNodeIn>();

            if (objList is ng.WiringNodeOut)
            {
                ng.WiringNodeOut nodeOut = objList as ng.WiringNodeOut;
                foreach (Node node in nodeOut.ChildNodes)
                {
                    if (node is ng.WiringNodeIn)
                    {
                        ng.WiringNodeIn nodeIn = node as ng.WiringNodeIn;
                        myNodeList.Add(nodeIn);
                    }
                }
            }
            else if (objList is List <ng.WiringNodeIn> )
            {
                myNodeList = objList as List <ng.WiringNodeIn>;
            }
            else
            {
                return(sortNodeInList);
            }

            foreach (ng.WiringNodeIn nodeIn in myNodeList)
            {
                if (nodeIn.RoomIndoorItem.IsMainIndoor)
                {
                    mainNodeInList.Add(nodeIn);
                }
                //nodeCout++;
            }
            if (mainNodeInList.Count == 0)
            {
                for (int i = 0; i < myNodeList.Count; i++)
                {
                    sortNodeInList.Add(myNodeList[i]);
                }
            }
            else
            {
                foreach (ng.WiringNodeIn mianNodeIn in mainNodeInList)
                {
                    sortNodeInList.Add(mianNodeIn);

                    if (mianNodeIn.RoomIndoorItem.IndoorItemGroup != null)
                    {
                        foreach (ng.WiringNodeIn nodeIn in myNodeList)
                        {
                            foreach (JCHVRF.Model.RoomIndoor rind in mianNodeIn.RoomIndoorItem.IndoorItemGroup)
                            {
                                if (nodeIn.RoomIndoorItem == rind && !nodeIn.RoomIndoorItem.IsMainIndoor)
                                {
                                    sortNodeInList.Add(nodeIn);
                                    break;
                                }
                            }
                        }
                    }
                }

                if (sortNodeInList.Count < myNodeList.Count)
                {
                    foreach (ng.WiringNodeIn nodeIn in myNodeList)
                    {
                        if (!sortNodeInList.Contains(nodeIn))
                        {
                            sortNodeInList.Add(nodeIn);
                        }
                    }
                }
            }
            return(sortNodeInList);
        }
Exemple #4
0
        private void DrawWiringRemoteControllers(List <ng.WiringNodeIn> nodeInList, string imgDir)
        {
            List <bool[]> rcPositionTable = new List <bool[]>();
            int           rowIndex        = 0;

            foreach (ng.WiringNodeIn nodeIn in nodeInList)
            {
                if (nodeIn.RoomIndoorItem == null || nodeIn.RoomIndoorItem.IndoorItem == null)
                {
                    continue;
                }

                ng.MyNodeRemoteControler_Wiring shardRCNode = null;
                List <JCHVRF.Model.Accessory>   accList     = new List <JCHVRF.Model.Accessory>();
                try
                {
                    if (nodeIn.RoomIndoorItem != null && nodeIn.RoomIndoorItem.ListAccessory != null)
                    {
                        foreach (var itemAcc in nodeIn.RoomIndoorItem.ListAccessory)
                        {
                            if (itemAcc != null && itemAcc.Count > 0)
                            {
                                for (int i = 0; i < itemAcc.Count; i++)
                                {
                                    accList.Add(itemAcc);
                                }
                            }
                        }
                    }
                }
                catch { accList = nodeIn.RoomIndoorItem.ListAccessory; }
                //accList = nodeIn.RoomIndoorItem.ListAccessory;
                List <JCHVRF.Model.RoomIndoor> indoorGroup = nodeIn.RoomIndoorItem.IndoorItemGroup;
                if (accList != null && accList.Count > 0)
                {
                    int RCIndex = 0;
                    if (nodeIn.RoomIndoorItem.IsMainIndoor)
                    {
                        if (!accList.Exists(acc => acc.IsShared))
                        {
                            accList[0].IsShared = true;
                        }
                    }

                    foreach (JCHVRF.Model.Accessory acc in accList)
                    {
                        if (acc.Type.ToLower() == "remote controler" ||
                            acc.Type.ToLower() == "remote control switch" ||
                            acc.Type.ToLower() == "half-size remote control switch" ||
                            acc.Type.ToLower() == "receiver kit for wireless control" ||
                            acc.Type.Contains("有線遙控器") ||
                            acc.Type == "受光器"
                            )
                        {
                            int  colIndex  = RCIndex;
                            bool isCovered = true;

                            int firstShare = rowIndex;
                            int lastShare  = rowIndex;
                            if (acc.IsShared && indoorGroup != null)
                            {
                                for (int index1 = 0; index1 < nodeInList.Count; index1++)
                                {
                                    ng.WiringNodeIn n = nodeInList[index1];
                                    if (indoorGroup.Contains(n.RoomIndoorItem))
                                    {
                                        firstShare = Math.Min(firstShare, index1);
                                        lastShare  = Math.Max(lastShare, index1);
                                    }
                                }
                            }
                            while (isCovered)
                            {
                                isCovered = false;
                                if (rcPositionTable.Count - 1 < colIndex)
                                {
                                    rcPositionTable.Add(new bool[nodeInList.Count]);
                                }
                                for (int index1 = firstShare; index1 <= lastShare; index1++)
                                {
                                    if (rcPositionTable[colIndex][index1])
                                    {
                                        isCovered = true;
                                        break;
                                    }
                                }
                                if (isCovered)
                                {
                                    colIndex++;
                                }
                            }
                            for (int index1 = firstShare; index1 <= lastShare; index1++)
                            {
                                rcPositionTable[colIndex][index1] = true;
                            }

                            ng.MyNodeRemoteControler_Wiring nodeRC = DrawWiringRCNode(nodeIn, acc, colIndex, imgDir);
                            if (nodeIn.RoomIndoorItem.IsMainIndoor)
                            {
                                if (acc.IsShared)
                                {
                                    shardRCNode = nodeRC;
                                }
                            }

                            if (nodeRC != null)
                            {
                                drawing.PointF ptf1 = new drawing.PointF((float)(nodeRC.Location.X + (nodeRC.Size.Width / 2)), (float)(nodeRC.Location.Y + nodeRC.Size.Height));
                                drawing.PointF ptf2 = new drawing.PointF((float)(nodeRC.Location.X + (nodeRC.Size.Width / 2)), (float)(nodeIn.Location.Y + 12));
                                drawing.PointF ptf3 = new drawing.PointF((float)(nodeIn.Location.X + nodeIn.Size.Width - 1), (float)(nodeIn.Location.Y + 12));
                                ptArrayList.Add(new drawing.PointF[] { ptf1, ptf2, ptf3 });

                                RCIndex++;
                            }
                        }
                    }
                }
                if (shardRCNode != null && indoorGroup != null && indoorGroup.Count > 0)
                {
                    foreach (OldModel.RoomIndoor ri in indoorGroup)
                    {
                        //共享其它Remote Controller的室内机
                        if (ri == nodeIn.RoomIndoorItem)
                        {
                            continue;
                        }
                        ng.WiringNodeIn nodeInShareTo = nodeInList.Find(n => n.RoomIndoorItem == ri);
                        if (nodeInShareTo == null)
                        {
                            continue;
                        }

                        //共享连接线
                        drawing.PointF ptf1 = new drawing.PointF((float)(shardRCNode.Location.X + (shardRCNode.Size.Width / 2)), (float)(shardRCNode.Location.Y + shardRCNode.Size.Height));
                        if (nodeInShareTo.Location.Y + 12 < shardRCNode.Location.Y)
                        {
                            //室内机在共享控制器的上面
                            ptf1.Y = (float)(shardRCNode.Location.Y);
                        }
                        drawing.PointF ptf2 = new drawing.PointF((float)(shardRCNode.Location.X + (shardRCNode.Size.Width / 2)), (float)(nodeInShareTo.Location.Y + 12));
                        drawing.PointF ptf3 = new drawing.PointF((float)(nodeInShareTo.Location.X + nodeInShareTo.Size.Width - 1), (float)(nodeInShareTo.Location.Y + 12));
                        ptArrayList.Add(new drawing.PointF[] { ptf1, ptf2, ptf3 });
                    }
                }
                rowIndex++;
            }
        }
Exemple #5
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++;
                }
            }
        }