Beispiel #1
0
 public static void SetBoundingBox(FrameworkElement element, BoundingBox value)
 {
     element.SetValue(BoundingBoxProperty, value);
 }
 protected virtual void UpdateImage(BoundingBox boundingBox, Uri uri)
 {
     UpdateImage(boundingBox, new BitmapImage(uri));
 }
Beispiel #3
0
        private static void ArrangeElementWithBoundingBox(FrameworkElement element, MapBase parentMap, BoundingBox boundingBox)
        {
            var rect     = new Rect();
            var rotation = 0d;

            if (parentMap != null)
            {
                var projection = parentMap.MapProjection;
                rect = projection.BoundingBoxToRect(boundingBox);

                var center = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d);
                var pos    = projection.ViewportTransform.Transform(center);

                if (parentMap.MapProjection.IsCylindrical &&
                    (pos.X < 0d || pos.X > parentMap.RenderSize.Width ||
                     pos.Y < 0d || pos.Y > parentMap.RenderSize.Height))
                {
                    var location = projection.PointToLocation(center);
                    location.Longitude = Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude);

                    pos = projection.LocationToViewportPoint(location);
                }

                rect.Width  *= projection.ViewportScale;
                rect.Height *= projection.ViewportScale;
                rect.X       = pos.X - rect.Width / 2d;
                rect.Y       = pos.Y - rect.Height / 2d;

                if (element.UseLayoutRounding)
                {
                    rect.X = Math.Round(rect.X);
                    rect.Y = Math.Round(rect.Y);
                }

                rotation = parentMap.Heading;
            }

            element.Width  = rect.Width;
            element.Height = rect.Height;
            element.Arrange(rect);

            var rotateTransform = element.RenderTransform as RotateTransform;

            if (rotateTransform == null)
            {
                rotateTransform               = new RotateTransform();
                element.RenderTransform       = rotateTransform;
                element.RenderTransformOrigin = new Point(0.5, 0.5);
            }

            rotateTransform.Angle = rotation;
        }