コード例 #1
0
        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());
                }
            }
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        /// <summary>
        /// Add 5 last shows on the tile
        /// </summary>
        /// <returns>The notification for the tile</returns>
        private async Task <TileNotification> AddShowsToTileAsync()
        {
            // Resolve model
            using (ILifetimeScope scope = ViewModelLocator.Container.BeginLifetimeScope())
            {
                // Get the shows from the model
                IReadableLimitable <Show> model = scope.Resolve <IReadableLimitable <Show> >();
                IList <Show> shows = await model.GetAsync(0, ItemsNumber);

                // Create the square tile if there is one show available
                if (shows.Any())
                {
                    ITileSquarePeekImageAndText02 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText02();
                    squareContent.TextHeading.Text  = ResourcesAccessor.GetString("Shows_Small");
                    squareContent.TextBodyWrap.Text = shows[0].Name;
                    squareContent.Image.Src         = shows[0].ImageUrl;
                    squareContent.Image.Alt         = shows[0].Name;

                    // Create the wide tile if there are enough elements
                    if (shows.Count == ItemsNumber)
                    {
                        ITileWidePeekImageCollection05 wideContent = TileContentFactory.CreateTileWidePeekImageCollection05();

                        // Link the square tile and the wide tile
                        wideContent.SquareContent = squareContent;

                        // Text
                        wideContent.TextHeading.Text  = ResourcesAccessor.GetString("Shows_Long");
                        wideContent.TextBodyWrap.Text = string.Format("{0} ({1})", shows[0].Name, DateFormatter.Format(shows[0].Start_DateTime));

                        // ImageUrls
                        wideContent.ImageMain.Src = shows[0].ImageUrl;
                        wideContent.ImageMain.Alt = shows[0].Name;

                        wideContent.ImageSecondary.Src = shows[0].ImageUrl;
                        wideContent.ImageSecondary.Alt = shows[0].Name;

                        wideContent.ImageSmallColumn1Row1.Alt = shows[1].Name;
                        wideContent.ImageSmallColumn1Row1.Src = shows[1].ImageUrl;

                        wideContent.ImageSmallColumn1Row2.Alt = shows[2].Name;
                        wideContent.ImageSmallColumn1Row2.Src = shows[2].ImageUrl;

                        wideContent.ImageSmallColumn2Row1.Alt = shows[3].Name;
                        wideContent.ImageSmallColumn2Row1.Src = shows[3].ImageUrl;

                        wideContent.ImageSmallColumn2Row2.Alt = shows[4].Name;
                        wideContent.ImageSmallColumn2Row2.Src = shows[4].ImageUrl;

                        return(wideContent.CreateNotification());
                    }
                }
            }

            return(null);
        }
