${WP_core_Rectangle2D_Title}

${WP_core_Rectangle2D_Description}

Inheritance: IFormattable
 //比较计算后bounds和每个bounds的相交
 private bool computeIntersectWithAll(Rectangle2D bounds)
 {
     var boundsCollection = (Layer as ElementsLayer).BoundsCollection.Values;
     foreach (Rectangle2D rect in boundsCollection)
     {
         if (rect != null)
         {
             if (bounds.IntersectsWith(rect))
             {
                 return true;
             }
         }
     }
     foreach (Rectangle2D rect in orignalBounds)
     {
         if (rect != null)
         {
             if (bounds.IntersectsWith(rect))
             {
                 return true;
             }
         }
     }
     return false;
 }
 private void coll_PointChanged(object sender, EventArgs e)
 {
     if (this.Parts.Contains(sender as Point2DCollection))
     {
         savedBounds = new Rectangle2D();
         base.RaiseGeometryChanged();
     }
 }
 private void Parts_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.OldItems != null)
     {
         RemoveGeoPointCollectionEvents(e.OldItems);
     }
     if (e.NewItems != null)
     {
         AddGeoPointCollectionEvents(e.NewItems);
     }
     savedBounds = new Rectangle2D();
     base.RaiseGeometryChanged();
 }
        /// <summary>${WP_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);
        }
