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
|
|
@ -15,101 +15,100 @@ using Avalonia.Controls;
|
|||
using Avalonia.Media;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
namespace MapControl;
|
||||
|
||||
/// <summary>
|
||||
/// Container class for an item in a MapItemsControl.
|
||||
/// </summary>
|
||||
public partial class MapItem : ListBoxItem, IMapElement
|
||||
{
|
||||
public static readonly DependencyProperty LocationProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, Location>(
|
||||
nameof(Location), MapPanel.LocationProperty, (item, _, _) => item.UpdateMapTransform());
|
||||
|
||||
public static readonly DependencyProperty AutoCollapseProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, bool>(
|
||||
nameof(AutoCollapse), MapPanel.AutoCollapseProperty);
|
||||
|
||||
/// <summary>
|
||||
/// Container class for an item in a MapItemsControl.
|
||||
/// Gets/sets MapPanel.Location.
|
||||
/// </summary>
|
||||
public partial class MapItem : ListBoxItem, IMapElement
|
||||
public Location Location
|
||||
{
|
||||
public static readonly DependencyProperty LocationProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, Location>(
|
||||
nameof(Location), MapPanel.LocationProperty, (item, _, _) => item.UpdateMapTransform());
|
||||
get => (Location)GetValue(LocationProperty);
|
||||
set => SetValue(LocationProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AutoCollapseProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, bool>(
|
||||
nameof(AutoCollapse), MapPanel.AutoCollapseProperty);
|
||||
/// <summary>
|
||||
/// Gets/sets MapPanel.AutoCollapse.
|
||||
/// </summary>
|
||||
public bool AutoCollapse
|
||||
{
|
||||
get => (bool)GetValue(AutoCollapseProperty);
|
||||
set => SetValue(AutoCollapseProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets MapPanel.Location.
|
||||
/// </summary>
|
||||
public Location Location
|
||||
/// <summary>
|
||||
/// Implements IMapElement.ParentMap.
|
||||
/// </summary>
|
||||
public MapBase ParentMap
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
get => (Location)GetValue(LocationProperty);
|
||||
set => SetValue(LocationProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets MapPanel.AutoCollapse.
|
||||
/// </summary>
|
||||
public bool AutoCollapse
|
||||
{
|
||||
get => (bool)GetValue(AutoCollapseProperty);
|
||||
set => SetValue(AutoCollapseProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implements IMapElement.ParentMap.
|
||||
/// </summary>
|
||||
public MapBase ParentMap
|
||||
{
|
||||
get;
|
||||
set
|
||||
if (field != null)
|
||||
{
|
||||
if (field != null)
|
||||
{
|
||||
field.ViewportChanged -= OnViewportChanged;
|
||||
}
|
||||
field.ViewportChanged -= OnViewportChanged;
|
||||
}
|
||||
|
||||
field = value;
|
||||
field = value;
|
||||
|
||||
if (field != null && mapTransform != null)
|
||||
if (field != null && mapTransform != null)
|
||||
{
|
||||
// Attach ViewportChanged handler only if MapTransform is actually used.
|
||||
//
|
||||
field.ViewportChanged += OnViewportChanged;
|
||||
UpdateMapTransform();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Transform for scaling and rotating geometries
|
||||
/// in map coordinates (meters) to view coordinates (pixels).
|
||||
/// </summary>
|
||||
public MatrixTransform MapTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mapTransform == null)
|
||||
{
|
||||
mapTransform = new MatrixTransform();
|
||||
|
||||
if (ParentMap != null)
|
||||
{
|
||||
// Attach ViewportChanged handler only if MapTransform is actually used.
|
||||
//
|
||||
field.ViewportChanged += OnViewportChanged;
|
||||
ParentMap.ViewportChanged += OnViewportChanged;
|
||||
|
||||
UpdateMapTransform();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Transform for scaling and rotating geometries
|
||||
/// in map coordinates (meters) to view coordinates (pixels).
|
||||
/// </summary>
|
||||
public MatrixTransform MapTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mapTransform == null)
|
||||
{
|
||||
mapTransform = new MatrixTransform();
|
||||
|
||||
if (ParentMap != null)
|
||||
{
|
||||
ParentMap.ViewportChanged += OnViewportChanged;
|
||||
|
||||
UpdateMapTransform();
|
||||
}
|
||||
}
|
||||
|
||||
return mapTransform;
|
||||
}
|
||||
}
|
||||
|
||||
private MatrixTransform mapTransform;
|
||||
|
||||
private void UpdateMapTransform()
|
||||
{
|
||||
if (mapTransform != null && ParentMap != null && Location != null)
|
||||
{
|
||||
mapTransform.Matrix = ParentMap.GetMapToViewTransform(Location);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnViewportChanged(object sender, ViewportChangedEventArgs e)
|
||||
{
|
||||
UpdateMapTransform();
|
||||
return mapTransform;
|
||||
}
|
||||
}
|
||||
|
||||
private MatrixTransform mapTransform;
|
||||
|
||||
private void UpdateMapTransform()
|
||||
{
|
||||
if (mapTransform != null && ParentMap != null && Location != null)
|
||||
{
|
||||
mapTransform.Matrix = ParentMap.GetMapToViewTransform(Location);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnViewportChanged(object sender, ViewportChangedEventArgs e)
|
||||
{
|
||||
UpdateMapTransform();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue