日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

重新想象 Windows 8 Store Apps (59) - 锁屏

發布時間:2023/12/15 windows 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 重新想象 Windows 8 Store Apps (59) - 锁屏 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
原文:重新想象 Windows 8 Store Apps (59) - 鎖屏

[源碼下載]


重新想象 Windows 8 Store Apps (59) - 鎖屏



作者:webabcd


介紹
重新想象 Windows 8 Store Apps 之?鎖屏

  • 登錄鎖屏,獲取當前程序的鎖屏權限,從鎖屏中移除
  • 發送徽章或文本到鎖屏
  • 將一個 app 的多個 tile 綁定到鎖屏
  • 自定義鎖屏圖片



示例
1、演示如何登錄鎖屏,獲取當前程序的鎖屏權限,從鎖屏中移除
LockScreen/AccessLockScreen.xaml

<Pagex:Class="XamlDemo.LockScreen.AccessLockScreen"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:XamlDemo.LockScreen"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d"><Grid Background="Transparent"><StackPanel Margin="120 0 0 0"><TextBlock Name="lblMsg" FontSize="14.667" /><Button Name="btnRequestAccess" Content="請求登錄鎖屏" Margin="0 10 0 0" Click="btnRequestAccess_Click" /><Button Name="btnGetAccessStatus" Content="獲取當前程序的鎖屏權限" Margin="0 10 0 0" Click="btnGetAccessStatus_Click" /><Button Name="btnRemoveAccess" Content="從鎖屏中移除" Margin="0 10 0 0" Click="btnRemoveAccess_Click" /></StackPanel></Grid> </Page>

LockScreen/AccessLockScreen.xaml.cs

