Exemplo n.º 1
0
        void UpdateTileWithImage_Click(object sender, RoutedEventArgs e)
        {
            // Note: This sample contains an additional project, NotificationsExtensions.
            // NotificationsExtensions exposes an object model for creating notifications, but you can also
            // modify the strings directly. See UpdateTileWithImageWithStringManipulation_Click for an example

            // Users can resize any app tile to the small (Square70x70 on Windows 8.1, Square71x71 on Windows Phone 8.1) and medium (Square150x150) tile sizes.
            // These are both tile sizes an app must minimally support.
            // An app can additionally support the wide (Wide310x150) tile size as well as the large (Square310x310) tile size.
            // Note that in order to support a large (Square310x310) tile size, an app must also support the wide (Wide310x150) tile size (but not vice versa).

            // This sample application supports all four tile sizes: small, medium, wide and large.
            // This means that the user may have resized their tile to any of these four sizes for their custom Start screen layout.
            // Because an app has no way of knowing what size the user resized their app tile to, an app should include template bindings
            // for each supported tile sizes in their notifications. Only Windows Phone 8.1 supports small tile notifications.
            // We assemble one notification with four template bindings by including the content for each smaller
            // tile in the next size up. Square310x310 includes Wide310x150, which includes Square150x150, which includes Square71x71.
            // If we leave off the content for a tile size which the application supports, the user will not see the
            // notification if the tile is set to that size.

            // Create a notification for the Square310x310 tile using one of the available templates for the size.
            ITileSquare310x310Image tileContent = TileContentFactory.CreateTileSquare310x310Image();

            tileContent.Image.Src = "ms-appx:///images/purpleSquare310x310.png";
            tileContent.Image.Alt = "Purple image";

            // Create a notification for the Wide310x150 tile using one of the available templates for the size.
            ITileWide310x150ImageAndText01 wide310x150Content = TileContentFactory.CreateTileWide310x150ImageAndText01();

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

            // Create a notification for the Square150x150 tile using one of the available templates for the size.
            ITileSquare150x150Image square150x150Content = TileContentFactory.CreateTileSquare150x150Image();

            square150x150Content.Image.Src = "ms-appx:///images/graySquare150x150.png";
            square150x150Content.Image.Alt = "Gray image";

            // Create a notification for the Square71x71 tile using one of the available templates for the size.
            ITileSquare71x71Image square71x71Content = TileContentFactory.CreateTileSquare71x71Image();

            square71x71Content.Image.Src = "ms-appx:///images/graySquare150x150.png";
            square71x71Content.Image.Alt = "Gray image";

            // Attach the Square71x71 template to the Square150x150 template.
            square150x150Content.Square71x71Content = square71x71Content;

            // Attach the Square150x150 template to the Wide310x150 template.
            wide310x150Content.Square150x150Content = square150x150Content;

            // Attach the Wide310x150 to the Square310x310 template.
            tileContent.Wide310x150Content = wide310x150Content;

            // Send the notification to the application’s tile.
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());

            OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent());
            rootPage.NotifyUser("Tile notification with local images sent", NotifyType.StatusMessage);
        }
        void SendTileNotificationWithQueryStrings_Click(object sender, RoutedEventArgs e)
        {
            ITileSquare310x310Image square310x310TileContent = TileContentFactory.CreateTileSquare310x310Image();

            square310x310TileContent.Image.Src = ImageUrl.Text;
            square310x310TileContent.Image.Alt = "Web image";

            // enable AddImageQuery on the notification
            square310x310TileContent.AddImageQuery = true;

            ITileWide310x150ImageAndText01 wide310x150TileContent = TileContentFactory.CreateTileWide310x150ImageAndText01();

            wide310x150TileContent.TextCaptionWrap.Text = "This tile notification uses query strings for the image src.";
            wide310x150TileContent.Image.Src            = ImageUrl.Text;
            wide310x150TileContent.Image.Alt            = "Web image";

            ITileSquare150x150Image square150x150TileContent = TileContentFactory.CreateTileSquare150x150Image();

            square150x150TileContent.Image.Src = ImageUrl.Text;
            square150x150TileContent.Image.Alt = "Web image";

            ITileSquare71x71Image square71x71TileContent = TileContentFactory.CreateTileSquare71x71Image();

            square71x71TileContent.Image.Src = ImageUrl.Text;
            square71x71TileContent.Image.Alt = "Web image";

            square150x150TileContent.Square71x71Content = square71x71TileContent;
            wide310x150TileContent.Square150x150Content = square150x150TileContent;
            square310x310TileContent.Wide310x150Content = wide310x150TileContent;

            TileUpdateManager.CreateTileUpdaterForApplication().Update(square310x310TileContent.CreateNotification());

            OutputTextBlock.Text = MainPage.PrettyPrint(square310x310TileContent.GetContent());
            rootPage.NotifyUser("Tile notification with image query strings sent.", NotifyType.StatusMessage);
        }
