PointToClient() public method

Transforms the specified point from screen to client coordinates.
public PointToClient ( Point point ) : Point
point Point /// A to transform. ///
return Point
Exemplo n.º 1
0
        private unsafe void UpdateImGuiInput(IO io)
        {
            MouseState cursorState = Mouse.GetCursorState();
            MouseState mouseState  = Mouse.GetState();

            if (_nativeWindow.Focused)
            {
                Point windowPoint = _nativeWindow.PointToClient(new Point(cursorState.X, cursorState.Y));
                io.MousePosition = new System.Numerics.Vector2(windowPoint.X / io.DisplayFramebufferScale.X, windowPoint.Y / io.DisplayFramebufferScale.Y);
            }
            else
            {
                io.MousePosition = new System.Numerics.Vector2(-1f, -1f);
            }

            io.MouseDown[0] = mouseState.LeftButton == ButtonState.Pressed;
            io.MouseDown[1] = mouseState.RightButton == ButtonState.Pressed;
            io.MouseDown[2] = mouseState.MiddleButton == ButtonState.Pressed;

            float newWheelPos = mouseState.WheelPrecise;
            float delta       = newWheelPos - _wheelPosition;

            _wheelPosition = newWheelPos;
            io.MouseWheel  = delta;
        }
Exemplo n.º 2
0
        public static void Main()
        {
            using (var window = new NativeWindow())
            {
                Trace.WriteLine(String.Format("Window bounds: {0}", window.Bounds));
                Trace.WriteLine(String.Format("Window client: {0}", window.ClientRectangle));

                Point pclient = new Point(100, 100);
                Point pscreen = window.PointToScreen(pclient);
                Point ptest = window.PointToClient(pscreen);
                Trace.WriteLine(String.Format("Client: {0} -> Screen: {1} -> Client: {2}",
                    pclient, pscreen, ptest));
                Trace.WriteLine(String.Format("Test {0}",
                    ptest == pclient ? "succeeded" : "failed"));

                pscreen = new Point(100, 100);
                pclient = window.PointToClient(pscreen);
                ptest = window.PointToScreen(pclient);
                Trace.WriteLine(String.Format("Screen: {0} -> Client: {1} -> Screen: {2}",
                    pscreen, pclient, ptest));
                Trace.WriteLine(String.Format("Test {0}",
                    ptest == pscreen ? "succeeded" : "failed"));
            }
        }