1. 程式人生 > >通知(Tile): secondary tile 模板之圖片, secondary tile 模板之分組

通知(Tile): secondary tile 模板之圖片, secondary tile 模板之分組

/*
 * 本例用於演示 tile 顯示模板的圖片相關的知識點
 * 
 * 
 * tile -  磁貼元素
 * visual - 可視元素
 *     addImageQuery
 *         是否將當前的部分環境資訊以 url 引數的方式附加到圖片地址中(一個 bool 值,預設值為 false)
 * binding - 繫結元素
 *     addImageQuery
 *         是否將當前的部分環境資訊以 url 引數的方式附加到圖片地址中(一個 bool 值,預設值為 false)
 *     hint-presentation - 內容的呈現方式
 *         none - 預設值
 *         photos - 讓最多 12 張圖片以幻燈片的方式迴圈顯示,圖片間切換時會有一些過渡效果(僅支援圖片,不支援文字)
 *         people - 類似 win10 的“人脈”應用,即將多張圖片圓形剪裁併堆在磁貼上,再增加一些動畫效果(僅支援圖片,不支援文字)
 * image - 圖片元素
 *     src - 圖片地址(ms-appx:/// 或 ms-appdata:///local/ 或 http:// 或 https://)
 *     hint-removeMargin - 是否移除圖片的 margin(預設值為 false)
 *         顯示圖片時,圖片自己預設會帶著 8 個畫素的 margin,此屬性用於指定是否將這 8 個畫素的 margin 去掉
 *         注:磁貼自帶的 padding 為 8 個畫素,所以即使設定了 hint-removeMargin='true' 圖片和磁貼邊緣還是有距離的
 *     placement - 圖片顯示方式
 *         inline - 圖片顯示在磁貼內部(預設值)
 *         background - 圖片作為磁貼的背景
 *         peek - 圖片與文字輪流顯示
 *     hint-overlay - 在圖片上覆蓋一層黑色的遮罩,並設定遮罩的不透明度(0 - 100)
 *         此屬性只對 background 圖片和 peek 圖片有效
 *         在 binding 節點也可以設定此屬性
 *     hint-align - 圖片對齊方式
 *         stretch - 拉伸(預設值)
 *         left - 居左(圖片以原始解析度顯示)
 *         center - 居中(圖片以原始解析度顯示)
 *         right - 居右(圖片以原始解析度顯示)
 *     hint-crop
 *         none - 圖片不剪裁(預設值)
 *         circle - 圖片剪裁成圓形
 *     addImageQuery
 *         是否將當前的部分環境資訊以 url 引數的方式附加到圖片地址中(一個 bool 值,預設值為 false)
 *         
 *         
 * 注:圖片不能大於 1024x1024 畫素,不能大於 200 KB,型別必須為 .png .jpg .jpeg .gif
 
*/ using System; using Windows.Data.Xml.Dom; using Windows.UI.Notifications; using Windows.UI.StartScreen; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; namespace Windows10.Notification.Tile { public sealed partial class TemplateImage : Page {
private const string TILEID = "tile_template_image"; public TemplateImage() { this.InitializeComponent(); } // 在開始螢幕固定一個 secondary tile 磁貼 protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); Uri square150x150Logo
= new Uri("ms-appx:///Assets/Square150x150Logo.png"); Uri wide310x150Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.png"); Uri square310x310Logo = new Uri("ms-appx:///Assets/Square310x310Logo.png"); SecondaryTile secondaryTile = new SecondaryTile(TILEID, "name", "arguments", square150x150Logo, TileSize.Wide310x150); secondaryTile.VisualElements.Wide310x150Logo = wide310x150Logo; secondaryTile.VisualElements.Square310x310Logo = square310x310Logo; try { bool isPinned = await secondaryTile.RequestCreateAsync(); lblMsg.Text = isPinned ? "固定成功" : "固定失敗"; } catch (Exception ex) { lblMsg.Text = "固定失敗: " + ex.ToString(); } } // hint-removeMargin private void btnSample1_Click(object sender, RoutedEventArgs e) { string tileXml = $@" <tile> <visual> <binding template='TileWide'> <text hint-style='caption'>title</text> <image src='ms-appx:///Assets/hololens.jpg' hint-removeMargin='{((FrameworkElement)cmbRemoveMargin.SelectedItem).Tag}' /> </binding> </visual> </tile>"; UpdateTileNotification(tileXml); } // placement private void btnSample2_Click(object sender, RoutedEventArgs e) { string tileXml = $@" <tile> <visual> <binding template='TileWide'> <text hint-style='caption'>title</text> <image src='ms-appx:///Assets/hololens.jpg' placement='{((FrameworkElement)cmbPlacement.SelectedItem).Tag}' /> </binding> </visual> </tile>"; UpdateTileNotification(tileXml); } // hint-align private void btnSample3_Click(object sender, RoutedEventArgs e) { string tileXml = $@" <tile> <visual> <binding template='TileWide'> <text hint-style='caption'>title</text> <image src='ms-appx:///Assets/hololens.small.jpg' hint-align='{((FrameworkElement)cmbAlign.SelectedItem).Tag}' /> </binding> </visual> </tile>"; UpdateTileNotification(tileXml); } // hint-crop='circle' addImageQuery='true' private void btnSample4_Click(object sender, RoutedEventArgs e) { /* * 本例中的 addImageQuery 被指定為 true * 所以以本例來說圖片的實際請求地址為 http://images.cnblogs.com/mvpteam.gif?ms-scale=100&ms-contrast=standard * 如果不指定 addImageQuery 或者將其設定為 false 則本例的圖片的實際請求地址與 src 設定的一致,就是 http://images.cnblogs.com/mvpteam.gif */ string tileXml = $@" <tile> <visual addImageQuery='true'> <binding template='TileWide'> <text hint-style='caption'>title</text> <image src='http://images.cnblogs.com/mvpteam.gif' hint-crop='circle' /> </binding> </visual> </tile>"; UpdateTileNotification(tileXml); } // peek 圖片和 background 圖片相結合 // “peek 圖片”和“background 圖片 + 文字”輪流顯示 private void btnSample5_Click(object sender, RoutedEventArgs e) { string tileXml = $@" <tile> <visual> <binding template='TileWide'> <text hint-style='caption'>title</text> <image src='ms-appx:///Assets/hololens.jpg' placement='peek' /> <image src='ms-appx:///Assets/StoreLogo.png' placement='background' /> </binding> </visual> </tile>"; UpdateTileNotification(tileXml); } // peek 圖片和 background 圖片相結合,並指定其 hint-overlay private void btnSample6_Click(object sender, RoutedEventArgs e) { string tileXml = $@" <tile> <visual> <binding template='TileWide'> <text hint-style='caption'>title</text> <image src='ms-appx:///Assets/hololens.jpg' placement='peek' hint-overlay='50' /> <image src='ms-appx:///Assets/StoreLogo.png' placement='background' hint-overlay='80' /> </binding> </visual> </tile>"; UpdateTileNotification(tileXml); } // hint-presentation private void btnSample7_Click(object sender, RoutedEventArgs e) { string tileXml = $@" <tile> <visual> <binding template='TileWide' hint-presentation='{((FrameworkElement)cmbPresentation.SelectedItem).Tag}'> <image src='ms-appx:///Assets/hololens.jpg' /> <image src='ms-appx:///Assets/StoreLogo.png' /> <image src='ms-appx:///Assets/hololens.jpg' /> <image src='ms-appx:///Assets/StoreLogo.png' /> <image src='ms-appx:///Assets/hololens.jpg' /> <image src='ms-appx:///Assets/StoreLogo.png' /> </binding> </visual> </tile>"; UpdateTileNotification(tileXml); } private void UpdateTileNotification(string tileXml) { XmlDocument tileDoc = new XmlDocument(); tileDoc.LoadXml(tileXml); TileNotification tileNotification = new TileNotification(tileDoc); TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TILEID); tileUpdater.Update(tileNotification); } } }

相關推薦

通知Tile: secondary tile 模板圖片, secondary tile 模板分組

/* * 本例用於演示 tile 顯示模板的圖片相關的知識點 * * * tile - 磁貼元素 * visual - 可視元素 * addImageQuery * 是否將當前的部分環境資訊以 url 引數的方式附加到圖片地址中(一個 bool 值

PJSIP開發手冊SIP事件通知十三

第十三章 SIP特定的事件通知 SIP事件特定的通知在RFC3265“Session Initiation Protocol-SpecificEvent Notification”描述。這個核心協議定義了建立事件訂閱的兩種SIP方法,即SUBSCRIBE和NOTIFY,儘管

物聯網平臺構架系列 :Amazon, Microsoft, IBM IoT 解決方案導論 結語

物聯網; iot; aws; 亞馬遜; greengrass;microsoft; azure;ibm; watson; bluemix最近研究了一些物聯網平臺技術資料,以做選型參考。腦子裏積累大量信息,便想寫出來做一些普及。作為科普文章,力爭通俗易懂,不確保概念嚴謹性。我會給考據癖者提供相關英文鏈接,以便深

一個鹹魚的Python爬蟲:爬取網頁圖片

you os.path odin 路徑 生成 存在 parent lose exist 學完Requests庫與Beautifulsoup庫我們今天來實戰一波,爬取網頁圖片。依照現在所學只能爬取圖片在html頁面的而不能爬取由JavaScript生成的圖。所以我找了這個網站

巧婦能為少米1——Android下小內存下的生存

直接內存 -a 響應時間 分區 popu 身邊 執行 人的 算法 常常聽到身邊用安卓的朋友抱怨手機卡頓,內存動不動就快沒了。而Google聲稱在512M的內存下也能流暢執行Android 4.4。究竟它做了什麽? 總結一下它主要做了四件事: 1.優化內核,使用Activ

《大話設計模式》——讀後感 8好菜每回味不同——建造者模式基礎案例1

ted builds src ret 分離 args 類圖 rec 方法 建造者模式:是將一個復雜的對象的構建與它的表示分離,使得同樣的構建過程可以創建不同的表示。 建造者模式通常包括下面幾個角色: 1. builder:給出一個抽象接口,以規範產品對象的各個組成成分的

基於MVC4+EasyUI的Web開發框架形成旅--MVC控制器的設計

cli dex txt strip -1 function 特殊 remote 文章 http://www.cnblogs.com/wuhuacong/p/3284628.html 自從上篇《基於MVC4+EasyUI的Web開發框架形成之旅--總體介紹》總體性的概括,得

通知Notification

defaults img ges oca data- 發送通知 ext image style 通知(Notification)1、通知的基本用法 //創建 NotificationManager 實例 NotificationManager manager

嵌入式開發學習5<S5PV210開發板刷系統那點破事兒二>

串口驅動 超級 mage idt android4 securecrt linux命令 log 這一 刷系統:利用刷機工具,向開發板中燒錄預先編譯好的鏡像。使之在開發板上跑起來。   S5PV210廠家默認安裝的是android4.0.4。   1、安裝usb轉串口驅動(如

Spring的通知Advice

obj throws npoi nts src pan joinpoint title 執行  Spring提供了5種Advice類型:   Interception Around:JointPoint前後調用   Before:JointPoint前調用   After

spring框架總結04----介紹的是Spring中的JDBC模板

aos 不用 get interface comm use clas table oid 1.1 Jdbc模板概述 它是spring框架中提供的一個對象,是對原始Jdbc API對象的簡單封裝。spring框架為我們提供了很多的操作模板類,入下圖所示: 我們今天的

屬性更改通知INotifyPropertyChanged——針對ObservableCollection

notify upd ev3 bsp blank rop ref ring handle 問題 在開發webform中,wpf中的ObservableCollection<T>,MSDN中說,在添加項,移除項時此集合通知控件,我們知道對一個集合的操作是CURD但

python基礎學習 因為修改前面較多不足處所以這裏就少了但是我還是會發的

優化 3的倍數 small align 如果 print big 10個 bre python3.5使用 第六天:   現在我們來講for循環的用法 先寫一段代碼來解釋它: 1 for i in range(10): 2 print(i) 第一段的意思是循環

十、無事勿擾,有事通知1——NSNotification

over ring pass tro 管理中心 代碼 aps pre 發生 概述 很久很久以前,有一只菜鳥正在美滋滋的擼著他的嵌入式C代碼。然而有一天,老板對菜鳥說:“別擼C了,從現在開始你就寫swift開發ios了。”菜鳥一臉懵逼,但還是照做了。 又有一天,菜蛋諂媚的對菜

安卓專案實戰Glide 3高手養成:Glide強大的圖片變換功能

使用Glide時普遍會遇到的一個問題,如何解決? 首先我們嘗試使用Glide來載入一張圖片,圖片URL地址是:https://www.baidu.com/img/bd_logo1.png 這是百度首頁logo的一張圖片,圖片尺寸是540*258畫素。 接下來我們編寫一個非常簡單的佈局檔案

Android安卓狀態列訊息推送通知Notification

我從不猜測,猜測是一個很壞的習慣——會影響正常的邏輯推理能力。              ——阿瑟·柯南·道爾 《福爾摩斯探案集》 近日,在做安卓專案開發的時候涉及到狀態列通知的需求,查了資料,總結一個簡

android使用通知notification

通知可以在活動中建立也可以廣播中建立,也可以在服務中建立。 其實通知只有一般是在我們的應用在後臺的時候才能使用到,所以,一般不再活動中建立。 但不困在哪裡建立大體的步驟都是差不多的。 具體的思路是: 第一我們要有一個通知的管理者,即我們的NotificationManager

swift ReactiveSwift框架下通知NotificationCenter的使用

註冊: NotificationCenter.default.post(name: Notification.Name(rawValue: "NotificationName"), object: object) 實現: NotificationCenter.default.reac

springmvc Controller中的通知aopspringmvc教程十二

目錄 工程程式碼 @ControllerAdvice @InitBinder @ExceptionHandler @ModelAttribute入門 @ModelAttribute與重定向

Python學習【第20篇】:互斥鎖以及程序之間的三種通訊方式IPC以及生產者個消費者模型 python併發程式設計多程序1-----------互斥鎖與程序間的通訊

python併發程式設計之多程序1-----------互斥鎖與程序間的通訊 一、互斥鎖 程序之間資料隔離,但是共享一套檔案系統,因而可以通過檔案來實現程序直接的通訊,