diff --git a/MapControl/Avalonia/Map.Avalonia.cs b/MapControl/Avalonia/Map.Avalonia.cs index 38513751..cbfed149 100644 --- a/MapControl/Avalonia/Map.Avalonia.cs +++ b/MapControl/Avalonia/Map.Avalonia.cs @@ -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); diff --git a/MapControl/Avalonia/MapItem.Avalonia.cs b/MapControl/Avalonia/MapItem.Avalonia.cs index 29addcd3..f61064ab 100644 --- a/MapControl/Avalonia/MapItem.Avalonia.cs +++ b/MapControl/Avalonia/MapItem.Avalonia.cs @@ -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)); - } - } } } diff --git a/MapControl/Avalonia/MapItemsControl.Avalonia.cs b/MapControl/Avalonia/MapItemsControl.Avalonia.cs index fc518068..54f960df 100644 --- a/MapControl/Avalonia/MapItemsControl.Avalonia.cs +++ b/MapControl/Avalonia/MapItemsControl.Avalonia.cs @@ -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)); } } }