Exemple #5
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);
        }
 private static Rectangle2D StringToRectangle2D(string value)
 {
     if (string.IsNullOrEmpty(value))
     {
         return Rectangle2D.Empty;
     }
     string[] array = value.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
     if (array.Length != 4)
     {
         return Rectangle2D.Empty;
     }
     bool success = true;
     double[] valuesArray = new double[4];
     for (int i = 0; i < 4; i++)
     {
         double convertValue = 0;
         if (!double.TryParse(array[i], out convertValue))
         {
             success = false;
             break;
         }
         else
         {
             valuesArray[i] = convertValue;
         }
     }
     if (success)
     {
         Rectangle2D rectangle = new Rectangle2D(valuesArray[0], valuesArray[1], valuesArray[2], valuesArray[3]);
         return rectangle;
     }
     else
     {
         return Rectangle2D.Empty;
     }
 }
        //由bounds获取tile的起始和结束行列号
        //[startColumn,startRow,endColumn,endRow] //Returns [0,0,-1,-1] if fails
        private int[] GetTileSpanWithin(Rectangle2D bounds, double resolution)
        {
            Rectangle2D temp = bounds.Intersect(this.Bounds);
            if (!Rectangle2D.IsNullOrEmpty(temp))
            {
                double x = this.Origin.X;
                double y = this.Origin.Y;

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

            }
            return new int[4] { 0, 0, -1, -1 };
        }
        private void RaiseTileLoad(Tile tile, Rectangle2D bounds)
        {
            if (TileLoaded != null)
            {
                TileLoadEventArgs loadTileArgs = new TileLoadEventArgs();
                loadTileArgs.Column = tile.Column;

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

                TileLoaded(this, loadTileArgs);
            }
        }
        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 (Rectangle2D.IsNullOrEmpty(fullBounds))
                {
                    fullBounds = rect2D;
                }
                else
                {
                    fullBounds=fullBounds.Union(rect2D);
                }
            }
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            double resolution = this.Resolution;
            Point2D origin = new Point2D(this.OriginX, this.OriginY);
            Rectangle2D clipBox = new Rectangle2D(
                origin.X - (resolution * 4191.0),
                origin.Y - (resolution * 4191.0),
                origin.X + (resolution * 4191.0),
                origin.Y + (resolution * 4191.0));
            if (this.Layer is ElementsLayer) (Layer as ElementsLayer).BoundsCollection.Clear();
            if (this.Layer is ElementsLayer) orignalBounds.Clear();
            bool istrue = this.Layer is ElementsLayer ? (this.Layer as ElementsLayer).IsAutoAvoidance : false;
            if (istrue)
            {
                foreach (UIElement element in base.Children)
                {
                    Rectangle2D b = GetBounds(element);
                    double referenceLength = (Layer as ElementsLayer).GetReferenceLength(element) * resolution;
                    if (b.BottomLeft == b.TopRight)
                    {
                        b = new Rectangle2D(b.Left - (referenceLength) / 2, b.Bottom - (element.DesiredSize.Height * resolution) / 2,
                                            b.Left + (referenceLength) / 2, b.Bottom + (element.DesiredSize.Height * resolution) / 2);
                    }
                    orignalBounds.Add(b);
                }
            }

            foreach (UIElement element in base.Children)
            {
                if (element.Visibility != Visibility.Visible)
                {
                    continue;
                }
                if (element is FeatureElement)
                {
                    this.ArrangeFeature(element as FeatureElement, clipBox);
                    continue;
                }
                if (element is ShapeElement)
                {
                    this.ArrangeShapeBase(element as ShapeElement, clipBox);
                    continue;
                }
                Rectangle2D b = GetBounds(element);

                if (istrue)
                {
                    if (b.BottomLeft == b.TopRight)
                    {
                        b = new Rectangle2D(b.Left - (element.DesiredSize.Width * resolution) / 2, b.Bottom - (element.DesiredSize.Height * resolution) / 2,
                                            b.Left + (element.DesiredSize.Width * resolution) / 2, b.Bottom + (element.DesiredSize.Height * resolution) / 2);
                    }
                    bool isIntersect;
                    bool isGetNewBounds;
                    double referenceLength = (Layer as ElementsLayer).GetReferenceLength(element) * resolution;
                    Size referenceSize = (Layer as ElementsLayer).GetReferenceSize(element);

                    b = isBoundsChange(b, referenceLength, referenceSize, out isIntersect, out isGetNewBounds);

                    if (isIntersect)
                    {
                        if (isGetNewBounds)
                        {
                            (element as UIElement).Opacity = 1;
                        }
                        else
                        {
                            (element as UIElement).Opacity = 0;
                        }
                    }
                    else
                    {
                        (element as UIElement).Opacity = 1;
                    }

                    (Layer as ElementsLayer).BoundsCollection.Add(element, b);
                }

                if (!Rectangle2D.IsNullOrEmpty(b))
                {
                    double pixelX = (b.Left - origin.X) / resolution;
                    double pixelY = (origin.Y - b.Top) / resolution;
                    double pixelWidth = b.Width / resolution;
                    double pixelHeight = b.Height / resolution;
                    //&& 
                    if (this.Layer is TiledLayer)
                    {
                        pixelWidth++;
                        pixelHeight++;
                        element.UseLayoutRounding = false;
                    }

                    if (((!double.IsInfinity(pixelWidth) && !double.IsInfinity(pixelHeight)) && (!double.IsInfinity(pixelX) && !double.IsInfinity(pixelY))) && ((!double.IsNaN(pixelWidth) && !double.IsNaN(pixelHeight)) && (!double.IsNaN(pixelX) && !double.IsNaN(pixelY))))
                    {
                        double width;
                        double height;
                        if (((element is FrameworkElement) && (pixelWidth != 0.0)) && (pixelHeight != 0.0))
                        {
                            (element as FrameworkElement).Width = pixelWidth;
                            (element as FrameworkElement).Height = pixelHeight;
                        }
                        if ((pixelWidth != 0.0) || (pixelHeight != 0.0))
                        {
                            element.Arrange(new Rect(pixelX, pixelY, pixelWidth, pixelHeight));
                            continue;
                        }
                        //相当于左上,右下,中心等位置的设定。
                        //设在某个点,bbox的宽和高都是0,比如pushpin\textbox等
                        switch (((HorizontalAlignment)element.GetValue(FrameworkElement.HorizontalAlignmentProperty)))
                        {
                            case HorizontalAlignment.Left:
                                width = element.DesiredSize.Width;
                                break;

                            case HorizontalAlignment.Right:
                                width = 0.0;
                                break;

                            default:
                                width = element.DesiredSize.Width * 0.5;
                                break;
                        }
                        switch (((VerticalAlignment)element.GetValue(FrameworkElement.VerticalAlignmentProperty)))
                        {
                            case VerticalAlignment.Top:
                                height = element.DesiredSize.Height;
                                break;

                            case VerticalAlignment.Bottom:
                                height = 0.0;
                                break;

                            default:
                                height = element.DesiredSize.Height * 0.5;
                                break;
                        }
                        element.Arrange(new Rect(new Point(pixelX - width, pixelY - height), element.DesiredSize));
                    }
                }
            }
            return base.ArrangeOverride(finalSize);
        }
 /// <summary>${WP_core_Rectangle2D_method_containsRectangle2D_D}</summary>
 /// <returns>${WP_core_Rectangle2D_method_containsRectangle2D_return_sl}</returns>
 /// <param name="rect">${WP_core_Rectangle2D_method_containsRectangle2D_param_rect}</param>
 public bool Contains(Rectangle2D rect)
 {
     if (Rectangle2D.IsNullOrEmpty(rect))
     {
         return false;
     }
     return (this.Left <= rect.Left) && (rect.Right <= this.Right) && (this.Bottom <= rect.Bottom) && (rect.Top <= this.Top);
 }
        /// <summary>${WP_core_Rectangle2D_method_union_Rectangle2D_D}</summary>
        /// <param name="rect">${WP_core_Rectangle2D_method_union_Rectangle2D_param_rect}</param>
        /// <returns>${WP_core_Rectangle2D_method_union_return}</returns>
        public Rectangle2D Union(Rectangle2D rect)
        {
            if (Rectangle2D.IsNullOrEmpty(rect))
            {
                return this.Clone();
            }
            if (Rectangle2D.IsNullOrEmpty(this))
            {
                return rect;
            }
            else
            {
                double minLeft = Math.Min(this.Left, rect.Left);
                double minBottom = Math.Min(this.Bottom, rect.Bottom);
                double maxRight = Math.Max(this.Right, rect.Right);
                double maxTop = Math.Max(this.Top, rect.Top);
                Rectangle2D clone = this.Clone();
                clone._width = Math.Max((double)(maxRight - minLeft), (double)0.0);
                clone._height = Math.Max((double)(maxTop - minBottom), (double)0.0);
                clone._x = minLeft;
                clone._y = minBottom;

                return clone;
            }
        }
        /// <summary>${WP_core_Rectangle2D_method_intersectsWith_D}</summary>
        /// <returns>${WP_core_Rectangle2D_method_intersectsWith_return}</returns>
        /// <param name="rect">${WP_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);
        }
 public static void SetBounds(DependencyObject o, Rectangle2D value)
 {
     o.SetValue(BoundsProperty, value);
 }
 internal GeoLineClip(Rectangle2D clipBox)
 {
     this.boundary = clipBox;  
 }
 //对于SL自带的Rectangle暂不做处理
 private void SetClipShapeBase(ShapeElement sb, Rectangle2D clipBox)
 {
     Rectangle2D bounds = sb.Point2Ds.GetBounds();
     if ((Rectangle2D.IsNullOrEmpty(bounds)) || ((bounds.Width / this.Resolution) < 16383.5))
     {
         if (sb.ClippedPoint2Ds != null)
         {
             sb.ClearClip();
         }
     }
     else if (((Rectangle2D.IsNullOrEmpty(sb.ClipBox)) || !clipBox.Within(sb.ClipBox)) || ((sb.ClipBox.Width / this.Resolution) >= 16383.5))
     {
         if (sb is PolygonElement)
         {
             sb.SetClip(new PolygonElementClip(clipBox).Clip(sb.Point2Ds), clipBox);
         }
         else if (sb is PolylineElement)
         {
             sb.SetClip(new PolylineElementClip(clipBox).Clip(sb.Point2Ds), clipBox);
         }
     }
 }
 //int最大值32765的一半16382.5,最大支持16383
 private void SetClip(FeatureElement fe, Rectangle2D clipBox)
 {
     Rectangle2D bounds = fe.Geometry.Bounds;
     if ((Rectangle2D.IsNullOrEmpty(bounds)) || ((bounds.Width / this.Resolution) < 16383.5))
     {
         if (fe.ClippedGeometry != null)
         {
             fe.ClearClip();
         }
     }
     else if (((Rectangle2D.IsNullOrEmpty(fe.ClipBox)) || !clipBox.Within(fe.ClipBox)) || ((fe.ClipBox.Width / this.Resolution) >= 16383.5))
     {
         if (fe.Geometry is GeoRegion)
         {
             fe.SetClip(new GeoRegionClip(clipBox).Clip(fe.Geometry as GeoRegion), clipBox);
         }
         else if (fe.Geometry is GeoLine)
         {
             fe.SetClip(new GeoLineClip(clipBox).Clip(fe.Geometry as GeoLine), clipBox);
         }
     }
 }
        private void ArrangeFeature(FeatureElement elm, Rectangle2D clipBox)
        {
            if (elm.Visibility != Visibility.Collapsed)
            {
                Rectangle2D b = GetBounds(elm);
                if (!Rectangle2D.IsNullOrEmpty(b))
                {
                    double x = (b.Left - this.Origin.X) / this.Resolution;
                    double y = (this.Origin.Y - b.Top) / this.Resolution;
                    if (((b.Width > 0.0) || (b.Height > 0.0)) && (elm.PathGeometry != null))
                    {
                        double ratio = elm.Resolution / this.Resolution;
                        this.SetClip(elm, clipBox);
                        if (elm.ClippedGeometry != null)
                        {
                            b = elm.ClippedGeometry.Bounds;
                            if (Rectangle2D.IsNullOrEmpty(b))
                            {
                                return;
                            }
                            x = (b.Left - this.Origin.X) / this.Resolution;
                            y = (this.Origin.Y - b.Top) / this.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));
                    }
                }
            }
        }
        private void ArrangeShapeBase(ShapeElement sb, Rectangle2D clipBox)
        {
            if (sb.Visibility != Visibility.Collapsed)
            {
                Rectangle2D b = GetBounds(sb);
                if (!Rectangle2D.IsNullOrEmpty(b))
                {
                    double x = (b.Left - this.Origin.X) / this.Resolution;
                    double y = (this.Origin.Y - b.Top) / this.Resolution;

                    if (((b.Width > 0.0) || (b.Height > 0.0)) && (sb.Point2Ds != null))
                    {
                        double ratio = sb.Resolution / this.Resolution;
                        this.SetClipShapeBase(sb, clipBox);
                        if (sb.ClippedPoint2Ds != null)
                        {
                            b = sb.ClippedPoint2Ds.GetBounds();
                            if (Rectangle2D.IsNullOrEmpty(b))
                            {
                                return;
                            }
                            x = (b.Left - this.Origin.X) / this.Resolution;
                            y = (this.Origin.Y - b.Top) / this.Resolution;
                        }

                        if (sb.EncapsulatedShape.RenderTransform is ScaleTransform)
                        {
                            (sb.EncapsulatedShape.RenderTransform as ScaleTransform).ScaleX = (sb.EncapsulatedShape.RenderTransform as ScaleTransform).ScaleY = ratio;
                        }
                        else
                        {
                            sb.EncapsulatedShape.RenderTransform = new ScaleTransform { ScaleX = ratio, ScaleY = ratio };
                        }
                        double num4 = b.Width / sb.Resolution * ratio + 10.0;
                        double num5 = b.Height / sb.Resolution * ratio + 10.0;
                        num4 = Math.Min(32000.0, num4);
                        num5 = Math.Min(32000.0, num5);
                        sb.Arrange(new Rect(x, y, num4, num5));
                    }
                    else
                    {
                        sb.Arrange(new Rect(new Point(x, y), sb.DesiredSize));
                    }
                }
            }
        }
 /// <summary>
 /// ${WP_core_Rectangle2D_method_IsNullOrEmpty_D}
 /// </summary>
 /// <param name="rect">${WP_core_Rectangle2D_method_IsNullOrEmpty_param_rect}</param>
 /// <returns>${WP_core_Rectangle2D_method_IsNullOrEmpty_return}</returns>
 public static bool IsNullOrEmpty(Rectangle2D rect)
 {
     if (rect == null)
     {
         return true;
     }
     if (rect._x.ValueCheck() && rect._y.ValueCheck() && rect._width.ValueCheck() && rect._height.ValueCheck())
     {
         return false;
     }
     if (rect._width < 0.0 || rect._height < 0.0)
     {
         return true;
     }
     return true;
 }
 /// <summary>${WP_core_Rectangle2D_method_equals_D}</summary>
 /// <returns>${WP_core_Rectangle2D_method_equals_return}</returns>
 /// <overloads>${WP_core_Rectangle2D_method_equals_overloads}</overloads>
 /// <param name="rectangle">${WP_core_Rectangle2D_method_equals_param_rectangle}</param>
 public bool Equals(Rectangle2D rectangle)
 {
     return (this == rectangle);
 }
        //获取是否需要变换bounds 以及bounds是否可以变换
        private Rectangle2D isBoundsChange(Rectangle2D bounds, double referenceLength, Size referenceSize, out bool isIntersect, out bool isGetNewBounds)
        {
            //初始化要修改的范围
            isIntersect = false;
            isGetNewBounds = false;
            var boundsCollection = (Layer as ElementsLayer).BoundsCollection.Values;
            var radius = referenceLength * 0.7;
            Rectangle2D newBounds = new Rectangle2D();
            if (referenceSize.Width == 0 && referenceSize.Height == 0)
            {
                referenceSize.Width = bounds.Width;
                referenceSize.Height = bounds.Height;
            }
            else
            {
                referenceSize.Width *= this.Resolution;
                referenceSize.Height *= this.Resolution;

            }

            for (int i = 0; i < 8; i++)
            {
                switch (i)
                {
                    case 0:
                        newBounds = new Rectangle2D(bounds.Left + referenceSize.Width / 2, bounds.Bottom + radius, bounds.Right + referenceSize.Width / 2, bounds.Top + radius);
                        break;
                    case 1:
                        newBounds = new Rectangle2D(bounds.Left + referenceSize.Width / 2 + radius, bounds.Bottom, bounds.Right + referenceSize.Width / 2 + radius, bounds.Top);
                        break;
                    case 2:
                        newBounds = new Rectangle2D(bounds.Left + referenceSize.Width / 2, bounds.Bottom - radius, bounds.Right + referenceSize.Width / 2, bounds.Top - radius);
                        break;
                    case 3:
                        newBounds = new Rectangle2D(bounds.Left, bounds.Bottom - radius, bounds.Right, bounds.Top - radius);
                        break;
                    case 4:
                        newBounds = new Rectangle2D(bounds.Left - referenceSize.Width / 2, bounds.Bottom - radius, bounds.Right - referenceSize.Width / 2, bounds.Top - radius);
                        break;
                    case 5:
                        newBounds = new Rectangle2D(bounds.Left - referenceSize.Width / 2 - radius, bounds.Bottom, bounds.Right - referenceSize.Width / 2 - radius, bounds.Top);
                        break;
                    case 6:
                        newBounds = new Rectangle2D(bounds.Left - referenceSize.Width / 2, bounds.Bottom + radius, bounds.Right - referenceSize.Width / 2, bounds.Top + radius);
                        break;
                    case 7:
                        newBounds = new Rectangle2D(bounds.Left, bounds.Bottom + radius, bounds.Right, bounds.Top + radius);
                        break;
                }

                if (computeIntersectWithAll(newBounds))
                {
                    isIntersect = true;
                    if (i == 1 || i == 5)
                    {
                        continue;
                    }

                    newBounds=new Rectangle2D(newBounds.Left, newBounds.Bottom + referenceSize.Height, newBounds.Right, newBounds.Top + referenceSize.Height);
                    if (computeIntersectWithAll(newBounds))
                    {
                        newBounds=new Rectangle2D(newBounds.Left, newBounds.Bottom - 2 * referenceSize.Height, newBounds.Right, newBounds.Top - 2 * referenceSize.Height);
                        if (computeIntersectWithAll(newBounds))
                        {
                            continue;
                        }
                        else
                        {
                            isGetNewBounds = true;
                            return newBounds;
                        }
                    }
                    else
                    {
                        isGetNewBounds = true;
                        return newBounds;

                    }
                }
                else
                {
                    isGetNewBounds = true;
                    return newBounds;

                }
            }
            return bounds;
        }
 /// <summary>${WP_core_Rectangle2D_method_intersect_D}</summary>
 /// <param name="rect">${WP_core_Rectangle2D_method_intersect_param_rect}</param>
 /// <returns>${WP_core_Rectangle2D_method_intersect_return}</returns>
 public Rectangle2D Intersect(Rectangle2D rect)
 {
     if (!this.IntersectsWith(rect))
     {
         return Rectangle2D.Empty;
     }
     else
     {
         Rectangle2D clone = this.Clone();
         double maxLeft = Math.Max(this.Left, rect.Left);
         double maxBottom = Math.Max(this.Bottom, rect.Bottom);
         clone._width = Math.Max((Math.Min(this.Right, rect.Right) - maxLeft), (double)0.0);
         clone._height = Math.Max((Math.Min(this.Top, rect.Top) - maxBottom), (double)0.0);
         clone._x = maxLeft;
         clone._y = maxBottom;
         return clone;
     }
 }
 internal void SetClip(Point2DCollection clippedPoint2Ds, Rectangle2D clipbox)
 {
     this.ClippedPoint2Ds = clippedPoint2Ds;
     this.ClipBox = clipbox;
     this.InvalidatePath(this.Resolution, this.OriginX, this.OriginY);
 }
 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 (!Rectangle2D.IsNullOrEmpty(this.fullBounds))
                {
                    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();

        }
 /// <example>${WP_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>${WP_mapping_ArbitraryLayer_method_setbbox_D}</summary>
 /// <param name="obj">${WP_mapping_ArbitraryLayer_method_setbbox_param_obj}</param>
 /// <param name="value">${WP_mapping_ArbitraryLayer_method_setbbox_param_value}</param>
 public static void SetBBox(DependencyObject obj, Rectangle2D value)
 {
     obj.SetValue(BBoxProperty, value);
 }
 /// <summary>
 ///     ${WP_pubilc_Constructors_Initializes} <see cref="ViewBoundsEventArgs">ViewBoundsEventArgs</see> ${WP_pubilc_Constructors_instance}
 /// </summary>
 /// <param name="oldViewBounds">${WP_mapping_ViewBoundsEventArgs_constructor_param_oldViewBounds}</param>
 /// <param name="newViewBounds">${WP_mapping_ViewBoundsEventArgs_constructor_param_newViewBounds}</param>
 public ViewBoundsEventArgs(Rectangle2D oldViewBounds, Rectangle2D newViewBounds)
 {
     OldViewBounds = oldViewBounds;
     NewViewBounds = newViewBounds;
 }
 private static string convertToString(Rectangle2D rect)
 {
     if (Rectangle2D.IsNullOrEmpty(rect))
     {
         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 });
 }
 /// <summary>${WP_mapping_ArbitraryLayer_method_addChild_UIElement_Rectangle2D_D}</summary>
 /// <param name="element">${WP_mapping_ArbitraryLayer_method_addChild_UIElement_pararm_element}</param>
 /// <param name="bbox">${WP_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);
 }