Windows Phone APP中禁用截图
生活随笔
收集整理的這篇文章主要介紹了
Windows Phone APP中禁用截图
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
原文:Windows Phone APP中禁用截圖
Windows Phone 8 有系統(tǒng)自帶的截圖功能,快捷鍵:電源鍵+Win鍵,可以隨意截圖。
Windows Phone 更新GDR2后新增了一個隱藏功能,允許APP禁用截圖功能。
PhoneApplicationPage.IsScreenCaptureEnabled?這個隱藏的屬性需要通過反射來訪問和修改狀態(tài)。
public static bool CanSetScreenCaptureEnabled(this PhoneApplicationPage page){return Environment.OSVersion.Version >= new Version(8, 0, 10322);}public static void SetScreenCaptureEnabled(this PhoneApplicationPage page, bool enabled){var propertyInfo = typeof(PhoneApplicationPage).GetProperty("IsScreenCaptureEnabled");if (propertyInfo == null){throw new NotSupportedException("Not supported in this Windows Phone version!");}propertyInfo.SetValue(page, enabled);}public static bool GetScreenCaptureEnabled(this PhoneApplicationPage page){var propertyInfo = typeof(PhoneApplicationPage).GetProperty("IsScreenCaptureEnabled");if (propertyInfo == null){throw new NotSupportedException("Not supported in this Windows Phone version!");}return (bool)propertyInfo.GetValue(page);}}調(diào)用CanSetScreenCaptureEnabled()方法檢測Windows Phone版本是否符合要求(version 8.0.10322以上)。符合條件,然后就通過擴(kuò)展方法GetScreenCaptureEnabled()和SetScreenCaptureEnabled()來修改PhoneApplicationPage.IsScreenCaptureEnabled屬性。
使用:
目前在真機(jī)上測試有效,沒弄懂模擬器如何像真機(jī)一樣截圖,所以模擬器上沒成。
效果如下圖
?
以后就有些東西不能截圖了( ╯□╰ )
?對了,需要看原文的戳:Disabling screenshot functionality in a Windows Phone app ?。
總結(jié)
以上是生活随笔為你收集整理的Windows Phone APP中禁用截图的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux中如何恢复被误删的数据文件
- 下一篇: squid反向代理(实现缓存)加速web