Exemple #1
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();
        }
Exemple #2
0
        public async Task <ISquare310x310TileNotificationContent> clearLiveTiles(string siteName)
        {
            await genTileImages(siteName);

            // Large tile.
            var largeContent = TileContentFactory.CreateTileSquare310x310Image();

            largeContent.Image.Src = $"ms-appdata:///local/{siteName}LargeTile.png";
            largeContent.Branding  = NotificationsExtensions.TileContent.TileBranding.None;

            // Wide tile.
            var wideContent = TileContentFactory.CreateTileWide310x150Image();

            wideContent.Image.Src = $"ms-appdata:///local/{siteName}WideTile.png";
            wideContent.Branding  = NotificationsExtensions.TileContent.TileBranding.None;

            // Square tile.
            var squareContent = TileContentFactory.CreateTileSquare150x150Image();

            squareContent.Image.Src = $"ms-appdata:///local/{siteName}MedTile.png";
            squareContent.Branding  = NotificationsExtensions.TileContent.TileBranding.None;

            // Smaill tile.
            var smallContent = TileContentFactory.CreateTileSquare71x71Image();

            smallContent.Image.Src = $"ms-appdata:///local/{siteName}SmallTile.png";
            smallContent.Branding  = NotificationsExtensions.TileContent.TileBranding.None;

            largeContent.Wide310x150Content  = wideContent;
            wideContent.Square150x150Content = squareContent;
            squareContent.Square71x71Content = smallContent;
            return(largeContent);
        }
Exemple #3
0
        public static void CreateTile(Post post)
        {
            TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.EnableNotificationQueue(true);
            updater.Clear();

            var tileLarge = TileContentFactory.CreateTileWide310x150PeekImage01();

            tileLarge.Image.Src = "ms-appx:///Assets/WideLogo.scale-240.png";
            string title = post.Title;

            //if (title.Length > 13)
            //{
            //    title = title.Substring(0, 12) + "…";
            //}
            tileLarge.TextBodyWrap.Text = post.Summary;
            tileLarge.TextHeading.Text  = title;

            var tileSmall = TileContentFactory.CreateTileSquare150x150PeekImageAndText02();

            tileSmall.Image.Src         = "ms-appx:///Assets/Logo.scale-240.png";
            tileSmall.TextHeading.Text  = post.BlogApp;
            tileSmall.TextBodyWrap.Text = post.Title;

            tileLarge.Square150x150Content = tileSmall;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileLarge.CreateNotification());
        }
Exemple #4
0
        private static void UpdateTile(string condition, string celsius, string fahrenheit)
        {
            var tile = TileUpdateManager.CreateTileUpdaterForApplication();

            if (tile.Setting != NotificationSetting.Enabled)
            {
                return;
            }

            var locationName = GetSetting("locationName");

            ITileWideText01 tileContent = TileContentFactory.CreateTileWideText01();

            tileContent.TextHeading.Text = locationName;
            tileContent.TextBody1.Text   = condition;
            tileContent.TextBody2.Text   = "Celsius: " + celsius;
            tileContent.TextBody3.Text   = "Fahrenheit: " + fahrenheit;

            ITileSquareBlock squareTileContent = TileContentFactory.CreateTileSquareBlock();

            squareTileContent.TextBlock.Text    = celsius;
            squareTileContent.TextSubBlock.Text = locationName;
            tileContent.SquareContent           = squareTileContent;

            tileContent.Branding = TileBranding.Logo;

            TileNotification tileNotification = new TileNotification(tileContent.GetXml());

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
Exemple #5
0
        public void Handle(UpdateTileMessage message)
        {
            var url = message.Image.MediaUrl;

            if (message.Image.Width > 800 || message.Image.Height > 800)
            {
                // after much testing it appears that images > 800px cannot be used as tiles
                url = message.Image.Thumbnail.MediaUrl;
            }

            var content = TileContentFactory.CreateTileWidePeekImageAndText01();

            content.TextBodyWrap.Text = message.Image.Title;
            content.Image.Src         = url;
            content.Image.Alt         = message.Image.Title;

            // Square image substitute
            var squareContent = TileContentFactory.CreateTileSquareImage();

            squareContent.Image.Src = url;
            squareContent.Image.Alt = message.Image.Title;

            content.SquareContent = squareContent;

            _tileUpdateManager.UpdatePrimaryTile(content);

            _statusService.TemporaryMessage = "Tile Update sent for " + message.Image.Title;
        }
        void SendTileNotificationWithQueryStrings_Click(object sender, RoutedEventArgs e)
        {
            ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01();

            tileContent.TextCaptionWrap.Text = "This tile notification uses query strings for the image src.";

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

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

            ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage();

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

            // include the square template.
            tileContent.SquareContent = squareContent;

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

            OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent());
        }