Exemplo n.º 3
0
        public async Task EnqueueSchemeTileAsync(Scheme scheme)
        {
            var wideImage = await bitmapService.CreateSchemeBitmapAsync(scheme, TileSize.Wide);

            var squareImage = await bitmapService.CreateSchemeBitmapAsync(scheme, TileSize.Square);

            var wideTile   = TileContentFactory.CreateTileWide310x150ImageAndText01();
            var squareTile = TileContentFactory.CreateTileSquare150x150PeekImageAndText01();

            wideTile.Square150x150Content = squareTile;

            squareTile.Branding         = TileBranding.None;
            squareTile.Image.Src        = squareImage;
            squareTile.TextHeading.Text = scheme.Name;

            wideTile.Branding             = TileBranding.None;
            wideTile.Image.Src            = wideImage;
            wideTile.TextCaptionWrap.Text = scheme.Name;

            var notification = wideTile.CreateNotification();

            notification.Tag = scheme.Id.GetHashCode().ToString();

            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.Update(notification);

            EnsureDefaultTile();
        }
        private void SendTileNotification_Click(object sender, RoutedEventArgs e)
        {
            IWide310x150TileNotificationContent wide310x150TileContent = null;

            if (ProtocolList.SelectedItem == package) //using the ms-appx:/// protocol
            {
                ITileWide310x150ImageAndText01 wide310x150ImageAndTextContent = TileContentFactory.CreateTileWide310x150ImageAndText01();

                wide310x150ImageAndTextContent.RequireSquare150x150Content = false;
                wide310x150ImageAndTextContent.TextCaptionWrap.Text        = "The image is in the appx package";
                wide310x150ImageAndTextContent.Image.Src = "ms-appx:///images/redWide310x150.png";
                wide310x150ImageAndTextContent.Image.Alt = "Red image";

                wide310x150TileContent = wide310x150ImageAndTextContent;
            }
            else if (ProtocolList.SelectedItem == appdata) //using the appdata:///local/ protocol
            {
                ITileWide310x150Image wide310x150ImageContent = TileContentFactory.CreateTileWide310x150Image();

                wide310x150ImageContent.RequireSquare150x150Content = false;
                wide310x150ImageContent.Image.Src = "ms-appdata:///local/" + this.imageRelativePath;
                wide310x150ImageContent.Image.Alt = "App data";

                wide310x150TileContent = wide310x150ImageContent;
            }
            else if (ProtocolList.SelectedItem == http) //using http:// protocol
            {
                // Important - The Internet (Client) capability must be checked in the manifest in the Capabilities tab
                ITileWide310x150PeekImageCollection04 wide310x150PeekImageCollectionContent = TileContentFactory.CreateTileWide310x150PeekImageCollection04();

                wide310x150PeekImageCollectionContent.RequireSquare150x150Content = false;
                try
                {
                    wide310x150PeekImageCollectionContent.BaseUri = HTTPBaseURI.Text;
                }
                catch (ArgumentException exception)
                {
                    OutputTextBlock.Text = exception.Message;
                    return;
                }
                wide310x150PeekImageCollectionContent.TextBodyWrap.Text         = "The base URI is " + HTTPBaseURI.Text;
                wide310x150PeekImageCollectionContent.ImageMain.Src             = HTTPImage1.Text;
                wide310x150PeekImageCollectionContent.ImageSmallColumn1Row1.Src = HTTPImage2.Text;
                wide310x150PeekImageCollectionContent.ImageSmallColumn1Row2.Src = HTTPImage3.Text;
                wide310x150PeekImageCollectionContent.ImageSmallColumn2Row1.Src = HTTPImage4.Text;
                wide310x150PeekImageCollectionContent.ImageSmallColumn2Row2.Src = HTTPImage5.Text;

                wide310x150TileContent = wide310x150PeekImageCollectionContent;
            }

            wide310x150TileContent.RequireSquare150x150Content = false;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(wide310x150TileContent.CreateNotification());

            OutputTextBlock.Text = MainPage.PrettyPrint(wide310x150TileContent.GetContent());
            rootPage.NotifyUser("Tile notification sent", NotifyType.StatusMessage);
        }
