private void Activate(Point2D item) { if (Map == null || Map.Layers == null) { return; } DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); rectangle = new Rectangle(); rectangle.Stroke = this.Stroke; rectangle.StrokeThickness = this.StrokeThickness; rectangle.StrokeMiterLimit = this.StrokeMiterLimit; rectangle.StrokeDashOffset = this.StrokeDashOffset; rectangle.StrokeDashArray = this.StrokeDashArray; rectangle.StrokeDashCap = this.StrokeDashCap; rectangle.StrokeEndLineCap = this.StrokeEndLineCap; rectangle.StrokeLineJoin = this.StrokeLineJoin; rectangle.StrokeStartLineCap = this.StrokeStartLineCap; rectangle.Opacity = this.Opacity; rectangle.Fill = this.Fill; rectangle.SetValue(ElementsLayer.BBoxProperty , new Rectangle2D(item , item)); DrawLayer.Children.Add(rectangle); isActivated = true; isDrawing = true; }
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); _pointsCount++; DrawLayer.Children.Add(_polyline); _isActivated = true; }
/// <summary>${core_Rectangle2D_constructor_Point2D_Point2D_D}</summary> /// <param name="point1">${core_Rectangle2D_constructor_Point2D_Point2D_param_bottomLeft}</param> /// <param name="point2">${core_Rectangle2D_constructor_Point2D_Point2D_param_topRight}</param> /// <example> /// <code> /// Rectangle2D rt=new Rectangle(new Point2D(10,20),new Point2D(58,69)); /// </code> /// </example> public Rectangle2D(Point2D point1, Point2D point2) { this._x = Math.Min(point1.X, point2.X); this._y = Math.Min(point1.Y, point2.Y); this._width = Math.Max((double)(Math.Max(point1.X, point2.X) - this._x), (double)0.0); this._height = Math.Max((double)(Math.Max(point1.Y, point2.Y) - this._y), (double)0.0); }
private void Activate(Point2D firstPoint) { if (Map == null || Map.Layers == null) { return; } polyline = new PolylineElement(); polyline.Stroke = Stroke; polyline.StrokeThickness = StrokeThickness; polyline.Opacity = Opacity; polyline.StrokeMiterLimit = StrokeMiterLimit; polyline.StrokeDashOffset = StrokeDashOffset; polyline.StrokeDashArray = StrokeDashArray; polyline.StrokeDashCap = StrokeDashCap; polyline.StrokeEndLineCap = StrokeEndLineCap; polyline.StrokeLineJoin = StrokeLineJoin; polyline.StrokeStartLineCap = StrokeStartLineCap; polyline.Fill = Fill; polyline.FillRule = FillRule; points = new Point2DCollection(); polyline.Point2Ds = points; points.Add(firstPoint); DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); DrawLayer.Children.Add(polyline); isActivated = true; isDrawing = true; }
private void Activate(Point2D item) { if (Map == null || Map.Layers == null) { return; } ellipse = new Ellipse(); #region 所有风格的控制 ellipse.Stroke = Stroke; ellipse.StrokeThickness = StrokeThickness; ellipse.Fill = Fill; ellipse.StrokeMiterLimit = StrokeMiterLimit; ellipse.StrokeDashOffset = StrokeDashOffset; ellipse.StrokeDashArray = StrokeDashArray; ellipse.StrokeDashCap = StrokeDashCap; ellipse.StrokeEndLineCap = StrokeEndLineCap; ellipse.StrokeLineJoin = StrokeLineJoin; ellipse.StrokeStartLineCap = StrokeStartLineCap; ellipse.Opacity = Opacity; #endregion DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); ellipse.SetValue(ElementsLayer.BBoxProperty, new Rectangle2D(item, item)); DrawLayer.Children.Add(ellipse); isActivated = true; isDrawing = true; }
public static Point MapToScreen(Point2D pt2D, Point2D origin, double resolution) { if ((!Point2D.IsNullOrEmpty(origin)) && !double.IsNaN(resolution)) { return new Point((pt2D.X - origin.X) / resolution, (origin.Y - pt2D.Y) / resolution); } return new Point(double.NaN, double.NaN); }
/// <summary>${utility_JsonHelper_method_FromPoint2D_D}</summary> public static string FromPoint2D(Point2D point) { if (Point2D.IsNullOrEmpty(point)) { return "{}"; //string.Empty? null? } return string.Format(CultureInfo.InvariantCulture, "{{\"x\":{0},\"y\":{1}}}", point.X, point.Y); }
/// <summary>${core_GeoCircle_constructor_Point2D_double_D}</summary> /// <param>${core_GeoCircle_constructor_Point2D_double_param__center}</param> /// <param>${core_GeoCircle_constructor_Point2D_double_param__radius}</param> /// <example> /// <code> /// Geometry geometry = new GeoCircle(new Point2D(35, 56), 23); /// </code> /// </example> public GeoCircle(Point2D _center, double _radius) { this.Parts = new ObservableCollection<Point2DCollection>(); if (_center != null) { this.center = _center; this.radius = _radius; caculateParts(); } }
internal string GetCoorStr(Point2D p1, Point2D p2) { string str = string.Empty; if (!Point2D.IsNullOrEmpty(p1) && !Point2D.IsNullOrEmpty(p2)) { str = p1.ToString(CultureInfo.InvariantCulture) + " " + p2.ToString(CultureInfo.InvariantCulture); } return str; }
//计算parts private void caculateParts() { double unitsAngle = 360 / 72; double startAngle = 0; double unitsPI = Math.PI / 180; this.parts.Clear(); Point2DCollection item = new Point2DCollection(); for (int i = 0; i < 72; i++) { Point2D p = new Point2D(Math.Cos(startAngle * unitsPI) * this.radius + center.X, Math.Sin(startAngle * unitsPI) * this.radius + center.Y); item.Add(p); startAngle += unitsAngle; } this.parts.Add(item); }
private void CreateRectangle(Point2D p1, Point2D p2) { double xmin = Math.Min(p1.X, p2.X); double xmax = Math.Max(p1.X, p2.X); double ymin = Math.Min(p1.Y, p2.Y); double ymax = Math.Max(p1.Y, p2.Y); Point2DCollection ps = new Point2DCollection(); ps.Add(new Point2D(xmin, ymin)); ps.Add(new Point2D(xmin, ymax)); ps.Add(new Point2D(xmax, ymax)); ps.Add(new Point2D(xmax, ymin)); ps.Add(new Point2D(xmin, ymin)); this.Parts.Add(ps); }
private void ArrangeFeature(FeatureElement elm, Rectangle2D clipBox, Point2D origin, double resolution) { if (elm.Visibility != Visibility.Collapsed) { Rectangle2D b = GetBounds(elm); if (!Rectangle2D.IsNullOrEmpty(b)) { double x = (b.Left - origin.X) / resolution; double y = (origin.Y - b.Top) / resolution; if (((b.Width > 0.0) || (b.Height > 0.0)) && (elm.PathGeometry != null)) { double ratio = elm.Resolution / resolution; this.SetClip(elm, clipBox, resolution); if (elm.ClippedGeometry != null) { b = elm.ClippedGeometry.Bounds; if (Rectangle2D.IsNullOrEmpty(b)) { return; } x = (b.Left - origin.X) / resolution; y = (origin.Y - b.Top) / resolution; } if (elm.PathGeometry.Transform is ScaleTransform) { (elm.PathGeometry.Transform as ScaleTransform).ScaleX = (elm.PathGeometry.Transform as ScaleTransform).ScaleY = ratio; } else { elm.PathGeometry.Transform = new ScaleTransform { ScaleX = ratio, ScaleY = ratio }; } double num4 = ((b.Width / elm.Resolution) * ratio) + 10.0; double num5 = ((b.Height / elm.Resolution) * ratio) + 10.0;//这也已经加了10.0 num4 = Math.Min(32000.0, num4); num5 = Math.Min(32000.0, num5); elm.Arrange(new Rect(x, y, num4, num5)); } else { elm.Arrange(new Rect(new Point(x, y), elm.DesiredSize)); } } } }
/// <summary>${ui_action_DrawRect_constructor_Map_D}</summary> /// <example> /// <code lang="CS"> /// DrawRectangle draw = new DrawRectangle(MyMap) /// </code> /// </example> /// <param name="map">${ui_action_DrawRect_constructor_Map_param_map}</param> /// <param name="cursor">${ui_action_MapAction_constructor_Map_param_cursor}</param> public DrawRectangle(Map map) : base(map , "DrawRectangle") { startPt = Point2D.Empty; if (map.Theme == null) { Stroke = new SolidColorBrush(Colors.Green); StrokeThickness = MagicNumber.ACTION_STYLE_DEFAULT_STROKETHICKNESS; Fill = new SolidColorBrush(Colors.Black); Opacity = MagicNumber.ACTION_STYLE_DEFAULT_OPACITY; } else { this.Stroke = map.Theme.Stroke; this.StrokeThickness = map.Theme.StrokeThickness; this.Fill = map.Theme.Fill; this.Opacity = map.Theme.Opacity; } }
public void DeltaZoom(double targetResolution, Point2D targetCenter, TimeSpan zoomDuration) { _targetResolution = targetResolution; _targetCenter = targetCenter; _startTime = DateTime.Now; _startCenter = _map.Center; _startResolution = _map.Resolution; if (Point2D.IsNullOrEmpty(_startCenter)) { _zoomDuration = new TimeSpan(0); } else { _zoomDuration = zoomDuration; } if (!_isZooming) { _isZooming = true; CompositionTarget.Rendering += CompositionTarget_Rendering; OnZoomStarted(); } }
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 static Point2D StringToPoint2D(string value) { if (string.IsNullOrEmpty(value)) { return Point2D.Empty; } string[] array = value.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length != 2) { return Point2D.Empty; } bool success = true; double[] valuesArray = new double[2]; for (int i = 0; i < 2; i++) { double convertValue = 0; if (!double.TryParse(array[i], out convertValue)) { success = false; break; } else { valuesArray[i] = convertValue; } } if (success) { Point2D point = new Point2D(valuesArray[0], valuesArray[1]); return point; } else { return Point2D.Empty; } }
/// <summary>${core_GeoPoint_constructor_Point2D_D}</summary> /// <param name="location">${core_GeoPoint_constructor_Point2D_param_point}</param> public GeoPoint(Point2D location) : this(location.X, location.Y) { }
private void DrawPoint(Point2D point, bool isTemp) { bool needRemovePoints = _points.Count > _pointsCount; while (_points.Count > _pointsCount) { _points.RemoveAt(_points.Count - 1); } _points.Add(point); if (!isTemp) { _pointsCount++; } Point2D lastPoint = _points[_points.Count - 2]; double distance = Math.Sqrt(Math.Pow(point.X - lastPoint.X, 2) + Math.Pow(point.Y - lastPoint.Y, 2)); if (needRemovePoints) { _distances.Remove(_distances.Count - 1); distance = _distances[_distances.Count - 1] + distance; _distances.Add(distance); _textBlockContainer[_textBlockContainer.Count - 1].Text = string.Format("{0:0.0000}千米", distance / 1000); DrawLayer.Children.Remove(_textBlockContainer[_textBlockContainer.Count - 1]); DrawLayer.AddChild(_textBlockContainer[_textBlockContainer.Count - 1], point); } else { distance = _distances[_distances.Count - 1] + distance; _distances.Add(distance); TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.ExtraBlack; textBlock.Foreground = new SolidColorBrush(Colors.White); textBlock.Text = string.Format("{0:0.0000}千米", distance / 1000); _textBlockContainer.Add(textBlock); DrawLayer.AddChild(textBlock, point); } }
private void DrawPoint(Point2D point, bool isTemp) { bool needRemovePoints = _points.Count > _pointsCount; while (_points.Count > _pointsCount) { _points.RemoveAt(_points.Count - 2); } _points.Insert(_points.Count - 1, point); if (!isTemp) { _pointsCount++; } string areaString = string.Format("{0:0.0000}平方千米", GetArea(_points)); if (needRemovePoints) { _textBlockContainer[_textBlockContainer.Count - 1].Text = areaString; DrawLayer.Children.Remove(_textBlockContainer[_textBlockContainer.Count - 1]); DrawLayer.AddChild(_textBlockContainer[_textBlockContainer.Count - 1], point); } else { TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.ExtraBlack; textBlock.Foreground = new SolidColorBrush(Colors.White); textBlock.Text = areaString; _textBlockContainer.Add(textBlock); DrawLayer.AddChild(textBlock, point); } }
/// <summary>${utility_Extensions_method_Contains_GeoRegion_Point2D_D}</summary> /// <param name="region">${utility_Extensions_method_Contains_GeoRegion_Point2D_param_region}</param> /// <param name="point">${utility_Extensions_method_Contains_GeoRegion_Point2D_param_point}</param> /// <returns>${utility_Extensions_method_Contains_GeoRegion_Point2D_returns_D}</returns> public static bool Contains(this GeoRegion region, Point2D point) { return CheckInRegion(region, point.X, point.Y); }
/// <summary>${mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_D}</summary> /// <param name="element">${mapping_ArbitraryLayer_method_addChild_UIElement_pararm_element}</param> /// <param name="location">${mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_param_location}</param> public void AddChild(UIElement element, Point2D location) { AddChild(element, new Rectangle2D(location, location)); }
private static Point2D FindPointOnLineClosestToPoint(Point2D p0 , Point2D p1 , Point2D p) { Point2D p0p = new Point2D(p.X - p0.X , p.Y - p0.Y); Point2D p1p = new Point2D(p1.X - p0.X , p1.Y - p0.Y); double p0p1sq = p1p.X * p1p.X + p1p.Y * p1p.Y; double p0p_p0p1 = p0p.X * p1p.X + p0p.Y * p1p.Y; double t = p0p_p0p1 / p0p1sq; if (t < 0.0) { t = 0.0; } else if (t > 1.0) { t = 1.0; } return new Point2D(p0.X + p1p.X * t , p0.Y + p1p.Y * t); }
/// <summary>${ui_action_DrawCircle_event_OnPointerPressed_D}</summary> public override void OnPointerPressed(Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { PointerPoint pointer = e.GetCurrentPoint(Map); Point2D item = Map.ScreenToMap(pointer.Position); startPt = item; if (!isActivated) { this.Activate(item); } e.Handled = true; base.OnPointerPressed(e); }
private bool IntersectLineSect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, out Point2D result) { result = Point2D.Empty; bool flag = false; double de = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); if (Math.Abs(de) > SMALL_VALUE) { double ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / de; if ((ub > (-SMALL_VALUE)) && ub < (1 + SMALL_VALUE)) { flag = true; } else { flag = false; } } else { flag = false; } if (flag) { if (Math.Abs(x1 - x2) < SMALL_VALUE) { result.X = x1; result.Y = ((y3 - y4) * x1 + x3 * y4 - x4 * y3) / (x3 - x4); } else if (Math.Abs(x3 - x4) < SMALL_VALUE) { result.X = x3; result.Y = ((x1 - y2) * x3 + x1 * y2 - x2 * y1) / (x1 - x2); } else if (Math.Abs(y1 - y2) < SMALL_VALUE) { result.Y = y1; result.X = ((x3 - x4) * y1 + y3 * x4 - y4 * x3) / (y3 - y4); } else if (Math.Abs(y3 - y4) < SMALL_VALUE) { result.Y = y3; result.X = ((x1 - x2) * y3 + y1 * x2 - y2 * x1) / (y1 - y2); } else { double k1 = (y1 - y2) / (x1 - x2); double k2 = (y3 - y4) / (x3 - x4); double b1 = (x2 * y1 - y2 * x1) / (x2 - x1); double b2 = (x4 * y3 - y4 * x3) / (x4 - x3); result.X = (b2 - b1) / (k1 - k2); result.Y = (b1 * k2 - b2 * k1) / (k2 - k1); } } return flag; }
/// <summary> /// ${core_Point2D_method_IsNullOrEmpty_D} /// </summary> /// <param name="point">${core_Point2D_method_IsNullOrEmpty_param_point}</param> /// <returns>${core_Point2D_method_IsNullOrEmpty_return}</returns> public static bool IsNullOrEmpty(Point2D point) { if (point == null) { return true; } if (point.X == double.NegativeInfinity || point.Y == double.NegativeInfinity) { return true; } else { return false; } }
public GeoRectangle(Point2D point1, Point2D point2) { CreateRectangle(point1, point2); }
/// <summary>${mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_double_D}</summary> /// <param name="element">${mapping_ArbitraryLayer_method_addChild_UIElement_pararm_element}</param> /// <param name="location">${mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_param_location}</param> /// <param name="referenceLength">${mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_double_param_referenceLength}</param> public void AddChild(UIElement element, Point2D location, double referenceLength) { element.SetValue(ReferLengthProperty, referenceLength); AddChild(element, new Rectangle2D(location, location)); }
/// <returns>${core_Point2D_method_equals_Point2D_return}</returns> /// <summary>${core_Point2D_method_equals_Point2D_D}<br/></summary> /// <overloads>${core_Point2D_method_equals_overloads}</overloads> /// <param name="point">${core_Point2D_method_equals_Point2D_param_point}<br/></param> public bool Equals(Point2D point) { return (this == point); }
private void startEdit(Feature feature , bool suppressEvent , Point2D start) { if (activeFeature != feature) { StopEdit(); activeFeature = feature; buildHoverLayer(activeFeature); if (!suppressEvent) { OnGeometryEdit(activeFeature , GeometryEditAction.EditStarted); } } else if (activeFeature.Geometry is GeoRegion && !start.IsEmpty) { prepareMoveLineOrRegionFeature(start); }//表明移动整个要素 }