mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Range selection in MapItemsControl
This commit is contained in:
parent
da63e55fd4
commit
1fc35d90c0
4 changed files with 41 additions and 9 deletions
|
|
@ -78,5 +78,42 @@ namespace MapControl
|
|||
{
|
||||
SelectItemsByPosition(rect.Contains);
|
||||
}
|
||||
|
||||
internal static void SetSelectedItemsRange(MapItem mapItem)
|
||||
{
|
||||
if (ItemsControlFromItemContainer(mapItem) is MapItemsControl mapItemsControl &&
|
||||
mapItemsControl.SelectionMode != SelectionMode.Single)
|
||||
{
|
||||
var pos = MapPanel.GetViewPosition(mapItem);
|
||||
|
||||
if (pos.HasValue)
|
||||
{
|
||||
var xMin = pos.Value.X;
|
||||
var xMax = pos.Value.X;
|
||||
var yMin = pos.Value.Y;
|
||||
var yMax = pos.Value.Y;
|
||||
|
||||
if (mapItemsControl.SelectedItem != null)
|
||||
{
|
||||
var selectedMapItem = mapItemsControl.ContainerFromItem(mapItemsControl.SelectedItem);
|
||||
|
||||
if (selectedMapItem != mapItem)
|
||||
{
|
||||
pos = MapPanel.GetViewPosition(selectedMapItem);
|
||||
|
||||
if (pos.HasValue)
|
||||
{
|
||||
xMin = Math.Min(xMin, pos.Value.X);
|
||||
xMax = Math.Max(xMax, pos.Value.X);
|
||||
yMin = Math.Min(yMin, pos.Value.Y);
|
||||
yMax = Math.Max(yMax, pos.Value.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mapItemsControl.SelectItemsInRect(new Rect(xMin, yMin, xMax - xMin, yMax - yMin));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue