示例#1
0
        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;
                    }
                }
            }
        }
示例#2
0
 private static void BingMapsLayer_DrawingException(object sender, DrawingExceptionLayerEventArgs e)
 {
     BaseMapsHelper.RaiseDrawingException <BingMapsLayer>("Bing Map", sender, e);
 }
示例#3
0
 private static void osmLayer_DrawingException(object sender, DrawingExceptionLayerEventArgs e)
 {
     BaseMapsHelper.RaiseDrawingException <OpenStreetMapLayer>("OpenStreetMap", sender, e);
 }
示例#4
0
 private static void WorldMapKitLayer_DrawingException(object sender, DrawingExceptionLayerEventArgs e)
 {
     BaseMapsHelper.RaiseDrawingException <WorldMapKitLayer>("World Map Kit", sender, e);
 }