コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
0
        /// <summary>
        /// CHeck if a new show is a available and display the toast notification
        /// </summary>
        public override async Task CheckAndDisplayAsync()
        {
            // Resolve model
            IReadableLimitable <Show> model;

            using (ILifetimeScope scope = ViewModelLocator.Container.BeginLifetimeScope())
                model = scope.Resolve <IReadableLimitable <Show> >();

            // Get last show Id from model
            int idLastShow = await model.GetLastInsertedId();

            // Get last show saved Id
            int idLastShowSaved = 0;

            if (ApplicationData.Current.LocalSettings.Values[_storageKey] != null)
            {
                idLastShowSaved = (int)ApplicationData.Current.LocalSettings.Values[_storageKey];
            }

            // If Ids are differents, update the saved Id and show a toast notification
            if (idLastShow != idLastShowSaved)
            {
                Show show = await model.GetAsync(idLastShow);

                IToastImageAndText04 toastContent = ToastContentFactory.CreateToastImageAndText04();

                toastContent.Image.Src = show.ImageUrl;
                toastContent.Image.Alt = show.Name;

                toastContent.TextHeading.Text = ResourcesAccessor.GetString("Shows_New");
                toastContent.TextBody1.Text   = show.Name;
                toastContent.TextBody2.Text   = string.Format(ResourcesAccessor.GetString("Shows_DateFormat"), show.Start_DateTime, show.End_DateTime);

                ToastNotification toast = toastContent.CreateNotification();
                ToastNotificationManager.CreateToastNotifier().Show(toast);

                ApplicationData.Current.LocalSettings.Values[_storageKey] = idLastShow;
            }
        }
コード例 #4
0
        /// <summary>
        /// CHeck if a new news is a available and display the toast notification
        /// </summary>
        public override async Task CheckAndDisplayAsync()
        {
            // Resolve model
            IReadableLimitable <News> model;

            using (ILifetimeScope scope = ViewModelLocator.Container.BeginLifetimeScope())
                model = scope.Resolve <IReadableLimitable <News> >();

            // Get last news Id from model
            int idLastNews = await model.GetLastInsertedId();

            // Get last news saved Id
            int idLastNewsSaved = 0;

            if (ApplicationData.Current.LocalSettings.Values[_storageKey] != null)
            {
                idLastNewsSaved = (int)ApplicationData.Current.LocalSettings.Values[_storageKey];
            }

            // If Ids are differents, update the saved Id and show a toast notification
            if (idLastNews != idLastNewsSaved)
            {
                News news = await model.GetAsync(idLastNews);

                IToastImageAndText04 toastContent = ToastContentFactory.CreateToastImageAndText04();

                toastContent.Image.Src = news.ImageUrl;
                toastContent.Image.Alt = news.Title;

                toastContent.TextHeading.Text = ResourcesAccessor.GetString("News_New");
                toastContent.TextBody1.Text   = news.Title;
                toastContent.TextBody2.Text   = news.ShortText;

                ToastNotification toast = toastContent.CreateNotification();
                ToastNotificationManager.CreateToastNotifier().Show(toast);

                ApplicationData.Current.LocalSettings.Values[_storageKey] = idLastNews;
            }
        }