mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +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
|
|
@ -21,6 +21,11 @@ namespace MapControl
|
|||
{
|
||||
public static partial class ImageLoader
|
||||
{
|
||||
public static ImageSource LoadImage(Uri uri)
|
||||
{
|
||||
return new BitmapImage(uri);
|
||||
}
|
||||
|
||||
public static async Task<WriteableBitmap> LoadImageAsync(BitmapDecoder decoder)
|
||||
{
|
||||
var image = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Replaces Windows.Foundation.Point for double floating point precision.
|
||||
/// </summary>
|
||||
public struct Point
|
||||
public readonly struct Point
|
||||
{
|
||||
public Point(double x, double y)
|
||||
{
|
||||
|
|
@ -15,8 +15,8 @@ namespace MapControl
|
|||
Y = y;
|
||||
}
|
||||
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
|
||||
public static implicit operator Windows.Foundation.Point(Point p)
|
||||
{
|
||||
|
|
|
|||
43
MapControl/WinUI/Rect.WinUI.cs
Normal file
43
MapControl/WinUI/Rect.WinUI.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Replaces Windows.Foundation.Rect for double floating point precision.
|
||||
/// </summary>
|
||||
public readonly struct Rect
|
||||
{
|
||||
public Rect(double x, double y, double width, double height)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
|
||||
public Rect(Point p1, Point p2)
|
||||
: this(p1.X, p1.Y, p2.X - p1.X, p2.Y - p1.Y)
|
||||
{
|
||||
}
|
||||
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
public double Width { get; }
|
||||
public double Height { get; }
|
||||
|
||||
public bool Contains(Point p) => p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height;
|
||||
|
||||
public static implicit operator Windows.Foundation.Rect(Rect r)
|
||||
{
|
||||
return new Windows.Foundation.Rect(r.X, r.Y, r.Width, r.Height);
|
||||
}
|
||||
|
||||
public static implicit operator Rect(Windows.Foundation.Rect r)
|
||||
{
|
||||
return new Rect(r.X, r.Y, r.Width, r.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
#if WINUI
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
#else
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
#endif
|
||||
|
||||
|
|
@ -14,6 +16,17 @@ 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 BitmapImage bitmap && bitmap.UriSource != null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue