简体   繁体   English

桌面应用程序的Windows 8方向

[英]Windows 8 orientation from desktop application

I am developing a windows 8 compatible desktop service that uses a camera preview stream. 我正在开发使用摄像头预览流的Windows 8兼容桌面服务。 On convertible laptops (dell xps 12), i am having trouble with the orientation of the camera. 在可转换笔记本电脑(dell xps 12)上,我在相机方向上遇到麻烦。 basically i need to rotate the stream in sync with the stream. 基本上我需要与流同步旋转流。 I am using windows rt apis (SimpleOrientationSensor, DisplayProperties, DisplayInformation) to get this orientation information. 我正在使用Windows rt api(SimpleOrientationSensor,DisplayProperties,DisplayInformation)来获取此方向信息。

if i only use SimpleOrientationSensor, that does not always change in sync with the windows desktop. 如果我仅使用SimpleOrientationSensor,则并不总是与Windows桌面同步更改。 sometimes the desktop orientation is locked, and SimpleOrientationSensor fires events but the desktop doesn't change orientations (laptop mode). 有时,桌面方向被锁定,并且SimpleOrientationSensor会触发事件,但桌面不会更改方向(笔记本电脑模式)。

I tried using DisplayProperties, but it only reports "landscape" while running from a service, and per http://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.display.displayproperties.aspx , DisplayProperties is deprecated: "DisplayProperties may be altered or unavailable for releases after Windows 8.1. Instead, use DisplayInformation." 我尝试使用DisplayProperties,但是从服务运行时,并且仅通过http://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.display.displayproperties.aspx ,它只会报告“风景”。不推荐使用DisplayProperty:“在Windows 8.1之后的版本中,DisplayProperty可能会更改或不可用。而应使用DisplayInformation。”

if i try to use DisplayInformation.GetForCurrentView() from my desktop app, i get an exception "Windows.Graphics.Display: GetForCurrentView must be called on a thread that is associated with a CoreWindow". 如果我尝试从桌面应用程序使用DisplayInformation.GetForCurrentView(),则会收到异常“ Windows.Graphics.Display:必须在与CoreWindow关联的线程上调用GetForCurrentView”。

I can use SimpleOrientationSensor, but I am wondering if there is an event or property for laptop mode (locked orientation) vs tablet mode (any orientation) in these convertible laptops. 我可以使用SimpleOrientationSensor,但是我想知道在这些可转换笔记本电脑中,笔记本电脑模式(锁定方向)与平板电脑模式(任何方向)是否存在事件或属性。 any help appreciated! 任何帮助表示赞赏!

Update: 更新:

I found the GetSystemMetrics() API, which doesn't seem to work very well (bad error handling). 我找到了GetSystemMetrics()API,该API似乎不能很好地工作(错误处理错误)。 Also found a registry key: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\PriorityControl ConvertibleSlateMode DWORD which seems more reliable, this is what i am implementing with. 还找到了一个注册表项:HKEY_LOCAL_MACHINE \\ SYSTEM \\ CurrentControlSet \\ Control \\ PriorityControl ConvertibleSlateMode DWORD似乎更可靠,这就是我要实现的。

I also found this article: https://software.intel.com/en-us/articles/detecting-slateclamshell-mode-screen-orientation-in-convertible-pc 我也找到了这篇文章: https : //software.intel.com/zh-cn/articles/detecting-slateclamshell-mode-screen-orientation-in-convertible-pc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM