protected override void Draw(IDrawDevice inDevice)
        {
            base.Draw(inDevice);

            _listArea[0] = inDevice.GetScreenCoord(_points[5].WorldCoords).Xy;
            _listArea[1] = inDevice.GetScreenCoord(_points[6].WorldCoords).Xy;
            _listArea[2] = inDevice.GetScreenCoord(_points[10].WorldCoords).Xy;
            _listArea[3] = inDevice.GetScreenCoord(_points[9].WorldCoords).Xy;
        }
        void ICmpRenderer.Draw(IDrawDevice device)
        {
            Canvas  canvas   = new Canvas(device);
            Vector2 mousePos = DualityApp.Mouse.Pos;

            // Make sure we'll draw below the sample info text
            canvas.State.ZOffset = 1.0f;

            // Draw drag anchor markers when dragging an object
            if (this.dragObj != null)
            {
                Transform dragTransform = this.dragObj.GameObj.Transform;
                Vector2   worldAnchor   = dragTransform.GetWorldPoint(this.dragAnchor);
                Vector2   screenAnchor  = device.GetScreenCoord(worldAnchor).Xy;
                canvas.State.ColorTint = this.interactionColor;
                if ((screenAnchor - mousePos).Length < 10.0f)
                {
                    canvas.DrawLine(mousePos.X, mousePos.Y, screenAnchor.X, screenAnchor.Y);
                }
                else
                {
                    canvas.DrawDashLine(mousePos.X, mousePos.Y, screenAnchor.X, screenAnchor.Y);
                }
                canvas.FillCircle(screenAnchor.X, screenAnchor.Y, 3.0f);
                canvas.State.ColorTint = this.defaultColor;
            }

            // When the mouse is hovering over the game area and the system cursor
            // is disabled, draw a custom cursor as a replacement
            if (!DualityApp.UserData.SystemCursorVisible && DualityApp.Mouse.IsAvailable)
            {
                canvas.State.ColorTint = (this.dragObj != null) ? this.interactionColor : this.defaultColor;
                canvas.FillThickLine(
                    mousePos.X - 5,
                    mousePos.Y,
                    mousePos.X + 5,
                    mousePos.Y,
                    2.0f);
                canvas.FillThickLine(
                    mousePos.X,
                    mousePos.Y - 5,
                    mousePos.X,
                    mousePos.Y + 5,
                    2.0f);
                canvas.State.ColorTint = this.defaultColor;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Transforms world space coordinates to screen space coordinates.
 /// </summary>
 /// <param name="spacePos"></param>
 /// <param name="device"></param>
 /// <returns></returns>
 public static Vector3 GetScreenCoord(this IDrawDevice device, Vector2 spacePos)
 {
     return(device.GetScreenCoord(new Vector3(spacePos)));
 }