private void checkBox1_Checked(object sender, RoutedEventArgs e) { if (this.measureCenterMarks != null) { for (int i = 0; i < this.measureCenterMarks.Count; i++) { IMSMark centermeasureMark = this.measureCenterMarks[i]; centermeasureMark.Visibility = System.Windows.Visibility.Visible; } } }
void m_graphicsLayer_MouseMove(object sender, MouseEventArgs e) { Point pnt = e.GetPosition(this.m_mapContainer); Point logpnt = this.m_mapContainer.ScreenToLogic(pnt.X, pnt.Y); if (this.m_graphicsLayer.DrawingType == DrawingType.Polyline) { IMSMark centermeasureMark = this.measureCenterMarks[this.measureCenterMarks.Count - 1]; (centermeasureMark.MarkControl as Label).Content = getCurrentLength(-1, -1, logpnt); IMSCircle pntCircle = this.measurePnts[this.measurePnts.Count - 1]; centermeasureMark.X = (logpnt.X + 3 * pntCircle.CenX) / 4; centermeasureMark.Y = (logpnt.Y + 3 * pntCircle.CenY) / 4; Point scrPnt = this.m_mapContainer.LogicToScreen(pntCircle.CenX, pntCircle.CenY); double angle = Math.Atan2(scrPnt.Y - pnt.Y, pnt.X - scrPnt.X); ((centermeasureMark.MarkControl as Label).RenderTransform as RotateTransform).Angle = 360 - angle * 360 / (2 * Math.PI); if ((bool)checkBox1.IsChecked) { centermeasureMark.Visibility = System.Windows.Visibility.Visible; } else { centermeasureMark.Visibility = System.Windows.Visibility.Collapsed; } } if (this.measureMark == null) { Label measureLabel = new Label(); measureLabel.Content = ""; measureLabel.Name = "measureResultLabel"; measureLabel.FontSize = 12; this.measureMark = new IMSMark(measureLabel, CoordinateType.Logic); this.measureMark.EnableDrag = false; mymarklayer.AddMark(this.measureMark); } this.measureMark.X = logpnt.X + 0.0055; this.measureMark.Y = logpnt.Y - 0.0055; try { if (measureMark != null) { this.measureMark.Visibility = Visibility.Visible; } } catch { return; } (this.measureMark.MarkControl as Label).Content = this.m_graphicsLayer.DrawingType == DrawingType.Polyline ? getLength(logpnt) : getArea(logpnt); }
//控制标注的点击事件 void mark_click(IMSMark mark, object obj, MouseEventArgs e) { if (DFwin.Visibility == Visibility.Visible) { DFwin.Visibility = Visibility.Collapsed; } else { DFwin.Margin = new Thickness(iMSMap1.LogicToScreen(pnt.X, pnt.Y).X + 15, iMSMap1.LogicToScreen(pnt.X, pnt.Y).Y + 15, 0, 0); DFwin.Visibility = Visibility.Visible; DFwin.AllowDrop = false; } }
/// <summary> /// 地图就绪事件 /// </summary> /// <param name="e"></param> void iMSMap1_MapReady(ZDIMS.Event.IMSMapEvent e) { if (!DesignerProperties.IsInDesignTool) { //监听地图容器鼠标左键弹起事件 this.iMSMap1.MouseLeftButtonUp += new MouseButtonEventHandler(iMSMap1_MouseLeftButtonUp); this.iMSMap1.SetInfoText(" 鼠标选择点编辑,点击地图取消选择!", Colors.Black); //定义点样式对象,添加到地图上 IMSSimpleMarkerSymbol markers; markers = new IMSSimpleMarkerSymbol(); //添加预定义点样式对象选择监听事件 markers.ChossedMarkerOverCallBack += new IMSMarkerSymbol.ChossedMarkerHander(markers_ChossedShapeOverCallBack); IMSMark mark; mark = new IMSMark(markers.control, ZDIMS.Interface.CoordinateType.Logic); mark.X = 6.99919517012924; mark.Y = 30.671057152220655; mark.EnableAnimation = false; this.markLayer.AddMark(mark); markers = new IMSSimpleMarkerSymbol(); markers.ChossedMarkerOverCallBack += markers_ChossedShapeOverCallBack; markers.SymbolStyle = MarkSymbolStyle.Star; mark = new IMSMark(markers.control, ZDIMS.Interface.CoordinateType.Logic); mark.EnableAnimation = false; mark.X = 8.89919517012924; mark.Y = 23.971057152220655; this.markLayer.AddMark(mark); //添加图片点样式对象 IMSPictureMarkerSymbol picMarker; picMarker = new IMSPictureMarkerSymbol(); //添加对象选择监听事件 picMarker.ChossedMarkerOverCallBack += markers_ChossedShapeOverCallBack; mark = new IMSMark(picMarker.control, ZDIMS.Interface.CoordinateType.Logic); mark.X = 18.99919517012924; mark.Y = 30.671057152220655; mark.EnableAnimation = false; this.markLayer.AddMark(mark); picMarker = new IMSPictureMarkerSymbol(); picMarker.Source = "../images/Ring.png";//设置图片路径 //添加对象选择监听事件 picMarker.ChossedMarkerOverCallBack += markers_ChossedShapeOverCallBack; mark = new IMSMark(picMarker.control, ZDIMS.Interface.CoordinateType.Logic); mark.X = 20.99919517012924; mark.Y = 23.671057152220655; mark.EnableAnimation = false; this.markLayer.AddMark(mark); } }
//对选择的统计图样式改变事件处理 void chart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { this.myChartCtrl1.chart = sender as Chart; for (int i = 0; i < this.markLayer1.ChildrenCount; i++) { IMSMark mark = this.markLayer1.GetMarkByIndex(i) as IMSMark; if ((mark.MarkControl as Chart) != this.myChartCtrl1.chart) { (mark.MarkControl as Chart).BorderThickness = new Thickness(0); } } (sender as Chart).BorderThickness = new Thickness(1); this.myChartCtrl1.dataSC = (sender as Chart).Series[0]; }
private void StartPntAdd2(MarkLayer markLayer, IMark mark, Point logicPnt) { m_barrierMark.Add(mark); m_barrierDots += logicPnt.X + "," + logicPnt.Y + ","; IMSMark markPnt = new IMSMark(new Image() { Source = new BitmapImage(new Uri("../images/mark/v0.png", UriKind.Relative)) }) { EnableAnimation = false }; MarkLayer.ManuallyAddMarkObj = markPnt; MarkLayer.ManuallyAddMarkOverCallback = new ManuallyAddMarkDelegate(StartPntAdd2); }
/// <summary> /// 添加预定义样式点对象 /// </summary> /// <param name="logPntArr"></param> private void mark(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr) { //初始化点样式对象 _markStyle = new IMSSimpleMarkerSymbol(); //设置点显示样式 _markStyle.SymbolStyle = this.markType; _markStyle.Size = 20;//点大小 //添加点样式到标注里面 IMSMark mark = new IMSMark(_markStyle.control, ZDIMS.Interface.CoordinateType.Logic); //设置坐标 mark.X = logPntArr[0].X; mark.Y = logPntArr[0].Y; mark.EnableAnimation = false; //不允许动态变换 this.markLayer.AddMark(mark); //添加点样式 }
/// <summary> /// 设置速度 /// </summary> private void Addcar() { //添加小车图片 img = new Image(); img.Source = new BitmapImage(new Uri("../images/car.PNG", UriKind.Relative)); img.Width = 32; img.Height = 20; Mark = new IMSMark(img, CoordinateType.Logic, this.m_markLayer); Mark.X = AllLineDispersePnts[0].Pnt.X; Mark.Y = AllLineDispersePnts[0].Pnt.Y; Mark.EnableAnimation = false; Mark.EnableRevisedPos = true; this.m_markLayer.AddMarkAt(Mark, 20000); m_timer = new DispatcherTimer(); m_timer.Interval = new TimeSpan(0, 0, 0, 0, 1); //设置播放速度 m_timer.Tick += new EventHandler(m_timer_Tick); //添加时间变化事件:小车标注变化 }
private void radioButton2_Click(object sender, RoutedEventArgs e) { GraphicsLayer.DrawingType = DrawingType.None; if (MarkLayer != null) { MarkLayer.ManuallyAddMarkObj = null; IMSMark markPnt = new IMSMark(new Image() { Source = new BitmapImage(new Uri("../images/mark/v0.png", UriKind.Relative)) }) { EnableAnimation = false }; MarkLayer.ManuallyAddMarkObj = markPnt; MarkLayer.ManuallyAddMarkOverCallback = new ManuallyAddMarkDelegate(StartPntAdd2); } }
private void image_marker1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (this.MapContainer == null) { MessageBox.Show("MapContainer属性为空,不能继续操作!"); return; } if (this.m_markLayer == null) { this.m_markLayer = new MarkLayer(); this.MapContainer.AddChild(this.m_markLayer); } Image targetimg = sender as Image; if (this.m_marker == null) { Image img = new Image(); img.Source = targetimg.Source; ContextMenu menu = new ContextMenu(); MenuItem del = new MenuItem(); del.Header = "删除"; del.Click += new RoutedEventHandler(del_Click); menu.Items.Add(del); MenuItem edit = new MenuItem(); edit.Header = "编辑"; edit.Click += new RoutedEventHandler(edit_Click); menu.Items.Add(edit); ContextMenuService.SetContextMenu((DependencyObject)img, menu); this.m_marker = new IMSMark(img); this.m_marker.CoordinateType = CoordinateType.Logic; this.m_marker.X = this.MapContainer.CenPntLogCoor.X; this.m_marker.Y = this.MapContainer.CenPntLogCoor.Y; this.textBox_markerx.Text = m_marker.X.ToString(); this.textBox_markery.Text = m_marker.Y.ToString(); this.m_marker.EnableDrag = true; this.m_markLayer.AddMark(this.m_marker); this.m_marker.MarkDragOverCallback = new MarkDragOverDelegate(onDragEnd); } else { ((Image)this.m_marker.MarkControl).Source = targetimg.Source; } this.image_marker.Source = targetimg.Source; e.Handled = true; }
/// <summary> /// 添加新店 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddMarke_Click(object sender, RoutedEventArgs e) { graphicsLayer.DrawingType = DrawingType.None; if (markLayer != null) { this.markLayer.ManuallyAddMarkObj = null; IMSMark markPnt = new IMSMark(new Image() { Source = new BitmapImage(new Uri("../images/red2.png", UriKind.Relative)), Width = 20, Height = 20 }) { EnableAnimation = false }; markLayer.ManuallyAddMarkObj = markPnt; graphicsLayer.DrawingType = DrawingType.Circle; markLayer.ManuallyAddMarkOverCallback = new ManuallyAddMarkDelegate(StartPntAdd1); } }
/// <summary> /// 添加点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddPnt_Click(object sender, RoutedEventArgs e) { //初始化点对象 IMSSimpleMarkerSymbol markers = new IMSSimpleMarkerSymbol(); markers.IsShowMenum = true; //监听对象选择事件 markers.ChossedMarkerOverCallBack += new IMSMarkerSymbol.ChossedMarkerHander(markers_ChossedShapeOverCallBack); //定义标注对象 IMSMark mark; //将点对象添加到标注中 mark = new IMSMark(markers.control, ZDIMS.Interface.CoordinateType.Logic); mark.EnableDrag = true; //设置点位置 mark.X = 6.99919517012924; mark.Y = 30.671057152220655; mark.EnableAnimation = false; this.markLayer.AddMark(mark);//添加到标注图层 }
/// <summary> /// 添加单个标注 /// </summary> /// <param name="LogPnt"></param> public void AddMarkGif(marketsInfo warnMarket) { GIFToolTip gif = new GIFToolTip(); gif.Addtip(warnMarket); IMSMark mark = new IMSMark(gif, CoordinateType.Logic, markLayer1); mark.EnableAnimation = false; mark.EnableRevisedPos = true; Point pnt = new Point(warnMarket.X, warnMarket.Y); pnt.X = pnt.X - 11; pnt.Y = pnt.Y - 11; pnt = this.mapContainer.ScreenToLogic(pnt.X, pnt.Y); mark.X = pnt.X; mark.Y = pnt.Y; markLayer1.AddMark(mark); }
private void AddShip() { img = new Image(); img.Source = new BitmapImage(new Uri("/images/bus/stop.png", UriKind.Relative)); img.Width = 28; img.Height = 24; //PlaneProjection Pg = new PlaneProjection(); //Pg.RotationX = 30; Mark = new IMSMark(img, CoordinateType.Logic, this.m_markLayer); Mark.X = AllLineDispersePnts[0].Pnt.X; Mark.Y = AllLineDispersePnts[0].Pnt.Y; Mark.EnableAnimation = false; Mark.EnableRevisedPos = true; this.m_markLayer.AddMark(Mark); if (this.showFlag == true) { m_timer.Interval = new TimeSpan(0, 0, 0, 0, 80); m_timer.Tick += new EventHandler(m_timer_Tick); this.showFlag = false; } }
private void ShowMarker(object obj) { //显示标记 if (this.m_markLayer == null) { this.m_markLayer = new MarkLayer(); this.MapContainer.AddChild(this.m_markLayer); } if (this.m_posMarker == null) { Image img = new Image(); img.Source = new BitmapImage(new Uri("images/mark/marker2/image2/p1.png",UriKind.Relative)); img.Width = 40; img.Height = 40; this.m_posMarker = new IMSMark(img); this.m_posMarker.CoordinateType = CoordinateType.Logic; this.m_posMarker.X = this.PLon; this.m_posMarker.Y = this.PLat; this.m_markLayer.AddMark(this.m_posMarker); } else { this.m_posMarker.X = this.PLon; this.m_posMarker.Y = this.PLat; } //居中显示标记 if (this.checkBox2.IsChecked.Value) { Point pnt = this.MapContainer.LogicToScreen(this.PLon,this.PLat); if (Math.Abs(pnt.X - this.MapContainer.CenPntScrCoor.X) > 10 || Math.Abs(pnt.Y - this.MapContainer.CenPntScrCoor.Y)>10) { this.MapContainer.PanTo(PLon, PLat); return; } } if (!m_posMarker.IsInMapViewBound) { this.MapContainer.PanTo(PLon, PLat); } }
void ServiceClient_addDataCompleted(object sender, addDataCompletedEventArgs e) { ServiceClient.addDataCompleted -= ServiceClient_addDataCompleted; if (e.Error == null) { MessageBox.Show(e.Result); if (Type == "marketsInfo") { //移除临时标注 bool f = this.markLayer.RemoveMark(tmp); if (AddMarkControl == null) { AddMarkControl = new addMarks(); AddMarkControl.markLayer1 = this.markLayer; AddMarkControl.mapContainer = this.mapContainer; } tmp = AddMarkControl.AddMark(_marketsInfo); this.markLayer.MapContainer.Refresh(); } } }
/// <summary> /// 统计 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void staticAna_Click(object sender, RoutedEventArgs e) { this.markLayer.ManuallyAddMarkObj = null; if (graphicsLayer == null) { MessageBox.Show("绘图为空"); } this.markLayer.ManuallyAddMarkObj = null; IMSMark markPnt = new IMSMark(new Image() { Source = new BitmapImage(new Uri("../images/btn_08.png", UriKind.Relative)), Width = 20, Height = 20 }) { EnableAnimation = false }; markLayer.ManuallyAddMarkObj = markPnt; graphicsLayer.DrawingType = DrawingType.Circle; markLayer.ManuallyAddMarkOverCallback += new ManuallyAddMarkDelegate(cal); graphicsLayer.DrawingOverCallback += new DrawingEventHandler(callback); }
void iMSMap1_MapReady(IMSMapEvent e) { if (!DesignerProperties.IsInDesignTool) { IMSMark mark = new IMSMark(new Image() { Source = new BitmapImage(new Uri("images/pin.png", UriKind.Relative)), Width = 36, Height = 48 }, ZDIMS.Interface.CoordinateType.Logic) { X = 114.125686114315, Y = 30.4582609083728, EnableDrag = true }; markLayer1.AddMark(mark); int totalNumber = 50; int count = 0; double xMin = 114.125686114315; double yMin = 30.4582609083728; double xMax = 114.500788705197; double yMax = 30.7085740673183; double centerX = (xMin + xMax) / 2; double centerY = (yMin + yMax) / 2; Point pnt; //IMSMark mark; Random rnd = new Random(); markLayer1.EnableZoomAnimation = true; markLayer1.EnableMarkHiden = false; markLayer1.EnablePolymericMark = true; int n = 1; while (count < totalNumber) { pnt = GetRandomCoordinate(rnd.Next(0, 1000) + rnd.Next(0, 100) + rnd.Next(0, 10), centerX, centerY, 0.025); centerX = pnt.X; centerY = pnt.Y; if (centerX > xMin && centerX < xMax && centerY > yMin && centerY < yMax) { count++; mark = new IMSMark(new Image() { Source = new BitmapImage(new Uri("/images/mark/p" + n.ToString() + ".png", UriKind.Relative)), Width = 16, Height = 18 }, CoordinateType.Logic, markLayer1); mark.X = centerX; //114.28793904776113;// mark.Y = centerY; //30.549563956006946;// //mark.EnableDrag = true; markLayer1.AddMark(mark); //mark.Flicker(400, 10); n = (++n) % 8 > 0 ? n % 8 : 1; } else { centerX = (xMin + xMax) / 2; centerY = (yMin + yMax) / 2; } } markLayer1.InitPolymericMark(); } }
private void mark2LengthOver(int curEditMarkIndex, Shape curEditMark, List <Shape> editMarkList, GraphicsBase g) { this.m_graphicsLayer.Drawing += new DrawingEventHandler(addMeasurePoint); Point pnt = m_mapContainer.ScreenToLogic(Canvas.GetLeft(g.EditMark1List[curEditMarkIndex + 1]), Canvas.GetTop(g.EditMark1List[curEditMarkIndex + 1])); IMSCircle circle = new IMSCircle(); circle.CenX = pnt.X; circle.CenY = pnt.Y; this.measurePnts.Insert(curEditMarkIndex + 1, circle); double currLength = 0; Label currmeasureLabel = new Label(); currmeasureLabel.Content = ""; currmeasureLabel.FontSize = 12; IMSMark currmeasureMark = new IMSMark(currmeasureLabel, CoordinateType.Logic); currmeasureMark.EnableDrag = false; mymarklayer.AddMark(currmeasureMark); measureMarks.Insert(curEditMarkIndex + 1, currmeasureMark); currmeasureMark.X = pnt.X + 0.0055; currmeasureMark.Y = pnt.Y - 0.0055; IMSMark lastmeasureMark = measureMarks[curEditMarkIndex]; currLength += Convert.ToDouble((lastmeasureMark.MarkControl as Label).Content.ToString().Split(':')[1]); IMSMark centermeasureMark = this.measureCenterMarks[curEditMarkIndex]; (centermeasureMark.MarkControl as Label).Content = getCurrentLength(curEditMarkIndex + 1, curEditMarkIndex, new Point(-1, -1)); IMSCircle pntCircle = this.measurePnts[curEditMarkIndex]; centermeasureMark.X = (pnt.X + 3 * pntCircle.CenX) / 4; centermeasureMark.Y = (pnt.Y + 3 * pntCircle.CenY) / 4; Point scrPnt = this.m_mapContainer.LogicToScreen(pntCircle.CenX, pntCircle.CenY); double angle = Math.Atan2(scrPnt.Y - Canvas.GetTop(g.EditMark1List[curEditMarkIndex + 1]), Canvas.GetLeft(g.EditMark1List[curEditMarkIndex + 1]) - scrPnt.X); ((centermeasureMark.MarkControl as Label).RenderTransform as RotateTransform).Angle = 360 - angle * 360 / (2 * Math.PI); if ((bool)checkBox1.IsChecked) { centermeasureMark.Visibility = System.Windows.Visibility.Visible; } else { centermeasureMark.Visibility = System.Windows.Visibility.Collapsed; } Label centermeasureLabel2 = new Label(); centermeasureLabel2.Content = ""; centermeasureLabel2.FontSize = 12; IMSMark centermeasureMark2 = new IMSMark(centermeasureLabel2, CoordinateType.Logic); centermeasureMark2.EnableDrag = false; centermeasureMark2.EnableAnimation = false; mymarklayer.AddMark(centermeasureMark2); measureCenterMarks.Insert(curEditMarkIndex + 1, centermeasureMark2); (centermeasureMark2.MarkControl as Label).RenderTransform = new RotateTransform(); (centermeasureMark2.MarkControl as Label).Content = getCurrentLength(curEditMarkIndex + 2, curEditMarkIndex + 1, new Point(-1, -1)); IMSCircle pntCircle2 = this.measurePnts[curEditMarkIndex + 2]; centermeasureMark2.X = (3 * pnt.X + pntCircle2.CenX) / 4; centermeasureMark2.Y = (3 * pnt.Y + pntCircle2.CenY) / 4; Point scrPnt2 = this.m_mapContainer.LogicToScreen(pntCircle2.CenX, pntCircle2.CenY); double angle2 = Math.Atan2(Canvas.GetTop(g.EditMark1List[curEditMarkIndex + 1]) - scrPnt2.Y, scrPnt2.X - Canvas.GetLeft(g.EditMark1List[curEditMarkIndex + 1])); ((centermeasureMark2.MarkControl as Label).RenderTransform as RotateTransform).Angle = 360 - angle2 * 360 / (2 * Math.PI); if ((bool)checkBox1.IsChecked) { centermeasureMark2.Visibility = System.Windows.Visibility.Visible; } else { centermeasureMark2.Visibility = System.Windows.Visibility.Collapsed; } for (int i = curEditMarkIndex; i < this.measureMarks.Count - 1; i++) { IMSMark nextmeasureMark = measureMarks[i + 1]; double nextLegth = Convert.ToDouble(getCurrentLength(i + 1, i, new Point(-1, -1)).Split(':')[1]); currLength += nextLegth; (nextmeasureMark.MarkControl as Label).Content = "总长度:" + currLength.ToString(); } }
private void markLengthMove(int curEditMarkIndex, Shape curEditMark, List <Shape> editMarkList, GraphicsBase g) { this.m_graphicsLayer.Drawing += new DrawingEventHandler(addMeasurePoint); this.m_graphicsLayer.Drawing -= new DrawingEventHandler(addMeasurePoint); Point pnt = m_mapContainer.ScreenToLogic(Canvas.GetLeft(curEditMark), Canvas.GetTop(curEditMark)); if (measurePnts.Count >= curEditMarkIndex) { this.measurePnts[curEditMarkIndex].CenX = pnt.X; this.measurePnts[curEditMarkIndex].CenY = pnt.Y; } else { return; } IMSMark currmeasureMark = measureMarks[curEditMarkIndex]; double currLength = Convert.ToDouble(getCurrentLength(curEditMarkIndex, curEditMarkIndex - 1, new Point(-1, -1)).Split(':')[1]); if (currLength != 0) { IMSMark lastmeasureMark = measureMarks[curEditMarkIndex - 1]; currLength += Convert.ToDouble((lastmeasureMark.MarkControl as Label).Content.ToString().Split(':')[1]); } (currmeasureMark.MarkControl as Label).Content = "总长度:" + currLength.ToString(); currmeasureMark.X = pnt.X + 0.0055; currmeasureMark.Y = pnt.Y - 0.0055; if (curEditMarkIndex != 0) { IMSMark centermeasureMark = this.measureCenterMarks[curEditMarkIndex - 1]; (centermeasureMark.MarkControl as Label).Content = getCurrentLength(curEditMarkIndex, curEditMarkIndex - 1, new Point(-1, -1)); IMSCircle pntCircle = this.measurePnts[curEditMarkIndex - 1]; centermeasureMark.X = (pnt.X + 3 * pntCircle.CenX) / 4; centermeasureMark.Y = (pnt.Y + 3 * pntCircle.CenY) / 4; Point scrPnt = this.m_mapContainer.LogicToScreen(pntCircle.CenX, pntCircle.CenY); double angle = Math.Atan2(scrPnt.Y - Canvas.GetTop(curEditMark), Canvas.GetLeft(curEditMark) - scrPnt.X); ((centermeasureMark.MarkControl as Label).RenderTransform as RotateTransform).Angle = 360 - angle * 360 / (2 * Math.PI); if ((bool)checkBox1.IsChecked) { centermeasureMark.Visibility = System.Windows.Visibility.Visible; } else { centermeasureMark.Visibility = System.Windows.Visibility.Collapsed; } } if (curEditMarkIndex < this.measureCenterMarks.Count) { IMSMark centermeasureMark = this.measureCenterMarks[curEditMarkIndex]; (centermeasureMark.MarkControl as Label).Content = getCurrentLength(curEditMarkIndex + 1, curEditMarkIndex, new Point(-1, -1)); IMSCircle pntCircle = this.measurePnts[curEditMarkIndex + 1]; centermeasureMark.X = (3 * pnt.X + pntCircle.CenX) / 4; centermeasureMark.Y = (3 * pnt.Y + pntCircle.CenY) / 4; Point scrPnt = this.m_mapContainer.LogicToScreen(pntCircle.CenX, pntCircle.CenY); double angle = Math.Atan2(Canvas.GetTop(curEditMark) - scrPnt.Y, scrPnt.X - Canvas.GetLeft(curEditMark)); ((centermeasureMark.MarkControl as Label).RenderTransform as RotateTransform).Angle = 360 - angle * 360 / (2 * Math.PI); if ((bool)checkBox1.IsChecked) { if (centermeasureMark != null) { centermeasureMark.Visibility = System.Windows.Visibility.Visible; } } else { if (centermeasureMark != null) { centermeasureMark.Visibility = System.Windows.Visibility.Collapsed; } } } for (int i = curEditMarkIndex; i < this.measureMarks.Count - 1; i++) { IMSMark nextmeasureMark = measureMarks[i + 1]; double nextLegth = Convert.ToDouble(getCurrentLength(i + 1, i, new Point(-1, -1)).Split(':')[1]); currLength += nextLegth; (nextmeasureMark.MarkControl as Label).Content = "总长度:" + currLength.ToString(); } }
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 addMatic_Click(object sender, RoutedEventArgs e) { clearChart(); this.iMSMap1.OperType = ZDIMS.Util.IMSOperType.None; for (int m = 0; m < pntList.Count; m++) { Chart chart = new Chart(); chart.BorderThickness = new Thickness(0); //去掉边框 chart.Background = new SolidColorBrush(Colors.Transparent); //设置背景色透明 //去掉x轴线 Axis xaxis = new Axis(); xaxis.Enabled = false; ChartGrid xgrid = new ChartGrid(); //xgrid.Enabled = false; xaxis.Grids.Add(xgrid); chart.AxesX.Add(xaxis); //去掉y轴线 Axis yaxis = new Axis(); //yaxis.Enabled = false; ChartGrid ygrid = new ChartGrid(); ygrid.Enabled = false; yaxis.Grids.Add(ygrid); chart.AxesY.Add(yaxis); //统计数据设置 dataS = new DataSeries(); dataS.RenderAs = RenderAs.Column;//设置默认统计图类型为柱状图 DataPoint point; for (int i = 0; i < list.Count; i++) { point = new DataPoint(); point.YValue = list[i].YValue; point.AxisXLabel = list[i].XLabel; dataS.DataPoints.Add(point); } chart.Width = 200; chart.Height = 150; chart.Opacity = 1.00; Title title = new Title(); title.Text = pntList[m].PlaceName; chart.Titles.Add(title); //统计图标题 chart.Series.Add(dataS); dataS.LabelEnabled = true; //显示标签 chart.AnimationEnabled = true; chart.AnimatedUpdate = true; dataS.LabelStyle = LabelStyles.OutSide; //设置标签显示位置 chart.MouseLeftButtonDown += new MouseButtonEventHandler(chart_MouseLeftButtonDown); //鼠标左键按下事件监听 IMSMark mark = new IMSMark(chart); mark.CoordinateType = CoordinateType.Logic; mark.X = pntList[m].X; mark.Y = pntList[m].Y; mark.EnableRevisedPos = true; mark.EnableAnimation = false; mark.EnableDrag = false; this.markLayer1.AddMark(mark); } this.iMSMap1.SetInfoText("选择统计图,进行样式设置;右键菜单“取消选择状态”,取消选择", Colors.Black); MenuItem item = new MenuItem(); item.Header = "取消选择状态"; this.iMSMap1.ContextMenu.Items.Add(item); item.Click += new RoutedEventHandler(item_Click); }