Esempio n. 1
0
        public override void Render(IViewport viewport, OrthographicCamera camera, Vector3 worldMin, Vector3 worldMax, Graphics graphics)
        {
            if (HighlightedViewport != viewport)
            {
                return;
            }

            var b     = GetRectangle(camera);
            var start = camera.WorldToScreen(camera.Expand(b.Start));
            var end   = camera.WorldToScreen(camera.Expand(b.End));

            graphics.SmoothingMode = SmoothingMode.HighQuality;

            using (var br = new SolidBrush(State.FillColour))
            {
                graphics.FillRectangle(br, start.X, end.Y, end.X - start.X, start.Y - end.Y);
            }
            if (Handle == ResizeHandle.Center && SnappedMoveOrigin != null)
            {
                const int size = 4;
                var       orig = camera.WorldToScreen(camera.Expand(SnappedMoveOrigin.Value));

                graphics.DrawLine(Pens.Yellow, orig.X - size, orig.Y - size, orig.X + size, orig.Y + size);
                graphics.DrawLine(Pens.Yellow, orig.X + size, orig.Y - size, orig.X - size, orig.Y + size);
            }

            graphics.SmoothingMode = SmoothingMode.Default;
        }
Esempio n. 2
0
        public override void Render(IViewport viewport, OrthographicCamera camera, Vector3 worldMin, Vector3 worldMax, I2DRenderer im)
        {
            if (Handle == ResizeHandle.Center)
            {
                if (HighlightedViewport != viewport)
                {
                    return;
                }

                var start = camera.WorldToScreen(BoxState.Start);
                var end   = camera.WorldToScreen(BoxState.End);

                im.AddRectFilled(start.ToVector2(), end.ToVector2(), State.FillColour);

                if (SnappedMoveOrigin != null)
                {
                    const int size = 4;
                    var       orig = camera.WorldToScreen(camera.Expand(SnappedMoveOrigin.Value));

                    im.AddLine(new Vector2(orig.X - size, orig.Y - size), new Vector2(orig.X + size, orig.Y + size), Color.Yellow, 1, false);
                    im.AddLine(new Vector2(orig.X + size, orig.Y - size), new Vector2(orig.X - size, orig.Y + size), Color.Yellow, 1, false);
                }
            }
            else
            {
                base.Render(viewport, camera, worldMin, worldMax, im);
            }
        }
Esempio n. 3
0
 public override void EndDrag(MapDocument document, MapViewport viewport, OrthographicCamera camera, ViewportEvent e, Vector3 position)
 {
     State.Viewport = null;
     State.Action   = BoxAction.Drawn;
     State.End      = Tool.SnapIfNeeded(camera.Expand(position)) + camera.GetUnusedCoordinate(State.End);
     State.FixBounds();
     base.EndDrag(document, viewport, camera, e, position);
 }
Esempio n. 4
0
        private IMapObject SelectionTest(OrthographicCamera camera, ViewportEvent e)
        {
            // Create a box to represent the click, with a tolerance level
            var unused    = camera.GetUnusedCoordinate(new Vector3(100000, 100000, 100000));
            var tolerance = 4 / camera.Zoom; // Selection tolerance of four pixels
            var used      = camera.Expand(new Vector3(tolerance, tolerance, 0));
            var add       = used + unused;
            var click     = camera.ScreenToWorld(e.X, e.Y);
            var box       = new Box(click - add, click + add);

            return(GetLineIntersections(box).FirstOrDefault());
        }
Esempio n. 5
0
        public override void StartDrag(MapDocument document, MapViewport viewport, OrthographicCamera camera, ViewportEvent e, Vector3 position)
        {
            State.Viewport  = viewport;
            State.Action    = BoxAction.Drawing;
            State.OrigStart = State.Start;
            State.OrigEnd   = State.End;
            var st  = RememberedDimensions == null ? Vector3.Zero : camera.GetUnusedCoordinate(RememberedDimensions.Start);
            var wid = RememberedDimensions == null ? Vector3.Zero : camera.GetUnusedCoordinate(RememberedDimensions.End - RememberedDimensions.Start);

            State.Start = Tool.SnapIfNeeded(camera.Expand(position) + st);
            State.End   = State.Start + wid;
            base.StartDrag(document, viewport, camera, e, position);
        }
Esempio n. 6
0
 public override void Drag(MapDocument document, MapViewport viewport, OrthographicCamera camera, ViewportEvent e, Vector3 lastPosition, Vector3 position)
 {
     State.End = Tool.SnapIfNeeded(camera.Expand(position)) + camera.GetUnusedCoordinate(State.End);
     base.Drag(document, viewport, camera, e, lastPosition, position);
 }
Esempio n. 7
0
 public override void Drag(MapViewport viewport, OrthographicCamera camera, ViewportEvent e, Vector3 lastPosition, Vector3 position)
 {
     Position = camera.Expand(position) + camera.GetUnusedCoordinate(Position);
     base.Drag(viewport, camera, e, lastPosition, position);
 }
Esempio n. 8
0
 public override void Drag(MapViewport viewport, OrthographicCamera camera, ViewportEvent e,
                           Vector3 lastPosition, Vector3 position)
 {
     Position = _vmScaleTool.SnapIfNeeded(camera.Expand(position) + camera.GetUnusedCoordinate(Position));
     OnDragMoved();
 }
 public override void Drag(MapDocument document, MapViewport viewport, OrthographicCamera camera,
                           ViewportEvent e, Vector3 lastPosition, Vector3 position)
 {
     Position = _tool.SnapToSelection(camera.Expand(position) + camera.GetUnusedCoordinate(Position), camera);
     OnDragMoved();
 }