当前位置: 首页>>代码示例>>C#>>正文


C# IStyle.ToAndroid方法代码示例

本文整理汇总了C#中IStyle.ToAndroid方法的典型用法代码示例。如果您正苦于以下问题:C# IStyle.ToAndroid方法的具体用法?C# IStyle.ToAndroid怎么用?C# IStyle.ToAndroid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IStyle的用法示例。


在下文中一共展示了IStyle.ToAndroid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        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();
                }
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:51,代码来源:PointRenderer.cs

示例2: Draw

 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();
     }
 }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:14,代码来源:LineStringRenderer.cs


注:本文中的IStyle.ToAndroid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。