本文整理汇总了C#中Sledge.UI.Viewport2D.WorldToScreen方法的典型用法代码示例。如果您正苦于以下问题:C# Viewport2D.WorldToScreen方法的具体用法?C# Viewport2D.WorldToScreen怎么用?C# Viewport2D.WorldToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sledge.UI.Viewport2D
的用法示例。
在下文中一共展示了Viewport2D.WorldToScreen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render2D
public void Render2D(Viewport2D viewport, MapObject o)
{
if (viewport.Zoom < 1) return;
var entityData = o.GetEntityData();
if (entityData == null) return;
var start = viewport.WorldToScreen(viewport.Flatten(o.BoundingBox.Start));
var end = viewport.WorldToScreen(viewport.Flatten(o.BoundingBox.End));
if (start.X >= viewport.Width || end.X <= 0 || start.Y >= viewport.Height || end.Y <= 0) return;
var text = entityData.Name;
var nameProp = entityData.GetPropertyValue("targetname");
if (!String.IsNullOrWhiteSpace(nameProp)) text += ": " + nameProp;
_printer.Print(text, _printerFont, o.Colour, new RectangleF((float)start.X + 2, viewport.Height - (float)end.Y - _printerFont.Height - 6, viewport.Width, viewport.Height));
}
示例2: RenderBoxText
protected void RenderBoxText(Viewport2D viewport, Coordinate boxStart, Coordinate boxEnd)
{
if (!Sledge.Settings.View.DrawBoxText) return;
var widthText = (Math.Round(boxEnd.X - boxStart.X, 1)).ToString("#.##");
var heightText = (Math.Round(boxEnd.Y - boxStart.Y, 1)).ToString("#.##");
var wid = _printer.Measure(widthText, _printerFont, new RectangleF(0, 0, viewport.Width, viewport.Height));
var hei = _printer.Measure(heightText, _printerFont, new RectangleF(0, 0, viewport.Width, viewport.Height));
boxStart = viewport.WorldToScreen(boxStart);
boxEnd = viewport.WorldToScreen(boxEnd);
var cx = (float)(boxStart.X + (boxEnd.X - boxStart.X) / 2);
var cy = (float)(boxStart.Y + (boxEnd.Y - boxStart.Y) / 2);
var wrect = new RectangleF(cx - wid.BoundingBox.Width / 2, viewport.Height - (float)boxEnd.Y - _printerFont.Height - 18, wid.BoundingBox.Width * 1.2f, wid.BoundingBox.Height);
var hrect = new RectangleF((float)boxEnd.X + 18, viewport.Height - cy - hei.BoundingBox.Height * 0.75f, hei.BoundingBox.Width * 1.2f, hei.BoundingBox.Height);
GL.Disable(EnableCap.CullFace);
_printer.Begin();
_printer.Print(widthText, _printerFont, BoxColour, wrect);
_printer.Print(heightText, _printerFont, BoxColour, hrect);
_printer.End();
GL.Enable(EnableCap.CullFace);
}
示例3: Render2D
public void Render2D(Viewport2D viewport, MapObject o)
{
if (viewport.Zoom < 1) return;
var entityData = o.GetEntityData();
if (entityData == null) return;
var start = viewport.WorldToScreen(viewport.Flatten(o.BoundingBox.Start));
var end = viewport.WorldToScreen(viewport.Flatten(o.BoundingBox.End));
if (start.X >= viewport.Width || end.X <= 0 || start.Y >= viewport.Height || end.Y <= 0) return;
var text = entityData.Name;
var nameProp = entityData.GetPropertyValue("targetname");
if (!String.IsNullOrWhiteSpace(nameProp)) text += ": " + nameProp;
// Center the text horizontally
var wid = _printer.Measure(text, _printerFont, new RectangleF(0, 0, viewport.Width, viewport.Height));
var cx = (float)(start.X + (end.X - start.X) / 2);
var bounds = new RectangleF(cx - wid.BoundingBox.Width / 2, viewport.Height - (float)end.Y - _printerFont.Height - 6, viewport.Width, viewport.Height);
_printer.Print(text, _printerFont, o.Colour, bounds);
}
示例4: MouseOverPivot
private bool MouseOverPivot(Viewport2D vp, ViewportEvent e)
{
if (Document.Selection.IsEmpty()) return false;
var pivot = vp.WorldToScreen(vp.Flatten(_pivotPoint));
var x = e.X;
var y = vp.Height - e.Y;
return pivot.X > x - 8 && pivot.X < x + 8 &&
pivot.Y > y - 8 && pivot.Y < y + 8;
}