/** 演示如何登錄鎖屏,獲取當前程序的鎖屏權限,從鎖屏中移除* * 注:* 要想請求鎖屏權限,需要后臺任務支持“推送通知”或“控制通道”*/using System; using Windows.ApplicationModel.Background; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls;namespace XamlDemo.LockScreen {public sealed partial class AccessLockScreen : Page{public AccessLockScreen(){this.InitializeComponent();}private async void btnRequestAccess_Click(object sender, RoutedEventArgs e){try{// 向系統請求登錄鎖屏,會彈出確認對話框// 需要后臺任務支持“推送通知”或“控制通道”,否則會拋出異常// 不能在模擬器中運行// 如果 BackgroundAccessStatus 不等于 Unspecified,則即使調用 RequestAccessAsync() 也不會出現對話框,需要用戶去“設置”中去添加或移除鎖屏應用BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();/** BackgroundAccessStatus - 當前 app 的鎖屏權限* Unspecified - 用戶尚未選擇* Denied - 被用戶拒絕* AllowedWithAlwaysOnRealTimeConnectivity - 用于允許了,且支持實時連接,即使電量低* AllowedMayUseActiveRealTimeConnectivity - 用于允許了,且支持實時連接,但是如果電量低則無法實時連接*/lblMsg.Text = "RequestAccessAsync(): " + status.ToString();}catch (Exception ex){lblMsg.Text = ex.ToString();}}private void btnGetAccessStatus_Click(object sender, RoutedEventArgs e){try{// 獲取當前應用程序的鎖屏權限BackgroundAccessStatus status = BackgroundExecutionManager.GetAccessStatus();lblMsg.Text = "GetAccessStatus(): " + status.ToString();}catch (Exception ex){lblMsg.Text = ex.ToString();}}private void btnRemoveAccess_Click(object sender, RoutedEventArgs e){try{// 將當前應用程序從鎖屏中移除 BackgroundExecutionManager.RemoveAccess();lblMsg.Text = "RemoveAccess()";}catch (Exception ex){lblMsg.Text = ex.ToString();}}} }


2、演示如何發送徽章或文本到鎖屏
LockScreen/SendNotification.xaml

<Pagex:Class="XamlDemo.LockScreen.SendNotification"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:XamlDemo.LockScreen"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d"><Grid Background="Transparent"><StackPanel Margin="120 0 0 0"><Button Name="btnSendBadge" Content="send badage to lock screen" Click="btnSendBadge_Click" /><Button Name="btnSendTile" Content="send tile text to lock screen" Margin="0 10 0 0" Click="btnSendTile_Click" /></StackPanel></Grid> </Page>

LockScreen/SendNotification.xaml.cs

/** 演示如何發送徽章或文本到鎖屏* * 注:* 如果需要發送文本到鎖屏,需要手動在“設置”中將 app 添加到“選擇要顯示詳細狀態的應用”中* * 另:* 關于 tile 和 badge 請參見:XamlDemo/Tile*/using NotificationsExtensions.BadgeContent; using NotificationsExtensions.TileContent; using Windows.UI.Notifications; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls;namespace XamlDemo.LockScreen {public sealed partial class SendNotification : Page{public SendNotification(){this.InitializeComponent();}private void btnSendBadge_Click(object sender, RoutedEventArgs e){// 發送 badge 到鎖屏BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(3);BadgeNotification badge = badgeContent.CreateNotification();BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();badgeUpdater.Update(badge);}private void btnSendTile_Click(object sender, RoutedEventArgs e){// 發送文本到鎖屏,前提是此 app 在“選擇要顯示詳細狀態的應用”中ITileWideSmallImageAndText03 tileContent = TileContentFactory.CreateTileWideSmallImageAndText03();tileContent.TextBodyWrap.Text = "hello webabcd";tileContent.Image.Src = "ms-appx:///Assets/Logo.png";tileContent.RequireSquareContent = false;TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());}} }


3、演示如何將一個 app 的多個 tile 綁定到鎖屏
LockScreen/MultipleTiles.xaml

<Pagex:Class="XamlDemo.LockScreen.MultipleTiles"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:XamlDemo.LockScreen"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d"><Grid Background="Transparent"><StackPanel Margin="120 0 0 0"><Button Name="btnOnlyBadge" Content="只能發送 badge 的可以綁定到鎖屏的 SecondaryTile" Click="btnOnlyBadge_Click" /><Button Name="btnBadgeAndText" Content="既能發送 badge 又能發送 text 的可以綁定到鎖屏的 SecondaryTile" Margin="0 10 0 0" Click="btnBadgeAndText_Click" /></StackPanel></Grid> </Page>

LockScreen/MultipleTiles.xaml.cs

/** 演示如何將一個 app 的多個 tile 綁定到鎖屏* * 要想將 SecondaryTile 綁定到鎖屏,需要注意:* 1、需要設置 SecondaryTile 的 LockScreenBadgeLogo* 2、如果需要文本支持則還需要設置 SecondaryTile 的 LockScreenDisplayBadgeAndTileText 為 true* 3、需要手動在“設置”中將 SecondaryTile 添加到鎖屏,當然如果需要文本支持則需要手動將 app 添加到“選擇要顯示詳細狀態的應用”中*/using NotificationsExtensions.BadgeContent; using NotificationsExtensions.TileContent; using System; using Windows.UI.Notifications; using Windows.UI.Popups; using Windows.UI.StartScreen; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using XamlDemo.Common;namespace XamlDemo.LockScreen {public sealed partial class MultipleTiles : Page{private string _tile1Id = "123";private string _tile2Id = "456";public MultipleTiles(){this.InitializeComponent();}// 僅支持 badge 的可以登錄鎖屏的 SecondaryTileprivate async void btnOnlyBadge_Click(object sender, RoutedEventArgs e){SecondaryTile secondTile = new SecondaryTile(_tile1Id,"testOnlyBadge","testOnlyBadge","argument1",TileOptions.ShowNameOnLogo,new Uri("ms-appx:///Assets/Logo.png"));// 需要指定 LockScreenBadgeLogosecondTile.LockScreenBadgeLogo = new Uri("ms-appx:///Assets/BadgeLogo.png");bool isPinned = await secondTile.RequestCreateForSelectionAsync(Helper.GetElementRect((FrameworkElement)sender), Placement.Above);if (isPinned){BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(2);BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(_tile1Id).Update(badgeContent.CreateNotification());}}// 即支持徽章又支持文本的可以登錄鎖屏的 SecondaryTileprivate async void btnBadgeAndText_Click(object sender, RoutedEventArgs e){SecondaryTile secondTile = new SecondaryTile(_tile2Id,"testBadgeAndText","testBadgeAndText","argument2",TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo,new Uri("ms-appx:///Assets/Logo.png"),new Uri("ms-appx:///Assets/WideLogo.png"));// 需要指定 LockScreenBadgeLogosecondTile.LockScreenBadgeLogo = new Uri("ms-appx:///Assets/BadgeLogo.png");// 需要設置 LockScreenDisplayBadgeAndTileText 為 truesecondTile.LockScreenDisplayBadgeAndTileText = true;bool isPinned = await secondTile.RequestCreateForSelectionAsync(Helper.GetElementRect((FrameworkElement)sender), Placement.Above);if (isPinned){ITileWideText03 tileContent = TileContentFactory.CreateTileWideText03();tileContent.TextHeadingWrap.Text = "hello webabcd";tileContent.RequireSquareContent = false;TileUpdateManager.CreateTileUpdaterForSecondaryTile(_tile2Id).Update(tileContent.CreateNotification());}}} }


4、演示如何自定義鎖屏圖片
LockScreen/CustomLockScreenImage.xaml

<Pagex:Class="XamlDemo.LockScreen.CustomLockScreenImage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:XamlDemo.LockScreen"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d"><Grid Background="Transparent"><StackPanel Margin="120 0 0 0"><Button Name="btnDemo" Content="自定義鎖屏圖片" Click="btnDemo_Click" /><Image Name="img" Width="200" Height="200" Margin="0 10 0 0" HorizontalAlignment="Left" /></StackPanel></Grid> </Page>

LockScreen/CustomLockScreenImage.xaml.cs

/** 演示如何自定義鎖屏圖片*/using System; using Windows.Storage; using Windows.Storage.Pickers; using Windows.Storage.Streams; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media.Imaging; using XamlDemo.Common;namespace XamlDemo.LockScreen {public sealed partial class CustomLockScreenImage : Page{public CustomLockScreenImage(){this.InitializeComponent();}private async void btnDemo_Click(object sender, RoutedEventArgs e){if (Helper.EnsureUnsnapped()){FileOpenPicker imagePicker = new FileOpenPicker{ViewMode = PickerViewMode.Thumbnail,SuggestedStartLocation = PickerLocationId.PicturesLibrary,FileTypeFilter = { ".jpg", ".jpeg", ".png", ".bmp" }};StorageFile imageFile = await imagePicker.PickSingleFileAsync();if (imageFile != null){// 將指定的圖片設置為鎖屏圖片await Windows.System.UserProfile.LockScreen.SetImageFileAsync(imageFile);// 獲取當前的鎖屏圖片IRandomAccessStream imageStream = Windows.System.UserProfile.LockScreen.GetImageStream();if (imageStream != null){BitmapImage lockScreenImage = new BitmapImage();lockScreenImage.SetSource(imageStream);img.Source = lockScreenImage;}}}}} }



OK
[源碼下載]

總結

以上是生活随笔為你收集整理的重新想象 Windows 8 Store Apps (59) - 锁屏的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 幸福宝在线观看 | 国产91在线精品 | 一级性爱视频 | 亚洲一区二区三区免费看 | 小箩莉末发育娇小性色xxxx | 亚洲视频免费在线 | 欧美成人做爰大片免费看黄石 | 亚洲第一偷拍 | 国产一区二区三区四区三区四 | 51成人网 | 久久久99精品国产一区二区三区 | 福利社91 | 色一五月 | 中文字幕日韩一区二区三区 | 久久丝袜视频 | 中文字幕电影一区 | 欧美中文字幕在线观看 | av第一福利大全导航 | 精品免费国产一区二区三区 | 国模人体私拍xvideos | 日本xxx在线播放 | 穿越异世荒淫h啪肉np文 | 香蕉在线视频播放 | 亚洲综合av一区二区三区 | 国产黑丝av| 黄色av大全 | 生活片av| 艳妇臀荡乳欲伦交换在线看 | 夜夜艹天天干 | 日韩无码电影 | 欧美一区二区三区四区在线观看 | 日本福利片在线观看 | 天天操穴 | 熟妇人妻精品一区二区三区视频 | 欧美熟妇激情一区二区三区 | 亚欧乱色 | 日韩五码在线 | 久久久久久久久久久91 | 色偷偷免费 | 美女一级视频 | 精品无码久久久久久久久成人 | 亚洲欧美另类在线视频 | 美女av片| 国产一级片a | 国产色区 | 最全aⅴ番号库网 | 性欧美大战久久久久久久久 | 色婷婷久久综合中文久久蜜桃av | 亚洲国产剧情 | 久久靖品 | www伊人 | 亚洲男人天堂2019 | 免费无码毛片一区二三区 | 亚洲色偷精品一区二区三区 | wwww欧美 | 人人爽人人爽人人爽人人爽 | 人妖一区二区三区 | 国产一区二区黄色 | 国产原创在线 | 视频免费观看在线 | 强行糟蹋人妻hd中文 | 致命弯道8在线观看免费高清完整 | 男女草逼网站 | 欧美寡妇性猛交 | 无码一区二区三区在线 | 日韩精品――色哟哟 | 亚洲中文无码久久 | 一区二区三区四区在线观看视频 | 色婷婷久久久亚洲一区二区三区 | 性奶老妇 视频 | 香蕉视频免费在线播放 | 国产乱人视频 | 国产人妻精品一区二区三区不卡 | 中日韩黄色片 | 国产片淫乱18一级毛片动态图 | 丁香花电影免费播放电影 | 熟女人妻视频 | av精选| 日韩精品免费看 | 尤物视频官网 | 操一操av| 黄色大尺度视频 | 久久久无码18禁高潮喷水 | 亚洲欧美系列 | 男生插女生视频在线观看 | 黄色片a级 | 国产成人在线视频网站 | www.youjizz.com国产| 国产爱搞| 丰满熟妇肥白一区二区在线 | 黑人精品一区二区三区不 | 激情图片在线观看 | 九九热精品 | 二区三区不卡 | 国产高清精品在线 | 2021狠狠干| 伊人久久大香线蕉综合网站 | 日韩成人在线免费视频 | 深夜网站在线观看 |