mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 14:08:32 +00:00
Replaced MapRect and Scale by Rect and Point
This commit is contained in:
parent
dd62545b41
commit
7e18b6b984
32 changed files with 256 additions and 238 deletions
|
|
@ -13,6 +13,11 @@ namespace MapControl
|
|||
{
|
||||
public static partial class ImageLoader
|
||||
{
|
||||
public static ImageSource LoadImage(Uri uri)
|
||||
{
|
||||
return new BitmapImage(uri);
|
||||
}
|
||||
|
||||
public static ImageSource LoadImage(Stream stream)
|
||||
{
|
||||
var image = new BitmapImage();
|
||||
|
|
|
|||
|
|
@ -37,18 +37,18 @@ namespace MapControl
|
|||
|
||||
if (projection != null && items != null)
|
||||
{
|
||||
var mapRect = projection.BoundingBoxToMapRect(boundingBox);
|
||||
var rect = projection.BoundingBoxToMap(boundingBox);
|
||||
|
||||
if (mapRect != null)
|
||||
if (rect.HasValue)
|
||||
{
|
||||
image = await Task.Run(() => GetImage(projection, mapRect, items));
|
||||
image = await Task.Run(() => GetImage(projection, rect.Value, items));
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
private DrawingImage GetImage(MapProjection projection, MapRect mapRect, IEnumerable<IMapDrawingItem> items)
|
||||
private DrawingImage GetImage(MapProjection projection, Rect rect, IEnumerable<IMapDrawingItem> items)
|
||||
{
|
||||
var scale = ParentMap.ViewTransform.Scale;
|
||||
var rotation = ParentMap.ViewTransform.Rotation;
|
||||
|
|
@ -62,13 +62,13 @@ namespace MapControl
|
|||
.Select(point => point.Value)
|
||||
.ToList();
|
||||
|
||||
if (points.Any(point => mapRect.Contains(point)))
|
||||
if (points.Any(point => rect.Contains(point)))
|
||||
{
|
||||
for (int i = 0; i < points.Count; i++)
|
||||
{
|
||||
points[i] = new Point(
|
||||
scale * (points[i].X - mapRect.XMin),
|
||||
scale * (mapRect.YMax - points[i].Y));
|
||||
scale * (points[i].X - rect.X),
|
||||
scale * ((rect.Y + rect.Height) - points[i].Y));
|
||||
}
|
||||
|
||||
drawings.Children.Add(item.GetDrawing(points, scale, rotation));
|
||||
|
|
@ -79,7 +79,7 @@ namespace MapControl
|
|||
{
|
||||
Drawing = drawings,
|
||||
ViewboxUnits = BrushMappingMode.Absolute,
|
||||
Viewbox = new Rect(0, 0, scale * mapRect.Width, scale * mapRect.Height),
|
||||
Viewbox = new Rect(0, 0, scale * rect.Width, scale * rect.Height),
|
||||
};
|
||||
|
||||
var drawing = new GeometryDrawing(
|
||||
|
|
|
|||
|
|
@ -3,14 +3,27 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public partial class Tile
|
||||
{
|
||||
private void BeginOpacityAnimation()
|
||||
{
|
||||
Image.BeginAnimation(UIElement.OpacityProperty,
|
||||
new DoubleAnimation
|
||||
{
|
||||
From = 0d,
|
||||
Duration = MapBase.ImageFadeDuration,
|
||||
FillBehavior = FillBehavior.Stop
|
||||
});
|
||||
}
|
||||
|
||||
private void AnimateImageOpacity()
|
||||
{
|
||||
if (Image.Source is BitmapSource bitmap && bitmap.IsDownloading && !bitmap.IsFrozen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue