/// <summary>${utility_ScaleHelper_method_GetSmDpi_D}</summary>
        /// <remarks>${utility_ScaleHelper_method_GetSmDpi_remarks}</remarks>
        /// <param name="referViewBounds">${utility_ScaleHelper_method_GetSmDpi_param_referViewBounds}</param>
        /// <param name="referViewer">${utility_ScaleHelper_method_GetSmDpi_param_referViewer}</param>
        ///  <param name="referScale">${utility_ScaleHelper_method_GetSmDpi_param_referScale}</param>
        /// <param name="unit">${utility_ScaleHelper_method_GetSmDpi_param_unit}</param>
        ///  <param name="datumAxis">${utility_ScaleHelper_method_GetSmDpi_param_datumAxis}</param>
        public static double GetSmDpi(Rectangle2D referViewBounds, Rect referViewer, double referScale, Unit unit = Unit.Degree, double datumAxis = 6378137)
        {
            int ratio = 10000;

            double num1 = referViewBounds.Width / referViewer.Width;//横向分辨率
            double num2 = referViewBounds.Height / referViewer.Height;//纵向分辨率

            if (unit == Unit.Undefined)
            {
                unit = Unit.Degree;
            }
            if (datumAxis <= 0||datumAxis==double.NaN)
            {
                datumAxis = 6378137;
            }
            //地图单位为经纬度
            if (unit == Unit.Degree)
            {
                double referResolution = num1 > num2 ? num1 : num2;//取横向或纵向分辨率中的较大者,用于计算DPI
                var dpi = 0.0254 * ratio / referResolution / referScale / ((Math.PI * 2 * datumAxis) / 360) / ratio;
                return dpi;
            }
            else
            {
                var dpi = 0.0254 * ratio / num1 / referScale / ratio;
                return dpi;
            }
        }
예제 #2
0
 /// <summary>${utility_JsonHelper_method_FromRectangle2D_D}</summary>
 public static string FromRectangle2D(Rectangle2D rectangle2D)
 {
     if (rectangle2D.IsEmpty)
     {
         return "{}";
     }
     return string.Format(CultureInfo.InvariantCulture, "{{\"rightTop\":{{\"y\":{0},\"x\":{1}}},\"leftBottom\":{{\"y\":{2},\"x\":{3}}}}}", rectangle2D.Top, rectangle2D.Right, rectangle2D.Bottom, rectangle2D.Left);
 }
 private Point2D ClipLineSegment(Point2D p0, Point2D p1, Rectangle2D box)
 {
     Point2D point = new Point2D(p1.X, p1.Y);
     if (p1.X < box.Left)
     {
         point = EdgeIntersection(p0, p1, box.Left, false);
     }
     else if (p1.X > box.Right)
     {
         point = EdgeIntersection(p0, p1, box.Right, false);
     }
     if (point.Y < box.Bottom)
     {
         return EdgeIntersection(p0, p1, box.Bottom, true);
     }
     if (point.Y > box.Top)
     {
         point = EdgeIntersection(p0, p1, box.Top, true);
     }
     return point;
 }