Exemplo n.º 5
0
        void UpdateTileWithWebImage_Click(object sender, RoutedEventArgs e)
        {
            // Note: This sample contains an additional project, NotificationsExtensions.
            // NotificationsExtensions exposes an object model for creating notifications, but you can also
            // modify the strings directly. See UpdateTileWithWebImageWithStringManipulation_Click for an example.

            // !Important!
            // The Internet (Client) capability must be checked in the manifest in the Capabilities tab
            // to display web images in tiles (either the http:// or https:// protocols)

            // Users can resize any app tile to the small (Square70x70) and medium (Square150x150) tile sizes.
            // These are both tile sizes an app must minimally support.
            // An app can additionally support the wide (Wide310x150) tile size as well as the large (Square310x310) tile size.
            // Note that in order to support a large (Square310x310) tile size, an app must also support the wide (Wide310x150) tile size (but not vice versa).

            // This sample application supports all four tile sizes – small (Square70x70), medium (Square150x150), wide (Wide310x150) and large (Square310x310).
            // This means that the user may have resized their tile to any of these four sizes for their custom Start screen layout.
            // Because an app has no way of knowing what size the user resized their app tile to, an app should include template bindings for each supported tile sizes in their notifications.
            // The only exception is the small (Square70x70) tile size because this size does not support live tile notifications, which is why there are no Square70x70 tile templates.             // We assemble one notification with three template bindings by including the content for each smaller
            // tile in the next size up. Square310x310 includes Wide310x150, which includes Square150x150.
            // If we leave off the content for a tile size which the application supports, the user will not see the
            // notification if the tile is set to that size.

            // Create a notification for the Square310x310 tile using one of the available templates for the size.
            ITileSquare310x310Image tileContent = TileContentFactory.CreateTileSquare310x310Image();

            tileContent.AddImageQuery = true;
            tileContent.Image.Src     = ImageUrl.Text;
            tileContent.Image.Alt     = "Web Image";

            // Create a notification for the Wide310x150 tile using one of the available templates for the size.
            ITileWide310x150ImageAndText01 wide310x150Content = TileContentFactory.CreateTileWide310x150ImageAndText01();

            wide310x150Content.TextCaptionWrap.Text = "This tile notification uses web images.";
            wide310x150Content.Image.Src            = ImageUrl.Text;
            wide310x150Content.Image.Alt            = "Web image";

            // Create a notification for the Square150x150 tile using one of the available templates for the size.
            ITileSquare150x150Image square150x150Content = TileContentFactory.CreateTileSquare150x150Image();

            square150x150Content.Image.Src = ImageUrl.Text;
            square150x150Content.Image.Alt = "Web image";

            // Attach the Square150x150 template to the Wide310x150 template.
            wide310x150Content.Square150x150Content = square150x150Content;

            // Attach the Wide310x150 template to the Square310x310 template.
            tileContent.Wide310x150Content = wide310x150Content;

            // Send the notification to the application’s tile.
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());

            OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent());
        }
Exemplo n.º 6
0
        private static TileNotification CreateNotifiction(string largeImageName, string wideImageName, string mediumImageName, string smallImageName, string notificationTag, string captionText)
        {
            return(GetTileNotification
                   (
                       GetLargeTile
                       (
                           TileContentFactory.CreateTileSquare310x310ImageAndText01()
                       ).CreateNotification()
                   ));

            TileNotification GetTileNotification(TileNotification tileNotification)
            {
                tileNotification.Tag = notificationTag;
                return(tileNotification);
            }

            ITileSquare310x310ImageAndText01 GetLargeTile(ITileSquare310x310ImageAndText01 largeTile)
            {
                largeTile.TextCaptionWrap.Text = ResourceStringNames.notificationText01.GetResourceString();
                largeTile.Image.Src            = $"ms-appx:///Tiles/{largeImageName}.png";
                largeTile.Wide310x150Content   = GetWideTile(TileContentFactory.CreateTileWide310x150ImageAndText01());

                return(largeTile);
            }

            ITileWide310x150ImageAndText01 GetWideTile(ITileWide310x150ImageAndText01 largeTile)
            {
                largeTile.TextCaptionWrap.Text = captionText;
                largeTile.Image.Src            = $"ms-appx:///Tiles/{wideImageName}.png";
                largeTile.Square150x150Content = GetMediumTile(TileContentFactory.CreateTileSquare150x150Image());

                return(largeTile);
            }

            ITileSquare150x150Image GetMediumTile(ITileSquare150x150Image mediumTile)
            {
                mediumTile.Image.Src          = $"ms-appx:///Tiles/{mediumImageName}.png";
                mediumTile.Square71x71Content = GetSmallTile(TileContentFactory.CreateTileSquare71x71Image());
                return(mediumTile);
            }

            ITileSquare71x71Image GetSmallTile(ITileSquare71x71Image smallTile)
            {
                smallTile.Image.Src = $"ms-appx:///Tiles/{smallImageName}.png";
                return(smallTile);
            }
        }
