/// <summary> /// 闪烁查询到要素 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void flashFeature(object sender, UploadStringCompletedEventArgs e) { geoObj = this.IMSCatalog.ActiveLayerObj.OnGetGeomByFID(e); if (geoObj == null) { return; } List <Point> pntArr = new List <Point>(); for (int i = 0; i < geoObj.RegGeom[0].Rings.Length; i++) { for (int j = 0; j < geoObj.RegGeom[0].Rings[i].Arcs.Length; j++) { for (int k = 0; k < geoObj.RegGeom[0].Rings[i].Arcs[j].Dots.Length; k++) { pntArr.Add(new Point(geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].x, geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].y)); } } } if (pntArr[0].X <this.IMSCatalog.ActiveLayerObj.MapContainer.WinViewBound.XMin || pntArr[0].X> this.IMSCatalog.ActiveLayerObj.MapContainer.WinViewBound.XMax || pntArr[0].Y <this.IMSCatalog.ActiveLayerObj.MapContainer.WinViewBound.YMin || pntArr[0].Y> this.IMSCatalog.ActiveLayerObj.MapContainer.WinViewBound.YMax) { this.IMSCatalog.ActiveLayerObj.MapContainer.PanTo(pntArr[0].X, pntArr[0].Y); } m_graphics = new IMSPolygon(CoordinateType.Logic) { Points = pntArr }; m_graphicsLayer.AddGraphics(m_graphics); m_graphics.FlickerOverCallback = new GraphicsFlickerOverDelegate(FlickerOverCallback); m_graphics.Draw(); m_graphics.Flicker(); }
public void Draw() { if (GraphicsLayer != null && RoadCoorArr.Length > 0) { if (m_road == null) { m_road = new IMSPolyline(CoordinateType.Logic); m_road.Shape.Stroke = new SolidColorBrush(Colors.Red); GraphicsLayer.AddGraphics(m_road); } for (int i = 0; i < RoadCoorArr.Length - 1; i += 2) { if (RoadCoorArr[i].Length > 0 && RoadCoorArr[i + 1].Length > 0) { m_road.Points.Add(new Point(Convert.ToDouble(RoadCoorArr[i]), Convert.ToDouble(RoadCoorArr[i + 1]))); } } m_road.Draw(); for (int i = 0; i < m_stopList.Count; i++) { MarkLayer.AddMark(m_stopList[i]); m_stopList[i].RevisedPosition(); } this.GraphicsLayer.MapContainer.PanTo(Convert.ToDouble(RoadCoorArr[0]), Convert.ToDouble(RoadCoorArr[1])); } }
/** * 添加测量标记点 */ private void addMeasurePoint(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr) { if (IsDrawOver) { clearMeasurePnts(null, null, null); } IMSCircle pnt = new IMSCircle(CoordinateType.Logic); pnt.RadiusEx = 4; pnt.CenX = logPntArr[logPntArr.Count - 1].X; pnt.CenY = logPntArr[logPntArr.Count - 1].Y; m_graphicsLayer.AddGraphics(pnt); pnt.Draw(); this.measurePnts.Add(pnt); this.measurePntsTmp.Add(new Point(logPntArr[logPntArr.Count - 1].X, logPntArr[logPntArr.Count - 1].Y)); if (this.m_graphicsLayer.DrawingType == DrawingType.Polyline) { Label currmeasureLabel = new Label(); currmeasureLabel.Content = ""; currmeasureLabel.FontSize = 12; IMSMark currmeasureMark = new IMSMark(currmeasureLabel, CoordinateType.Logic); currmeasureMark.EnableDrag = false; currmeasureMark.EnableAnimation = false; mymarklayer.AddMark(currmeasureMark); measureMarks.Add(currmeasureMark); // (currmeasureMark.MarkControl as Label).Content = getLength(new Point(-1, -1)); ; string tollength = getCurrentLength(-1, -1, new Point(-1, -1)); measureleng += Convert.ToDouble(tollength.Split(':')[1]); currmeasureMark.X = logPntArr[logPntArr.Count - 1].X + 0.0055; currmeasureMark.Y = logPntArr[logPntArr.Count - 1].Y - 0.0055; Label centermeasureLabel = new Label(); centermeasureLabel.Content = ""; centermeasureLabel.FontSize = 12; IMSMark centermeasureMark = new IMSMark(centermeasureLabel, CoordinateType.Logic); centermeasureMark.EnableDrag = false; centermeasureMark.EnableAnimation = false; mymarklayer.AddMark(centermeasureMark); measureCenterMarks.Add(centermeasureMark); (centermeasureMark.MarkControl as Label).RenderTransform = new RotateTransform(); if ((bool)checkBox1.IsChecked) { if (centermeasureMark != null) { // centermeasureMark.Visibility = System.Windows.Visibility.Visible; } } else { if (centermeasureMark != null) { centermeasureMark.Visibility = System.Windows.Visibility.Collapsed; } } } this.m_mapContainer.MouseMove -= new MouseEventHandler(m_graphicsLayer_MouseMove); this.m_mapContainer.MouseMove += new MouseEventHandler(m_graphicsLayer_MouseMove); IsDrawOver = false; }
public IMSPolygon drawGetFeature(SFeatureGeometry sfeatureTemp) { GRegion reg = sfeatureTemp.RegGeom[0]; AnyLine arcLine = reg.Rings[0]; Arc arc = arcLine.Arcs[0]; //获取要素边界的点 Dot_2D[] Arcpnts = arc.Dots; int arcpntNum = Arcpnts.Length; //绘制多边形 IMSPolygon poly = new IMSPolygon(CoordinateType.Logic); m_gpLayer.AddGraphics(poly); for (int i = 0; i < arcpntNum; i++) { poly.Points.Add(new Point(arc.Dots[i].x, arc.Dots[i].y)); } poly.Draw(); return(poly); }
//将圆形区域添加到地图上 private void AddCircle() { cirObj = new Circle(); cirObj.Center = new Dot_2D(); cirObj.Center.x = 114.3041267836914; cirObj.Center.y = 30.651509197753906; cirObj.Radius = 0.004484101072174819; //在地图上显示圆形区域 Clipcir = new IMSCircle(CoordinateType.Logic); // cir.Stroke = new SolidColorBrush(Colors.Orange); Clipcir.StrokeThickness = 2; //设置圆心 Clipcir.CenX = cirObj.Center.x; Clipcir.CenY = cirObj.Center.y; //设置半径 Clipcir.Radius = cirObj.Radius; //绘制圆形 Clipcir.Draw(); m_gpLayer.AddGraphics(Clipcir); }
private void OnSubmit(object sender, UploadStringCompletedEventArgs e) { LinePnts = new List <Point>(); CPathAnalyzeResult obj = _spatial.OnNetAnalyse(e); if (obj == null || obj.Paths == null) { return; } CNetPath path = obj.Paths[0]; int edgeNum = path.Edges.Length; Paragraph myParagraph = new Paragraph(); myParagraph.Inlines.Add(new Run() { Text = "1.从起点出发" }); Bold bold; IMSMark mark; StackPanel panel; for (int i = 0; i < edgeNum; i++) { CNetEdge edge = path.Edges[i]; if (i != 0) { myParagraph.Inlines.Add(new Run() { Text = (i + 1).ToString() + "." }); } myParagraph.Inlines.Add(new Run() { Text = "经" }); bold = new Bold() { Foreground = new SolidColorBrush(Colors.Red) }; bold.Inlines.Add(edge.FieldValus[2]); myParagraph.Inlines.Add(bold); if (i != edgeNum - 1) { myParagraph.Inlines.Add(new Run() { Text = "到达" }); bold = new Bold() { Foreground = new SolidColorBrush(Colors.Red) }; bold.Inlines.Add(path.Nodes[i + 1].FieldValus[0] + "\n"); myParagraph.Inlines.Add(bold); } else { myParagraph.Inlines.Add(new Run() { Text = "到达终点" }); } if (GraphicsLayer != null) { if (m_road == null) { m_road = new IMSPolyline(CoordinateType.Logic); m_road.Shape.Stroke = new SolidColorBrush(Colors.Red); GraphicsLayer.AddGraphics(m_road); } for (int j = 0; j < edge.Dots.Length; j++) { m_road.Points.Add(new Point(edge.Dots[j].x, edge.Dots[j].y)); LinePnts.Add(new Point(edge.Dots[j].x, edge.Dots[j].y)); } panel = new StackPanel() { Orientation = Orientation.Horizontal }; panel.Children.Add(new Image() { Source = new BitmapImage(new Uri("/images/bus/stop.png", UriKind.Relative)) }); panel.Children.Add(new TextBlock() { Text = edge.FieldValus[2] }); mark = new IMSMark(panel, CoordinateType.Logic) { EnableDrag = false, EnableAnimation = false }; mark.X = edge.Dots[edge.Dots.Length / 2].x; mark.Y = edge.Dots[edge.Dots.Length / 2].y; m_markLayer.AddMark(mark); m_stopList.Add(mark); } } m_road.Draw(); if (netWindow == null) { netWindow = new NetWindow(); } if (netWindow != null) { this.netWindow.g_graphicLayer = this.GraphicsLayer; this.netWindow.m_markLayer = this.m_markLayer; this.netWindow.OgicPnts = this.LinePnts; netWindow.Show(); this.netWindow.Margin = new Thickness(0, 120, 0, 0); this.netWindow.HorizontalAlignment = HorizontalAlignment.Right; this.netWindow.roadReslut.Blocks.Add(myParagraph); } SuccessFlag = true; }
private void OnSubmit(object sender, UploadStringCompletedEventArgs e) { ClearRoad(); roadReslut.Blocks.Clear(); if (e.Error != null) { MessageBox.Show("分析失败,错误原因为:" + e.Error.Message, "提示", MessageBoxButton.OK); return; } try { if (e.Result.IndexOf("COperResult") > -1) { COperResult res = VectorObj.GetObject(e, typeof(COperResult)) as COperResult; MessageBox.Show(res.ErrorInfo, "提示", MessageBoxButton.OK); return; } CPathAnalyzeResult obj = _spatial.OnNetAnalyse(e); if (obj == null || obj.Paths == null) { return; } CNetPath path = obj.Paths[0]; int edgeNum = path.Edges.Length; Paragraph myParagraph = new Paragraph(); myParagraph.Inlines.Add(new Run() { Text = "1.从起点出发" }); Bold bold; IMSMark mark; StackPanel panel; for (int i = 0; i < edgeNum; i++) { CNetEdge edge = path.Edges[i]; if (i != 0) { myParagraph.Inlines.Add(new Run() { Text = (i + 1).ToString() + "." }); } myParagraph.Inlines.Add(new Run() { Text = "经" }); bold = new Bold() { Foreground = new SolidColorBrush(Colors.Red) }; bold.Inlines.Add(edge.FieldValus[2]); myParagraph.Inlines.Add(bold); if (i != edgeNum - 1) { myParagraph.Inlines.Add(new Run() { Text = "到达" }); bold = new Bold() { Foreground = new SolidColorBrush(Colors.Red) }; bold.Inlines.Add(path.Nodes[i + 1].FieldValus[0] + "\n"); myParagraph.Inlines.Add(bold); } else { myParagraph.Inlines.Add(new Run() { Text = "到达终点" }); } if (GraphicsLayer != null) { if (m_road == null) { m_road = new IMSPolyline(CoordinateType.Logic); m_road.Shape.Stroke = new SolidColorBrush(Colors.Red); GraphicsLayer.AddGraphics(m_road); } for (int j = 0; j < edge.Dots.Length; j++) { m_road.Points.Add(new Point(edge.Dots[j].x, edge.Dots[j].y)); } panel = new StackPanel() { Orientation = Orientation.Horizontal }; panel.Children.Add(new Image() { Source = new BitmapImage(new Uri("../images/bus/stop.png", UriKind.Relative)) }); panel.Children.Add(new TextBlock() { Text = edge.FieldValus[2] }); mark = new IMSMark(panel, CoordinateType.Logic, MarkLayer) { EnableAnimation = false, EnableDrag = false }; mark.X = edge.Dots[edge.Dots.Length / 2].x; mark.Y = edge.Dots[edge.Dots.Length / 2].y; MarkLayer.AddMark(mark); m_stopList.Add(mark); } } m_road.Draw(); roadReslut.Blocks.Add(myParagraph); radioButton1.IsChecked = false; radioButton2.IsChecked = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK); } }
/// <summary> /// 闪烁图形 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FlashFeature(object sender, UploadStringCompletedEventArgs e) { try { m_featureGeo = activeMapDoc.OnGetGeomByID(e); } catch (Exception ex) { MessageBox.Show("获取该要素空间信息失败!" + ex.Message); return; } bool flg = false; if (m_featureGeo.LinGeom != null && m_featureGeo.LinGeom.Length > 0) { List <Point> pntArr = new List <Point>(); for (int i = 0; i < m_featureGeo.LinGeom.Length; i++) { for (int j = 0; j < m_featureGeo.LinGeom[i].Line.Arcs.Length; j++) { for (int k = 0; k < m_featureGeo.LinGeom[i].Line.Arcs[j].Dots.Length; k++) { pntArr.Add(new Point(m_featureGeo.LinGeom[i].Line.Arcs[j].Dots[k].x, m_featureGeo.LinGeom[i].Line.Arcs[j].Dots[k].y)); } } } if (pntArr[0].X <activeMapDoc.MapContainer.WinViewBound.XMin || pntArr[0].X> activeMapDoc.MapContainer.WinViewBound.XMax || pntArr[0].Y <activeMapDoc.MapContainer.WinViewBound.YMin || pntArr[0].Y> activeMapDoc.MapContainer.WinViewBound.YMax) { activeMapDoc.MapContainer.PanTo(pntArr[0].X, pntArr[0].Y); } m_graphics = new IMSPolyline(CoordinateType.Logic) { Points = pntArr, StrokeThickness = 4 }; flg = true; } if (m_featureGeo.PntGeom != null && m_featureGeo.PntGeom.Length > 0) { if (m_featureGeo.PntGeom[0].Dot.x <activeMapDoc.MapContainer.WinViewBound.XMin || m_featureGeo.PntGeom[0].Dot.x> activeMapDoc.MapContainer.WinViewBound.XMax || m_featureGeo.PntGeom[0].Dot.y <activeMapDoc.MapContainer.WinViewBound.YMin || m_featureGeo.PntGeom[0].Dot.y> activeMapDoc.MapContainer.WinViewBound.YMax) { activeMapDoc.MapContainer.PanTo(m_featureGeo.PntGeom[0].Dot.x, m_featureGeo.PntGeom[0].Dot.y); } m_graphics = new IMSCircle(CoordinateType.Logic) { CenX = m_featureGeo.PntGeom[0].Dot.x, CenY = m_featureGeo.PntGeom[0].Dot.y, RadiusEx = 6 }; flg = true; } if (m_featureGeo.RegGeom != null && m_featureGeo.RegGeom.Length > 0) { List <Point> pntArr = new List <Point>(); for (int i = 0; i < m_featureGeo.RegGeom[0].Rings.Length; i++) { for (int j = 0; j < m_featureGeo.RegGeom[0].Rings[i].Arcs.Length; j++) { for (int k = 0; k < m_featureGeo.RegGeom[0].Rings[i].Arcs[j].Dots.Length; k++) { pntArr.Add(new Point(m_featureGeo.RegGeom[0].Rings[i].Arcs[j].Dots[k].x, m_featureGeo.RegGeom[0].Rings[i].Arcs[j].Dots[k].y)); } } } if (pntArr[0].X <activeMapDoc.MapContainer.WinViewBound.XMin || pntArr[0].X> activeMapDoc.MapContainer.WinViewBound.XMax || pntArr[0].Y <activeMapDoc.MapContainer.WinViewBound.YMin || pntArr[0].Y> activeMapDoc.MapContainer.WinViewBound.YMax) { activeMapDoc.MapContainer.PanTo(pntArr[0].X, pntArr[0].Y); } m_graphics = new IMSPolygon(CoordinateType.Logic) { Points = pntArr }; flg = true; } if (flg) { m_graphicsLayer.AddGraphics(m_graphics); m_graphics.FlickerOverCallback = new GraphicsFlickerOverDelegate(FlickerOverCallback); m_graphics.Draw(); m_graphics.Flicker(); } }
private void DrawFeature(object sender, UploadStringCompletedEventArgs e) { SFeatureGeometry geoObj = null; try { geoObj = ActiveMapDoc.OnGetGeomByID(e); } catch (Exception ex) { MessageBox.Show("获取该要素空间信息失败!" + ex.Message); return; } m_targetGeo = geoObj; bool flg = false; if (geoObj.LinGeom != null && geoObj.LinGeom.Length > 0) { List <Point> pntArr = new List <Point>(); for (int i = 0; i < geoObj.LinGeom.Length; i++) { for (int j = 0; j < geoObj.LinGeom[i].Line.Arcs.Length; j++) { for (int k = 0; k < geoObj.LinGeom[i].Line.Arcs[j].Dots.Length; k++) { pntArr.Add(new Point(geoObj.LinGeom[i].Line.Arcs[j].Dots[k].x, geoObj.LinGeom[i].Line.Arcs[j].Dots[k].y)); } } } if (pntArr[0].X <ActiveMapDoc.MapContainer.WinViewBound.XMin || pntArr[0].X> ActiveMapDoc.MapContainer.WinViewBound.XMax || pntArr[0].Y <ActiveMapDoc.MapContainer.WinViewBound.YMin || pntArr[0].Y> ActiveMapDoc.MapContainer.WinViewBound.YMax) { ActiveMapDoc.MapContainer.PanTo(pntArr[0].X, pntArr[0].Y); } m_graphics = new IMSPolyline(CoordinateType.Logic) { Points = pntArr, StrokeThickness = 4 }; flg = true; } if (geoObj.PntGeom != null && geoObj.PntGeom.Length > 0) { if (geoObj.PntGeom[0].Dot.x <ActiveMapDoc.MapContainer.WinViewBound.XMin || geoObj.PntGeom[0].Dot.x> ActiveMapDoc.MapContainer.WinViewBound.XMax || geoObj.PntGeom[0].Dot.y <ActiveMapDoc.MapContainer.WinViewBound.YMin || geoObj.PntGeom[0].Dot.y> ActiveMapDoc.MapContainer.WinViewBound.YMax) { ActiveMapDoc.MapContainer.PanTo(geoObj.PntGeom[0].Dot.x, geoObj.PntGeom[0].Dot.y); } m_graphics = new IMSCircle(CoordinateType.Logic) { CenX = geoObj.PntGeom[0].Dot.x, CenY = geoObj.PntGeom[0].Dot.y, RadiusEx = 6 }; flg = true; } if (geoObj.RegGeom != null && geoObj.RegGeom.Length > 0) { List <Point> pntArr = new List <Point>(); for (int i = 0; i < geoObj.RegGeom[0].Rings.Length; i++) { for (int j = 0; j < geoObj.RegGeom[0].Rings[i].Arcs.Length; j++) { for (int k = 0; k < geoObj.RegGeom[0].Rings[i].Arcs[j].Dots.Length; k++) { pntArr.Add(new Point(geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].x, geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].y)); } } } if (pntArr[0].X <ActiveMapDoc.MapContainer.WinViewBound.XMin || pntArr[0].X> ActiveMapDoc.MapContainer.WinViewBound.XMax || pntArr[0].Y <ActiveMapDoc.MapContainer.WinViewBound.YMin || pntArr[0].Y> ActiveMapDoc.MapContainer.WinViewBound.YMax) { ActiveMapDoc.MapContainer.PanTo(pntArr[0].X, pntArr[0].Y); } m_graphics = new IMSPolygon(CoordinateType.Logic) { Points = pntArr }; flg = true; } if (flg) { GraphicsLayer.AddGraphics(m_graphics); m_graphics.EnableEdit = true; m_graphics.EnableEditMark2 = false; m_graphics.Draw(); } }