コード例 #1
0
ファイル: PointRenderer.cs プロジェクト: whztt1989/Mapsui
        public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
        {
            var point      = feature.Geometry as Point;
            var dest       = viewport.WorldToScreen(point);
            var symbolSize = (float)SymbolStyle.DefaultHeight;
            var symbolType = SymbolType.Ellipse;

            var symbolStyle = style as SymbolStyle;

            if (symbolStyle != null)
            {
                if (symbolStyle.BitmapId >= 0)
                {
                    // Bitmap
                    if (!feature.RenderedGeometry.ContainsKey(style))
                    {
                        var imageStream = BitmapRegistry.Instance.Get(symbolStyle.BitmapId);
                        imageStream.Position = 0;
                        var androidBitmap = BitmapFactory.DecodeStream(imageStream);
                        feature.RenderedGeometry[style] = androidBitmap;
                    }

                    var bitmap           = (Bitmap)feature.RenderedGeometry[style];
                    var halfWidth        = bitmap.Width / 2;
                    var halfHeight       = bitmap.Height / 2;
                    var dstRectForRender = new RectF((float)dest.X - halfWidth, (float)dest.Y - halfHeight, (float)dest.X + halfWidth, (float)dest.Y + halfHeight);
                    canvas.DrawBitmap(bitmap, null, dstRectForRender, null);
                    return;
                }
                symbolType = symbolStyle.SymbolType;
                if (symbolStyle.SymbolScale > 0)
                {
                    symbolSize = (float)symbolStyle.SymbolScale * symbolSize;
                }
            }

            // Drawing
            var paints = style.ToAndroid();

            if (symbolType == SymbolType.Ellipse)
            {
                foreach (var paint in paints)
                {
                    canvas.DrawCircle((int)dest.X, (int)dest.Y, symbolSize, paint);
                    paint.Dispose();
                }
            }
            else
            {
                foreach (var paint in paints)
                {
                    canvas.DrawRect(-(float)SymbolStyle.DefaultWidth, (float)SymbolStyle.DefaultHeight, (float)SymbolStyle.DefaultWidth, -(float)SymbolStyle.DefaultHeight, paint);
                    paint.Dispose();
                }
            }
        }
コード例 #2
0
ファイル: PointRenderer.cs プロジェクト: pauldendulk/Mapsui
        public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
        {
            var point = feature.Geometry as Point;
            var dest = viewport.WorldToScreen(point);
            var symbolSize = (float)SymbolStyle.DefaultHeight;
            var symbolType = SymbolType.Ellipse;

            var symbolStyle = style as SymbolStyle;
            if (symbolStyle != null)
            {
                if (symbolStyle.BitmapId >= 0)
                {
                    // Bitmap
                    if (!feature.RenderedGeometry.ContainsKey(style))
                    {
                        var imageStream = BitmapRegistry.Instance.Get(symbolStyle.BitmapId);
                        imageStream.Position = 0;
                        var androidBitmap = BitmapFactory.DecodeStream(imageStream);
                        feature.RenderedGeometry[style] = androidBitmap;
                    }

                    var bitmap = (Bitmap)feature.RenderedGeometry[style];
                    var halfWidth = bitmap.Width / 2;
                    var halfHeight = bitmap.Height / 2;
                    var dstRectForRender = new RectF((float)dest.X - halfWidth, (float)dest.Y - halfHeight, (float)dest.X + halfWidth, (float)dest.Y + halfHeight);
                    canvas.DrawBitmap(bitmap, null, dstRectForRender, null);
                    return;
                }
                symbolType = symbolStyle.SymbolType;
                if (symbolStyle.SymbolScale > 0) symbolSize = (float)symbolStyle.SymbolScale * symbolSize;
            }

            // Drawing
            var paints = style.ToAndroid();
            if (symbolType == SymbolType.Ellipse)
            {
                foreach (var paint in paints)
                {
                    canvas.DrawCircle((int)dest.X, (int)dest.Y, symbolSize, paint);
                    paint.Dispose();
                }
            }
            else
            {
                foreach (var paint in paints)
                {
                    canvas.DrawRect(-(float)SymbolStyle.DefaultWidth, (float)SymbolStyle.DefaultHeight, (float)SymbolStyle.DefaultWidth, -(float)SymbolStyle.DefaultHeight, paint);
                    paint.Dispose();
                }
            }
        }
コード例 #3
0
 public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
 {
     var lineString = ((LineString) feature.Geometry).Vertices;
     var paints = style.ToAndroid();
     //using (var paint = new Paint {Color = Color.Black, StrokeWidth = 8, AntiAlias = true})
     foreach (var paint in paints)
     {
         var vertices = lineString;
         var points = vertices.ToAndroid();
         WorldToScreen(viewport, points);
         canvas.DrawLines(points, paint);
         paint.Dispose();
     }
 }
コード例 #4
0
        public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
        {
            var lineString = ((LineString)feature.Geometry).Vertices;
            var paints     = style.ToAndroid();

            //using (var paint = new Paint {Color = Color.Black, StrokeWidth = 8, AntiAlias = true})
            foreach (var paint in paints)
            {
                var vertices = lineString;
                var points   = vertices.ToAndroid();
                WorldToScreen(viewport, points);
                canvas.DrawLines(points, paint);
                paint.Dispose();
            }
        }