示例#1
0
        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
0
        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
0
        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
0
        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;
        }