Exemplo n.º 7
0
        //public static CreateSecondaryTile(string tileId)
        //{

        //}



        /// <summary>
        /// 更新默认磁贴内容(不通用)
        /// </summary>
        /// <param name="tileModel"></param>
        public static void UpdateTileNotifications(string ImageSrc, string TextHeading, string TextBody1, string TextBody2, string TextBody3)
        {
            ITileWide310x150ImageAndText01 tileWide310x150ImageAndText01 = TileContentFactory.CreateTileWide310x150ImageAndText01();

            ITileSquare150x150PeekImageAndText01 tileSquare150x150PeekImageAndText01 = TileContentFactory.CreateTileSquare150x150PeekImageAndText01();

            //磁铁内容赋值
            tileSquare150x150PeekImageAndText01.Image.Src        = ImageSrc;
            tileSquare150x150PeekImageAndText01.TextHeading.Text = TextHeading;
            tileSquare150x150PeekImageAndText01.TextBody1.Text   = TextBody1;
            tileSquare150x150PeekImageAndText01.TextBody2.Text   = TextBody2;
            tileSquare150x150PeekImageAndText01.TextBody3.Text   = TextBody3;
            tileWide310x150ImageAndText01.Square150x150Content   = tileSquare150x150PeekImageAndText01;
            tileWide310x150ImageAndText01.Image.Src            = "ms-appx:///Assets/WideLogo.scale-100.png";
            tileWide310x150ImageAndText01.TextCaptionWrap.Text = TextHeading + TextBody1 + TextBody2 + TextBody3;
            //更新至磁贴
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileWide310x150ImageAndText01.CreateNotification());
        }
Exemplo n.º 8
0
        private void UpdateTile()
        {
            Random rnd = new Random();

            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            for (int i = 0; i < 6; i++)
            {
                ITileSquare310x310Image tileContent = TileContentFactory.CreateTileSquare310x310Image();
                tileContent.AddImageQuery = true;
                tileContent.Image.Src     = "Assets/" + i + ".png";
                tileContent.Image.Alt     = "Web image";

                ITileWide310x150ImageAndText01 wide310x150Content = TileContentFactory.CreateTileWide310x150ImageAndText01();
                wide310x150Content.Image.Src = "Assets/" + i + ".png";
                wide310x150Content.Image.Alt = "Web image";

                ITileSquare150x150Image square150x150Content = TileContentFactory.CreateTileSquare150x150Image();
                square150x150Content.Image.Src = "Assets/" + i + ".png";
                square150x150Content.Image.Alt = "Web image";

                wide310x150Content.Square150x150Content = square150x150Content;
                tileContent.Wide310x150Content          = wide310x150Content;

                TileNotification tileNotification = tileContent.CreateNotification();

                string tag = "Image" + i;
                tileNotification.Tag = tag;
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            }

            /*ITileSquare310x310Text09 square310x310TileContent = TileContentFactory.CreateTileSquare310x310Text09();
             * square310x310TileContent.TextHeadingWrap.Text = "ATMOS '14";
             * ITileWide310x150Text03 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text03();
             * wide310x150TileContent.TextHeadingWrap.Text = "ATMOS '14";
             * ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04();
             * square150x150TileContent.TextBodyWrap.Text = "ATMOS '14";
             * wide310x150TileContent.Square150x150Content = square150x150TileContent;
             * square310x310TileContent.Wide310x150Content = wide310x150TileContent;
             * tileNotification = square310x310TileContent.CreateNotification();
             * tag = "Title";
             * tileNotification.Tag = tag;
             * TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);*/
        }
