mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-01 22:30:14 +01:00
Added ViewRect,cs
This commit is contained in:
parent
9956e78028
commit
58ba1328c6
|
|
@ -25,27 +25,6 @@ namespace MapControl
|
|||
MapBase ParentMap { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rotated rectangle used to arrange and rotate an element with a BoundingBox.
|
||||
/// </summary>
|
||||
public struct ViewRect
|
||||
{
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
public double Width { get; }
|
||||
public double Height { get; }
|
||||
public double Rotation { get; }
|
||||
|
||||
public ViewRect(double x, double y, double width, double height, double rotation)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Width = width;
|
||||
Height = height;
|
||||
Rotation = rotation;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arranges child elements on a Map at positions specified by the attached property Location,
|
||||
/// or in rectangles specified by the attached property BoundingBox.
|
||||
|
|
@ -120,15 +99,15 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Returns the potentially rotated view rectangle of a BoundingBox.
|
||||
/// </summary>
|
||||
public ViewRect GetViewRectangle(BoundingBox boundingBox)
|
||||
public ViewRect GetViewRect(BoundingBox boundingBox)
|
||||
{
|
||||
return GetViewRectangle(parentMap.MapProjection.BoundingBoxToRect(boundingBox));
|
||||
return GetViewRect(parentMap.MapProjection.BoundingBoxToRect(boundingBox));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the potentially rotated view rectangle of a map coordinate rectangle.
|
||||
/// </summary>
|
||||
public ViewRect GetViewRectangle(Rect rect)
|
||||
public ViewRect GetViewRect(Rect rect)
|
||||
{
|
||||
var center = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d);
|
||||
var pos = parentMap.ViewTransform.MapToView(center);
|
||||
|
|
@ -213,7 +192,7 @@ namespace MapControl
|
|||
|
||||
if (boundingBox != null)
|
||||
{
|
||||
ArrangeElement(element, GetViewRectangle(boundingBox));
|
||||
ArrangeElement(element, GetViewRect(boundingBox));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
27
MapControl/Shared/ViewRect.cs
Normal file
27
MapControl/Shared/ViewRect.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2020 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Rotated rectangle used to arrange and rotate an element with a BoundingBox.
|
||||
/// </summary>
|
||||
public struct ViewRect
|
||||
{
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
public double Width { get; }
|
||||
public double Height { get; }
|
||||
public double Rotation { get; }
|
||||
|
||||
public ViewRect(double x, double y, double width, double height, double rotation)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Width = width;
|
||||
Height = height;
|
||||
Rotation = rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -273,7 +273,7 @@ namespace MapControl
|
|||
}
|
||||
|
||||
var mapRect = projection.BoundingBoxToRect(BoundingBox);
|
||||
var viewRect = GetViewRectangle(mapRect);
|
||||
var viewRect = GetViewRect(mapRect);
|
||||
var viewSize = ParentMap.RenderSize;
|
||||
|
||||
var transform = new Matrix(1, 0, 0, 1, -viewSize.Width / 2, -viewSize.Height / 2);
|
||||
|
|
|
|||
|
|
@ -149,6 +149,9 @@
|
|||
<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