Exemple #1
0
        ///// 绘制配线图
        ///// <summary>
        ///// 绘制配线图,界面显示
        ///// </summary>
        //public void DoDrawingWiring(TreeNode tnOut, AddFlow addFlowWiring, SystemVRF curSystemItem, string WiringImageDir, string brandCode)
        //{
        //    Graphics g = addFlowWiring.CreateGraphics();

        //    InitWiringNodes(addFlowWiring);
        //    if (tnOut != null)
        //        CreatePipingNodeStructure_wiring(tnOut, curSystemItem);

        //    ptArrayList.Clear();
        //    ptArrayList_dash.Clear();

        //    // 当删除所有的室内机后,curSystemItem.MyWiringNodeOut即为空
        //    if (curSystemItem == null || curSystemItem.MyWiringNodeOut == null)
        //        return;

        //    //----------------
        //    // 检测是否可以绘图
        //    MyNodeOut_Wiring nodeOut = curSystemItem.MyWiringNodeOut;
        //    if (nodeOut.NodeInList == null || curSystemItem.OutdoorItem == null)
        //    {
        //        Label lbl2 = new Label();
        //        lbl2.Dock = DockStyle.Fill;
        //        lbl2.Text = "ERROR! Cannot draw the Wiring diagrams because there is no indoor unit";
        //        lbl2.ForeColor = Color.Red;
        //        addFlowWiring.Controls.Add(lbl2);
        //        return;
        //    }

        //    Node textNode = new Node();
        //    PointF ptText = new PointF();

        //    // 1. 绘制室外机节点
        //    NodeElement_Wiring item_wiring = GetNodeElement_Wiring_ODU(curSystemItem.OutdoorItem, brandCode);
        //    double current = curSystemItem.OutdoorItem.MaxCurrent; // 电流值
        //    nodeOut.Location = new PointF(10f, UtilPiping.HeightForNodeText + UtilPiping.OutdoorOffset_Y_wiring); // 必须先设置好 Location
        //    // 设置主节点加载的图片
        //    string imgFile = Path.Combine(WiringImageDir, item_wiring.KeyName + ".png");
        //    pipingUtil.setNode_wiring(nodeOut, imgFile, ref addFlowWiring, item_wiring);

        //    //----------------
        //    // 2. 室外机节点文字
        //    string text = "";
        //    ptText = item_wiring.PtNodeNames[0];
        //    if (item_wiring.UnitCount == 1)
        //    {
        //        //nodeOut.Text = item_wiring.ShortModel;
        //        ptText.Y += UtilPiping.HeightForNodeText / 2;

        //        // 4. 独立的室外机节点节点右下方电流参数
        //        text = current.ToString() + "A";
        //        createTextNode_wiring(text, item_wiring.PtStrGroup3[0], nodeOut, g);
        //    }

        //    text = curSystemItem.Name;
        //    createTextNode_wiring(text, ptText, nodeOut, g);
        //    if (item_wiring.UnitCount > 1)
        //    {
        //        text = curSystemItem.OutdoorItem.AuxModelName;
        //        // curSystemItem.OutdoorItem.Model;
        //        createTextNode_wiring(text, item_wiring.PtNodeNames[1], nodeOut, g);
        //    }

        //    //----------------
        //    createTextNode_wiring(item_wiring.Str1, item_wiring.PtStr1, nodeOut, g);
        //    // 3. 室外机上的电流线,虚线,以及室外机节点中的文字
        //    for (int i = 0; i < item_wiring.UnitCount; ++i)
        //    {
        //        PointF ptf1 = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2L[i], nodeOut.Location);
        //        PointF ptf2 = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2R[i], nodeOut.Location);
        //        ptArrayList_dash.Add(new PointF[] { ptf1, ptf2 });

        //        createTextNode_wiring(item_wiring.ModelGroup[i], item_wiring.PtModelGroup[i], nodeOut, g);
        //        if (i < 2)
        //            createTextNode_wiring(item_wiring.StrGroup1[i], item_wiring.PtStrGroup1[i], nodeOut, g);
        //        createTextNode_wiring(item_wiring.StrGroup2[i], item_wiring.PtStrGroup2[i], nodeOut, g);
        //        if (item_wiring.UnitCount > 1)
        //        {
        //            createTextNode_wiring(item_wiring.StrGroup3[i], item_wiring.PtStrGroup3[i], nodeOut, g);
        //        }
        //    }

        //    //----------------
        //    // 5. 绘制室内机节点
        //    PointF ptf4 = new PointF(0, 0);
        //    PointF ptf5 = new PointF(0, 0);
        //    PointF ptf6;
        //    double sumCurrent = 0;
        //    ptText = item_wiring.PtNodeNames[0];
        //    ptText.Y += UtilPiping.HeightForNodeText / 2;
        //    for (int i = 0; i < nodeOut.NodeInList.Length; i++)
        //    {
        //        MyNodeIn nodeIn = nodeOut.NodeInList[i];
        //        item_wiring = GetNodeElement_Wiring_IDU(nodeIn.RoomIndooItem.IndoorItem, brandCode);
        //        current = nodeIn.RoomIndooItem.IndoorItem.RatedCurrent;
        //        sumCurrent += current;

        //        nodeIn.Location = pipingUtil.getLocationChild_wiring(nodeOut, i);
        //        nodeIn.Text = item_wiring.ShortModel;
        //        // 设置主节点加载的图片
        //        imgFile = Path.Combine(WiringImageDir, item_wiring.KeyName + ".png");
        //        pipingUtil.setNode_wiring(nodeIn, imgFile, ref addFlowWiring, item_wiring);

        //        //----------------
        //        // 6. 室内机节点文字
        //        createTextNode_wiring(nodeIn.RoomIndooItem.IndoorName, ptText, nodeIn, g);
        //        createTextNode_wiring(current.ToString() + "A", item_wiring.PtStrGroup3[0], nodeIn, g);

        //        createTextNode_wiring(item_wiring.Str1, item_wiring.PtStr1, nodeIn, g);
        //        createTextNode_wiring(item_wiring.StrGroup1[0], item_wiring.PtStrGroup1[0], nodeIn, g);
        //        createTextNode_wiring(item_wiring.StrGroup2[0], item_wiring.PtStrGroup2[0], nodeIn, g);


        //        //----------------
        //        // 8.生成连接线的坐标点集合
        //        float x = nodeOut.Location.X + nodeOut.Size.Width - 1;
        //        float y = nodeIn.Location.Y + nodeIn.Size.Height - 2; // 因为室内机节点的高度为52
        //        if (i == 0)
        //        {
        //            PointF ptf1 = new PointF(x, y);
        //            PointF ptf2 = new PointF(nodeIn.Location.X + 1, y);
        //            ptArrayList.Add(new PointF[] { ptf1, ptf2 });
        //        }
        //        else
        //        {
        //            x = nodeIn.Location.X;
        //            PointF ptf1 = new PointF(x, y);
        //            PointF ptf2 = new PointF(x, y - 15);
        //            PointF ptf3 = new PointF(x + 60, y - UtilPiping.VDistanceVertical_wiring);
        //            ptArrayList.Add(new PointF[] { ptf1, ptf2, ptf3 });
        //        }

        //        ptf4 = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2L[0], nodeIn.Location);
        //        ptf5 = UtilEMF.OffsetLocation(item_wiring.PtStrGroupLine2R[0], nodeIn.Location);
        //        ptArrayList_dash.Add(new PointF[] { ptf4, ptf5 });
        //    }
        //    ptf4 = new PointF(ptf5.X, nodeOut.NodeInList[0].Location.Y);
        //    ptf6 = new PointF(ptf5.X + 90, ptf4.Y);
        //    ptArrayList_dash.Add(new PointF[] { ptf5, ptf4, ptf6 }); // 节点右侧的电流汇总,虚线

        //    //----------------
        //    // 9. 电流汇总显示
        //    text = sumCurrent.ToString() + "A";
        //    textNode = createTextNode_wiring(text, new PointF(ptf4.X + 12, ptf4.Y + 2), g);
        //    textNode.Location = new PointF(ptf4.X + 12, ptf4.Y + 2);
        //    addFlowWiring.Nodes.Add(textNode);
        //    //----------------

        //    // 10.绘制连线
        //    // 实线
        //    foreach (PointF[] pt in ptArrayList)
        //    {
        //        Node nd1 = pipingUtil.createLinePoint(pt[0]);
        //        addFlowWiring.Nodes.Add(nd1);
        //        Node nd2 = pipingUtil.createLinePoint(pt[pt.Length - 1]);
        //        addFlowWiring.Nodes.Add(nd2);
        //        Link lnk1 = pipingUtil.createLine();
        //        nd1.OutLinks.Add(lnk1, nd2);
        //        if (pt.Length > 2)
        //            lnk1.Points.Add(pt[1]);
        //    }
        //    // 虚线
        //    foreach (PointF[] pt in ptArrayList_dash)
        //    {
        //        Node nd1 = pipingUtil.createLinePoint(pt[0]);
        //        addFlowWiring.Nodes.Add(nd1);
        //        Node nd2 = pipingUtil.createLinePoint(pt[pt.Length - 1]);
        //        Link lnk1 = pipingUtil.createLine();
        //        if (pt.Length > 2)
        //            lnk1.Line.Style = LineStyle.VH;
        //        lnk1.DashStyle = DashStyle.Dash;
        //        nd1.OutLinks.Add(lnk1, nd2);
        //    }
        //}


        ///// 根据 TreeView 布局构造 Wiring 图中的机组节点对象
        ///// <summary>
        ///// 根据 TreeView 布局构造 Wiring 图中的机组节点对象
        ///// </summary>
        ///// <param name="tnOut"></param>
        //private void CreatePipingNodeStructure_wiring(TreeNode tnOut, SystemVRF curSystemItem)
        //{
        //    curSystemItem = tnOut.Tag as SystemVRF;
        //    curSystemItem.MyWiringNodeOut = utilPiping.createNodeOut_wiring(tnOut.Nodes.Count);
        //    MyNodeOut_Wiring nodeOut = curSystemItem.MyWiringNodeOut;

        //    foreach (TreeNode tn in tnOut.Nodes)
        //    {
        //        RoomIndoor riItem = tn.Tag as RoomIndoor;
        //        MyNodeIn nodeIn = utilPiping.createNodeIn_wiring(riItem);
        //        nodeOut.AddNodeIn(nodeIn, tn.Index);
        //    }
        //}

        ///// 创建文字节点--Wiring
        ///// <summary>
        ///// 创建文字节点--Wiring
        ///// </summary>
        ///// <param name="text"></param>
        ///// <param name="pt"></param>
        ///// <param name="parent"></param>
        ///// <returns></returns>
        //Node createTextNode_wiring(string text, PointF pt, Node parent, Graphics g)
        //{
        //    Node label = new Node();

        //    // 设置字体并量取文字标题的尺寸
        //    //Graphics g = this.CreateGraphics();
        //    g.PageUnit = GraphicsUnit.Pixel;            //单位为像素
        //    Font ft = utilPiping.textFont_wiring;
        //    label.Font = ft;
        //    SizeF size = g.MeasureString(text, ft);

        //    label.Transparent = true;
        //    label.Text = text;
        //    label.Size = new SizeF(size.Width + 15, size.Height);

        //    label.Alignment = Alignment.LeftJustifyTOP;
        //    label.DrawColor = Color.Transparent;
        //    label.Shape.Style = ShapeStyle.Rectangle;
        //    label.Logical = false;
        //    label.Selectable = false;
        //    label.AttachmentStyle = AttachmentStyle.Item;

        //    label.Location = UtilEMF.OffsetLocation(pt, parent.Location);

        //    parent.AddFlow.Nodes.Add(label);
        //    label.Parent = parent;
        //    return label;
        //}

        //Node createTextNode_wiring(string text, PointF pt, Graphics g)
        //{
        //    Node label = new Node();

        //    // 设置字体并量取文字标题的尺寸
        //    //Graphics g = this.CreateGraphics();
        //    g.PageUnit = GraphicsUnit.Pixel;            //单位为像素
        //    Font ft = utilPiping.textFont_wiring;
        //    label.Font = ft;
        //    SizeF size = g.MeasureString(text, ft);

        //    label.Transparent = true;
        //    label.Text = text;
        //    label.Size = new SizeF(size.Width + 15, size.Height);

        //    label.Alignment = Alignment.LeftJustifyTOP;
        //    label.DrawColor = Color.Transparent;
        //    label.Shape.Style = ShapeStyle.Rectangle;
        //    label.Logical = false;
        //    label.Selectable = false;
        //    label.AttachmentStyle = AttachmentStyle.Item;
        //    return label;
        //}

        //private void InitWiringNodes(AddFlow addFlowWiring)
        //{
        //    addFlowWiring.Controls.Clear();
        //    addFlowWiring.Nodes.Clear();
        //    addFlowWiring.AutoScrollPosition = new Point(0, 0);
        //}

        #endregion

        /// 绘制连接线文字节点 add on 20170122 add by axj
        /// <summary>
        /// 绘制连接线文字节点
        /// </summary>
        /// <param name="g"></param>
        /// <param name="nd"></param>
        public void DrawLabelText(Graphics g, Node nd)
        {
            if (nd == null || nd.Text == null)
            {
                return;
            }
            float x = 0;

            if (nd.Alignment == Alignment.CenterBOTTOM || nd.Alignment == Alignment.CenterMIDDLE || nd.Alignment == Alignment.CenterTOP)
            {
                PointF pf = pipingUtil.getTopCenterPointF(nd);
                x = pf.X;
            }
            float h = 0;

            string[] ArrayTxt  = nd.Text.Split('\n');
            Brush    textBrush = new SolidBrush(nd.TextColor);

            for (int i = 0; i < ArrayTxt.Length; i++)
            {
                var sz = g.MeasureString(ArrayTxt[i], textFont_piping);
                ptText = new PointF(x == 0 ? nd.Location.X : (x - sz.Width / 2), nd.Location.Y + h);
                g.DrawString(ArrayTxt[i], textFont_piping, textBrush, ptText);
                h = h + sz.Height;
            }
        }
Exemple #2
0
        private void CustomizeLink(JCHNode nodeStart, JCHNode nodeEnd, Link customLink)
        {
            customLink.IsStretchable = true;
            customLink.IsSelectable  = false;
            customLink.IsAdjustDst   = false;
            customLink.IsAdjustOrg   = false;

            Point start  = utilPiping.getTopCenterPointF(nodeStart);
            Point end    = utilPiping.getTopCenterPointF(nodeEnd);
            Point midPt1 = new Point(start.X + 15, start.Y - 20);
            Point midPt2 = new Point(end.X, end.Y - 20);

            customLink.Points[0] = start;
            customLink.Points.Add(midPt1);
            customLink.Points.Add(midPt2);
            customLink.Points[1] = midPt1;
            customLink.Points[2] = midPt2;
            customLink.Points[3] = end;
        }