【问题标题】:WPF detect reverse landscape orientationWPF检测反向横向
【发布时间】:2015-06-10 12:14:28
【问题描述】:

我知道如何detect general orientations,例如纵向或横向,但是有没有办法知道当前方向是左纵向还是右纵向、横向还是反向横向?

我需要了解反向,因为在我的视频录制应用程序中,当设备旋转时,实时预览窗口看起来很奇怪。

【问题讨论】:

  • 可能你将不得不消费一些像OrientationChanged这样的事件。
  • @MangeshGhotage 但我在哪里可以找到发布此类事件的对象? Window 或 UserControl 没有。
  • @MangeshGhotage 我在问题中提到(这会导致您发布的链接)这种方法不会去任何地方。

标签: wpf tablet screen-orientation


【解决方案1】:

要获得准确的方向,您可以收听链接中提到的DisplaySettingsChanged 事件。然后您可以检索System.Windows.Forms.SystemInformation.ScreenOrientation 枚举参数。它可以有following values 之一:

  • 角度0
  • 角度90
  • 角度180
  • 角度270

要能够在 WPF 中使用它,您需要添加对 System.Windows.Forms 的引用。

private int GetOrientation()
{
    return ((int) System.Windows.Forms.SystemInformation) * 90;
}

【讨论】:

    猜你喜欢
    • 2013-08-05
    • 2012-07-24
    • 1970-01-01
    • 2011-07-02
    • 2011-09-30
    • 2011-01-30
    • 1970-01-01
    • 1970-01-01
    • 2011-03-01
    相关资源
    最近更新 更多