Exemplo n.º 9
0
        private void UpdateTile()
        {
            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            ITileSquare310x310Image tileContent = TileContentFactory.CreateTileSquare310x310Image();

            tileContent.AddImageQuery = true;
            tileContent.Image.Src     = ImageUrl;
            tileContent.Image.Alt     = "Web Image";
            ITileWide310x150ImageAndText01 wide310x150Content = TileContentFactory.CreateTileWide310x150ImageAndText01();

            wide310x150Content.TextCaptionWrap.Text = "Last Book:ISBN-" + MainPage.isbn;
            wide310x150Content.Image.Src            = ImageUrl;
            wide310x150Content.Image.Alt            = "Web image";
            ITileSquare150x150Image square150x150Content = TileContentFactory.CreateTileSquare150x150Image();

            square150x150Content.Image.Src          = ImageUrl;
            square150x150Content.Image.Alt          = "Web image";
            wide310x150Content.Square150x150Content = square150x150Content;
            tileContent.Wide310x150Content          = wide310x150Content;
            TileNotification tileNotification = tileContent.CreateNotification();
            string           tag = "Image";

            tileNotification.Tag = tag;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            ITileSquare310x310Text09 square310x310TileContent = TileContentFactory.CreateTileSquare310x310Text09();

            square310x310TileContent.TextHeadingWrap.Text = Title.Text + Environment.NewLine + "ISBN-" + MainPage.isbn;
            ITileWide310x150Text03 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text03();

            wide310x150TileContent.TextHeadingWrap.Text = Title.Text + Environment.NewLine + "ISBN-" + MainPage.isbn;
            ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04();

            square150x150TileContent.TextBodyWrap.Text  = Title.Text + Environment.NewLine + "ISBN-" + MainPage.isbn;
            wide310x150TileContent.Square150x150Content = square150x150TileContent;
            square310x310TileContent.Wide310x150Content = wide310x150TileContent;
            tileNotification = square310x310TileContent.CreateNotification();
            tag = "Title";
            tileNotification.Tag = tag;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
Exemplo n.º 10
0
        /// <summary>
        /// TileWideImageAndText01
        /// One wide image over one string of regular text wrapped over a maximum of two lines.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileWideImageAndText01
        ///
        /// TileSquarePeekImageAndText04
        /// Top: Square image, no text. Bottom: One string of regular text wrapped over a maximum of four lines.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileSquarePeekImageAndText04
        /// </summary>
        /// <param name="item"></param>
        private static void CreateNotePreviewTile(NoteDataCommon item)
        {
            var imgWideUrl = GetPreviewImage(item, true).ToString();
            ITileWide310x150ImageAndText01 tileContent = TileContentFactory.CreateTileWide310x150ImageAndText01();

            tileContent.TextCaptionWrap.Text = item.Title;
            tileContent.Image.Src            = imgWideUrl;
            tileContent.Image.Alt            = item.Title;

            var imgUrl = GetPreviewImage(item, false).ToString();
            ITileSquare150x150PeekImageAndText04 squareTileContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText04();

            squareTileContent.Image.Src         = imgUrl;
            squareTileContent.Image.Alt         = item.Title;
            squareTileContent.TextBodyWrap.Text = item.Title;
            tileContent.Square150x150Content    = squareTileContent;

            tileContent.Branding = TileBranding.Logo;
            ScheduledTileNotification schduleTile = new ScheduledTileNotification(tileContent.GetXml(), DateTime.Now.AddSeconds(10));

            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(schduleTile);
        }
        void SendScaledImageTileNotification_Click(object sender, RoutedEventArgs e)
        {
            string scale;

            ResourceContext.GetForCurrentView().QualifierValues.TryGetValue("Scale", out scale);

            ITileSquare310x310Image square310x310TileContent = TileContentFactory.CreateTileSquare310x310Image();

            square310x310TileContent.Image.Src = "ms-appx:///images/purpleSquare310x310.png";
            square310x310TileContent.Image.Alt = "Purple square";

            ITileWide310x150ImageAndText01 wide310x150TileContent = TileContentFactory.CreateTileWide310x150ImageAndText01();

            wide310x150TileContent.TextCaptionWrap.Text = "scaled version of blueWide310x150.png in the xml is selected based on the current Start scale";
            wide310x150TileContent.Image.Src            = "ms-appx:///images/blueWide310x150.png";
            wide310x150TileContent.Image.Alt            = "Blue wide";

            ITileSquare150x150Image square150x150TileContent = TileContentFactory.CreateTileSquare150x150Image();

            square150x150TileContent.Image.Src = "ms-appx:///images/graySquare150x150.png";
            square150x150TileContent.Image.Alt = "Gray square";

            ITileSquare71x71Image square71x71TileContent = TileContentFactory.CreateTileSquare71x71Image();

            square71x71TileContent.Image.Src = "ms-appx:///images/graySquare150x150.png";
            square71x71TileContent.Image.Alt = "Gray square";

            square150x150TileContent.Square71x71Content = square71x71TileContent;
            wide310x150TileContent.Square150x150Content = square150x150TileContent;
            square310x310TileContent.Wide310x150Content = wide310x150TileContent;

            TileUpdateManager.CreateTileUpdaterForApplication().Update(square310x310TileContent.CreateNotification());

            OutputTextBlock.Text = MainPage.PrettyPrint(square310x310TileContent.GetContent());
            rootPage.NotifyUser("Tile notification with scaled images sent.", NotifyType.StatusMessage);
        }