mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Update MapItem.WinUI.cs
This commit is contained in:
parent
c510e32014
commit
946d28a50c
|
|
@ -28,10 +28,6 @@ namespace MapControl
|
||||||
item.UpdateMapTransform(newValue);
|
item.UpdateMapTransform(newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Used to detect pointer movement between PointerPressed and
|
|
||||||
// PointerReleased in order to possibly cancel item selection.
|
|
||||||
//
|
|
||||||
private const float pointerMovementThreshold = 2f;
|
|
||||||
private Windows.Foundation.Point? pointerPressedPosition;
|
private Windows.Foundation.Point? pointerPressedPosition;
|
||||||
|
|
||||||
public MapItem()
|
public MapItem()
|
||||||
|
|
@ -49,25 +45,31 @@ namespace MapControl
|
||||||
|
|
||||||
protected override void OnPointerReleased(PointerRoutedEventArgs e)
|
protected override void OnPointerReleased(PointerRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var p = e.GetCurrentPoint(null).Position;
|
if (pointerPressedPosition.HasValue)
|
||||||
|
|
||||||
if (pointerPressedPosition.HasValue &&
|
|
||||||
Math.Abs(p.X - pointerPressedPosition.Value.X) <= pointerMovementThreshold &&
|
|
||||||
Math.Abs(p.Y - pointerPressedPosition.Value.Y) <= pointerMovementThreshold &&
|
|
||||||
ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
|
|
||||||
{
|
{
|
||||||
if (mapItemsControl.SelectionMode == SelectionMode.Extended &&
|
const float pointerMovementThreshold = 2f;
|
||||||
e.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift))
|
var p = e.GetCurrentPoint(null).Position;
|
||||||
|
|
||||||
|
// Perform selection only when no significant pointer movement occured.
|
||||||
|
//
|
||||||
|
if (Math.Abs(p.X - pointerPressedPosition.Value.X) <= pointerMovementThreshold &&
|
||||||
|
Math.Abs(p.Y - pointerPressedPosition.Value.Y) <= pointerMovementThreshold &&
|
||||||
|
ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
|
||||||
{
|
{
|
||||||
mapItemsControl.SelectItemsInRange(this);
|
if (mapItemsControl.SelectionMode == SelectionMode.Extended &&
|
||||||
}
|
e.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift))
|
||||||
else
|
{
|
||||||
{
|
mapItemsControl.SelectItemsInRange(this);
|
||||||
base.OnPointerReleased(e);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base.OnPointerReleased(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pointerPressedPosition = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pointerPressedPosition = null;
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue