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());
        }
示例#2
0
        void ScheduleTile(String updateString, DateTime dueTime, int idNumber)
        {
            // Set up the wide tile text
            ITileWideText09 tileContent = TileContentFactory.CreateTileWideText09();

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

            // Set up square tile text
            ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();

            squareContent.TextBodyWrap.Text = updateString;

            tileContent.SquareContent = 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);
        }
        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;
        }
        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;
        }
示例#5
0
        /// <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
                    ITileWideText04 tileContent = TileContentFactory.CreateTileWideText04();
                    tileContent.TextBodyWrap.Text = "Sent to a secondary tile from NotificationsExtensions!";

                    ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();
                    squareContent.TextBodyWrap.Text = "Sent to a secondary tile from NotificationExtensions!";
                    tileContent.SquareContent       = 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);
                }
            }
        }
示例#6
0
        public async void pinButton_Click(object sender, RoutedEventArgs e)
        {
            this.BottomAppBar.IsSticky = true;

            _item.IsPin = true;

            var logo      = new Uri("ms-appx:///Assets/Logo.png");
            var logoWide  = new Uri("ms-appx:///Assets/WideLogo.png");
            Uri smallLogo = new Uri("ms-appx:///Assets/SmallLogo.png");


            SecondaryTile tile = new SecondaryTile(
                _item.UniqueId,                 // Tile ID
                "Think",                        // Tile short name
                _item.Autor,                    // Tile display name
                _item.UniqueId,                 // Activation argument
                TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo,
                logo,                           // Tile logo
                logoWide
                );

            // Specify a foreground text value.
            // The tile background color is inherited from the parent unless a separate value is specified.
            tile.ForegroundText = ForegroundText.Light;


            // Like the background color, the small tile logo is inherited from the parent application tile by default. Let's override it, just to see how that's done.
            tile.SmallLogo = smallLogo;


            bool created = await tile.RequestCreateAsync();

            if (created)
            {
                // Note: This sample contains an additional reference, NotificationsExtensions, which you can use in your apps
                ITileWideText09 tileContent = TileContentFactory.CreateTileWideText09();
                tileContent.TextHeading.Text  = _item.Autor;
                tileContent.TextBodyWrap.Text = _item.Quote;


                ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();
                squareContent.TextBodyWrap.Text = _item.Quote;
                tileContent.SquareContent       = squareContent;


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

            // Show pin button in the appbar
            CheckAppBarButtons();

            this.BottomAppBar.IsSticky = false;
            ThinkDataSource.SaveLocalDataAsync();
        }
示例#7
0
        private void UpdateTileWithText()
        {
            ITileWideText03 tileContent = TileContentFactory.CreateTileWideText03();

            tileContent.TextHeadingWrap.Text = "你有三条未读短信!";

            ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();

            squareContent.TextBodyWrap.Text = "你有三条未读短信!";
            tileContent.SquareContent       = squareContent;

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
        }
        void SendTileNotificationText_Click(object sender, RoutedEventArgs e)
        {
            ITileWideText03 tileContent = TileContentFactory.CreateTileWideText03();

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

            ITileSquareText04 squareTileContent = TileContentFactory.CreateTileSquareText04();

            squareTileContent.TextBodyWrap.Text = "ms-resource:greeting";
            tileContent.SquareContent           = squareTileContent;

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

            OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent());
        }