2023-01-19 17:16:02 +01:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2024-02-03 21:01:53 +01:00
|
|
|
|
// Copyright © 2024 Clemens Fischer
|
2023-01-19 17:16:02 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using Windows.System;
|
2024-05-22 11:25:32 +02:00
|
|
|
|
#if UWP
|
2023-01-19 17:16:02 +01:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
|
using Windows.UI.Xaml.Input;
|
2024-05-22 11:25:32 +02:00
|
|
|
|
#else
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Input;
|
2023-01-19 17:16:02 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MapItem
|
|
|
|
|
|
{
|
2024-05-23 18:08:14 +02:00
|
|
|
|
public static readonly DependencyProperty AutoCollapseProperty =
|
2024-05-23 18:22:52 +02:00
|
|
|
|
DependencyPropertyHelper.Register<MapItem, bool>(nameof(AutoCollapse), false,
|
2024-05-23 18:08:14 +02:00
|
|
|
|
(item, oldValue, newValue) => MapPanel.SetAutoCollapse(item, newValue));
|
2023-01-19 17:16:02 +01:00
|
|
|
|
|
2024-05-23 18:08:14 +02:00
|
|
|
|
public static readonly DependencyProperty LocationProperty =
|
2024-05-23 18:22:52 +02:00
|
|
|
|
DependencyPropertyHelper.Register<MapItem, Location>(nameof(Location), null,
|
2024-05-25 15:55:31 +02:00
|
|
|
|
(item, oldValue, newValue) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
MapPanel.SetLocation(item, newValue);
|
|
|
|
|
|
item.UpdateMapTransform(newValue);
|
|
|
|
|
|
});
|
2023-01-19 17:16:02 +01:00
|
|
|
|
|
|
|
|
|
|
public MapItem()
|
|
|
|
|
|
{
|
|
|
|
|
|
DefaultStyleKey = typeof(MapItem);
|
|
|
|
|
|
MapPanel.InitMapElement(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnPointerPressed(PointerRoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
(ItemsControl.ItemsControlFromItemContainer(this) as MapItemsControl)?.OnItemClicked(
|
|
|
|
|
|
this, e.KeyModifiers.HasFlag(VirtualKeyModifiers.Control), e.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnApplyTemplate()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnApplyTemplate();
|
|
|
|
|
|
|
|
|
|
|
|
var parentMap = MapPanel.GetParentMap(this);
|
|
|
|
|
|
|
|
|
|
|
|
if (parentMap != null)
|
|
|
|
|
|
{
|
2024-05-25 15:55:31 +02:00
|
|
|
|
// Workaround for missing RelativeSource AncestorType=MapBase Bindings in default Style.
|
|
|
|
|
|
//
|
2024-05-24 18:24:44 +02:00
|
|
|
|
if (Background == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetBinding(BackgroundProperty, parentMap.CreateBinding(nameof(Background)));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Foreground == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetBinding(ForegroundProperty, parentMap.CreateBinding(nameof(Foreground)));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (BorderBrush == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetBinding(BorderBrushProperty, parentMap.CreateBinding(nameof(Foreground)));
|
|
|
|
|
|
}
|
2023-01-19 17:16:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|