private API.SRect GetWindownRect(IntPtr hWnd) { try { if (hWnd == IntPtr.Zero) { return(new API.SRect()); } API.SPoint clientPoint = new API.SPoint(); if (!API.ClientToScreen(hWnd, ref clientPoint)) { Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.GetWindownRect", $"error{Marshal.GetLastWin32Error()} hWnd:{hWnd}"); return(new API.SRect()); } API.SRect lpRect = new API.SRect(); if (!API.GetClientRect(hWnd, out lpRect)) { Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.GetWindownRect", $"error{Marshal.GetLastWin32Error()} hWnd:{hWnd}"); return(new API.SRect()); } return(new API.SRect(clientPoint.x, clientPoint.y, lpRect.right + clientPoint.x, lpRect.bottom + clientPoint.y)); } catch (Exception ex) { Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.GetWindownRect", ex); return(new API.SRect()); } }
/// <summary> /// 让UI来更新 => 为了保证 其他脚本调用时不在UI获取到那帧数据前 /// </summary> public void Process() { if (!IsUsing) { return; } if (m_LogLevel <= Common.LogLevel.DEBUG) { Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.Update", $"start"); } /*-- 窗口数据 --*/ m_projectorWindowRect = GetWindownRect(m_projectorHandle); m_projectorMonitorRect = F3Device.DeviceManager.Instance.FindMonitorRect(m_projectorWindowRect); m_u3dWindowRect = GetWindownRect(Window32Msg.Instance.m_u3dHandle); m_u3dMonitorRect = F3Device.DeviceManager.Instance.FindMonitorRect(m_u3dWindowRect); /*-- 鼠标位置 --*/ API.GetCursorPos(out m_curFrameMouseScreenPosition); if (m_LogLevel <= Common.LogLevel.DEBUG) { Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.Update", $"curFrameMouse={m_curFrameMouseScreenPosition.x} {m_curFrameMouseScreenPosition.y} "); } //处理消息队列 //在这里计算当前帧数据 UpdateMsg(); //输出对应使用数据 UpdatePosition(); UpdateTouchFeedback(); if (m_LogLevel <= Common.LogLevel.DEBUG) { Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.Update", $"end"); } }