本文整理汇总了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();
}
}
}
示例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();
}
}