Minor improvements

This commit is contained in:
ClemensFischer 2022-12-04 20:10:00 +01:00
parent fe1ac924b4
commit 7b69215a30
3 changed files with 17 additions and 11 deletions

View file

@ -10,7 +10,7 @@ using System.Windows;
namespace MapControl
{
/// <summary>
/// Map rectangle with double floating point precision, unlike Windows.Foundation.Rect does.
/// Map rectangle with double floating point precision, in contrast to Windows.Foundation.Rect.
/// Used by MapProjection to convert geodetic bounding boxes to/from projected map coordinates.
/// </summary>
public class MapRect

View file

@ -4,7 +4,7 @@
namespace MapControl
{
public struct Scale
public readonly struct Scale
{
public Scale(double x, double y)
{
@ -12,8 +12,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 Scale operator *(double f, Scale v)
{

View file

@ -2,18 +2,17 @@
// © 2022 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using ABI.Microsoft.UI.Xaml.Media;
using System;
#if WINUI
using XamlMedia = Microsoft.UI.Xaml.Media;
using WindowsUI = Microsoft.UI;
#else
using XamlMedia = Windows.UI.Xaml.Media;
using WindowsUI = Windows.UI;
#endif
namespace MapControl
{
/// <summary>
/// Replaces Windows.UI.Xaml.Media.Matrix to achieve necessary floating point precision.
/// Replaces Windows.UI.Xaml.Media.Matrix for double floating point precision.
/// </summary>
public struct Matrix
{
@ -34,14 +33,21 @@ namespace MapControl
public double OffsetX { get; set; }
public double OffsetY { get; set; }
public static implicit operator XamlMedia.Matrix(Matrix m)
public static implicit operator WindowsUI.Xaml.Media.Matrix(Matrix m)
{
return new XamlMedia.Matrix(m.M11, m.M12, m.M21, m.M22, m.OffsetX, m.OffsetY);
return new WindowsUI.Xaml.Media.Matrix(m.M11, m.M12, m.M21, m.M22, m.OffsetX, m.OffsetY);
}
public static implicit operator Matrix(WindowsUI.Xaml.Media.Matrix m)
{
return new Matrix(m.M11, m.M12, m.M21, m.M22, m.OffsetX, m.OffsetY);
}
public Point Transform(Point p)
{
return new Point(M11 * p.X + M21 * p.Y + OffsetX, M12 * p.X + M22 * p.Y + OffsetY);
return new Point(
M11 * p.X + M21 * p.Y + OffsetX,
M12 * p.X + M22 * p.Y + OffsetY);
}
public void Translate(double x, double y)