internal static void RaiseDrawingException <T>(string name, object sender, EventArgs e) { DrawingExceptionLayerEventArgs drawingExceptionLayerEventArgs = e as DrawingExceptionLayerEventArgs; DrawingExceptionTileOverlayEventArgs drawingExceptionTileOverlayEventArgs = e as DrawingExceptionTileOverlayEventArgs; if (!sender.Equals(default(T))) { var message = string.Format(CultureInfo.InvariantCulture, ConnectionFailed, name); var font = new GeoFont("Arial", 10, DrawingFontStyles.Italic); if (drawingExceptionLayerEventArgs != null) { if (drawingExceptionLayerEventArgs.Canvas.ClippingArea != null) { var clippingCenter = drawingExceptionLayerEventArgs.Canvas.ClippingArea.GetCenterPoint(); drawingExceptionLayerEventArgs.Canvas.DrawTextWithWorldCoordinate(message, font, new GeoSolidBrush(GeoColor.StandardColors.GrayText), clippingCenter.X, clippingCenter.Y, DrawingLevel.LabelLevel); drawingExceptionLayerEventArgs.Cancel = true; } else { var drawingArea = drawingExceptionLayerEventArgs.Canvas.MeasureText(message, font); drawingExceptionLayerEventArgs.Canvas.DrawTextWithScreenCoordinate(message, font, new GeoSolidBrush(GeoColor.StandardColors.GrayText), 20 + drawingArea.Width * .5f, 20 + drawingArea.Height * .5f, DrawingLevel.LabelLevel); drawingExceptionLayerEventArgs.Cancel = true; } } else if (drawingExceptionTileOverlayEventArgs != null) { if (drawingExceptionTileOverlayEventArgs.Canvas.ClippingArea != null) { var clippingCenter = drawingExceptionTileOverlayEventArgs.Canvas.ClippingArea.GetCenterPoint(); drawingExceptionTileOverlayEventArgs.Canvas.DrawTextWithWorldCoordinate(message, font, new GeoSolidBrush(GeoColor.StandardColors.GrayText), clippingCenter.X, clippingCenter.Y, DrawingLevel.LabelLevel); drawingExceptionTileOverlayEventArgs.Cancel = true; } else { var drawingArea = drawingExceptionTileOverlayEventArgs.Canvas.MeasureText(message, font); drawingExceptionTileOverlayEventArgs.Canvas.DrawTextWithScreenCoordinate(message, font, new GeoSolidBrush(GeoColor.StandardColors.GrayText), 20 + drawingArea.Width * .5f, 20 + drawingArea.Height * .5f, DrawingLevel.LabelLevel); drawingExceptionTileOverlayEventArgs.Cancel = true; } } } }
private static void BingMapsLayer_DrawingException(object sender, DrawingExceptionLayerEventArgs e) { BaseMapsHelper.RaiseDrawingException <BingMapsLayer>("Bing Map", sender, e); }
private static void osmLayer_DrawingException(object sender, DrawingExceptionLayerEventArgs e) { BaseMapsHelper.RaiseDrawingException <OpenStreetMapLayer>("OpenStreetMap", sender, e); }
private static void WorldMapKitLayer_DrawingException(object sender, DrawingExceptionLayerEventArgs e) { BaseMapsHelper.RaiseDrawingException <WorldMapKitLayer>("World Map Kit", sender, e); }