Skip to content

Commit

Permalink
GMap.NET.WindowsPresentation: optimize item update
Browse files Browse the repository at this point in the history
  • Loading branch information
radioman committed May 11, 2015
1 parent c42942f commit 8f3b90f
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,17 +644,16 @@ public void InvalidateVisual(bool forced)

protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);

if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
{
foreach(GMapMarker marker in e.NewItems)
{
marker.ForceUpdateLocalPosition(this);
}
ForceUpdateOverlays(e.NewItems);
}
else
{
InvalidateVisual();
}

base.OnItemsChanged(e);

Position = Position; // force refresh to repaint map
}

/// <summary>
Expand Down Expand Up @@ -729,14 +728,19 @@ void GMapControl_SizeChanged(object sender, SizeChangedEventArgs e)
ForceUpdateOverlays();
}
}

void ForceUpdateOverlays()
{
ForceUpdateOverlays(ItemsSource);
}

void ForceUpdateOverlays(System.Collections.IEnumerable items)
{
using(Dispatcher.DisableProcessing())
{
UpdateMarkersOffset();

foreach(GMapMarker i in ItemsSource)
foreach(GMapMarker i in items)
{
if(i != null)
{
Expand Down

0 comments on commit 8f3b90f

Please sign in to comment.