Windows 8 系列 Toast_Title_Badge 随笔

Toast:

View Code
IToastNotificationContent toastContent = null;
            IToastText01 templateContent = ToastContentFactory.CreateToastText01();
            templateContent.TextBodyWrap.Text = "wow my Jusoc, Turn me up";
            toastContent = templateContent;
            ToastNotification toast = toastContent.CreateNotification();
            ToastNotificationManager.CreateToastNotifier().Show(toast);  

Title - Text

View Code
//ITileWideText03 tileContent = TileContentFactory.CreateTileWideText03();
            //tileContent.TextHeadingWrap.Text = "wow my Jusoc,Turn me up!";

            //ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();
            //squareContent.TextBodyWrap.Text = "wow my Jusoc,Turn me up!";
            //tileContent.SquareContent = squareContent;

            //TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());  



            string tileXmlString = "<tile>"
                             + "<visual>"
                             + "<binding template='TileWideText03'>"
                             + "<text id='1'>wow my Jusoc,Turn me up</text>"
                             + "</binding>"
                             + "<binding template='TileSquareText04'>"
                             + "<text id='1'>wow my Jusoc,Turn me up</text>"
                             + "</binding>"
                             + "</visual>"
                             + "</tile>";

            // create a DOM
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            // load the xml string into the DOM, catching any invalid xml characters 
            tileDOM.LoadXml(tileXmlString);

            // create a tile notification
            TileNotification tile = new TileNotification(tileDOM);

            // send the notification to the app's application tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

Title - Image

View Code
//ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01();

            //tileContent.TextCaptionWrap.Text = "高清:撑杆跳伊辛巴耶娃4米70无缘奥运三连冠";

            //tileContent.Image.Src = "http://img1.gtimg.com/4/460/46005/4600509_980x1200_292.jpg";
            //tileContent.Image.Alt = "Web image";

            //ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage();

            //squareContent.Image.Src = "http://img1.gtimg.com/4/460/46005/4600509_980x1200_292.jpg";
            //squareContent.Image.Alt = "Web image";

            //tileContent.SquareContent = squareContent;

            //TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());  

            //ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01();

            //tileContent.TextCaptionWrap.Text = "This tile notification uses ms-appx images";
            //tileContent.Image.Src = "ms-appx:///images/redWide.png";
            //tileContent.Image.Alt = "Red image";

            //ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage();
            //squareContent.Image.Src = "ms-appx:///images/graySquare.png";
            //squareContent.Image.Alt = "Gray image";
            //tileContent.SquareContent = squareContent;

            //TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());



            string tileXmlString = "<tile>"
                              + "<visual>"
                              + "<binding template='TileWideImageAndText01'>"
                              + "<text id='1'>This tile notification uses ms-appx images</text>"
                              + "<image id='1' src='ms-appx:///images/redWide.png' alt='Red image'/>"
                              + "</binding>"
                              + "<binding template='TileSquareImage'>"
                              + "<image id='1' src='ms-appx:///images/graySquare.png' alt='Gray image'/>"
                              + "</binding>"
                              + "</visual>"
                              + "</tile>";

            // create a DOM
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            // load the xml string into the DOM, catching any invalid xml characters 
            tileDOM.LoadXml(tileXmlString);

            // create a tile notification
            TileNotification tile = new TileNotification(tileDOM);

            // send the notification to the app's application tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

设置有期限Title

View Code
int seconds = 10;

            Windows.Globalization.Calendar cal = new Windows.Globalization.Calendar();
            cal.SetToNow();
            cal.AddSeconds(seconds);

            var longTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            DateTimeOffset expiryTime = cal.GetDateTime();
            string expiryTimeString = longTime.Format(expiryTime);

            ITileWideText04 tileContent = TileContentFactory.CreateTileWideText04();
            tileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString;

            ITileSquareText04 squareTileContent = TileContentFactory.CreateTileSquareText04();
            squareTileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString;
            tileContent.SquareContent = squareTileContent;

            TileNotification tileNotification = tileContent.CreateNotification();

            // set the expirationTime
            tileNotification.ExpirationTime = expiryTime;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

设置Title是否队列循环

View Code
//设置为队列循环
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
//取消为队列循环
 TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(false);

删除Title

View Code
 BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();  

Title 模板枚举