예제 #4
0
        /// <summary>${ui_action_MapAction_event_onMouseUp_D}</summary>
        /// <param name="e">${ui_action_MapAction_event_onMouseUp_param_e}</param>
        public override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            if (Rectangle == null)
            {
                return;
            }
            Rectangle2D zoomBounds = (Rectangle2D)Rectangle.GetValue(ElementsLayer.BBoxProperty);
            if (zoomBounds.IsEmpty || zoomBounds.Width == 0.0 || zoomBounds.Height == 0.0)
            {
                return;
            }
            Point2D center = zoomBounds.Center;
            Rectangle2D currentBounds = Map.ViewBounds;

            double whRatioCurrent = currentBounds.Width / currentBounds.Height;
            double whRatioZoomBox = zoomBounds.Width / zoomBounds.Height;
            Rectangle2D newBounds = Rectangle2D.Empty;
            if (whRatioZoomBox > whRatioCurrent)  // use width
            {
                double multiplier = currentBounds.Width / zoomBounds.Width;
                double newWidth = currentBounds.Width * multiplier;
                newBounds = new Rectangle2D(new Point2D(center.X - (newWidth / 2), center.Y - (newWidth / 2)),
                                               new Point2D(center.X + (newWidth / 2), center.Y + (newWidth / 2)));
            }
            else// use height
            {
                double multiplier = currentBounds.Height / zoomBounds.Height;
                double newHeight = currentBounds.Height * multiplier;
                newBounds = new Rectangle2D(new Point2D(center.X - (newHeight / 2), center.Y - (newHeight / 2)),
                                               new Point2D(center.X + (newHeight / 2), center.Y + (newHeight / 2)));
            }

            if (!newBounds.IsEmpty)
            {
                Map.ZoomTo(newBounds);
            }
            base.OnMouseLeftButtonUp(e);
        }
 /// <summary>${mapping_ArbitraryLayer_method_addChild_UIElement_Rectangle2D_D}</summary>
 /// <param name="element">${mapping_ArbitraryLayer_method_addChild_UIElement_pararm_element}</param>
 /// <param name="bbox">${mapping_ArbitraryLayer_method_addChild_UIElement_Rectangle2D_param_bbox}</param>
 public void AddChild(UIElement element, Rectangle2D bbox)
 {
     if (!(element is ShapeElement))
     {
         ElementsLayer.SetBBox(element, bbox);
     }
     Children.Add(element);
 }
 /// <example>${mapping_ArbitraryLayer_method_setbbox_Example_D}<code inline="false" title="" description="" lang="CS"></code><code title="Example1" description="" lang="C#">Ellipse myellipse = new Ellipse();     
 /// Rectangle2D ellbounds = new Rectangle2D(left, bottom, right, top);
 /// myellipse.SetValue(ElementsLayer.BBoxProperty, ellbounds);
 /// this.ElementsLayer.AddChild(myellipse);</code><code title="Example2" description="" lang="CS">&lt;ELLIPSE id=dxCrLf &lt;SPAN x:Name="MyEllipse"&gt;&lt;/SPAN&gt; namespace:ElementsLayer.BBox="left, bottom, right, top"&amp;gt; 
 /// &lt;/ELLIPSE&gt;</code></example>
 /// <summary>${mapping_ArbitraryLayer_method_setbbox_D}</summary>
 /// <param name="obj">${mapping_ArbitraryLayer_method_setbbox_param_obj}</param>
 /// <param name="value">${mapping_ArbitraryLayer_method_setbbox_param_value}</param>
 public static void SetBBox(DependencyObject obj, Rectangle2D value)
 {
     obj.SetValue(BBoxProperty, value);
 }
        /// <summary>${core_Rectangle2D_method_intersectsWith_D}</summary>
        /// <returns>${core_Rectangle2D_method_intersectsWith_return}</returns>
        /// <param name="rect">${core_Rectangle2D_method_intersectsWith_param_rect}</param>
        public bool IntersectsWith(Rectangle2D rect)
        {
            if ((this._width < 0.0) || (rect.Width < 0.0))
            {
                return false;
            }

            return (rect.Left <= this.Right) && (rect.Right >= this.Left) && (rect.Bottom <= this.Top) && (rect.Top >= this.Bottom);
        }
        /// <summary>${core_Rectangle2D_method_union_Rectangle2D_D}</summary>
        /// <param name="rect">${core_Rectangle2D_method_union_Rectangle2D_param_rect}</param>
        public void Union(Rectangle2D rect)
        {
            if (this.IsEmpty)
            {
                this = rect;
            }
            else if (!rect.IsEmpty)
            {
                double minLeft = Math.Min(this.Left, rect.Left);
                double minBottom = Math.Min(this.Bottom, rect.Bottom);

                if ((rect.Width == double.PositiveInfinity) || (this.Width == double.PositiveInfinity))
                {
                    this._width = double.PositiveInfinity;
                }
                else
                {
                    double maxRight = Math.Max(this.Right, rect.Right);
                    this._width = Math.Max((double)(maxRight - minLeft), (double)0.0);
                }
                if ((rect.Height == double.PositiveInfinity) || (this.Height == double.PositiveInfinity))
                {
                    this._height = double.PositiveInfinity;
                }
                else
                {
                    double maxHeight = Math.Max(this.Top, rect.Top);
                    this._height = Math.Max((double)(maxHeight - minBottom), (double)0.0);
                }
                this._x = minLeft;
                this._y = minBottom;

            }
        }
        private void RemoveTiles(Rectangle2D bounds, double resolution)
        {
            if (!bounds.IsEmpty)
            {
                if (base.Container == null)
                {
                    pendingTiles.Clear();
                }
                else
                {
                    int level = MathUtil.GetIndex(resolution, realResolutions);

                    int[] span = this.GetTileSpanWithin(bounds, resolution);
                    if ((span[2] >= 0) || (span[3] >= 0))
                    {
                        int startCloumn = span[0];
                        int startRow = span[1];
                        int endCloumn = span[2];
                        int endRow = span[3];
                        for (int i = base.Container.Children.Count - 1; i >= 0; i--)
                        {
                            UIElement element = base.Container.Children[i];
                            Image image = element as Image;
                            if (image != null)
                            {
                                Tile tile = (Tile)image.Tag;
                                bool flag = (level != -1) ? (level != tile.Level) : (!DoubleUtil.AreClose(resolution, tile.Resolution));
                                //只要分级别,不管在map上还是layer上,都用level判断。否则用Resolution判断
                                if ((tile.Row < (startRow - 1)) || (tile.Row > (endRow + 1)) || (tile.Column < (startCloumn - 1)) || (tile.Column > (endCloumn + 1)) || flag)
                                {
                                    string key = null;
                                    if (image.Source != null)
                                    {
                                        key = (image.Source as BitmapImage).UriSource.OriginalString;
                                        if (pendingTiles.ContainsKey(key))
                                        {
                                            pendingTiles.Remove(key);
                                        }
                                    }
                                    if (tile.Progress < 100)
                                    {
                                        if (image.Source is BitmapImage)
                                        {
                                            (image.Source as BitmapImage).UriSource = null;
                                        }
                                        image.Source = null;
                                        base.Container.Children.Remove(image);
                                    }
                                    else
                                    {
                                        image.SetValue(LayerContainer.OutdatedProperty, true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #10
0
        //由bounds获取tile的起始和结束行列号
        //[startColumn,startRow,endColumn,endRow] //Returns [0,0,-1,-1] if fails
        private int[] GetTileSpanWithin(Rectangle2D bounds, double resolution)
        {
            bounds.Intersect(this.Bounds);
            if (!bounds.IsEmpty)
            {
                double x = this.Origin.X;
                double y = this.Origin.Y;

                int startColumn = (int)Math.Floor((double)(((bounds.Left - x) + (resolution * 0.5)) / (resolution * this.TileSize)));
                int startRow = (int)Math.Floor((double)(((y - bounds.Top) + (resolution * 0.5)) / (resolution * this.TileSize)));
                startColumn = (startColumn < 0) ? 0 : startColumn;
                startRow = (startColumn < 0) ? 0 : startRow;
                int endColumn = (int)Math.Floor((double)(((bounds.Right - x) - (resolution * 0.5)) / (resolution * this.TileSize)));
                int endRow = (int)Math.Floor((double)(((y - bounds.Bottom) - (resolution * 0.5)) / (resolution * this.TileSize)));
                return new int[] { startColumn, startRow, endColumn, endRow };

                //if (GetCachedResolutions() != null)
                //{
                //    return new int[] { startColumn, startRow, endColumn, endRow };
                //}
                //else
                //{
                //    return new int[] { startColumn - 1, startRow - 1, endColumn + 1, endRow + 1 };
                //}//动态的话,上下左右各扩充一张,但边缘处不美观
            }
            return new int[4] { 0, 0, -1, -1 };
        }
 /// <summary>${ui_action_MapAction_event_onMouseWheel_D}</summary>
 /// <param name="e">${ui_action_MapAction_event_onMouseWheel_param_e}</param>
 protected override void OnMouseWheel(MouseWheelEventArgs e)
 {
     base.OnMouseWheel(e);
     if (_mouseWheelTimer.IsEnabled)
     {
         _mouseWheelTimer.Stop();
     }
     _mouseWheelTimer.Start();
     if (_isWheeling)
     {
         return;
     }
     _isWheeling = true;
     if (zoomEffectContainer != null && ZoomEffectEnabled == true)
     {
         this.zoomEffectContainer.Margin = new Thickness(curMousePos.X - 44, curMousePos.Y - 34, 0, 0);
         if (e.Delta > 0)
         {
             zoomEffect.beginZoomin();
         }
         else
         {
             zoomEffect.beiginZoomout();
         }
     }
     if (this.Action != null)
     {
         this.Action.OnMouseWheel(e);
         if (!e.Handled && EnableWheel)
         {
             e.Handled = true;
             base.Focus();
             Point2D pnt = ScreenToMap(curMousePos);
             double newResolution = GetNextResolution(e.Delta > 0);
             Rectangle2D newBounds = new Rectangle2D(pnt.X - curMousePos.X * newResolution, pnt.Y - (currentSize.Height - curMousePos.Y) * newResolution, pnt.X + (currentSize.Width - curMousePos.X) * newResolution, pnt.Y + curMousePos.Y * newResolution);
             ZoomTo(newBounds);
         }
     }
 }
 internal PolylineElementClip(Rectangle2D clipBox)
 {
     this.boundary = clipBox;
 }
예제 #13
0
        private 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.arbitrarylayer.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.arbitrarylayer.AddChild(beijing);

            Pushpin ulanBator = new Pushpin();
            ulanBator.Location = new Point2D(106.5, 47.6);
            ulanBator.Background = new SolidColorBrush(Colors.Blue);
            this.arbitrarylayer.AddChild(ulanBator);

            Pushpin moscow = new Pushpin();
            moscow.Location = new Point2D(37.4, 55.5);
            moscow.Background = new SolidColorBrush(Colors.Yellow);
            this.arbitrarylayer.AddChild(moscow);

            Pushpin prague = new Pushpin();
            prague.Location = new Point2D(14.3, 50.1);
            prague.Background = new SolidColorBrush(Colors.Orange);
            this.arbitrarylayer.AddChild(prague);

            Pushpin berlin = new Pushpin();
            berlin.Location = new Point2D(13.3, 52.3);
            berlin.Background = new SolidColorBrush(Colors.Purple);
            this.arbitrarylayer.AddChild(berlin);
            #endregion

            #region PolygonElement
            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.arbitrarylayer.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.arbitrarylayer.AddChild(polygon);
            #endregion

            #region Button
            Button btn = new Button();
            btn.Height = 32;
            btn.Width = 32;
            btn.Content = "点击";
            btn.Click += new RoutedEventHandler(btn_Click);
            Rectangle2D btnbounds = new Rectangle2D(95, 29, 115, 38);
            btn.SetValue(ElementsLayer.BBoxProperty, btnbounds);
            this.arbitrarylayer.AddChild(btn);
            #endregion
        }
예제 #14
0
 private static void OnLocationChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs eventArgs)
 {
     Rectangle2D bounds = new Rectangle2D((Point2D)eventArgs.NewValue, (Point2D)eventArgs.NewValue);
     ElementsLayer.SetBBox(d, bounds);
 }
 /// <summary>${core_Rectangle2D_method_containsRectangle2D_D}</summary>
 /// <returns>${core_Rectangle2D_method_containsRectangle2D_return_sl}</returns>
 /// <param name="rect">${core_Rectangle2D_method_containsRectangle2D_param_rect}</param>
 public bool Contains(Rectangle2D rect)
 {
     if (rect.IsEmpty)
     {
         return false;
     }
     return (this.Left <= rect.Left) && (rect.Right <= this.Right) && (this.Bottom <= rect.Bottom) && (rect.Top <= this.Top);
 }
 internal bool Within(Rectangle2D other)
 {
     return ((((this.Left >= other.Left) && (this.Right <= other.Right)) && (this.Bottom >= other.Bottom)) && (this.Top <= other.Top));
 }
 private void children_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         if (!this.fullBounds.IsEmpty)
         {
             UpdateFullBounds(e.NewItems);
         }
     }
     else
     {
         if (e.Action == NotifyCollectionChangedAction.Reset)
         {
             base.Container.Children.Clear();
         }
         else
         {
             base.Container.Children.Remove(e.OldItems[0] as UIElement);
         }
         this.fullBounds = Rectangle2D.Empty;
     }
     this.Invalidate();
 }
        private IList<Point2DCollection> ClipPointCollection(Point2DCollection points, Rectangle2D box)
        {
            List<Point2DCollection> list = new List<Point2DCollection>();
            Rectangle2D rect = points.GetBounds();
            if (((rect.Right < box.Left) || (rect.Top < box.Bottom)) || ((rect.Left > box.Right) || (rect.Bottom > box.Top)))
            {
                return null;
            }//全部在外,不相交
            if (box.Contains(rect))
            {
                list.Add(points);
                return list;
            }//全部在内
            if (points.Count < 2)
            {
                return null;
            }
            Point2DCollection item = null;
            bool flag = box.Contains(points[0]);
            if (flag)
            {
                item = new Point2DCollection();
                list.Add(item);
                item.Add(points[0]);
            }//第一个点在内
            for (int i = 0; i < (points.Count - 1); i++)
            {
                Point2D head = points[i];
                Point2D end = points[i + 1];
                bool flag2 = box.Contains(end);
                if (flag && flag2)
                {
                    item.Add(end);
                }//同时在内。那么else则有三种情况,head内end外,head外edn内,hean外end外
                else
                {
                    if (flag != flag2)
                    {
                        if (flag)
                        {
                            item.Add(this.ClipLineSegment(head, end, box));
                        }//head内end外,添加交点
                        else
                        {
                            item = new Point2DCollection();
                            list.Add(item);
                            item.Add(this.ClipLineSegment(head, end, box));
                            item.Add(end);
                        }//head外edn内,添加交点和end点
                    }
                    else
                    {
                        Rectangle2D segmentBox = new Rectangle2D(Math.Min(head.X, end.X), Math.Min(head.Y, end.Y), Math.Max(head.X, end.X), Math.Max(head.Y, end.Y));
                        if (segmentBox.IntersectsWith(box))
                        {
                            item = new Point2DCollection();
                            list.Add(item);
                            //与四条边框求交点,在中间就添加上去
                            Point2D point3 = EdgeIntersection(head, end, box.Left, false);
                            Point2D point4 = EdgeIntersection(head, end, box.Right, false);
                            Point2D point5 = EdgeIntersection(head, end, box.Bottom, true);
                            Point2D point6 = EdgeIntersection(head, end, box.Top, true);
                            if ((point6.X >= box.Left) && (point6.X <= box.Right))
                            {
                                item.Add(point6);
                            }
                            if ((point5.X >= box.Left) && (point5.X <= box.Right))
                            {
                                item.Add(point5);
                            }
                            if ((point4.Y >= box.Bottom) && (point4.Y <= box.Top))
                            {
                                item.Add(point4);
                            }
                            if ((point3.Y >= box.Bottom) && (point3.Y <= box.Top))
                            {
                                item.Add(point3);
                            }
                            if (item.Count < 2)
                            {
                                list.Remove(item);
                            }

                        }//hean外end外,添加两个交点
                    }
                    flag = flag2;
                }
            }
            for (int j = list.Count - 1; j >= 0; j--)
            {
                Point2DCollection pts = list[j];
                if (pts.Count < 2)
                {
                    list.RemoveAt(j);
                }
            }
            if (list.Count == 0)
            {
                return null;
            }
            return list;
        }
        private void UpdateFullBounds(IEnumerable items)
        {
            foreach (object obj2 in items)
            {
                UIElement element = (UIElement)obj2;
                Rectangle2D rect2D = GetBBox(element);
                if (element is ShapeElement)
                {
                    rect2D = ((ShapeElement)element).Bounds;
                }

                if (fullBounds.IsEmpty)
                {
                    fullBounds = rect2D;
                }
                else
                {
                    fullBounds.Union(rect2D);
                }
            }
        }
        internal void SetClip(SuperMap.Web.Core.Geometry clippedGeometry, Rectangle2D clipbox)
        {
            this.ClippedGeometry = clippedGeometry;
            this.ClipBox = clipbox;
            this.InvalidatePath(this.Resolution, this.OriginX, this.OriginY);

            if (this.Feature.dOldInflate > 0.0)
                return;
            //当线宽的外接矩形超过范围时,线不需偏移,重置偏移值为0
            this.Feature.dOldInflate = this.Feature.dInflate;
            this.Feature.dInflate = 0;
        }
 private static string convertToString(Rectangle2D rect)
 {
     if (rect.IsEmpty)
     {
         return null;
     }
     CultureInfo invariantCulture = CultureInfo.InvariantCulture;
     string listSeparator = invariantCulture.TextInfo.ListSeparator;
     return string.Format(invariantCulture, "{0}{4}{1}{4}{2}{4}{3}", new object[] { rect.Left, rect.Bottom, rect.Right, rect.Top, listSeparator });
 }
예제 #22
0
        private static Rectangle2D GetBounds(XElement element)
        {
            if (element == null)
                return Rectangle2D.Empty;

            Rectangle2D rect = new Rectangle2D(
                 (element.Attribute("minx") == null) ? double.MinValue : double.Parse(element.Attribute("minx").Value, CultureInfo.InvariantCulture),
                 (element.Attribute("miny") == null) ? double.MinValue : double.Parse(element.Attribute("miny").Value, CultureInfo.InvariantCulture),
                 (element.Attribute("maxx") == null) ? double.MinValue : double.Parse(element.Attribute("maxx").Value, CultureInfo.InvariantCulture),
                 (element.Attribute("maxy") == null) ? double.MinValue : double.Parse(element.Attribute("maxy").Value, CultureInfo.InvariantCulture)
                 );
            return rect;
        }
예제 #23
0
        private void RaiseTileLoad(Tile tile, Rectangle2D bounds)
        {
            if (TileLoaded != null)
            {
                TileLoadEventArgs loadTileArgs = new TileLoadEventArgs();
                loadTileArgs.Column = tile.Column;
                loadTileArgs.ImageSource = tile.Image.Source;

                loadTileArgs.Level = tile.Level;
                loadTileArgs.Row = tile.Row;
                loadTileArgs.Bounds = bounds;

                TileLoaded(this, loadTileArgs);
            }
        }
예제 #24
0
        /// <summary>${ui_action_MapAction_event_onMouseMove_D}</summary>
        /// <param name="e">${ui_action_MapAction_event_onMouseMove_param_e}</param>
        public override void OnMouseMove(MouseEventArgs e)
        {
            if (isDrawing)
            {
                Point2D item = Map.ScreenToMap(e.GetPosition(Map));
                double width = Math.Abs(item.X - startPt.X);
                double height = Math.Abs(startPt.Y - item.Y);
                double r = Math.Sqrt(width * width + height * height);
                this._radius = r;
                Rectangle2D bounds = new Rectangle2D(startPt.X - r, startPt.Y - r, startPt.X + r, startPt.Y + r);//圆
                ellipse.SetValue(ElementsLayer.BBoxProperty, bounds);
            }

            base.OnMouseMove(e);
        }
 private double GetValueFromMap(Rectangle2D bounds)
 {
     if (((this.layerResolutions == null) || (this.layerResolutions.Length == 0)) || ((this.Map == null) || (bounds.IsEmpty)))
     {
         return -1.0;
     }
     double num = bounds.Width / this.Map.ActualWidth;
     double t = this.Map.Resolution;
     for (int i = 0; i < (this.layerResolutions.Length - 1); i++)
     {
         double num3 = this.layerResolutions[i];
         double num4 = this.layerResolutions[i + 1];
         if (num >= num3)
         {
             return (double)i;
         }
         if ((num < num3) && (num > num4))
         {
             return (i + ((num3 - num) / (num3 - num4)));
         }
     }
     return Convert.ToDouble((int)(this.layerResolutions.Length - 1));
 }
 /// <summary>${core_Rectangle2D_method_intersect_D}</summary>
 /// <param name="rect">${core_Rectangle2D_method_intersect_param_rect}</param>
 public void Intersect(Rectangle2D rect)
 {
     if (!this.IntersectsWith(rect))
     {
         this = s_empty;
     }
     else
     {
         double maxLeft = Math.Max(this.Left, rect.Left);
         double maxBottom = Math.Max(this.Bottom, rect.Bottom);
         this._width = Math.Max((Math.Min(this.Right, rect.Right) - maxLeft), (double)0.0);
         this._height = Math.Max((Math.Min(this.Top, rect.Top) - maxBottom), (double)0.0);
         this._x = maxLeft;
         this._y = maxBottom;
     }
 }
 internal void SetClip(Point2DCollection clippedPoint2Ds, Rectangle2D clipbox)
 {
     this.ClippedPoint2Ds = clippedPoint2Ds;
     this.ClipBox = clipbox;
     this.InvalidatePath(this.Resolution, this.OriginX, this.OriginY);
 }
예제 #28
0
        internal void SetElementReference(FeatureElement element)
        {
            if (element == null)
            {
                this.ElementReference = null;
            }
            else
            {
                this.ElementReference = new WeakReference(element);
                Canvas.SetZIndex(element, this.zIndex);
                if (this.geometry != null)
                {
                    Rectangle2D biggerBounds = new Rectangle2D(this.geometry.Bounds.Left, this.geometry.Bounds.Bottom, this.geometry.Bounds.Right, this.geometry.Bounds.Top);
                    //拓宽GeoLine的外接矩形
                    if (this.Layer != null && (!double.IsNaN(this.Layer.Resolution)) && this.Style !=null && this.Style is LineStyle)
                    {
                        LineStyle lineStyle = this.Style as LineStyle;
                        if (!double.IsNaN(lineStyle.StrokeThickness))
                        {
                            Double dInflate = this.Layer.Resolution * lineStyle.StrokeThickness;
                            biggerBounds.Inflate(dInflate, dInflate);
                            this.dInflate = dInflate;
                        }
                    }
                    SuperMap.Web.Mapping.LayerContainer.SetBounds(element, biggerBounds);

                }
            }
        }
        /// <summary>${mapping_HeatMapLayer_constructor_None_D}</summary>
        public HeatMapLayer()
        {
            heatPoints = new HeatPointCollection();
            heatPoints.CollectionChanged += new NotifyCollectionChangedEventHandler(heatPoints_CollectionChanged);
            fullBounds = Rectangle2D.Empty;

            //设置GradientStops的默认值
            GradientStopCollection stops = new GradientStopCollection();
            stops.Add(new GradientStop() { Color = Color.FromArgb(0, 0, 0, 0), Offset = 0 });
            stops.Add(new GradientStop() { Color = new Color() { A = 0xff, R = 0xff, G = 0x42, B = 0x00 }, Offset = 0.75 });
            stops.Add(new GradientStop() { Color = new Color() { A = 0xff, R = 0xff, G = 0xff, B = 0x00 }, Offset = .5 });
            stops.Add(new GradientStop() { Color = new Color() { A = 0xff, R = 0x1a, G = 0xa4, B = 0x03 }, Offset = .25 });
            GradientStops = stops;

            //初始化后台线程
            worker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true };
            worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            worker.DoWork += new DoWorkEventHandler(worker_DoWork);
        }
 /// <summary>${core_Rectangle2D_method_equals_D}</summary>
 /// <returns>${core_Rectangle2D_method_equals_return}</returns>
 /// <overloads>${core_Rectangle2D_method_equals_overloads}</overloads>
 /// <param name="rectangle">${core_Rectangle2D_method_equals_param_rectangle}</param>
 public bool Equals(Rectangle2D rectangle)
 {
     return (this == rectangle);
 }