mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-31 22:00:12 +01:00
Removed ViewRect
This commit is contained in:
parent
3468940ebf
commit
2a0f363377
|
|
@ -40,9 +40,6 @@
|
|||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Shared\MBTileData.cs">
|
||||
<Link>MBTileData.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\MBTileLayer.cs">
|
||||
<Link>MBTileLayer.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace MapControl
|
|||
|
||||
private static async Task LoadGeoImageAsync(Image image, string sourcePath)
|
||||
{
|
||||
if (sourcePath != null)
|
||||
if (!string.IsNullOrEmpty(sourcePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ namespace MapControl
|
|||
return position;
|
||||
}
|
||||
|
||||
protected ViewRect? GetViewRect(BoundingBox boundingBox)
|
||||
protected Rect? GetViewRect(BoundingBox boundingBox)
|
||||
{
|
||||
var mapRect = parentMap.MapProjection.BoundingBoxToMap(boundingBox);
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ namespace MapControl
|
|||
return null;
|
||||
}
|
||||
|
||||
protected ViewRect GetViewRect(Rect mapRect)
|
||||
protected Rect GetViewRect(Rect mapRect)
|
||||
{
|
||||
var center = new Point(mapRect.X + mapRect.Width / 2d, mapRect.Y + mapRect.Height / 2d);
|
||||
var position = parentMap.ViewTransform.MapToView(center);
|
||||
|
|
@ -246,7 +246,7 @@ namespace MapControl
|
|||
var x = position.X - width / 2d;
|
||||
var y = position.Y - height / 2d;
|
||||
|
||||
return new ViewRect(x, y, width, height, parentMap.ViewTransform.Rotation);
|
||||
return new Rect(x, y, width, height);
|
||||
}
|
||||
|
||||
private void ArrangeChildElement(FrameworkElement element, Size panelSize)
|
||||
|
|
@ -277,11 +277,11 @@ namespace MapControl
|
|||
|
||||
if (boundingBox != null)
|
||||
{
|
||||
var viewRect = GetViewRect(boundingBox);
|
||||
var rect = GetViewRect(boundingBox);
|
||||
|
||||
if (viewRect.HasValue)
|
||||
if (rect.HasValue)
|
||||
{
|
||||
ArrangeElement(element, viewRect.Value);
|
||||
ArrangeElement(element, rect.Value, parentMap.ViewTransform.Rotation);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -291,20 +291,20 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
private static void ArrangeElement(FrameworkElement element, ViewRect rect)
|
||||
private static void ArrangeElement(FrameworkElement element, Rect rect, double rotation)
|
||||
{
|
||||
element.Width = rect.Rect.Width;
|
||||
element.Height = rect.Rect.Height;
|
||||
element.Width = rect.Width;
|
||||
element.Height = rect.Height;
|
||||
|
||||
element.Arrange(rect.Rect);
|
||||
element.Arrange(rect);
|
||||
|
||||
if (element.RenderTransform is RotateTransform rotateTransform)
|
||||
{
|
||||
rotateTransform.Angle = rect.Rotation;
|
||||
rotateTransform.Angle = rotation;
|
||||
}
|
||||
else if (rect.Rotation != 0d)
|
||||
else if (rotation != 0d)
|
||||
{
|
||||
SetRenderTransform(element, new RotateTransform { Angle = rect.Rotation }, 0.5, 0.5);
|
||||
SetRenderTransform(element, new RotateTransform { Angle = rotation }, 0.5, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
#if WPF
|
||||
using System.Windows;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Rotated rectangle used to arrange and rotate an element with a BoundingBox.
|
||||
/// </summary>
|
||||
public readonly struct ViewRect
|
||||
{
|
||||
public ViewRect(double x, double y, double width, double height, double rotation)
|
||||
{
|
||||
Rect = new Rect(x, y, width, height);
|
||||
Rotation = rotation;
|
||||
}
|
||||
|
||||
public Rect Rect { get; }
|
||||
public double Rotation { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -270,8 +270,8 @@ namespace MapControl
|
|||
|
||||
var transform = ViewTransform.CreateTransformMatrix(
|
||||
-viewport.Width / 2d, -viewport.Height / 2d,
|
||||
-viewRect.Rotation,
|
||||
viewRect.Rect.Width / 2d, viewRect.Rect.Height / 2d);
|
||||
-ParentMap.ViewTransform.Rotation,
|
||||
viewRect.Width / 2d, viewRect.Height / 2d);
|
||||
|
||||
var imagePos = transform.Transform(position);
|
||||
|
||||
|
|
@ -286,8 +286,8 @@ namespace MapControl
|
|||
{ "INFO_FORMAT", format },
|
||||
{ "CRS", GetCrsValue() },
|
||||
{ "BBOX", GetBboxValue(mapRect.Value) },
|
||||
{ "WIDTH", Math.Round(viewRect.Rect.Width).ToString("F0") },
|
||||
{ "HEIGHT", Math.Round(viewRect.Rect.Height).ToString("F0") },
|
||||
{ "WIDTH", Math.Round(viewRect.Width).ToString("F0") },
|
||||
{ "HEIGHT", Math.Round(viewRect.Height).ToString("F0") },
|
||||
{ "I", Math.Round(imagePos.X).ToString("F0") },
|
||||
{ "J", Math.Round(imagePos.Y).ToString("F0") }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -182,9 +182,6 @@
|
|||
<Compile Include="..\Shared\ViewportChangedEventArgs.cs">
|
||||
<Link>ViewportChangedEventArgs.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\ViewRect.cs">
|
||||
<Link>ViewRect.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\ViewTransform.cs">
|
||||
<Link>ViewTransform.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
|||
Loading…
Reference in a new issue