本文整理汇总了C#中IViewport.WorldToScreen方法的典型用法代码示例。如果您正苦于以下问题:C# IViewport.WorldToScreen方法的具体用法?C# IViewport.WorldToScreen怎么用?C# IViewport.WorldToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IViewport
的用法示例。
在下文中一共展示了IViewport.WorldToScreen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertPointBoundingBox
public static CGRect ConvertPointBoundingBox(SymbolStyle symbolStyle, BoundingBox boundingBox, IViewport viewport)
{
var screenMin = viewport.WorldToScreen(boundingBox.Min);
var screenMax = viewport.WorldToScreen(boundingBox.Max);
//boundingBox.Offset = symbolStyle.SymbolOffset;
//var newMin = boundingBox.Min;
//var newMax = boundingBox.Max;
if (symbolStyle.SymbolOffset != null)
{
screenMin = new Geometries.Point(
screenMin.X - symbolStyle.SymbolOffset.X,
screenMin.Y - symbolStyle.SymbolOffset.Y);
screenMax = new Geometries.Point(
screenMax.X - symbolStyle.SymbolOffset.X,
screenMax.Y - symbolStyle.SymbolOffset.Y);
var w = viewport.ScreenToWorld(screenMin);
boundingBox.Offset(new Geometries.Point(w.X - boundingBox.MinX, w.Y - boundingBox.MinY));
screenMin = viewport.WorldToScreen(boundingBox.Min);
screenMax = viewport.WorldToScreen(boundingBox.Max);
}
var min = new Geometries.Point(screenMin.X - (32 / 2), screenMax.Y - (32 / 2)); //!!!
var max = new Geometries.Point((min.X + 32), (min.Y + 32)); //!!!
var frame = RoundToPixel(min, max);
//if(symbolStyle.SymbolOffset != null)
// frame.Offset ((float)symbolStyle.SymbolOffset.X, (float)symbolStyle.SymbolOffset.Y);
return frame;
}
示例2: ToSkia
private static SKPath ToSkia(IViewport viewport, Polygon polygon)
{
var vertices = polygon.ExteriorRing.Vertices;
var path = new SKPath();
{
// todo: use transform matrix
var first = viewport.WorldToScreen(vertices[0].X, vertices[0].Y);
path.MoveTo((float)first.X, (float) first.Y);
for (var i = 1; i < vertices.Count; i++)
{
var point = viewport.WorldToScreen(vertices[i].X, vertices[i].Y);
path.LineTo((float) point.X, (float) point.Y);
}
path.Close();
foreach (var interiorRing in polygon.InteriorRings)
{
// note: For Skia inner rings need to be clockwise and outer rings
// need to be counter clockwise (if this is the other way around it also
// seems to work)
// this is not a requirement of the OGC polygon.
var firstInner = viewport.WorldToScreen(interiorRing.Vertices[0].X, interiorRing.Vertices[0].Y);
path.MoveTo((float)firstInner.X, (float)firstInner.Y);
for (var i = 1; i < interiorRing.Vertices.Count; i++)
{
var point = viewport.WorldToScreen(interiorRing.Vertices[i].X, interiorRing.Vertices[i].Y);
path.LineTo((float)point.X, (float)point.Y);
}
}
path.Close();
return path;
}
}
示例3: Render
public static void Render(Graphics graphics, IGeometry feature, IStyle style, IViewport viewport)
{
var stream = ((IRaster)feature).Data;
stream.Position = 0;
var bitmap = new Bitmap(stream);
Geometries.Point min = viewport.WorldToScreen(new Geometries.Point(feature.GetBoundingBox().MinX, feature.GetBoundingBox().MinY));
Geometries.Point max = viewport.WorldToScreen(new Geometries.Point(feature.GetBoundingBox().MaxX, feature.GetBoundingBox().MaxY));
Rectangle destination = RoundToPixel(new RectangleF((float)min.X, (float)max.Y, (float)(max.X - min.X), (float)(min.Y - max.Y)));
graphics.DrawImage(bitmap,
destination,
0, 0, bitmap.Width, bitmap.Height,
GraphicsUnit.Pixel,
new ImageAttributes());
if (DeveloperTools.DeveloperMode)
{
var font = new System.Drawing.Font("Arial", 12);
var message = (GC.GetTotalMemory(true) / 1000).ToString(CultureInfo.InvariantCulture) + " KB";
graphics.DrawString(message, font, new SolidBrush(Color.Black), 10f, 10f);
}
bitmap.Dispose();
}
示例4: ConvertBoundingBox
public static CGRect ConvertBoundingBox(BoundingBox boundingBox, IViewport viewport)
{
var min = viewport.WorldToScreen(boundingBox.Min);
var max = viewport.WorldToScreen(boundingBox.Max);
return RoundToPixel(min, max);
}
示例5: WorldToScreen
private static BoundingBox WorldToScreen(IViewport viewport, BoundingBox boundingBox)
{
var box = new BoundingBox
{
Min = viewport.WorldToScreen(boundingBox.Min),
Max = viewport.WorldToScreen(boundingBox.Max)
};
return box;
}
示例6: WorldToScreen
private static BoundingBox WorldToScreen(IViewport viewport, BoundingBox boundingBox)
{
var first = viewport.WorldToScreen(boundingBox.Min);
var second = viewport.WorldToScreen(boundingBox.Max);
return new BoundingBox
(
Math.Min(first.X, second.X),
Math.Min(first.Y, second.Y),
Math.Max(first.X, second.X),
Math.Max(first.Y, second.Y)
);
}
示例7: RenderLabel
public static CATextLayer RenderLabel(Mapsui.Geometries.Point point, LabelStyle style, IFeature feature, IViewport viewport, string text)
{
// Offset stackOffset,
Mapsui.Geometries.Point p = viewport.WorldToScreen(point);
//var pointF = new xPointF((float)p.X, (float)p.Y);
var label = new CATextLayer ();
var aString = new Foundation.NSAttributedString (text,
new CoreText.CTStringAttributes(){
Font = new CoreText.CTFont("ArialMT", 10)
});
var frame = new CGRect(new CoreGraphics.CGPoint((int)p.X, (int)p.Y), GetSizeForText(0, aString));
//label.Frame = frame;
//frame.Width = (float)(p2.X - p1.X);// + margin);
//frame.Height = (float)(p1.Y - p2.Y);
label.FontSize = 10;
label.ForegroundColor = new CoreGraphics.CGColor (0, 0, 255, 150);
label.BackgroundColor = new CoreGraphics.CGColor (255, 0, 2, 150);
label.String = text;
label.Frame = frame;
Console.WriteLine ("Pos " + label.Frame.X + ":" + label.Frame.Y + " w " + label.Frame.Width + " h " + label.Frame.Height);
// = MonoTouch.UIKit.UIScreen.MainScreen.Scale;
// label.ContentsScale = scale;
return label;
}
示例8: Draw
// todo:
// try to remove the feature argument. LabelStyle should already contain the feature specific text
// The visible feature iterator should create this LabelStyle
public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature,
IGeometry geometry, IDictionary<int, SKBitmapInfo> symbolBitmapCache)
{
var point = geometry as Point;
var destination = viewport.WorldToScreen(point);
if (style is LabelStyle) // case 1) LabelStyle
{
LabelRenderer.Draw(canvas, (LabelStyle) style, feature, (float) destination.X, (float) destination.Y);
}
else if (style is SymbolStyle)
{
var symbolStyle = (SymbolStyle)style;
if ( symbolStyle.BitmapId >= 0) // case 2) Bitmap Style
{
DrawPointWithBitmapStyle(canvas, symbolStyle, destination, symbolBitmapCache);
}
else // case 3) SymbolStyle without bitmap
{
DrawPointWithSymbolStyle(canvas, symbolStyle, destination, symbolStyle.SymbolType);
}
}
else if (style is VectorStyle) // case 4) VectorStyle
{
DrawPointWithVectorStyle(canvas, (VectorStyle) style, destination);
}
else
{
throw new Exception($"Style of type '{style.GetType()}' is not supported for points");
}
}
示例9: WorldToScreen
internal static IEnumerable<Point> WorldToScreen(LineString linearRing, IViewport viewport)
{
var v = new Point[linearRing.Vertices.Count];
for (int i = 0; i < linearRing.Vertices.Count; i++)
v[i] = viewport.WorldToScreen(linearRing.Vertices[i]);
return v;
}
示例10: WorldToScreen
private static List<Point> WorldToScreen(IViewport viewport, IEnumerable<Point> points)
{
var result = new List<Point>();
foreach (var point in points)
{
result.Add(viewport.WorldToScreen(point.X, point.Y));
}
return result;
}
示例11: WorldToScreen
private static void WorldToScreen(IViewport viewport, float[] points)
{
for (var i = 0; i < points.Length / 2; i++)
{
var point = viewport.WorldToScreen(points[i * 2], points[i * 2 + 1]);
points[i * 2] = (float)point.X;
points[i * 2 + 1] = (float)point.Y;
}
}
示例12: RenderBox
private static UIElement RenderBox(BoundingBox box, IViewport viewport)
{
const int margin = 32;
const int halfMargin = margin / 2;
var p1 = viewport.WorldToScreen(box.Min);
var p2 = viewport.WorldToScreen(box.Max);
var rectangle = new Rectangle();
rectangle.Width = p2.X - p1.X + margin;
rectangle.Height = p1.Y - p2.Y + margin;
Canvas.SetLeft(rectangle, p1.X - halfMargin);
Canvas.SetTop(rectangle, p2.Y - halfMargin);
rectangle.Stroke = new SolidColorBrush(Colors.White);
rectangle.StrokeThickness = 2;
return rectangle;
}
示例13: ToUIKit
public static UIBezierPath ToUIKit(this IEnumerable<Point> points, IViewport viewport)
{
var pathGeometry = new UIBezierPath ();
points = points.ToList();
if (points.Any()) {
var first = points.FirstOrDefault ();
var start = viewport.WorldToScreen (first);
pathGeometry.MoveTo(ToUIKit (start));
for (int i = 1; i < points.Count (); i++) {
var point = points.ElementAt (i);
var p = viewport.WorldToScreen (point);
pathGeometry.AddLineTo (new CGPoint ((float)p.X, (float)p.Y));
}
}
return pathGeometry;
}
示例14: RenderBox
private static CALayer RenderBox(BoundingBox box, IViewport viewport)
{
//const int margin = 32;
//const int halfMargin = margin / 2;
var p1 = viewport.WorldToScreen(box.Min);
var p2 = viewport.WorldToScreen(box.Max);
var rectangle = new RectangleF();
rectangle.Width = (float)(p2.X - p1.X);// + margin);
rectangle.Height = (float)(p1.Y - p2.Y);// + margin);
var v = GeometryRenderer.ConvertBoundingBox (box, viewport);
var canvas = new CALayer ();
canvas.Frame = v;
canvas.BorderColor = new MonoTouch.CoreGraphics.CGColor (255, 255, 255, 1);
canvas.BorderWidth = 2;
return canvas;
}
示例15: Draw
public static void Draw(IViewport viewport, IStyle style, IFeature feature, IDictionary<int, TextureInfo> bitmapCache)
{
var point = feature.Geometry as Point;
var destination = viewport.WorldToScreen(point);
if (style is LabelStyle)
{
var labelStyle = (LabelStyle) style;
LabelRenderer.Draw(labelStyle, labelStyle.GetLabelText(feature), (float)destination.X, (float)destination.Y);
}
var symbolStyle = style as SymbolStyle;
if (symbolStyle != null && symbolStyle.BitmapId >= 0) DrawPointWithSymbolStyle(symbolStyle, destination, bitmapCache);
else if (style is VectorStyle) DrawPointWithVectorStyle((VectorStyle)style, destination);
}