View Code
 public enum TileTemplateType
    {
        // Summary:
        //     One square image that fills the entire tile, no text.
        TileSquareImage = 0,
        //
        // Summary:
        //     One string of large block text over a single, short line of bold, regular
        //     text.
        TileSquareBlock = 1,
        //
        // Summary:
        //     One header string in larger text on the first line; three strings of regular
        //     text on each of the next three lines. Text does not wrap.
        TileSquareText01 = 2,
        //
        // Summary:
        //     One header string in larger text on the first line, over one string of regular
        //     text wrapped over a maximum of three lines.
        TileSquareText02 = 3,
        //
        // Summary:
        //     Four strings of regular text on four lines. Text does not wrap.
        TileSquareText03 = 4,
        //
        // Summary:
        //     One string of regular text wrapped over a maximum of four lines.
        TileSquareText04 = 5,
        //
        // Summary:
        //     Top: One square image, no text. Bottom: One header string in larger text
        //     on the first line, three strings of regular text on each of the next three
        //     lines. Text does not wrap.
        TileSquarePeekImageAndText01 = 6,
        //
        // Summary:
        //     Top: Square image, no text. Bottom: One header string in larger text on the
        //     first line, over one string of regular text wrapped over a maximum of three
        //     lines.
        TileSquarePeekImageAndText02 = 7,
        //
        // Summary:
        //     Top: Square image, no text. Bottom: Four strings of regular text on four
        //     lines. Text does not wrap.
        TileSquarePeekImageAndText03 = 8,
        //
        // Summary:
        //     Top: Square image, no text. Bottom: One string of regular text wrapped over
        //     a maximum of four lines.
        TileSquarePeekImageAndText04 = 9,
        //
        // Summary:
        //     One wide image that fills the entire tile, no text.
        TileWideImage = 10,
        //
        // Summary:
        //     One large square image with four smaller square images to its right, no text.
        TileWideImageCollection = 11,
        //
        // Summary:
        //     One wide image over one string of regular text wrapped over a maximum of
        //     two lines.
        TileWideImageAndText01 = 12,
        //
        // Summary:
        //     One wide image over two strings of regular text on two lines. Text does not
        //     wrap.
        TileWideImageAndText02 = 13,
        //
        // Summary:
        //     Four strings of regular, unwrapped text on the left; large block text over
        //     a single, short string of bold, regular text on the right.
        TileWideBlockAndText01 = 14,
        //
        // Summary:
        //     One string of regular text wrapped over a maximum of four lines on the left;
        //     large block text over a single, short string of bold, regular text on the
        //     right.
        TileWideBlockAndText02 = 15,
        //
        // Summary:
        //     Top: One large square image with four smaller square images to its right,
        //     no text. Bottom: One header string in larger text over one string of regular
        //     text wrapped over a maximum of four lines.
        TileWidePeekImageCollection01 = 16,
        //
        // Summary:
        //     Top: One large square image with four smaller square images to its right,
        //     no text. Bottom: One header string in larger text on the first line, four
        //     strings of regular text on the next four lines. Text does not wrap.
        TileWidePeekImageCollection02 = 17,
        //
        // Summary:
        //     Top: One large square image with four smaller square images to its right,
        //     no text. Bottom: One string of large text wrapped over a maximum of three
        //     lines.
        TileWidePeekImageCollection03 = 18,
        //
        // Summary:
        //     Top: One large square image with four smaller square images to its right,
        //     no text. Bottom: One string of regular text wrapped over a maximum of five
        //     lines.
        TileWidePeekImageCollection04 = 19,
        //
        // Summary:
        //     Top: One large square image with four smaller square images to its right,
        //     no text. Bottom: On the left, one small image; on the right, one header string
        //     of larger text on the first line over one string of regular text wrapped
        //     over a maximum of four lines.
        TileWidePeekImageCollection05 = 20,
        //
        // Summary:
        //     Top: One large square image with four smaller square images to its right,
        //     no text. Bottom: On the left, one small image; on the right, one string of
        //     large text wrapped over a maximum of three lines.
        TileWidePeekImageCollection06 = 21,
        //
        // Summary:
        //     Top: One wide image. Bottom: One string of regular text wrapped over a maximum
        //     of five lines.
        TileWidePeekImageAndText01 = 22,
        //
        // Summary:
        //     Top: One wide image. Bottom: Five strings of regular text on five lines.
        //     Text does not wrap.
        TileWidePeekImageAndText02 = 23,
        //
        // Summary:
        //     Top: One wide image. Bottom: One header string in larger text over one string
        //     of regular text that wraps over a maximum of four lines.
        TileWidePeekImage01 = 24,
        //
        // Summary:
        //     Top: One wide image. Bottom: One header string in larger text on the first
        //     line, four strings of regular text on the next four lines. Text does not
        //     wrap.
        TileWidePeekImage02 = 25,
        //
        // Summary:
        //     Top: One wide image. Bottom: One string of large text wrapped over a maximum
        //     of three lines.
        TileWidePeekImage03 = 26,
        //
        // Summary:
        //     Top: One wide image. Bottom: One string of regular text wrapped over a maximum
        //     of five lines.
        TileWidePeekImage04 = 27,
        //
        // Summary:
        //     Top: One wide image. Bottom: On the left, one small image; on the right,
        //     one header string of larger text on the first line over one string of regular
        //     text wrapped over a maximum of four lines.
        TileWidePeekImage05 = 28,
        //
        // Summary:
        //     Top: One wide image. Bottom: On the left, one small image; on the right,
        //     one string of large text wrapped over a maximum of three lines.
        TileWidePeekImage06 = 29,
        //
        // Summary:
        //     On the left, one small image; on the right, one string of large text wrapped
        //     over a maximum of three lines.
        TileWideSmallImageAndText01 = 30,
        //
        // Summary:
        //     On the left, one small image; on the right, one header string in larger text
        //     on the first line, four strings of regular text on the next four lines. Text
        //     does not wrap.
        TileWideSmallImageAndText02 = 31,
        //
        // Summary:
        //     On the left, one small image; on the right, one string of regular text wrapped
        //     over a maximum of five lines.
        TileWideSmallImageAndText03 = 32,
        //
        // Summary:
        //     On the left, one small image; on the right, one header string of larger text
        //     on the first line over one string of regular text wrapped over a maximum
        //     of four lines.
        TileWideSmallImageAndText04 = 33,
        //
        // Summary:
        //     On the left, one header string in larger text over one string of regular
        //     text wrapped over a maximum of four lines; on the right, one small image
        //     with 3:4 dimensions.
        TileWideSmallImageAndText05 = 34,
        //
        // Summary:
        //     One header string in larger text on the first line, four strings of regular
        //     text on the next four lines. Text does not wrap.
        TileWideText01 = 35,
        //
        // Summary:
        //     One header string in larger text over eight short strings arranged in two
        //     columns of four lines each. Columns are of equal width.
        TileWideText02 = 36,
        //
        // Summary:
        //     One string of large text wrapped over a maximum of three lines.
        TileWideText03 = 37,
        //
        // Summary:
        //     One string of regular text wrapped over a maximum of five lines.
        TileWideText04 = 38,
        //
        // Summary:
        //     Five strings of regular text on five lines. Text does not wrap.
        TileWideText05 = 39,
        //
        // Summary:
        //     Ten short strings of regular text, arranged in two columns of five lines
        //     each. Columns are of equal width.
        TileWideText06 = 40,
        //
        // Summary:
        //     One header string in larger text over eight short strings of regular text
        //     arranged in two columns of four lines each. The column widths are such that
        //     the first column acts as a label and the second column as the content. This
        //     template is similar to TileWideText10, but the first column is wider.
        TileWideText07 = 41,
        //
        // Summary:
        //     Ten short strings of regular text arranged in two columns of five lines each.
        //     The column widths are such that the first column acts as a label and the
        //     second column as the content. This template is similar to TileWideText11,
        //     but the first column is wider.
        TileWideText08 = 42,
        //
        // Summary:
        //     One header string in larger text over one string of regular text wrapped
        //     over a maximum of four lines.
        TileWideText09 = 43,
        //
        // Summary:
        //     One header string in larger text over eight short strings of regular text
        //     arranged in two columns of four lines each. The column widths are such that
        //     the first column acts as a label and the second column as the content. This
        //     template is similar to TileWideText07, but the first column is narrower.
        TileWideText10 = 44,
        //
        // Summary:
        //     Ten short strings of regular text arranged in two columns of five lines each.
        //     The column widths are such that the first column acts as a label and the
        //     second column as the content. This template is similar to TileWideText08,
        //     but the first column is narrower.
        TileWideText11 = 45,
    }

Badge -- Number

View Code
  BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)12);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());  

Badge -- Glyph

View Code
学徒帮-jQuery帮帮帮 欢迎更多的前端交流、Js交流、jQuery交流
原文地址:https://www.cnblogs.com/Jusoc/p/2768776.html