private async void CreateBadgeAndTextTile_Click(object sender, RoutedEventArgs e)
        {
            if (!SecondaryTile.Exists(TEXT_TILE_ID))
            {
                SecondaryTile secondTile = new SecondaryTile(
                    TEXT_TILE_ID,
                    "LockScreen CS - Badge and tile text",
                    "TEXT_ARGS",
                    new Uri("ms-appx:///images/squareTile-sdk.png"),
                    TileSize.Wide310x150
                    );
                secondTile.VisualElements.Wide310x150Logo    = new Uri("ms-appx:///images/tile-sdk.png");
                secondTile.LockScreenBadgeLogo               = new Uri("ms-appx:///images/badgelogo-sdk.png");
                secondTile.LockScreenDisplayBadgeAndTileText = true;

                bool isPinned = await secondTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender), Placement.Above);

                if (isPinned)
                {
                    ITileWide310x150Text03 tileContent = TileContentFactory.CreateTileWide310x150Text03();
                    tileContent.TextHeadingWrap.Text        = "Text for the lock screen";
                    tileContent.RequireSquare150x150Content = false;
                    TileUpdateManager.CreateTileUpdaterForSecondaryTile(TEXT_TILE_ID).Update(tileContent.CreateNotification());
                    rootPage.NotifyUser("Secondary tile created and updated. Go to PC settings to add it to the lock screen.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Tile not created.", NotifyType.ErrorMessage);
                }
            }
            else
            {
                rootPage.NotifyUser("Badge and text secondary tile already exists.", NotifyType.ErrorMessage);
            }
        }
Exemple #2
0
        private void UpdateTileWithText_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 UpdateTileWithTextWithStringManipulation_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,
            // and there are no text templates available for this size.
            // 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.
            ITileSquare310x310Text09 tileContent = TileContentFactory.CreateTileSquare310x310Text09();

            tileContent.TextHeadingWrap.Text = "Hello World! My very own tile notification";

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

            wide310x150Content.TextHeadingWrap.Text = "Hello World! My very own tile notification";

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

            square150x150Content.TextBodyWrap.Text = "Hello World! My very own tile notification";

            // 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? tile.
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());

            OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent());
            rootPage.NotifyUser("Tile notification with text sent", NotifyType.StatusMessage);
        }
Exemple #3
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);
        }
Exemple #4
0
        void SendTextResourceTileNotification_Click(object sender, RoutedEventArgs e)
        {
            ITileSquare310x310Text09 square310x310TileContent = TileContentFactory.CreateTileSquare310x310Text09();

            // Check out /en-US/resources.resw to understand where this string will come from.
            square310x310TileContent.TextHeadingWrap.Text = "ms-resource:greeting";

            ITileWide310x150Text03 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text03();

            wide310x150TileContent.TextHeadingWrap.Text = "ms-resource:greeting";

            ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04();

            square150x150TileContent.TextBodyWrap.Text = "ms-resource:greeting";

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

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

            OutputTextBlock.Text = MainPage.PrettyPrint(square310x310TileContent.GetContent());
        }
