Moved Matrix creation to ViewTransform

This commit is contained in:
ClemensFischer 2024-05-22 09:42:21 +02:00
parent a1b8ed1ce8
commit 9cb4a9be7e
7 changed files with 138 additions and 103 deletions

View file

@ -92,20 +92,10 @@ namespace MapControl
/// Gets the scaling factor from projected map coordinates to view coordinates,
/// as pixels per meter.
/// </summary>
public double ViewScale => (double)GetValue(ViewScaleProperty);
/// <summary>
/// Gets a transform Matrix for scaling and rotating objects that are anchored
/// at a Location from map coordinates (i.e. meters) to view coordinates.
/// </summary>
public Matrix GetMapTransform(Location location)
public double ViewScale
{
var scale = GetScale(location);
var transform = new Matrix(scale.X, 0d, 0d, scale.Y, 0d, 0d);
transform.Rotate(ViewTransform.Rotation);
return transform;
get => (double)GetValue(ViewScaleProperty);
private set => SetValue(ViewScaleProperty, value);
}
private void OnSizeChanged(object sender, SizeChangedEventArgs e)
@ -119,11 +109,6 @@ namespace MapControl
UpdateTransform();
}
private void SetViewScale(double scale)
{
SetValue(ViewScaleProperty, scale);
}
private void CenterPropertyChanged(Location value)
{
if (!internalPropertyChange)