Exemple #7
0
        void SendTileNotificationScaledImage_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";

            ITileWide310x150SmallImageAndText03 wide310x150TileContent = TileContentFactory.CreateTileWide310x150SmallImageAndText03();

            wide310x150TileContent.TextBodyWrap.Text = "blueWide310x150.png in the xml is actually blueWide310x150.scale-" + scale + ".png";
            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";

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

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

            OutputTextBlock.Text = MainPage.PrettyPrint(square310x310TileContent.GetContent());
        }
Exemple #8
0
        public static async Task UpdateTile()
        {
            var article = SampleDataSource.GetItem("Group-1-Item-1");



            var tileContent = TileContentFactory.CreateTileWideImageAndText01();

            tileContent.TextCaptionWrap.Text = article.Title;
            tileContent.Image.Src            = article.ImagePath;
            tileContent.Image.Alt            = article.Subtitle;


            var squareContent = TileContentFactory.CreateTileSquareImage();

            squareContent.Image.Src = article.ImagePath;
            squareContent.Image.Alt = article.Title;

            tileContent.SquareContent = squareContent;



            TileNotification notification = tileContent.CreateNotification();

            TileUpdateManager
            .CreateTileUpdaterForApplication()
            .Update(notification);
        }
        /// <summary>
        /// This is the click handler for the 'Sending tile notification' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendTileNotification_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                if (SecondaryTile.Exists(MainPage.dynamicTileId))
                {
                    // Note: This sample contains an additional reference, NotificationsExtensions, which you can use in your apps
                    ITileWide310x150Text04 tileContent = TileContentFactory.CreateTileWide310x150Text04();
                    tileContent.TextBodyWrap.Text = "Sent to a secondary tile from NotificationsExtensions!";

                    ITileSquare150x150Text04 squareContent = TileContentFactory.CreateTileSquare150x150Text04();
                    squareContent.TextBodyWrap.Text  = "Sent to a secondary tile from NotificationExtensions!";
                    tileContent.Square150x150Content = squareContent;

                    // Send the notification to the secondary tile by creating a secondary tile updater
                    TileUpdateManager.CreateTileUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(tileContent.CreateNotification());

                    rootPage.NotifyUser("Tile notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
                }
                else
                {
                    ToggleButtons(false);
                    rootPage.NotifyUser(MainPage.dynamicTileId + " not pinned.", NotifyType.ErrorMessage);
                }
            }
        }
        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);
            }
        }
        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

            // create the wide template
            ITileWideText03 tileContent = TileContentFactory.CreateTileWideText03();

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

            // Users can resize tiles to square or wide.
            // Apps can choose to include only square assets (meaning the app's tile can never be wide), or
            // include both wide and square assets (the user can resize the tile to square or wide).
            // Apps cannot include only wide assets.

            // Apps that support being wide should include square tile notifications since users
            // determine the size of the tile.

            // create the square template and attach it to the wide template
            ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();

            squareContent.TextBodyWrap.Text = "Hello World! My very own tile notification";
            tileContent.SquareContent       = squareContent;

            // send the notification
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());

            OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent());
        }
        private static void UpdateSecondaryTileWithImage(string tileId, NotificationTile notificationTile, NotificationSecondaryTileType tileType)
        {
            if (!string.IsNullOrEmpty(tileId) && !string.IsNullOrWhiteSpace(tileId) && notificationTile != null)
            {
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).EnableNotificationQueue(false);
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Clear();

                ITileSquarePeekImageAndText02 squareImageAndTextContent = TileContentFactory.CreateTileSquarePeekImageAndText02();
                squareImageAndTextContent.Image.Src         = notificationTile.ImageUri;
                squareImageAndTextContent.Image.Alt         = notificationTile.ImageAltName;
                squareImageAndTextContent.TextHeading.Text  = notificationTile.TextHeading;
                squareImageAndTextContent.TextBodyWrap.Text = notificationTile.TextBodyWrap;
                if (tileType == NotificationSecondaryTileType.CustomTile)
                {
                    ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01();
                    tileContent.Image.Src            = notificationTile.ImageUri;
                    tileContent.Image.Alt            = notificationTile.ImageAltName;
                    tileContent.TextCaptionWrap.Text = notificationTile.TextBodyWrap;
                    tileContent.SquareContent        = squareImageAndTextContent;
                    TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(tileContent.CreateNotification());
                }
                else
                {
                    ITileWidePeekImage05 tileContent = TileContentFactory.CreateTileWidePeekImage05();
                    tileContent.ImageMain.Src     = tileContent.ImageSecondary.Src = notificationTile.ImageUri;
                    tileContent.ImageMain.Alt     = tileContent.ImageSecondary.Alt = notificationTile.ImageAltName;
                    tileContent.TextHeading.Text  = notificationTile.TextHeading;
                    tileContent.TextBodyWrap.Text = notificationTile.TextBodyWrap;
                    tileContent.SquareContent     = squareImageAndTextContent;
                    TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(tileContent.CreateNotification());
                }
            }
        }
