Reputation: 5038
I'm using the GMaps.NET Controls and I catch the event "TileLoadComplete":
I create several controls at run-time and all of them share the same function for that event:
for (int i = 0; i < 5; i++)
{
GMap.NET.WindowsForms.GMapControl control = new GMap.NET.WindowsForms.GMapControl();
control.Manager.Mode = AccessMode.ServerOnly;
control.MapProvider = GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance;
control.OnTileLoadComplete += Control_OnTileLoadComplete;
// set other map properties
}
private void Control_OnTileLoadComplete(long ElapsedMilliseconds)
{
// who has completed the loading?
}
Because there is no sender object in the event signature, I wonder if there is another way to know which control has completed the loading of the map.
Upvotes: 0
Views: 157
Reputation:
Would this work? Use a lambda to capture the sender:
for (int i = 0; i < 5; i++)
{
GMap.NET.WindowsForms.GMapControl control = new GMap.NET.WindowsForms.GMapControl();
//...snip...
control.OnTileLoadComplete += x => Control_OnTileLoadComplete(control, x);
}
private void Control_OnTileLoadComplete(object sender, long ElapsedMilliseconds)
{
// who has completed the loading?
// the sender, that's who!
}
You'd have to update each usage of Control_OnTileLoadComplete
to use that lamdba. You can change the type from object sender
to GMapControl sender
if the only 'senders' are of type GMapControl
.
Upvotes: 3