コード例 #4
0
        /// <summary>
        /// Add 5 last conferences on the tile
        /// </summary>
        /// <returns>The notification for the tile</returns>
        private async Task <TileNotification> AddConferencesToTileAsync()
        {
            // Resolve the model
            using (ILifetimeScope scope = ViewModelLocator.Container.BeginLifetimeScope())
            {
                // Get conferences from model
                IReadableLimitable <Conference> model = scope.Resolve <IReadableLimitable <Conference> >();
                IList <Conference> conferences        = await model.GetAsync(0, ItemsNumber);

                // Create the square tile if there is one conference available
                if (conferences.Any())
                {
                    ITileSquarePeekImageAndText02 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText02();
                    squareContent.TextHeading.Text  = ResourcesAccessor.GetString("Conferences_Small");
                    squareContent.TextBodyWrap.Text = conferences[0].Name;
                    squareContent.Image.Src         = conferences[0].ImageUrl;
                    squareContent.Image.Alt         = conferences[0].Name;

                    // Create the wide tile if there are enough elements
                    if (conferences.Count == ItemsNumber)
                    {
                        ITileWidePeekImageCollection02 wideContent = TileContentFactory.CreateTileWidePeekImageCollection02();

                        // Link the square tile and the wide tile
                        wideContent.SquareContent = squareContent;

                        // Texts
                        wideContent.TextHeading.Text = ResourcesAccessor.GetString("Conferences_Large");
                        wideContent.TextBody1.Text   = conferences[0].Name;
                        wideContent.TextBody2.Text   = conferences[1].Name;
                        wideContent.TextBody3.Text   = conferences[2].Name;
                        wideContent.TextBody4.Text   = conferences[3].Name;

                        // ImageUrls
                        wideContent.ImageMain.Src = conferences[0].ImageUrl;
                        wideContent.ImageMain.Alt = conferences[0].Name;

                        wideContent.ImageSmallColumn1Row1.Alt = conferences[1].Name;
                        wideContent.ImageSmallColumn1Row1.Src = conferences[1].ImageUrl;

                        wideContent.ImageSmallColumn1Row2.Alt = conferences[2].Name;
                        wideContent.ImageSmallColumn1Row2.Src = conferences[2].ImageUrl;

                        wideContent.ImageSmallColumn2Row1.Alt = conferences[3].Name;
                        wideContent.ImageSmallColumn2Row1.Src = conferences[3].ImageUrl;

                        wideContent.ImageSmallColumn2Row2.Alt = conferences[4].Name;
                        wideContent.ImageSmallColumn2Row2.Src = conferences[4].ImageUrl;

                        return(wideContent.CreateNotification());
                    }
                }
            }

            return(null);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="notificationTileList"></param>
        public static void UpdateTileWithImages(List <NotificationTile> notificationTileList)
        {
            if (notificationTileList != null && notificationTileList.Count > 0)
            {
                TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
                TileUpdateManager.CreateTileUpdaterForApplication().Clear();
                for (int i = 0; i < notificationTileList.Count; i++)
                {
                    if (i < 5)
                    {
                        ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01();
                        tileContent.Image.Src = notificationTileList[i].ImageUri;
                        tileContent.Image.Alt = notificationTileList[i].ImageAltName;
                        if (notificationTileList[i].TextBodyWrap.Length > 80)
                        {
                            tileContent.TextCaptionWrap.Text = notificationTileList[i].TextBodyWrap.Substring(0, 80);
                        }
                        else
                        {
                            tileContent.TextCaptionWrap.Text = notificationTileList[i].TextBodyWrap;
                        }

                        ITileSquarePeekImageAndText02 squareImageAndTextContent = TileContentFactory.CreateTileSquarePeekImageAndText02();
                        squareImageAndTextContent.Image.Src = notificationTileList[i].ImageUri;
                        squareImageAndTextContent.Image.Alt = notificationTileList[i].ImageAltName;
                        if (notificationTileList[i].TextHeading.Length > 30)
                        {
                            squareImageAndTextContent.TextHeading.Text = notificationTileList[i].TextHeading.Substring(0, 30);
                        }
                        else
                        {
                            squareImageAndTextContent.TextHeading.Text = notificationTileList[i].TextHeading;
                        }

                        if (notificationTileList[i].TextBodyWrap.Length > 80)
                        {
                            squareImageAndTextContent.TextBodyWrap.Text = notificationTileList[i].TextBodyWrap.Substring(0, 80);
                        }
                        else
                        {
                            squareImageAndTextContent.TextBodyWrap.Text = notificationTileList[i].TextBodyWrap;
                        }
                        tileContent.SquareContent = squareImageAndTextContent;

                        TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Add 5 last news on the tile
        /// </summary>
        /// <returns>The notification for the tile</returns>
        private async Task <TileNotification> AddNewsToTileAsync()
        {
            // Resolve the model
            using (ILifetimeScope scope = ViewModelLocator.Container.BeginLifetimeScope())
            {
                // Get news from model
                IReadableLimitable <News> model = scope.Resolve <IReadableLimitable <News> >();
                IList <News> newsList           = await model.GetAsync(0, ItemsNumber);

                // Create the tile
                if (newsList.Count == ItemsNumber)
                {
                    var  random = new Random();
                    int  index  = random.Next(0, ItemsNumber);
                    News news   = newsList[index];

                    // Create the square tile
                    ITileSquarePeekImageAndText02 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText02();

                    // Square tile text
                    squareContent.TextHeading.Text  = DateFormatter.Format(news.DateTime);
                    squareContent.TextBodyWrap.Text = news.Title;

                    // Square tile image
                    squareContent.Image.Src = news.ImageUrl;
                    squareContent.Image.Alt = news.Title;

                    // Create the wide tile
                    ITileWideSmallImageAndText04 wideContent = TileContentFactory.CreateTileWideSmallImageAndText04();

                    // Link the square tile and the wide tile
                    wideContent.SquareContent = squareContent;

                    // Wide tile text
                    wideContent.TextHeading.Text  = DateFormatter.Format(news.DateTime);
                    wideContent.TextBodyWrap.Text = news.Title;

                    // Wide tile image
                    wideContent.Image.Src = news.ImageUrl;
                    wideContent.Image.Alt = news.Title;

                    return(wideContent.CreateNotification());
                }
            }

            return(null);
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="notificationTile"></param>
        public static void UpdateTileWithImage(NotificationTile notificationTile)
        {
            if (notificationTile != null)
            {
                TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(false);
                TileUpdateManager.CreateTileUpdaterForApplication().Clear();
                ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01();
                tileContent.Image.Src = notificationTile.ImageUri;
                tileContent.Image.Alt = notificationTile.ImageAltName;
                if (notificationTile.TextBodyWrap.Length > 80)
                {
                    tileContent.TextCaptionWrap.Text = notificationTile.TextBodyWrap.Substring(0, 80);
                }
                else
                {
                    tileContent.TextCaptionWrap.Text = notificationTile.TextBodyWrap;
                }

                ITileSquarePeekImageAndText02 squareImageAndTextContent = TileContentFactory.CreateTileSquarePeekImageAndText02();
                squareImageAndTextContent.Image.Src = notificationTile.ImageUri;
                squareImageAndTextContent.Image.Alt = notificationTile.ImageAltName;
                if (notificationTile.TextHeading.Length > 30)
                {
                    squareImageAndTextContent.TextHeading.Text = notificationTile.TextHeading.Substring(0, 30);
                }
                else
                {
                    squareImageAndTextContent.TextHeading.Text = notificationTile.TextHeading;
                }

                if (notificationTile.TextBodyWrap.Length > 80)
                {
                    squareImageAndTextContent.TextBodyWrap.Text = notificationTile.TextBodyWrap.Substring(0, 80);
                }
                else
                {
                    squareImageAndTextContent.TextBodyWrap.Text = notificationTile.TextBodyWrap;
                }
                tileContent.SquareContent = squareImageAndTextContent;

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