public static BitmapImage GetImageSource(GeoBrush geoBrush)
        {
            BitmapImage result = null;

            System.Drawing.Bitmap nativeImage = new System.Drawing.Bitmap(16, 16);
            PlatformGeoCanvas     geoCanvas   = new PlatformGeoCanvas();
            RectangleShape        area        = new RectangleShape(-90, 90, 90, -90);

            geoCanvas.BeginDrawing(nativeImage, area, GeographyUnit.DecimalDegree);
            try
            {
                geoCanvas.DrawArea(area, geoBrush, DrawingLevel.LevelOne);
                geoCanvas.EndDrawing();

                MemoryStream streamSource = new MemoryStream();
                nativeImage.Save(streamSource, System.Drawing.Imaging.ImageFormat.Png);

                result = new BitmapImage();
                result.BeginInit();
                result.StreamSource = streamSource;
                result.EndInit();
                result.Freeze();
            }
            catch (Exception ex)
            {
                GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
            }
            finally
            {
                nativeImage.Dispose();
            }

            return(result);
        }
Beispiel #2
0
        private static void DrawPolygon(PolygonShape p, string f)
        {
            Bitmap            bmp    = new Bitmap(256, 256);
            PlatformGeoCanvas canvas = new PlatformGeoCanvas();

            canvas.BeginDrawing(bmp, new RectangleShape(-30, 30, 30, -30), GeographyUnit.DecimalDegree);
            canvas.DrawArea(p, GeoBrushes.Blue, DrawingLevel.LabelLevel);
            canvas.EndDrawing();

            string resultFilePath = f;

            bmp.Save(resultFilePath);
            Process.Start(resultFilePath);
        }