Exemple #13
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 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

            // Create notification content based on a visual template.
            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";

            // Users can resize tiles to square or wide.
            // Apps can choose to include only square assets (meaning the app's tile can never be wide), or
            // include both wide and square assets (the user can resize the tile to square or wide).
            // Apps should not include only wide assets.

            // Apps that support being wide should include square tile notifications since users
            // determine the size of the tile.

            // create the square template and attach it to the wide template
            ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage();

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

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

            OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent());
        }
        void UpdateTile_Click(object sender, RoutedEventArgs e)
        {
            ITileWideText03 tileContent = TileContentFactory.CreateTileWideText03();

            tileContent.TextHeadingWrap.Text = TextContent.Text;

            ITileSquareText04 squareTileContent = TileContentFactory.CreateTileSquareText04();

            squareTileContent.TextBodyWrap.Text = TextContent.Text;
            tileContent.SquareContent           = squareTileContent;

            TileNotification tileNotification = tileContent.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;
        }
        public static void UpdateDefaultTile(bool transparentTile = false)
        {
            var tileSubFolder       = transparentTile ? "Transparent" :  "Solid";
            var tileSquare71Content = TileContentFactory.CreateTileSquare71x71Image();
            ITileNotificationContent biggerTile;

            tileSquare71Content.Image.Src = String.Format("ms-appx:///Assets/Tiles/{0}/Square71x71Logo.png", tileSubFolder);

            var tileSquare150Content = TileContentFactory.CreateTileSquare150x150Image();

            tileSquare150Content.Image.Src          = String.Format("ms-appx:///Assets/Tiles/{0}/Square150x150Logo.png", tileSubFolder);
            tileSquare150Content.Square71x71Content = tileSquare71Content;

            var tileWideContent = TileContentFactory.CreateTileWide310x150Image();

            tileWideContent.Image.Src            = String.Format("ms-appx:///Assets/Tiles/{0}/Wide310x150Logo.png", tileSubFolder);
            tileWideContent.Square150x150Content = tileSquare150Content;

#if WINDOWS_PHONE_APP
            biggerTile = tileWideContent;
#else
            var tileSquare310Content = TileContentFactory.CreateTileSquare310x310Image();
            tileSquare310Content.Image.Src          = String.Format("ms-appx:///Assets/Tiles/{0}/Square310x310Logo.png", tileSubFolder);
            tileSquare310Content.Wide310x150Content = tileWideContent;

            biggerTile = tileSquare310Content;
#endif

            TileUpdateManager.CreateTileUpdaterForApplication().Update(biggerTile.CreateNotification());
        }
        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);
        }
        private void FutureLiveTile()
        {
            var applicationTile = TileContentFactory.CreateTileWidePeekImage02();
            var tileUpdater     = TileUpdateManager.CreateTileUpdaterForApplication(CoreApplication.Id);

            // clear the existing tile info
            tileUpdater.Clear();

            applicationTile.TextHeading.Text = "Future Top Scores";
            applicationTile.TextBody1.Text   = "Future Player 1 - 100";
            applicationTile.TextBody2.Text   = "Future Player 1 - 92";
            applicationTile.TextBody3.Text   = "Future Player 1 - 90";
            applicationTile.TextBody4.Text   = "Future Player 1 - 85";

            applicationTile.RequireSquareContent = false;
            applicationTile.Image.Src            = "/Images/AltLiveTileImage_310x150.png";

            var futureTile = new ScheduledTileNotification(applicationTile.GetXml(), DateTime.Now.AddSeconds(10));

            if (ExpireContent)
            {
                futureTile.ExpirationTime = DateTime.Now.AddSeconds(20);
            }

            tileUpdater.AddToSchedule(futureTile);
        }
