mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-05-07 13:37:47 +00:00
File scoped namespaces
This commit is contained in:
parent
c14377f976
commit
65aba44af6
152 changed files with 11962 additions and 12115 deletions
|
|
@ -12,105 +12,104 @@ using Avalonia;
|
|||
using Avalonia.Media;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
namespace MapControl;
|
||||
|
||||
/// <summary>
|
||||
/// A path element with a Data property that holds a Geometry in view coordinates or
|
||||
/// projected map coordinates that are relative to an origin Location.
|
||||
/// </summary>
|
||||
public partial class MapPath : IMapElement
|
||||
{
|
||||
public static readonly DependencyProperty LocationProperty =
|
||||
DependencyPropertyHelper.Register<MapPath, Location>(nameof(Location), null,
|
||||
(path, oldValue, newValue) => path.UpdateData());
|
||||
|
||||
/// <summary>
|
||||
/// A path element with a Data property that holds a Geometry in view coordinates or
|
||||
/// projected map coordinates that are relative to an origin Location.
|
||||
/// Gets or sets a Location that is either used as
|
||||
/// - the origin point of a geometry specified in projected map coordinates (meters) or
|
||||
/// - as an optional anchor point to constrain the view position of MapPaths with
|
||||
/// multiple Locations (like MapPolyline or MapPolygon) to the visible map viewport,
|
||||
/// as done for elements where the MapPanel.Location property is set.
|
||||
/// </summary>
|
||||
public partial class MapPath : IMapElement
|
||||
public Location Location
|
||||
{
|
||||
public static readonly DependencyProperty LocationProperty =
|
||||
DependencyPropertyHelper.Register<MapPath, Location>(nameof(Location), null,
|
||||
(path, oldValue, newValue) => path.UpdateData());
|
||||
get => (Location)GetValue(LocationProperty);
|
||||
set => SetValue(LocationProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a Location that is either used as
|
||||
/// - the origin point of a geometry specified in projected map coordinates (meters) or
|
||||
/// - as an optional anchor point to constrain the view position of MapPaths with
|
||||
/// multiple Locations (like MapPolyline or MapPolygon) to the visible map viewport,
|
||||
/// as done for elements where the MapPanel.Location property is set.
|
||||
/// </summary>
|
||||
public Location Location
|
||||
/// <summary>
|
||||
/// Implements IMapElement.ParentMap.
|
||||
/// </summary>
|
||||
public MapBase ParentMap
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
get => (Location)GetValue(LocationProperty);
|
||||
set => SetValue(LocationProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implements IMapElement.ParentMap.
|
||||
/// </summary>
|
||||
public MapBase ParentMap
|
||||
{
|
||||
get;
|
||||
set
|
||||
if (field != null)
|
||||
{
|
||||
if (field != null)
|
||||
{
|
||||
field.ViewportChanged -= OnViewportChanged;
|
||||
}
|
||||
|
||||
field = value;
|
||||
|
||||
if (field != null)
|
||||
{
|
||||
field.ViewportChanged += OnViewportChanged;
|
||||
}
|
||||
|
||||
UpdateData();
|
||||
field.ViewportChanged -= OnViewportChanged;
|
||||
}
|
||||
|
||||
field = value;
|
||||
|
||||
if (field != null)
|
||||
{
|
||||
field.ViewportChanged += OnViewportChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnViewportChanged(object sender, ViewportChangedEventArgs e)
|
||||
{
|
||||
UpdateData();
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetDataTransform(Matrix matrix)
|
||||
{
|
||||
if (Data.Transform is MatrixTransform transform
|
||||
private void OnViewportChanged(object sender, ViewportChangedEventArgs e)
|
||||
{
|
||||
UpdateData();
|
||||
}
|
||||
|
||||
protected void SetDataTransform(Matrix matrix)
|
||||
{
|
||||
if (Data.Transform is MatrixTransform transform
|
||||
#if WPF
|
||||
&& !transform.IsFrozen
|
||||
&& !transform.IsFrozen
|
||||
#endif
|
||||
)
|
||||
{
|
||||
transform.Matrix = matrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.Transform = new MatrixTransform { Matrix = matrix };
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UpdateData()
|
||||
)
|
||||
{
|
||||
if (Data != null && ParentMap != null && Location != null)
|
||||
{
|
||||
SetDataTransform(ParentMap.GetMapToViewTransform(Location));
|
||||
}
|
||||
|
||||
MapPanel.SetLocation(this, Location);
|
||||
transform.Matrix = matrix;
|
||||
}
|
||||
|
||||
protected Point LocationToMap(Location location, double longitudeOffset)
|
||||
else
|
||||
{
|
||||
var point = ParentMap.MapProjection.LocationToMap(location.Latitude, location.Longitude + longitudeOffset);
|
||||
|
||||
if (point.Y == double.PositiveInfinity)
|
||||
{
|
||||
point = new Point(point.X, 1e9);
|
||||
}
|
||||
else if (point.Y == double.NegativeInfinity)
|
||||
{
|
||||
point = new Point(point.X, -1e9);
|
||||
}
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
protected Point LocationToView(Location location, double longitudeOffset)
|
||||
{
|
||||
return ParentMap.ViewTransform.MapToView(LocationToMap(location, longitudeOffset));
|
||||
Data.Transform = new MatrixTransform { Matrix = matrix };
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UpdateData()
|
||||
{
|
||||
if (Data != null && ParentMap != null && Location != null)
|
||||
{
|
||||
SetDataTransform(ParentMap.GetMapToViewTransform(Location));
|
||||
}
|
||||
|
||||
MapPanel.SetLocation(this, Location);
|
||||
}
|
||||
|
||||
protected Point LocationToMap(Location location, double longitudeOffset)
|
||||
{
|
||||
var point = ParentMap.MapProjection.LocationToMap(location.Latitude, location.Longitude + longitudeOffset);
|
||||
|
||||
if (point.Y == double.PositiveInfinity)
|
||||
{
|
||||
point = new Point(point.X, 1e9);
|
||||
}
|
||||
else if (point.Y == double.NegativeInfinity)
|
||||
{
|
||||
point = new Point(point.X, -1e9);
|
||||
}
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
protected Point LocationToView(Location location, double longitudeOffset)
|
||||
{
|
||||
return ParentMap.ViewTransform.MapToView(LocationToMap(location, longitudeOffset));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue