From 58ba1328c69a664c9242e6d3c291b9d6a7230f0c Mon Sep 17 00:00:00 2001 From: ClemensF Date: Tue, 1 Sep 2020 07:34:28 +0200 Subject: [PATCH] Added ViewRect,cs --- MapControl/Shared/MapPanel.cs | 29 ++++------------------------ MapControl/Shared/ViewRect.cs | 27 ++++++++++++++++++++++++++ MapControl/Shared/WmsImageLayer.cs | 2 +- MapControl/UWP/MapControl.UWP.csproj | 3 +++ 4 files changed, 35 insertions(+), 26 deletions(-) create mode 100644 MapControl/Shared/ViewRect.cs diff --git a/MapControl/Shared/MapPanel.cs b/MapControl/Shared/MapPanel.cs index 0e89db9a..cfd5493a 100644 --- a/MapControl/Shared/MapPanel.cs +++ b/MapControl/Shared/MapPanel.cs @@ -25,27 +25,6 @@ namespace MapControl MapBase ParentMap { get; set; } } - /// - /// Rotated rectangle used to arrange and rotate an element with a BoundingBox. - /// - 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; - } - } - /// /// 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 /// /// Returns the potentially rotated view rectangle of a BoundingBox. /// - public ViewRect GetViewRectangle(BoundingBox boundingBox) + public ViewRect GetViewRect(BoundingBox boundingBox) { - return GetViewRectangle(parentMap.MapProjection.BoundingBoxToRect(boundingBox)); + return GetViewRect(parentMap.MapProjection.BoundingBoxToRect(boundingBox)); } /// /// Returns the potentially rotated view rectangle of a map coordinate rectangle. /// - 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 { diff --git a/MapControl/Shared/ViewRect.cs b/MapControl/Shared/ViewRect.cs new file mode 100644 index 00000000..3e187de8 --- /dev/null +++ b/MapControl/Shared/ViewRect.cs @@ -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 +{ + /// + /// Rotated rectangle used to arrange and rotate an element with a BoundingBox. + /// + 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; + } + } +} diff --git a/MapControl/Shared/WmsImageLayer.cs b/MapControl/Shared/WmsImageLayer.cs index 4e953981..30319e8f 100644 --- a/MapControl/Shared/WmsImageLayer.cs +++ b/MapControl/Shared/WmsImageLayer.cs @@ -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); diff --git a/MapControl/UWP/MapControl.UWP.csproj b/MapControl/UWP/MapControl.UWP.csproj index 136c3a7b..3081940f 100644 --- a/MapControl/UWP/MapControl.UWP.csproj +++ b/MapControl/UWP/MapControl.UWP.csproj @@ -149,6 +149,9 @@ ViewportChangedEventArgs.cs + + ViewRect.cs + ViewTransform.cs