Exemple #19
0
        /// <summary>
        /// Create the secondary tile
        /// </summary>
        /// <param name="element">Element to pin</param>
        public async Task PinAsync(PinnableObject element)
        {
            SecondaryTile tile = new SecondaryTile
            {
                TileId      = element.Id,
                ShortName   = element.Title,
                DisplayName = element.Title,
                Arguments   = element.Id,
                TileOptions = TileOptions.ShowNameOnLogo,
                Logo        = new Uri("ms-appx:///Assets/Logo.png")
            };

            if (await tile.RequestCreateAsync())
            {
                // Tile template definition
                ITileSquarePeekImageAndText04 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText04();
                squareContent.TextBodyWrap.Text = element.Content;
                squareContent.Image.Src         = element.ImageUrl;
                squareContent.Image.Alt         = element.Content;

                // Tile creation
                TileNotification tileNotification = squareContent.CreateNotification();

                // Send the notification
                TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(element.Id);
                tileUpdater.Update(tileNotification);
            }
        }
        void UpdateTileExpiring_Click(object sender, RoutedEventArgs e)
        {
            int seconds;

            if (!Int32.TryParse(Time.Text, out seconds))
            {
                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);

            OutputTextBlock.Text = "Tile notification sent. It will expire at " + expiryTimeString;
        }
        private void UpdateTile()
        {
            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            ITileWidePeekImage05 tileContent = TileContentFactory.CreateTileWidePeekImage05();

            tileContent.ImageMain.Src      = "http://ww3.sinaimg.cn/bmiddle/643be833jw1e5jg5horgij20dc0hsabq.jpg";
            tileContent.ImageSecondary.Src = "http://ww1.sinaimg.cn/bmiddle/643be833jw1e5jg5ioqhpj20dc0hsmyk.jpg";
            tileContent.TextHeading.Text   = "可可曾";
            tileContent.TextBodyWrap.Text  = "Mat" + ":" + "马童";

            /*
             * ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage();
             *
             * squareContent.Image.Src = "http://ww4.sinaimg.cn/bmiddle/643be833jw1e5jg5l8dapj20hs0dcwga.jpg";
             * squareContent.Image.Alt = "Web image";
             */

            ITileSquarePeekImageAndText02 squareImageAndTextContent = TileContentFactory.CreateTileSquarePeekImageAndText02();

            squareImageAndTextContent.Image.Src         = "http://ww4.sinaimg.cn/bmiddle/643be833jw1e5jg5l8dapj20hs0dcwga.jpg";
            squareImageAndTextContent.Image.Alt         = "Web image";
            squareImageAndTextContent.TextHeading.Text  = string.Format("{0:t}", DateTime.Now);
            squareImageAndTextContent.TextBodyWrap.Text = "Here is some text that is displayed on the peek";

            // include the square template.
            //tileContent.SquareContent = squareContent;
            tileContent.SquareContent = squareImageAndTextContent;

            // send the notification to the app's application tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
        }
        void ScheduleTile(String updateString, DateTime dueTime, int idNumber)
        {
            // Set up the wide tile text
            ITileWide310x150Text09 tileContent = TileContentFactory.CreateTileWide310x150Text09();

            tileContent.TextHeading.Text  = updateString;
            tileContent.TextBodyWrap.Text = "Received: " + dueTime.ToLocalTime();

            // Set up square tile text
            ITileSquare150x150Text04 squareContent = TileContentFactory.CreateTileSquare150x150Text04();

            squareContent.TextBodyWrap.Text = updateString;

            tileContent.Square150x150Content = squareContent;

            // Create the notification object
            ScheduledTileNotification futureTile = new ScheduledTileNotification(tileContent.GetXml(), dueTime);

            futureTile.Id = "Tile" + idNumber;

            // Add to schedule
            // You can update a secondary tile in the same manner using CreateTileUpdaterForSecondaryTile(tileId)
            // See "Tiles" sample for more details
            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile);
            rootPage.NotifyUser("Scheduled a tile with ID: " + futureTile.Id, NotifyType.StatusMessage);
        }
        public void Handle(UpdateTileImageCollectionMessage message)
        {
            if (_history.Contains(message.Instance))
            {
                return;
            }

            var content = TileContentFactory.CreateTileWidePeekImageCollection06();

            content.RequireSquareContent = false;
            content.TextHeadingWrap.Text = "Search for " + message.Instance.Query;

            var images = message.Instance.GetRandomImages(6).ToList();

            UpdateImage(content.ImageMain, images[0]);
            UpdateImage(content.ImageSecondary, images[1]);
            UpdateImage(content.ImageSmallColumn1Row1, images[2]);
            UpdateImage(content.ImageSmallColumn1Row2, images[3]);
            UpdateImage(content.ImageSmallColumn2Row1, images[4]);
            UpdateImage(content.ImageSmallColumn2Row2, images[5]);

            _tileUpdateManager.UpdatePrimaryTile(content);

            _history.Add(message.Instance);
        }
