public void SetPicDrawData(DrawGraphType type, object o) { int nModeSel = 0; int strTypeID = 0; string strTypeName = ""; string strBody = ""; string strSelTextH = "<GraphData>" + System.Environment.NewLine + "<GraphTypeInfo typeid =\"{1}\" >" + System.Environment.NewLine + "<GraphTypeItem pattern=\"{0}\" graphname=\"{2}\">" + System.Environment.NewLine; string strSelTextT = "</GraphTypeItem>" + System.Environment.NewLine + "</GraphTypeInfo>" + System.Environment.NewLine + "</GraphData>" + System.Environment.NewLine; bool needDraw = true; switch (type) { case DrawGraphType.AnalyseAreaEx: Rectangle rect = (Rectangle)o; if (rect != null) { Point p1 = rect.Location; Point p2 = new Point(p1.X + rect.Width, p1.Y); Point p3 = new Point(p2.X, p2.Y + rect.Height); Point p4 = new Point(p1.X, p1.Y + rect.Height); strBody = "<PointList>" + System.Environment.NewLine + "<Point>" + p1.X + "," + p1.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p2.X + "," + p2.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p3.X + "," + p3.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p4.X + "," + p4.Y + "</Point>" + System.Environment.NewLine + "</PointList>" + System.Environment.NewLine; } else { needDraw = false; } nModeSel = 3; strTypeName = "检测区域"; strTypeID = (int)type; break; case DrawGraphType.PassLine: nModeSel = 7; strTypeID = (int)type; strTypeName = "越界线"; PassLine pl = o as PassLine; if (pl != null) { strBody = "<PointList>" + System.Environment.NewLine + "<Point>" + pl.PassLineStart.X + "," + pl.PassLineStart.Y + "</Point>" + System.Environment.NewLine + "<Point>" + pl.PassLineEnd.X + "," + pl.PassLineEnd.Y + "</Point>" + System.Environment.NewLine + "</PointList>" + System.Environment.NewLine + "<LineDirection>" + pl.PassLineType + "</LineDirection>" + System.Environment.NewLine + "<StartPoint>" + pl.DirectLineStart.X + "," + pl.DirectLineStart.Y + "</StartPoint>" + System.Environment.NewLine + "<EndPoint>" + pl.DirectLineEnd.X + "," + pl.DirectLineEnd.Y + "</EndPoint>" + System.Environment.NewLine; } else { needDraw = false; } break; case DrawGraphType.PassRegion: nModeSel = 3; strTypeID = (int)type; strTypeName = "闯入闯出"; BreakRegion br = o as BreakRegion; if (br != null) { string poings = ""; foreach (Point p in br.RegionPointList) { poings += "<Point>" + p.X + "," + p.Y + "</Point>" + System.Environment.NewLine; } strBody += "<PointList>" + System.Environment.NewLine + poings + "</PointList>" + System.Environment.NewLine + "<PolygonDirection>" + br.RegionType + "</PolygonDirection>" + System.Environment.NewLine; } else { needDraw = false; } break; case DrawGraphType.DriveWay1: case DrawGraphType.DriveWay2: case DrawGraphType.DriveWay3: case DrawGraphType.DriveWay4: case DrawGraphType.DriveWay5: case DrawGraphType.DriveWay6: nModeSel = 5; strTypeID = (int)type; strTypeName = "车道" + (strTypeID - 10); DriveWayRegion dwr = o as DriveWayRegion; if (dwr != null) { string poings = ""; foreach (Point p in dwr.RegionPointList) { poings += "<Point>" + p.X + "," + p.Y + "</Point>" + System.Environment.NewLine; } strBody = "<PointList>" + System.Environment.NewLine + poings + "</PointList>" + System.Environment.NewLine + "<Angle></Angle>" + System.Environment.NewLine + "<StartPoint>" + dwr.DirectLineStart.X + "," + dwr.DirectLineStart.Y + "</StartPoint>" + System.Environment.NewLine + "<EndPoint>" + dwr.DirectLineEnd.X + "," + dwr.DirectLineEnd.Y + "</EndPoint>" + System.Environment.NewLine; } else { needDraw = false; } break; case DrawGraphType.VehicleRegion: nModeSel = 3; strTypeID = (int)type; strTypeName = "车牌检测区"; Rectangle vehrect = (Rectangle)o; if (vehrect != null) { Point p1 = vehrect.Location; Point p2 = new Point(p1.X + vehrect.Width, p1.Y); Point p3 = new Point(p2.X, p2.Y + vehrect.Height); Point p4 = new Point(p1.X, p1.Y + vehrect.Height); strBody = "<PointList>" + System.Environment.NewLine + "<Point>" + p1.X + "," + p1.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p2.X + "," + p2.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p3.X + "," + p3.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p4.X + "," + p4.Y + "</Point>" + System.Environment.NewLine + "</PointList>" + System.Environment.NewLine; } else { needDraw = false; } break; case DrawGraphType.ImageSC: nModeSel = 3; strTypeID = (int)type; strTypeName = "标定"; List <Point> sm = (List <Point>)o; if (sm != null) { string poings = ""; foreach (Point p in sm) { poings += "<Point>" + p.X + "," + p.Y + "</Point>" + System.Environment.NewLine; } strBody += "<PointList>" + System.Environment.NewLine + poings + "</PointList>" + System.Environment.NewLine; } else { needDraw = false; } break; case DrawGraphType.FarArea: nModeSel = 3; strTypeID = (int)type; strTypeName = "远处行人框"; Rectangle recFar = (Rectangle)o; if (recFar != null) { Point p1 = recFar.Location; Point p2 = new Point(p1.X + recFar.Width, p1.Y); Point p3 = new Point(p2.X, p2.Y + recFar.Height); Point p4 = new Point(p1.X, p1.Y + recFar.Height); strBody = "<PointList>" + System.Environment.NewLine + "<Point>" + p1.X + "," + p1.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p2.X + "," + p2.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p3.X + "," + p3.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p4.X + "," + p4.Y + "</Point>" + System.Environment.NewLine + "</PointList>" + System.Environment.NewLine; } else { needDraw = false; } break; case DrawGraphType.NearArea: nModeSel = 3; strTypeID = (int)type; strTypeName = "近处行人框"; Rectangle recNear = (Rectangle)o; if (recNear != null) { Point p1 = recNear.Location; Point p2 = new Point(p1.X + recNear.Width, p1.Y); Point p3 = new Point(p2.X, p2.Y + recNear.Height); Point p4 = new Point(p1.X, p1.Y + recNear.Height); strBody = "<PointList>" + System.Environment.NewLine + "<Point>" + p1.X + "," + p1.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p2.X + "," + p2.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p3.X + "," + p3.Y + "</Point>" + System.Environment.NewLine + "<Point>" + p4.X + "," + p4.Y + "</Point>" + System.Environment.NewLine + "</PointList>" + System.Environment.NewLine; } else { needDraw = false; } break; case DrawGraphType.None: needDraw = false; break; default: needDraw = false; break; } if (needDraw) { string strSelText = string.Format("<?xml version=\"1.0\"?>" + System.Environment.NewLine + strSelTextH + System.Environment.NewLine + strBody + System.Environment.NewLine + strSelTextT, nModeSel, strTypeID, strTypeName); m_PicControl.SetGraphData(strSelText); } }
public void SetPicDrawTypeRect(DrawGraphType type, string graphName = null) { int nModeSel = 0; int strTypeID = 0; string strTypeName = ""; string strSelText = ""; switch (type) { case DrawGraphType.AnalyseAreaEx: nModeSel = 2; strTypeID = (int)type; strTypeName = "检测区域"; break; case DrawGraphType.PassLine: nModeSel = 7; strTypeID = (int)type; strTypeName = "越界线"; break; case DrawGraphType.PassRegion: nModeSel = 3; strTypeID = (int)type; strTypeName = "闯入闯出"; break; case DrawGraphType.DriveWay1: case DrawGraphType.DriveWay2: case DrawGraphType.DriveWay3: case DrawGraphType.DriveWay4: case DrawGraphType.DriveWay5: case DrawGraphType.DriveWay6: nModeSel = 5; strTypeID = (int)type; strTypeName = "车道" + (strTypeID - 10); break; case DrawGraphType.VehicleRegion: nModeSel = 3; strTypeID = (int)type; strTypeName = "车牌检测区"; break; case DrawGraphType.FarArea: nModeSel = 2; strTypeID = (int)type; strTypeName = "远处行人框"; break; case DrawGraphType.NearArea: nModeSel = 2; strTypeID = (int)type; strTypeName = "近处行人框"; break; case DrawGraphType.ImageSC: nModeSel = 3; strTypeID = (int)type; strTypeName = "标定"; break; case DrawGraphType.None: nModeSel = 0; strTypeID = 0; strTypeName = ""; break; default: break; } strSelText = string.Format("<?xml version=\"1.0\"?>" + System.Environment.NewLine + "<DrawingMode>" + System.Environment.NewLine + "<GraphPattern>{0}</GraphPattern>" + System.Environment.NewLine + "<GraphTypeId>{1}</GraphTypeId>" + System.Environment.NewLine + "<GraphName>{2}</GraphName>" + System.Environment.NewLine + "</DrawingMode>", nModeSel, strTypeID, graphName == null?strTypeName : graphName); m_PicControl.SetCurrentDrawMode(strSelText); }