/// <summary> /// Update labels on window with Device data /// </summary> /// <param name="Controller"></param> public void UpdateRawAxis(RawInputController Controller) { Lbl_RawInput.Text = "[ 0x" + Controller.Computed_X.ToString("X8") + ", " + Controller.Computed_Y.ToString("X8") + " ]"; Lbl_AxisXMin.Text = Controller.Axis_X_Min.ToString() + " [ 0x" + Controller.Axis_X_Min.ToString("X8") + " ]"; Lbl_AxisXMax.Text = Controller.Axis_X_Max.ToString() + " [ 0x" + Controller.Axis_X_Max.ToString("X8") + " ]"; Lbl_AxisYMin.Text = Controller.Axis_Y_Min.ToString() + " [ 0x" + Controller.Axis_Y_Min.ToString("X8") + " ]"; Lbl_AxisYMax.Text = Controller.Axis_Y_Max.ToString() + " [ 0x" + Controller.Axis_Y_Max.ToString("X8") + " ]"; // Update screen/client info GetScreenResolution(); GetClientSize(); // Convert RAW to SCREEN Controller.Computed_X = ScreenScale(Controller.Computed_X, Controller.Axis_X_Min, Controller.Axis_X_Max, 0, _ScreenWidth); Controller.Computed_Y = ScreenScale(Controller.Computed_Y, Controller.Axis_Y_Min, Controller.Axis_Y_Max, 0, _ScreenHeight); _OnScreenX = Controller.Computed_X; _OnScreenY = Controller.Computed_Y; Lbl_OnScreen.Text = _OnScreenX.ToString() + "x" + _OnScreenY.ToString(); // Convert SCREEN to CLIENT AxisInfo i = new AxisInfo(); i.pTarget.X = Controller.Computed_X; i.pTarget.Y = Controller.Computed_Y; ClientScale(i); Lbl_OnClient.Text = _OnClientX.ToString() + "x" + _OnClientY.ToString(); // Display mark on client, moved to Timer to not overload GUI thread with too many rawinout data drawing //this.Invalidate(); //Custom crosshair with PNG, not displaying well at all.... //SetTargetLocation(i.pTarget.X, i.pTarget.Y); }
/// <summary> /// Convert screen location of pointer to Client area location /// </summary> private void ClientScale(AxisInfo AxisData) { //_OnClientX = mouse.pTarget.X * _ClientWidth / _ScreenWidth; //_OnClientY = mouse.pTarget.Y * _ClientHeight / _ScreenHeight; //_OnClientX = mouse.pTarget.X - this.ClientRectangle.Left; //_OnClientY = mouse.pTarget.Y - this.ClientRectangle.Top; POINT lp = new POINT(AxisData.pTarget.X, AxisData.pTarget.Y); Win32API.ScreenToClient(this.Handle, ref lp); _OnClientX = lp.X; _OnClientY = lp.Y; }