Exemple #24
0
        private static void SetDefaultValues(ModelBindingContext bindingContext, object model)
        {
            // When sending a wide tile in a notification, the payload also includes a square tile
            // because it is not guaranteed which will be displayed; the user has the option to choose
            // either representation in their Start screen.
            var wideTile = model as IWideTileNotificationContent;

            if (wideTile != null)
            {
                var tileImageUrl = bindingContext.ValueProvider.GetValue("AlternativeTileImage");
                var tileText     = bindingContext.ValueProvider.GetValue("AlternativeTileText");

                if (tileImageUrl != null && tileText != null)
                {
                    var squareTile = TileContentFactory.CreateTileSquarePeekImageAndText04();
                    squareTile.Image.Src         = tileImageUrl.AttemptedValue;
                    squareTile.TextBodyWrap.Text = tileText.AttemptedValue;
                    wideTile.SquareContent       = squareTile;
                    return;
                }

                if (tileImageUrl != null)
                {
                    var squareTile = TileContentFactory.CreateTileSquareImage();
                    squareTile.Image.Src   = tileImageUrl.AttemptedValue;
                    wideTile.SquareContent = squareTile;
                    return;
                }

                if (tileText != null)
                {
                    var squareTile = TileContentFactory.CreateTileSquareText04();
                    squareTile.TextBodyWrap.Text = tileText.AttemptedValue;
                    wideTile.SquareContent       = squareTile;
                }
            }

            // When sending a toast notification that has looping audio src, the Audio.Loop property should be set to true
            // and the Duration property should be set to Long, as specified by the WNS model.
            var toast = model as IToastNotificationContent;

            if (toast != null)
            {
                var result = bindingContext.ValueProvider.GetValue("Audio.Content");
                if (result != null)
                {
                    ToastAudioContent audioContent;
                    if (Enum.TryParse <ToastAudioContent>(result.AttemptedValue, out audioContent))
                    {
                        toast.Audio.Loop = audioContent == ToastAudioContent.LoopingAlarm || audioContent == ToastAudioContent.LoopingAlarm2 ||
                                           audioContent == ToastAudioContent.LoopingCall || audioContent == ToastAudioContent.LoopingCall2;
                        if (toast.Audio.Loop)
                        {
                            toast.Duration = ToastDuration.Long;
                        }
                    }
                }
            }
        }
        private TileSquare150x150PeekImageAndText02 get150x150Content(string title, string content)
        {
            TileSquare150x150PeekImageAndText02 tileContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText02() as TileSquare150x150PeekImageAndText02;

            tileContent.TextHeading.Text  = title;
            tileContent.TextBodyWrap.Text = content;
            tileContent.Image.Src         = "ms-appx:///Images/" + imageNum + "/150_150.jpg";
            return(tileContent);
        }
