${mapping_PolygonBase_Title}
private void Activate() { if (Map == null || Map.Layers == null) { return; } polygon = new PolygonElement(); #region 所有风格的控制 polygon.Stroke = Stroke; polygon.StrokeThickness = StrokeThickness; polygon.StrokeMiterLimit = StrokeMiterLimit; polygon.StrokeDashOffset = StrokeDashOffset; polygon.StrokeDashArray = StrokeDashArray; polygon.StrokeDashCap = StrokeDashCap; polygon.StrokeEndLineCap = StrokeEndLineCap; polygon.StrokeLineJoin = StrokeLineJoin; polygon.StrokeStartLineCap = StrokeStartLineCap; polygon.Opacity = Opacity; polygon.Fill = Fill; polygon.FillRule = FillRule; #endregion points = new Point2DCollection(); polygon.Point2Ds = points; points.Add(startPt); DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); DrawLayer.Children.Add(polygon); isActivated = true; isDrawing = true; }
private void Activate(Point2D firstPoint) { if (Map == null || Map.Layers == null) { return; } DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); _startPoint = firstPoint; _polygon = new PolygonElement(); #region 所有风格的控制 _polygon.Stroke = this.Stroke; _polygon.StrokeThickness = this.StrokeThickness; _polygon.StrokeMiterLimit = this.StrokeMiterLimit; _polygon.StrokeDashOffset = this.StrokeDashOffset; _polygon.StrokeDashArray = this.StrokeDashArray; _polygon.StrokeDashCap = this.StrokeDashCap; _polygon.StrokeEndLineCap = this.StrokeEndLineCap; _polygon.StrokeLineJoin = this.StrokeLineJoin; _polygon.StrokeStartLineCap = this.StrokeStartLineCap; _polygon.Opacity = this.Opacity; _polygon.Fill = this.Fill; _polygon.FillRule = this.FillRule; #endregion _points = new Point2DCollection(); _polygon.Point2Ds = _points; _points.Add(firstPoint); _pointsCount++; _points.Add(firstPoint.Clone()); _pointsCount++; DrawLayer.Children.Add(_polygon); _isActivated = true; }
private void Activate(Point2D firstPoint) { _polygon = new PolygonElement(); _textBlockContainer = new List<TextBlock>(); #region 所有风格的控制 _polygon.Stroke = Stroke; _polygon.StrokeThickness = StrokeThickness; _polygon.StrokeMiterLimit = StrokeMiterLimit; _polygon.StrokeDashOffset = StrokeDashOffset; _polygon.StrokeDashArray = StrokeDashArray; _polygon.StrokeDashCap = StrokeDashCap; _polygon.StrokeEndLineCap = StrokeEndLineCap; _polygon.StrokeLineJoin = StrokeLineJoin; _polygon.StrokeStartLineCap = StrokeStartLineCap; _polygon.Opacity = Opacity; _polygon.Fill = Fill; _polygon.FillRule = FillRule; #endregion _points = new Point2DCollection(); _polygon.Point2Ds = _points; _points.Add(firstPoint); _pointsCount++; _points.Add(firstPoint.Clone()); _pointsCount++; DrawLayer.Children.Add(_polygon); TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.ExtraBlack; textBlock.Foreground = new SolidColorBrush(Colors.White); textBlock.Text = "起点"; _textBlockContainer.Add(textBlock); DrawLayer.AddChild(textBlock, firstPoint); _isActivated = true; }
private void Complete() { _points = null; _isActivated = false; _pointsCount = 0; _polygon = null; _textBlockContainer = null; }
public override void OnPointerReleased(PointerRoutedEventArgs e) { if (this.points != null) { GeoRegion geoRegion = new GeoRegion(); points.Add(a0); geoRegion.Parts.Add(points); PolygonElement pPen = new PolygonElement() { Point2Ds = points, #region 所有风格的控制 Stroke = this.Stroke, StrokeThickness = this.StrokeThickness, StrokeMiterLimit = this.StrokeMiterLimit, StrokeDashOffset = this.StrokeDashOffset, StrokeDashArray = this.StrokeDashArray, StrokeDashCap = this.StrokeDashCap, StrokeEndLineCap = this.StrokeEndLineCap, StrokeLineJoin = this.StrokeLineJoin, StrokeStartLineCap = this.StrokeStartLineCap, Opacity = this.Opacity, Fill = this.Fill, FillRule = this.FillRule #endregion }; DrawEventArgs args2 = new DrawEventArgs { DrawName = Name, Element = pPen, Geometry = geoRegion }; Deactivate(); OnDrawComplete(args2); } e.Handled = true; base.OnPointerReleased(e); }
public override void Deactivate() { isActivated = false; isDrawing = false; oldPentagrams = null; pentagram = null; points = null; if (DrawLayer != null) { DrawLayer.Children.Clear(); } if (Map != null) { Map.Layers.Remove(DrawLayer); } }
private void Activate() { pentagram = new PolygonElement(); #region 所有风格的控制 pentagram.Stroke = this.Stroke; pentagram.StrokeThickness = this.StrokeThickness; pentagram.Fill = this.Fill; pentagram.FillRule = this.FillRule; pentagram.Opacity = this.Opacity; pentagram.StrokeMiterLimit = this.StrokeMiterLimit; pentagram.StrokeDashOffset = this.StrokeDashOffset; pentagram.StrokeDashArray = this.StrokeDashArray; pentagram.StrokeDashCap = this.StrokeDashCap; pentagram.StrokeEndLineCap = this.StrokeEndLineCap; pentagram.StrokeLineJoin = this.StrokeLineJoin; pentagram.StrokeStartLineCap = this.StrokeStartLineCap; #endregion a0 = new Point2D(); a1 = new Point2D(); a2 = new Point2D(); a3 = new Point2D(); a4 = new Point2D(); points = new Point2DCollection(); pentagram.Point2Ds = points; oldPentagrams = new List<PolygonElement>(); DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); isActivated = true; isDrawing = true; }
/// <summary>${ui_action_DrawPolygon_method_deactivate_D}</summary> public override void Deactivate() { _isActivated = false; _polygon = null; _points = null; _pointsCount = 0; _startPoint = Point2D.Empty; if (DrawLayer != null) { DrawLayer.Children.Clear(); } if (Map != null && Map.Layers != null) { Map.Layers.Remove(DrawLayer); } }
private void endDraw(bool isCancel = false) { if (_points != null) { while (_points.Count > _pointsCount) { _points.RemoveAt(_points.Count - 2); } PolygonElement pRegion = new PolygonElement() { Point2Ds = _points.Clone(),//不克隆,在返回后还与下面的GeoRegion指向一个内存地址 #region 所有风格的控制 Stroke = this.Stroke, StrokeThickness = this.StrokeThickness, StrokeMiterLimit = this.StrokeMiterLimit, StrokeDashOffset = this.StrokeDashOffset, StrokeDashArray = this.StrokeDashArray, StrokeDashCap = this.StrokeDashCap, StrokeEndLineCap = this.StrokeEndLineCap, StrokeLineJoin = this.StrokeLineJoin, StrokeStartLineCap = this.StrokeStartLineCap, Opacity = this.Opacity, Fill = this.Fill, FillRule = this.FillRule #endregion };//构造返回Element对象 GeoRegion geoRegion = new GeoRegion();//构造返回的Geometry geoRegion.Parts.Add(_points); DrawEventArgs args = new DrawEventArgs { DrawName = Name, Element = pRegion, //Element = this.polyline //直接返回是固定像素的 Geometry = geoRegion, Canceled = isCancel }; Deactivate(); OnDrawCompleted(args); } }
void MyMap_ViewBoundsChanged(object sender, ViewBoundsEventArgs e) { #region Ellipse Ellipse myellipse = new Ellipse(); myellipse.Fill = new SolidColorBrush(Colors.Red); Rectangle2D ellbounds = new Rectangle2D(119.5, 21, 122.5, 26); this.elementsLayer.AddChild(myellipse, ellbounds); MyEllipseStory.Stop(); Storyboard.SetTarget(myDoubleAnimation, myellipse); MyEllipseStory.Begin(); #endregion #region Pushpin Pushpin beijing = new Pushpin(); beijing.Location = new Point2D(116.2, 39.6); this.elementsLayer.AddChild(beijing); Pushpin ulanBator = new Pushpin(); ulanBator.Location = new Point2D(106.5, 47.6); ulanBator.Background = new SolidColorBrush(Colors.Blue); this.elementsLayer.AddChild(ulanBator); Pushpin moscow = new Pushpin(); moscow.Location = new Point2D(37.4, 55.5); moscow.Background = new SolidColorBrush(Colors.Yellow); this.elementsLayer.AddChild(moscow); Pushpin prague = new Pushpin(); prague.Location = new Point2D(14.3, 50.1); prague.Background = new SolidColorBrush(Colors.Orange); this.elementsLayer.AddChild(prague); Pushpin berlin = new Pushpin(); berlin.Location = new Point2D(13.3, 52.3); berlin.Background = new SolidColorBrush(Colors.Purple); this.elementsLayer.AddChild(berlin); #endregion #region Polylinebase PolygonElement line = new PolygonElement(); line.Stroke = new SolidColorBrush(Colors.Yellow); line.StrokeThickness = 3; line.Opacity = 1; line.StrokeDashArray = new DoubleCollection { 3, 3 }; line.StrokeEndLineCap = PenLineCap.Triangle; Point2DCollection points = new Point2DCollection(); points.Add(new Point2D(121.3, 25)); points.Add(new Point2D(116.2, 39.6)); points.Add(new Point2D(106.5, 47.6)); points.Add(new Point2D(37.4, 55.5)); points.Add(new Point2D(14.3, 50.1)); points.Add(new Point2D(13.3, 52.3)); points.Add(new Point2D(0.1, 51.3)); line.Point2Ds = points; this.elementsLayer.AddChild(line); #endregion #region PolygonElement PolygonElement polygon = new PolygonElement(); polygon.Stroke = new SolidColorBrush(Colors.Purple); polygon.Opacity = 0.5; polygon.Fill = this.British; Point2DCollection gonpoints = new Point2DCollection(); gonpoints.Add(new Point2D(-8, 61)); gonpoints.Add(new Point2D(-6, 55)); gonpoints.Add(new Point2D(-8, 50)); gonpoints.Add(new Point2D(2, 50)); gonpoints.Add(new Point2D(1, 61)); polygon.Point2Ds = gonpoints; this.elementsLayer.AddChild(polygon); #endregion #region Button Button btn = new Button(); btn.Content = "点击"; Brush btnbackground = new SolidColorBrush(Colors.Blue); btn.SetValue(Button.BackgroundProperty, btnbackground); btn.Click += new RoutedEventHandler(btn_Click); Rectangle2D btnbounds = new Rectangle2D(95, 29, 115, 43); btn.SetValue(ElementsLayer.BBoxProperty, btnbounds); this.elementsLayer.AddChild(btn); #endregion MyMap.ViewBoundsChanged -= MyMap_ViewBoundsChanged; }
/// <summary>${ui_action_DrawFreePolygon_method_deactivate_D}</summary> public override void Deactivate() { isActivated = false; isDrawing = false; polygon = null; points = null; if (DrawLayer != null) { DrawLayer.Children.Clear(); } if (Map != null && Map.Layers != null) { Map.Layers.Remove(DrawLayer); } }
private void endDraw(bool isCancel = false) { if (points != null) { PolygonElement pRegion = new PolygonElement() { Point2Ds = this.points.Clone(), #region 所有风格的控制 Stroke = this.Stroke, StrokeThickness = this.StrokeThickness, StrokeMiterLimit = this.StrokeMiterLimit, StrokeDashOffset = this.StrokeDashOffset, StrokeDashArray = this.StrokeDashArray, StrokeDashCap = this.StrokeDashCap, StrokeEndLineCap = this.StrokeEndLineCap, StrokeLineJoin = this.StrokeLineJoin, StrokeStartLineCap = this.StrokeStartLineCap, Opacity = this.Opacity, Fill = this.Fill, FillRule = this.FillRule #endregion }; GeoRegion geoRegion = new GeoRegion();//构造返回的Geometry points.Add(startPt);//需要添加起始点做为最后一个点 geoRegion.Parts.Add(points); DrawEventArgs args = new DrawEventArgs { DrawName = Name, Element = pRegion, Geometry = geoRegion, Canceled = isCancel }; Deactivate(); OnDrawCompleted(args); } }