Ejemplo n.º 1
0
        //Writeable Bitmap Approach
        //Consider Labeling
        public Path AsTileUsingWriteableBitmap(List <SqlGeometry> geometries, List <string> labels, double mapScale, TileInfo region, double tileWidth, double tileHeight, RectangleGeometry area, Func <Point, Point> viewTransform, sb.BoundingBox totalExtent)
        {
            if (geometries == null)
            {
                return(null);
            }

            Brush brush = this.VisualParameters.Fill;

            var color = ((SolidColorBrush)this.VisualParameters.Stroke)?.Color ?? ((SolidColorBrush)this.VisualParameters.Fill).Color;

            //var pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B), (int)this.VisualParameters.StrokeThickness);

            //if (this.VisualParameters.DashStyle != null)
            //{
            //    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            //}

            var transform = MapToTileScreenWpf(totalExtent, region.WebMercatorExtent, viewTransform);

            var image = new SqlSpatialToWriteableBitmap().ParseSqlGeometry(
                geometries,
                transform,
                (int)tileWidth,
                (int)tileHeight,
                this.VisualParameters.Stroke.AsSolidColor().Value,
                this.VisualParameters.Fill.AsSolidColor().Value);

            if (image == null)
            {
                return(null);
            }

            Path path = new Path()
            {
                Data = area,
                Tag  = new LayerTag(mapScale)
                {
                    Layer = this, IsTiled = true, Tile = region, IsDrawn = true, IsNew = true
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(image);

            return(path);
        }
Ejemplo n.º 2
0
        //Consider Labels
        public Path AsBitmapUsingWriteableBitmap(List <SqlGeometry> geometries, List <string> labels, double mapScale, sb.BoundingBox boundingBox, double width, double height, Func <Point, Point> mapToScreen, RectangleGeometry area)
        {
            if (geometries == null)
            {
                return(null);
            }

            var image = new SqlSpatialToWriteableBitmap().ParseSqlGeometry(
                geometries,
                mapToScreen,
                (int)width,
                (int)height,
                this.VisualParameters.Stroke.AsSolidColor().Value,
                this.VisualParameters.Fill.AsSolidColor().Value);

            if (image == null)
            {
                return(null);
            }

            //if (labels != null)
            //{
            //    this.DrawLabel(labels, geometries, image, transform);
            //}

            //BitmapImage bitmapImage = IRI.Jab.Common.Imaging.ImageUtility.AsBitmapImage(image);

            //Try #3
            Path path = new Path()
            {
                Data = area,
                Tag  = new LayerTag(mapScale)
                {
                    Layer = this, Tile = null, IsDrawn = true, IsNew = true
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(image);

            return(path);
        }