Exemple #5
0
        void UpdateTile_Click(object sender, RoutedEventArgs e)
        {
            // Create a notification for the Square310x310 tile using one of the available templates for the size.
            ITileSquare310x310Text09 square310x310TileContent = TileContentFactory.CreateTileSquare310x310Text09();

            square310x310TileContent.TextHeadingWrap.Text = TextContent.Text;

            // Create a notification for the Wide310x150 tile using one of the available templates for the size.
            ITileWide310x150Text03 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text03();

            wide310x150TileContent.TextHeadingWrap.Text = TextContent.Text;

            // Create a notification for the Square150x150 tile using one of the available templates for the size.
            ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04();

            square150x150TileContent.TextBodyWrap.Text = TextContent.Text;

            // Attach the Square150x150 template to the Wide310x150 template.
            wide310x150TileContent.Square150x150Content = square150x150TileContent;

            // Attach the Wide310x150 template to the Square310x310 template.
            square310x310TileContent.Wide310x150Content = wide310x150TileContent;

            TileNotification tileNotification = square310x310TileContent.CreateNotification();

            string tag = "TestTag01";

            if (!Id.Text.Equals(String.Empty))
            {
                tag = Id.Text;
            }

            // Set the tag on the notification.
            tileNotification.Tag = tag;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            OutputTextBlock.Text = "Tile notification sent. It is tagged with '" + tag + "'.\n" + MainPage.PrettyPrint(square310x310TileContent.GetContent());
        }
        void SendNotifications_Click(object sender, RoutedEventArgs e)
        {
            // Create a notification for the first set of stories with bindings for all 3 tile sizes
            ITileSquare310x310Text09 square310x310TileContent1 = TileContentFactory.CreateTileSquare310x310Text09();

            square310x310TileContent1.TextHeadingWrap.Text = "Main Story";

            ITileWide310x150Text03 wide310x150TileContent1 = TileContentFactory.CreateTileWide310x150Text03();

            wide310x150TileContent1.TextHeadingWrap.Text = "Main Story";

            ITileSquare150x150Text04 square150x150TileContent1 = TileContentFactory.CreateTileSquare150x150Text04();

            square150x150TileContent1.TextBodyWrap.Text = "Main Story";

            wide310x150TileContent1.Square150x150Content = square150x150TileContent1;
            square310x310TileContent1.Wide310x150Content = wide310x150TileContent1;

            // Set the contentId on the Square310x310 tile
            square310x310TileContent1.ContentId = "Main_1";

            // Tag the notification and send it to the tile
            TileNotification tileNotification = square310x310TileContent1.CreateNotification();

            tileNotification.Tag = "1";
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            // Create the first notification for the second set of stories with binding for all 3 tiles sizes
            ITileSquare310x310TextList03 square310x310TileContent2 = TileContentFactory.CreateTileSquare310x310TextList03();

            square310x310TileContent2.TextHeading1.Text = "Additional Story 1";
            square310x310TileContent2.TextHeading2.Text = "Additional Story 2";
            square310x310TileContent2.TextHeading3.Text = "Additional Story 3";

            ITileWide310x150Text03 wide310x150TileContent2 = TileContentFactory.CreateTileWide310x150Text03();

            wide310x150TileContent2.TextHeadingWrap.Text = "Additional Story 1";

            ITileSquare150x150Text04 square150x150TileContent2 = TileContentFactory.CreateTileSquare150x150Text04();

            square150x150TileContent2.TextBodyWrap.Text = "Additional Story 1";

            wide310x150TileContent2.Square150x150Content = square150x150TileContent2;
            square310x310TileContent2.Wide310x150Content = wide310x150TileContent2;

            // Set the contentId on the Square310x310 tile
            square310x310TileContent2.ContentId = "Additional_1";

            // Tag the notification and send it to the tile
            tileNotification     = square310x310TileContent2.CreateNotification();
            tileNotification.Tag = "2";
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            // Create the second notification for the second set of stories with binding for all 3 tiles sizes
            // Notice that we only replace the Wide310x150 and Square150x150 binding elements,
            // and keep the Square310x310 content the same - this will cause the Square310x310 to be ignored for this notification,
            // since the contentId for this size is the same as in the first notification of the second set of stories.
            ITileWide310x150Text03 wide310x150TileContent3 = TileContentFactory.CreateTileWide310x150Text03();

            wide310x150TileContent3.TextHeadingWrap.Text = "Additional Story 2";

            ITileSquare150x150Text04 square150x150TileContent3 = TileContentFactory.CreateTileSquare150x150Text04();

            square150x150TileContent3.TextBodyWrap.Text = "Additional Story 2";

            wide310x150TileContent3.Square150x150Content = square150x150TileContent3;
            square310x310TileContent2.Wide310x150Content = wide310x150TileContent3;

            // Tag the notification and send it to the tile
            tileNotification     = square310x310TileContent2.CreateNotification();
            tileNotification.Tag = "3";
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            // Create the third notification for the second set of stories with binding for all 3 tiles sizes
            // Notice that we only replace the Wide310x150 and Square150x150 binding elements,
            // and keep the Square310x310 content the same again - this will cause the Square310x310 to be ignored for this notification,
            // since the contentId for this size is the same as in the first notification of the second set of stories.
            ITileWide310x150Text03 wide310x150TileContent4 = TileContentFactory.CreateTileWide310x150Text03();

            wide310x150TileContent4.TextHeadingWrap.Text = "Additional Story 3";

            ITileSquare150x150Text04 square150x150TileContent4 = TileContentFactory.CreateTileSquare150x150Text04();

            square150x150TileContent4.TextBodyWrap.Text = "Additional Story 3";

            wide310x150TileContent4.Square150x150Content = square150x150TileContent4;
            square310x310TileContent2.Wide310x150Content = wide310x150TileContent4;

            // Tag the notification and send it to the tile
            tileNotification     = square310x310TileContent2.CreateNotification();
            tileNotification.Tag = "4";
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            rootPage.NotifyUser("Four notifications sent.", NotifyType.StatusMessage);
        }