public void DrawItemRecursion(Graphics g, WL.Item item, string WiringImageDir) { if (item is WL.Node) { if (item is NextGenModel.MyNodeGround_Wiring) { NextGenModel.MyNodeGround_Wiring ndGnd = item as NextGenModel.MyNodeGround_Wiring; string nodePointsFile = Path.Combine(WiringImageDir, "Ground.txt"); DrawNode_wiring(g, ndGnd, nodePointsFile, "", null); } else { WL.Node nd = item as WL.Node; DrawNode(g, nd); if (nd.AddFlow != null) { if (nd.AddFlow.Children != null) { foreach (WL.Item child in nd.AddFlow.Children) { DrawItemRecursion(g, child, WiringImageDir); } } } } } else if (item is WL.Link) { DrawLine(g, item as WL.Link); } }
public void DrawNode(Graphics g, WL.Node nd) { if (nd == null) { return; } SizeF sf = new SizeF((float)nd.Bounds.Width, (float)nd.Bounds.Height); RectangleF rect = new RectangleF(utilWiring.convertSystemPointToDrawingPoint(nd.Location), sf); string text = nd.Text; pt.Media.SolidColorBrush newBrush = (pt.Media.SolidColorBrush)nd.Stroke; Color clr = System.Drawing.Color.FromArgb(newBrush.Color.A, newBrush.Color.R, newBrush.Color.G, newBrush.Color.B); if (newBrush.Color.R != 255 || newBrush.Color.G != 255 || newBrush.Color.B != 255) { Pen pen = new Pen(clr, (float)(0.3f)); if (nd.Geometry is System.Windows.Media.RectangleGeometry) { g.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height); } } pt.Media.SolidColorBrush newFill = (pt.Media.SolidColorBrush)nd.Fill; if (newFill.Color.R != 255 || newFill.Color.G != 255 || newFill.Color.B != 255) { Color clr1 = System.Drawing.Color.FromArgb(newFill.Color.A, newFill.Color.R, newFill.Color.G, newFill.Color.B); Brush brush = new SolidBrush(clr1); g.FillRectangle(brush, rect); } if (!string.IsNullOrEmpty(text)) { Font ft1; if (nd.FontSize > 8f) { ft1 = new Font("Arial", 8f, GraphicsUnit.Pixel); } else { ft1 = new Font("Arial", 6f, GraphicsUnit.Pixel); } SizeF textSize = g.MeasureString(text, ft1); textSize.Height = textSize.Height * 0.7f; float x = 0, y = 0; pt.Media.SolidColorBrush textClr = (pt.Media.SolidColorBrush)nd.Foreground; Color clr2 = System.Drawing.Color.FromArgb(textClr.Color.A, textClr.Color.R, textClr.Color.G, textClr.Color.B); x = rect.X + (rect.Width - textSize.Width) / 2; y = rect.Y + (rect.Height - textSize.Height) / 2; g.DrawString(text, ft1, new SolidBrush(clr2), x, y); } }
public void GetHeightDifferenceNodes(Lassalle.WPF.Flow.Node node, Lassalle.WPF.Flow.Node parent, JCHVRF.Model.NextGen.SystemVRF sysItem, List <JCHVRF.Model.NextGen.MyNode> list) { if (node is JCHVRF.Model.NextGen.MyNodeOut) { JCHVRF.Model.NextGen.MyNodeOut nodeOut = node as JCHVRF.Model.NextGen.MyNodeOut; GetHeightDifferenceNodes(nodeOut.ChildNode, nodeOut, sysItem, list); } else if (node is JCHVRF.Model.NextGen.MyNodeYP) { JCHVRF.Model.NextGen.MyNodeYP nodeYP = node as JCHVRF.Model.NextGen.MyNodeYP; foreach (Lassalle.WPF.Flow.Node item in nodeYP.ChildNodes) { GetHeightDifferenceNodes(item, nodeYP, sysItem, list); } } else if (node is JCHVRF.Model.NextGen.MyNodeCH) { JCHVRF.Model.NextGen.MyNodeCH nodeCH = node as JCHVRF.Model.NextGen.MyNodeCH; list.Add(nodeCH); GetHeightDifferenceNodes(nodeCH.ChildNode, nodeCH, sysItem, list); } else if (node is JCHVRF.Model.NextGen.MyNodeMultiCH) { JCHVRF.Model.NextGen.MyNodeMultiCH nodeMCH = node as JCHVRF.Model.NextGen.MyNodeMultiCH; list.Add(nodeMCH); foreach (Lassalle.WPF.Flow.Node item in nodeMCH.ChildNodes) { GetHeightDifferenceNodes(item, nodeMCH, sysItem, list); } } else if (node is JCHVRF.Model.NextGen.MyNodeIn) { //因为DoPipingCalculation之后可能影响indoor的管径, //所以绘制YP型号的时候顺便绘制indoor的管径 add on 20170512 by Shen Junjie JCHVRF.Model.NextGen.MyNodeIn nodeIn = node as JCHVRF.Model.NextGen.MyNodeIn; list.Add(nodeIn); } }
public void DrawLine(Graphics g, WL.Link line) { List <PointF> ptl = new List <PointF>(); foreach (pt.Point p in line.Points) { ptl.Add(utilWiring.convertSystemPointToDrawingPoint(p)); } if (ptl.Count <= 1) { return; } PointF[] pts = ptl.ToArray(); pt.Media.SolidColorBrush newBrush = (pt.Media.SolidColorBrush)line.Stroke; Color clr = System.Drawing.Color.FromArgb(newBrush.Color.A, newBrush.Color.R, newBrush.Color.G, newBrush.Color.B); Pen pen = new Pen(clr, 0.1f); WL.Node nd = line.Dst; if (nd != null && nd is NextGenModel.MyNodeGround_Wiring) { pen = new Pen(Color.Yellow, 0.1f); } g.DrawLines(pen, pts); }
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 } } } }
private void BindHighDifference() { this.ListIDU = new ObservableCollection <IDUList>(); this.ListIDU.Clear(); List <JCHVRF.Model.NextGen.MyNode> nodes = new List <JCHVRF.Model.NextGen.MyNode>(); WL.Node addFlowItemPiping = (WL.Node)sysItemSource.MyPipingNodeOut; GetHeightDifferenceNodes(addFlowItemPiping, null, sysItemSource, nodes); int i = -1; foreach (JCHVRF.Model.NextGen.MyNode node in nodes) { int Id = this.ListIDU.Count + 1; string modelName = ""; if (node is JCHVRF.Model.NextGen.MyNodeCH) { JCHVRF.Model.NextGen.MyNodeCH nodeCH = node as JCHVRF.Model.NextGen.MyNodeCH; string PositionType = PipingPositionType.Upper.ToString(); if (!string.IsNullOrEmpty(nodeCH.Model)) { modelName = "CHBox [" + nodeCH.Model + "]"; } else { modelName = "CHBox"; } double HeightDiff = nodeCH.HeightDiff; if (HeightDiff < 0) { PositionType = PipingPositionType.Lower.ToString(); HeightDiff = -HeightDiff; } else if (HeightDiff == 0) { PositionType = PipingPositionType.SameLevel.ToString(); } ListIDU.Add(new IDUList { IndoorNo = (int)Id, IndoorName = (string)modelName, Name = Id + "[" + modelName + "]", PositionType = (string)PositionType, HeightDiff = Convert.ToDouble(Unit.ConvertToControl(HeightDiff, UnitType.LENGTH_M, ut_length).ToString("n1")), IndoorTag = node }); } if (node is JCHVRF.Model.NextGen.MyNodeMultiCH) { JCHVRF.Model.NextGen.MyNodeMultiCH nodeCH = node as JCHVRF.Model.NextGen.MyNodeMultiCH; string PositionType = PipingPositionType.Upper.ToString(); if (!string.IsNullOrEmpty(nodeCH.Model)) { modelName = "MultiCHBox [" + nodeCH.Model + "]"; } else { modelName = "MultiCHBox"; } double HeightDiff = nodeCH.HeightDiff; if (HeightDiff < 0) { PositionType = PipingPositionType.Lower.ToString(); HeightDiff = -HeightDiff; } else if (HeightDiff == 0) { PositionType = PipingPositionType.SameLevel.ToString(); } ListIDU.Add(new IDUList { IndoorNo = (int)Id, IndoorName = (string)modelName, Name = Id + "[" + modelName + "]", PositionType = (string)PositionType, HeightDiff = Convert.ToDouble(Unit.ConvertToControl(HeightDiff, UnitType.LENGTH_M, ut_length).ToString("n1")), IndoorTag = node }); } if (node is JCHVRF.Model.NextGen.MyNodeIn) { JCHVRF.Model.NextGen.MyNodeIn nodeIn = node as JCHVRF.Model.NextGen.MyNodeIn; string Room = ""; if (!string.IsNullOrEmpty((new ProjectBLL(thisProject)).GetFloorAndRoom(nodeIn.RoomIndooItem.RoomID))) { Room = (new ProjectBLL(thisProject)).GetFloorAndRoom(nodeIn.RoomIndooItem.RoomID) + " : "; } Room = Room + nodeIn.RoomIndooItem.IndoorName + " [" + (thisProject.BrandCode == "Y" ? nodeIn.RoomIndooItem.IndoorItem.Model_York : nodeIn.RoomIndooItem.IndoorItem.Model_Hitachi) + "]"; if (nodeIn.RoomIndooItem != null) { modelName = nodeIn.RoomIndooItem.IndoorFullName; } else { modelName = ""; } ListIDU.Add(new IDUList { IndoorNo = (int)Id, IndoorName = modelName, Name = modelName, PositionType = nodeIn.RoomIndooItem.PositionType, HeightDiff = Convert.ToDouble(Unit.ConvertToControl(nodeIn.RoomIndooItem.HeightDiff, UnitType.LENGTH_M, ut_length)), IndoorTag = node }); } } RecalculateMaxHeightDifference(nodes); }