XAML-Map-Control/MapControl/Avalonia/MapItem.Avalonia.cs

44 lines
1.3 KiB
C#
Raw Normal View History

2025-08-19 19:43:02 +02:00
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
namespace MapControl
2024-05-27 16:35:02 +02:00
{
public partial class MapItem
{
public static readonly StyledProperty<bool> AutoCollapseProperty =
MapPanel.AutoCollapseProperty.AddOwner<MapItem>();
2024-05-27 16:35:02 +02:00
public static readonly StyledProperty<Location> LocationProperty =
MapPanel.LocationProperty.AddOwner<MapItem>();
static MapItem()
{
LocationProperty.Changed.AddClassHandler<MapItem, Location>((item, e) => item.UpdateMapTransform());
}
2024-05-27 16:35:02 +02:00
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
if (e.Pointer.Type != PointerType.Mouse &&
ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
2025-03-12 19:45:08 +01:00
{
mapItemsControl.UpdateSelection(this, e);
}
2025-03-19 11:14:13 +01:00
e.Handled = true;
}
protected override void OnPointerReleased(PointerReleasedEventArgs e)
{
if (e.Pointer.Type == PointerType.Mouse &&
e.InitialPressMouseButton == MouseButton.Left &&
ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
{
mapItemsControl.UpdateSelection(this, e);
2025-03-12 19:45:08 +01:00
}
e.Handled = true;
2024-05-27 16:35:02 +02:00
}
}
}