Ejemplo n.º 1
0
        /// <summary>
        /// TileWideText09
        /// One header string in larger text over one string of regular text wrapped over a maximum of four lines.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileWideText09
        ///
        /// TileSquareText02
        /// One header string in larger text on the first line, over one string of regular text wrapped over a maximum of three lines.
        /// http://msdn.microsoft.com/en-us/library/windows/apps/hh761491#TileSquareText02
        /// </summary>
        /// <param name="item"></param>
        private static void CreateTextOnlyTile(NoteDataCommon item)
        {
            ITileWide310x150Text09 tileContent = TileContentFactory.CreateTileWide310x150Text09();

            tileContent.RequireSquare150x150Content = true;
            tileContent.TextHeading.Text            = item.Title;
            tileContent.TextBodyWrap.Text           = item.Description.Equals(Consts.DefaultDescriptionText) ? string.Empty : item.Description;

            ITileSquare150x150Text02 squareTileContent = TileContentFactory.CreateTileSquare150x150Text02();

            squareTileContent.TextHeading.Text  = item.Title;
            squareTileContent.TextBodyWrap.Text = item.Description.Equals(Consts.DefaultDescriptionText) ? string.Empty : item.Description;

            tileContent.Branding             = TileBranding.Name;
            tileContent.Square150x150Content = squareTileContent;

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(item.UniqueId).Update(tileContent.CreateNotification());
        }
Ejemplo n.º 2
0
        public static async Task <bool> UpdateNoteTileIfExists(Note note, bool transparentTile = false)
        {
            //must exists
            if (!SecondaryTile.Exists(note.ID))
            {
                return(false);
            }

            //update background
            await UpdateNoteTileBackgroundColor(note, transparentTile);

            string contentWithoutTitle = note.GetContent(true, false, 150, 3);
            string contentWithTitle    = note.GetContent(true, true, 200, 3);

            var tileSquare71Content = TileContentFactory.CreateTileSquare71x71Image();

            tileSquare71Content.Image.Src = "ms-appx:///Assets/Tiles/Transparent/Square71x71Logo.png";

            ITileNotificationContent biggerTile;
            ISquare150x150TileNotificationContent tileSquare150Content;

            if (note.Images != null && note.Images.Count > 0)
            {
                tileSquare150Content = TileContentFactory.CreateTileSquare150x150PeekImageAndText02();

                var _tileSquare150Content = tileSquare150Content as ITileSquare150x150PeekImageAndText02;
                _tileSquare150Content.TextHeading.Text   = note.Title;
                _tileSquare150Content.TextBodyWrap.Text  = contentWithoutTitle;
                _tileSquare150Content.Image.Src          = note.Images[0].URL;
                _tileSquare150Content.Square71x71Content = tileSquare71Content;
                _tileSquare150Content.Branding           = NotificationsExtensions.TileContent.TileBranding.Logo;
            }
            else
            {
                tileSquare150Content = TileContentFactory.CreateTileSquare150x150Text02();

                var _tileSquare150Content = tileSquare150Content as ITileSquare150x150Text02;
                _tileSquare150Content.TextHeading.Text   = note.Title;
                _tileSquare150Content.TextBodyWrap.Text  = contentWithoutTitle;
                _tileSquare150Content.Square71x71Content = tileSquare71Content;
                _tileSquare150Content.Branding           = NotificationsExtensions.TileContent.TileBranding.Logo;
            }

            IWide310x150TileNotificationContent tileWide310x150Content;

            if (note.Images != null && note.Images.Count > 0)
            {
                tileWide310x150Content = TileContentFactory.CreateTileWide310x150PeekImage01();

                var _tileWide310x150Content = tileWide310x150Content as ITileWide310x150PeekImage01;
                _tileWide310x150Content.TextHeading.Text     = note.Title;
                _tileWide310x150Content.TextBodyWrap.Text    = contentWithoutTitle;
                _tileWide310x150Content.Image.Src            = note.Images[0].URL;
                _tileWide310x150Content.Square150x150Content = tileSquare150Content;
                _tileWide310x150Content.Branding             = NotificationsExtensions.TileContent.TileBranding.Logo;
            }
            else
            {
                tileWide310x150Content = TileContentFactory.CreateTileWide310x150Text09();

                var _tileWide310x150Content = tileWide310x150Content as ITileWide310x150Text09;
                _tileWide310x150Content.TextHeading.Text     = note.Title;
                _tileWide310x150Content.TextBodyWrap.Text    = contentWithoutTitle;
                _tileWide310x150Content.Square150x150Content = tileSquare150Content;
                _tileWide310x150Content.Branding             = NotificationsExtensions.TileContent.TileBranding.Logo;
            }

#if WINDOWS_PHONE_APP
            biggerTile = tileWide310x150Content;
#else
            ISquare310x310TileNotificationContent tileSquare310Content;
            if (note.Images != null && note.Images.Count > 0)
            {
                tileSquare310Content = TileContentFactory.CreateTileSquare310x310ImageAndTextOverlay02();

                var _tileSquare310Content = tileSquare310Content as ITileSquare310x310ImageAndTextOverlay02;
                _tileSquare310Content.TextHeadingWrap.Text = note.Title;
                _tileSquare310Content.TextBodyWrap.Text    = contentWithoutTitle;
                _tileSquare310Content.Image.Src            = note.Images[0].URL;
                _tileSquare310Content.Wide310x150Content   = tileWide310x150Content;
                _tileSquare310Content.Branding             = NotificationsExtensions.TileContent.TileBranding.Logo;
            }
            else
            {
                tileSquare310Content = TileContentFactory.CreateTileSquare310x310ImageAndTextOverlay02();

                var _tileSquare310Content = tileSquare310Content as ITileSquare310x310ImageAndTextOverlay02;
                _tileSquare310Content.TextHeadingWrap.Text = note.Title;
                _tileSquare310Content.TextBodyWrap.Text    = contentWithoutTitle;
                _tileSquare310Content.Image.Src            = "";
                _tileSquare310Content.Wide310x150Content   = tileWide310x150Content;
                _tileSquare310Content.Branding             = NotificationsExtensions.TileContent.TileBranding.Logo;
            }

            biggerTile = tileSquare310Content;
#endif

            //create notification
            var notification = biggerTile.CreateNotification();
            notification.Tag = note.ID.Substring(0, 16);

            //update
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(note.ID);
            tileUpdater.Clear();
            //tileUpdater.EnableNotificationQueue(false); //crashing on w10mobile
            tileUpdater.Update(notification);

            return(true);
        }