mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Input handling in Avalonia Map and MapItem
This commit is contained in:
parent
f2d82e910b
commit
1bb03e1102
|
|
@ -72,15 +72,20 @@ namespace MapControl
|
|||
{
|
||||
HandleManipulation(point.Pointer, point.Position);
|
||||
}
|
||||
else if (point.Pointer.Type == PointerType.Mouse || ManipulationModes.HasFlag(ManipulationModes.Translate))
|
||||
else if (point.Pointer.Type == PointerType.Mouse ||
|
||||
ManipulationModes.HasFlag(ManipulationModes.Translate))
|
||||
{
|
||||
TranslateMap(new Point(point.Position.X - position1.X, point.Position.Y - position1.Y));
|
||||
position1 = point.Position;
|
||||
}
|
||||
}
|
||||
else if (
|
||||
pointer1 == null && point.Pointer.Type == PointerType.Mouse && point.Properties.IsLeftButtonPressed && e.KeyModifiers == KeyModifiers.None ||
|
||||
pointer2 == null && point.Pointer.Type == PointerType.Touch && ManipulationModes != ManipulationModes.None)
|
||||
else if (pointer1 == null &&
|
||||
point.Pointer.Type == PointerType.Mouse &&
|
||||
point.Properties.IsLeftButtonPressed &&
|
||||
e.KeyModifiers == KeyModifiers.None ||
|
||||
pointer2 == null &&
|
||||
point.Pointer.Type == PointerType.Touch &&
|
||||
ManipulationModes != ManipulationModes.None)
|
||||
{
|
||||
point.Pointer.Capture(this);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@
|
|||
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
if (e.Pointer.Type == PointerType.Touch)
|
||||
if (e.Pointer.Type != PointerType.Mouse &&
|
||||
ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
|
||||
{
|
||||
UpdateSelection(e);
|
||||
mapItemsControl.UpdateSelection(this, e);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
|
|
@ -21,19 +22,14 @@
|
|||
|
||||
protected override void OnPointerReleased(PointerReleasedEventArgs e)
|
||||
{
|
||||
UpdateSelection(e);
|
||||
if (e.Pointer.Type == PointerType.Mouse &&
|
||||
e.InitialPressMouseButton == MouseButton.Left &&
|
||||
ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
|
||||
{
|
||||
mapItemsControl.UpdateSelection(this, e);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void UpdateSelection(PointerEventArgs e)
|
||||
{
|
||||
if (ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
|
||||
{
|
||||
mapItemsControl.UpdateSelection(this,
|
||||
e.KeyModifiers.HasFlag(KeyModifiers.Control),
|
||||
e.KeyModifiers.HasFlag(KeyModifiers.Shift));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,15 +57,16 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
internal void UpdateSelection(MapItem mapItem, bool controlKeyPressed, bool shiftKeyPressed)
|
||||
internal void UpdateSelection(MapItem mapItem, PointerEventArgs e)
|
||||
{
|
||||
if (SelectionMode != SelectionMode.Single && shiftKeyPressed)
|
||||
if (SelectionMode != SelectionMode.Single &&
|
||||
e.KeyModifiers.HasFlag(KeyModifiers.Shift))
|
||||
{
|
||||
SelectItemsInRange(mapItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateSelection(mapItem, true, false, controlKeyPressed);
|
||||
UpdateSelection(mapItem, true, false, e.KeyModifiers.HasFlag(KeyModifiers.Control));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue