private void gcw_PositionChanged(object sender, GeoPositionChangedEventArgs e)
{
// Stop the GeoCoordinateWatcher now that we have the device location.
this.gcw.Stop();
bannerAd.LocationLatitude = e.Position.Location.Latitude;
bannerAd.LocationLongitude = e.Position.Location.Longitude;
AdGameComponent.Current.Enabled = true;
}
Any idea what is causing this error?
public void CreateAd()
{
int width = 480;
int height = 80;
int x = (GraphicsDevice.Viewport.Bounds.Width - width) / 2;
int y = 720;
bannerAd = adGameComponent.CreateAd(AdUnitId, new Rectangle(x, y, width, height),
true);
// Set some visual properties (optional).
//bannerAd.BorderEnabled = true; // default is true
//bannerAd.BorderColor = Color.White; // default is White
//bannerAd.DropShadowEnabled = true; // default is true
// Provide the location to the ad for better targeting (optional).
// This is done by starting a GeoCoordinateWatcher and waiting for the location to
// available.
// The callback will set the location into the ad.
// Note: The location may not be available in time for the first ad request.
adGameComponent.Enabled = false;
this.gcw = new GeoCoordinateWatcher();
this.gcw.PositionChanged += new
EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>
(gcw_PositionChanged);
this.gcw.Start();
}
Error 1 Using the generic type 'System.Device.Location.GeoPositionChangedEventArgs<T>' requires 1 type arguments
&&
Error 2 Using the generic type 'System.Device.Location.GeoPositionChangedEventArgs' requires 1 type arguments
This is how I've always done it.
Declare the format of the delegate, all handlers will use this format
public delegate void gcw_PosChangedEventHandler(GeoPositionChangedEventArgs args);
Declare an event that others can register for
public event gcw_PosChangedEventHandler gcw_PosChanged;
Register for the event
someOtherClass.gcw_PosChanged += this.gcw_PositionChanged;
Make the event occur, by directly firing the event.
// Inside of 'someOtherClass'
gcw_PosChanged(args);
Handle the event that we registered for a couple steps earlier.
private void gcw_PositionChanged(GeoPositionChangedEventArgs args)
{
// Stop the GeoCoordinateWatcher now that we have the device location.
this.gcw.Stop();
bannerAd.LocationLatitude = e.Position.Location.Latitude;
bannerAd.LocationLongitude = e.Position.Location.Longitude;
AdGameComponent.Current.Enabled = true;
}