Exemple #26
0
        private static ITileSquarePeekImageAndText04 GetSquateTempalte(PlaybackNotificationOptions options)
        {
            var tile = TileContentFactory.CreateTileSquarePeekImageAndText04();

            tile.Image.Src         = options.ImageUrl;
            tile.TextBodyWrap.Text = string.Format("{0} - {1}", options.Title, options.Subtitle);

            return(tile);
        }
        /// <summary>
        /// メッセージの追加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addMessageButton_Click(object sender, RoutedEventArgs e)
        {
            ITileWideSmallImageAndText03 tileContent = TileContentFactory.CreateTileWideSmallImageAndText03();

            tileContent.TextBodyWrap.Text    = "このメッセージはタイルとロックスクリーンに表示されます。";
            tileContent.Image.Src            = "ms-appx:///Assets/24.png";
            tileContent.RequireSquareContent = false;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
        }
        private TileSquare150x150PeekImageAndText02 get150x150Content(string title, string content)
        {
            TileSquare150x150PeekImageAndText02 tileContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText02() as TileSquare150x150PeekImageAndText02;

            tileContent.TextHeading.Text  = title;
            tileContent.TextBodyWrap.Text = content;
            tileContent.Image.Src         = "ms-appx:///Assets/squaretile-sdk.png";
            return(tileContent);
        }
Exemple #29
0
        public async void UpdateAsync(long count)
        {
            try
            {
                var wideImage = await RenderAsync(new StartTileWide(count), 310, 150);

                if (wideImage == null)
                {
                    return;
                }
                var wideName = await SaveFileAsync(wideImage, WideFileName, 310U, 150U);

                var squareImage = await RenderAsync(new StartTileSquare(count), 150, 150);

                if (squareImage == null)
                {
                    return;
                }
                var squareName = await SaveFileAsync(squareImage, SquareFileName, 150U, 150U);

                var squareSmallImage = await RenderAsync(new StartTileSquareSmall(count), 71, 71);

                if (squareSmallImage == null)
                {
                    return;
                }
                var squareSmallName = await SaveFileAsync(squareSmallImage, SquareSmallFileName, 71U, 71U);

                var tileWide = TileContentFactory.CreateTileWide310x150Image();
                tileWide.StrictValidation = true;

                tileWide.Branding  = TileBranding.Name;
                tileWide.Image.Src = "ms-appdata:///local/" + wideName;

                var tileSquare = TileContentFactory.CreateTileSquare150x150Image();
                tileSquare.Branding           = TileBranding.Name;
                tileSquare.Image.Src          = "ms-appdata:///local/" + squareName;
                tileWide.Square150x150Content = tileSquare;

                var tileSquareSmall = TileContentFactory.CreateTileSquare71x71Image();
                tileSquareSmall.Branding      = TileBranding.None;
                tileSquareSmall.Image.Src     = "ms-appdata:///local/" + squareSmallName;
                tileSquare.Square71x71Content = tileSquareSmall;

                var tileNotification = tileWide.CreateNotification();
                tileNotification.ExpirationTime = DateTimeOffset.Now.AddDays(1D);

                var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
                tileUpdater.Clear();
                tileUpdater.Update(tileNotification);
            }
            catch (Exception ex)
            {
                _telemetryClient.TrackException(ex);
            }
        }
        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);
        }