private void RefreshBounds(MapAnimationKind animation) { if (Model == null || Model.Core == null || Model.Core.Cartridge == null) { return; } // Gets the current location data out of the engine. CoordBounds bounds = Model.Core.Bounds; GeoCoordinate deviceLoc = Model.Core.DeviceLocation; // Are the bounds valid? // YES -> Computes a view around them. // NO -> Computes a default view around the starting location // of the cartridge or the current location of the player. MapViewRequestedEventArgs e = null; if (bounds != null && bounds.IsValid) { // Inflates the bounds to include the player. if (deviceLoc != null && !deviceLoc.IsUnknown) { bounds.Inflate(deviceLoc.ToZonePoint()); } e = new MapViewRequestedEventArgs(bounds.ToLocationRectangle(), animation); } else { // Is the cartridge play anywhere? // YES -> Try to get the player's location as center. // NO -> Sets the starting location of the cartridge as center. if (Model.Core.Cartridge.IsPlayAnywhere) { // If there is a current location of the player, use it as center. // If not, do nothing more. if (deviceLoc != null && !deviceLoc.IsUnknown) { e = new MapViewRequestedEventArgs(deviceLoc, DEFAULT_ZOOM_LEVEL, animation); } else { return; } } else { // Makes the event. e = new MapViewRequestedEventArgs(Model.Core.Cartridge.StartingLocation.ToGeoCoordinate(), DEFAULT_ZOOM_LEVEL, animation); } } // If an event was prepared, send it. if (MapViewRequested != null) { MapViewRequested(this, e); } }