private void Activate(Point2D firstPoint) { DrawLayer = new ElementsLayer(); if (Map.Layers == null) { return; } Map.Layers.Add(DrawLayer); polyline = new PolylineElement(); #region 所有风格的控制 polyline.Stroke = Stroke; polyline.StrokeThickness = StrokeThickness; polyline.StrokeMiterLimit = StrokeMiterLimit; polyline.StrokeDashOffset = StrokeDashOffset; polyline.StrokeDashArray = StrokeDashArray; polyline.StrokeDashCap = StrokeDashCap; polyline.StrokeEndLineCap = StrokeEndLineCap; polyline.StrokeLineJoin = StrokeLineJoin; polyline.StrokeStartLineCap = StrokeStartLineCap; polyline.Opacity = Opacity; polyline.Fill = Fill; polyline.FillRule = FillRule; #endregion points = new Point2DCollection(); polyline.Point2Ds = points; points.Add(firstPoint); points.Add(firstPoint); DrawLayer.Children.Add(polyline); isDrawing = true; isActivated = true; }
/// <summary>${ui_action_MapAction_method_deactivate_D}</summary> public override void Deactivate() { isActivated = false; isDrawing = false; polyline = null; points = null; if (DrawLayer != null) { DrawLayer.Children.Clear(); } if (Map != null && Map.Layers != null) { Map.Layers.Remove(DrawLayer); } }
private void endDraw(bool isDblClick = false, bool isCancel = false) { if (points != null) { if (isDblClick) { points.RemoveAt(points.Count - 1); } PolylineElement pLine = new PolylineElement() { 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 }; GeoLine geoLine = new GeoLine();//构造返回的Geometry geoLine.Parts.Add(points); DrawEventArgs args = new DrawEventArgs { DrawName = Name, Element = pLine, //Element = this.polyline //直接返回是固定像素的 Geometry = geoLine, Canceled = isCancel }; Deactivate(); OnDrawCompleted(args); } }