private void endDraw(bool isDblClick = false, bool isCancel = false)
{
if (points != null)
{
points.RemoveAt(points.Count - 2);
if (isDblClick)
{
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
points.Add(startPoint);//需要添加起始点做为最后一个点
geoRegion.Parts.Add(points);
DrawEventArgs args = new DrawEventArgs
{
DrawName = Name,
Element = pRegion, //Element = this.polyline //直接返回是固定像素的
Geometry = geoRegion,
Canceled = isCancel
};
Deactivate();
OnDrawCompleted(args);
}
}