2025-02-27 18:46:32 +01:00
|
|
|
|
using System.Windows;
|
2023-01-19 17:16:02 +01:00
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MapItem
|
|
|
|
|
|
{
|
2024-05-23 18:08:14 +02:00
|
|
|
|
public static readonly DependencyProperty AutoCollapseProperty =
|
2024-05-24 15:14:05 +02:00
|
|
|
|
DependencyPropertyHelper.AddOwner<MapItem, bool>(MapPanel.AutoCollapseProperty);
|
2023-01-19 17:16:02 +01:00
|
|
|
|
|
2024-05-23 18:08:14 +02:00
|
|
|
|
public static readonly DependencyProperty LocationProperty =
|
2024-07-05 09:20:30 +02:00
|
|
|
|
DependencyPropertyHelper.AddOwner<MapItem, Location>(MapPanel.LocationProperty, null,
|
2024-05-23 18:08:14 +02:00
|
|
|
|
(item, oldValue, newValue) => item.UpdateMapTransform(newValue));
|
2023-01-19 17:16:02 +01:00
|
|
|
|
|
|
|
|
|
|
static MapItem()
|
|
|
|
|
|
{
|
|
|
|
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(MapItem), new FrameworkPropertyMetadata(typeof(MapItem)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-12 19:45:08 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Replaces ListBoxItem mouse event handling by not calling base.OnMouseLeftButtonDown.
|
|
|
|
|
|
/// Setting e.Handled = true generates a MouseLeftButtonUp event in the parent MapItemsControl,
|
|
|
|
|
|
/// which resembles the behavior of the ListBox base class.
|
|
|
|
|
|
/// </summary>
|
2023-01-19 17:16:02 +01:00
|
|
|
|
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
2025-03-12 17:53:56 +01:00
|
|
|
|
if (!e.Handled)
|
|
|
|
|
|
{
|
|
|
|
|
|
e.Handled = true;
|
2025-03-13 15:52:45 +01:00
|
|
|
|
|
|
|
|
|
|
if (ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
|
|
|
|
|
|
{
|
|
|
|
|
|
mapItemsControl.OnItemClicked(this, Keyboard.Modifiers.HasFlag(ModifierKeys.Control));
|
|
|
|
|
|
}
|
2025-03-12 17:53:56 +01:00
|
|
|
|
}
|
2023-01-19 17:16:02 +01:00
|
|
|
|
}
|
2025-03-12 15:30:59 +01:00
|
|
|
|
|
2025-03-12 19:45:08 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Replaces ListBoxItem mouse event handling by not calling base.OnMouseRightButtonDown.
|
|
|
|
|
|
/// Setting e.Handled = true generates a MouseRightButtonUp event in the parent MapItemsControl,
|
|
|
|
|
|
/// which resembles the behavior of the ListBox base class.
|
|
|
|
|
|
/// </summary>
|
2025-03-12 15:30:59 +01:00
|
|
|
|
protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
2025-03-12 17:53:56 +01:00
|
|
|
|
e.Handled = true;
|
2025-03-12 15:30:59 +01:00
|
|
|
|
}
|
2023-01-19 17:16:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|