private async void PinTile()
        {
            SecondaryTile tile = new SecondaryTile(DateTime.Now.Ticks.ToString())
            {
                DisplayName = "Xbox",
                Arguments   = "args"
            };

            tile.VisualElements.Square150x150Logo           = Constants.Square150x150Logo;
            tile.VisualElements.Wide310x150Logo             = Constants.Wide310x150Logo;
            tile.VisualElements.Square310x310Logo           = Constants.Square310x310Logo;
            tile.VisualElements.ShowNameOnSquare150x150Logo = true;
            tile.VisualElements.ShowNameOnSquare310x310Logo = true;
            tile.VisualElements.ShowNameOnWide310x150Logo   = true;

            if (!await tile.RequestCreateAsync())
            {
                return;
            }

            // Generate the tile notification content and update the tile
            TileContent content = GenerateTileContent("MasterHip", "Assets/Photos/Owl.jpg");

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(new TileNotification(content.GetXml()));
        }
예제 #2
0
        public static void UpdateLiveTiles()
        {
            Settings settings = new Settings();

            var tileXml = TileCreator.GenerateTile(settings.AppLanguage, DateTimeOffset.Now, settings.TileTier);

            Debug.WriteLine("Tile XML generated");
            var tileNotification = new TileNotification(tileXml);

            var tileUpdaterApp = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdaterApp.Update(tileNotification);

            Debug.WriteLine("Primary tile updated");
            GC.Collect();

            // a simple check that should avoid the exception
            if (SecondaryTile.Exists(SecondaryAppTileId))
            {
                try
                {
                    tileNotification = new TileNotification(tileXml);
                    var tileUpdaterSecondary = TileUpdateManager.CreateTileUpdaterForSecondaryTile(SecondaryAppTileId);
                    tileUpdaterSecondary.Update(tileNotification);

                    Debug.WriteLine("Secondary tile updated");
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Secondary tile update failure. Non-critical - {0}", ex);
                }
            }
        }
예제 #3
0
 private void Update(string tileId, XmlDocument doc)
 {
     if (SecondaryTile.Exists(tileId))
     {
         TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(new TileNotification(doc));
     }
 }
예제 #4
0
        private async void Pin(object sender, RoutedEventArgs e)
        {
            string        tileID = $@"MenetrendApp-{line.FromsID}-{line.FromlsID}-{line.TosID}-{line.TolsID}";
            SecondaryTile tile   = new SecondaryTile(tileID, line.Name, $@"{line.From}|{line.To}|{line.Name}", new Uri("ms-appx:///Assets/Wide310x150Secondary.scale-200.png"), TileSize.Wide310x150);

            var visual = tile.VisualElements;

            visual.ShowNameOnSquare150x150Logo = true;
            visual.ShowNameOnWide310x150Logo   = true;
            visual.Square150x150Logo           = new Uri("ms-appx:///Assets/Square150x150Secondary.scale-200.png");
            visual.Wide310x150Logo             = new Uri("ms-appx:///Assets/Wide310x150Secondary.scale-200.png");
            visual.Square71x71Logo             = new Uri("ms-appx:///Assets/Square70x70Secondary.scale-100.png");

            await tile.RequestCreateAsync();

            AppbarPin.Visibility   = Visibility.Collapsed;
            AppbarUnPin.Visibility = Visibility.Visible;
#if WINDOWS_UWP
            AppbarPin2.Visibility   = Visibility.Collapsed;
            AppbarUnPin2.Visibility = Visibility.Visible;

            await App.trigger.RequestAsync(); // run tile updater
#elif WINDOWS_PHONE_APP
            XmlDocument      tileXml = Utilities.TileData.getXML("", current.LineNumber, current.StartTime, current.From, current.EndTime, current.To, false);
            TileNotification notif   = new TileNotification(tileXml);
            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileID).Update(notif);
#endif
        }
        private async void UpdateMedium(TileBindingContentAdaptive mediumContent)
        {
            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = new TileBinding()
                    {
                        Content = mediumContent
                    }
                }
            };

            try
            {
                TileUpdateManager.CreateTileUpdaterForSecondaryTile("SecondaryTile").Update(new TileNotification(content.GetXml()));
            }

            catch
            {
                SecondaryTile tile = new SecondaryTile("SecondaryTile", "Example", "args", new Uri("ms-appx:///Assets/Logo.png"), TileSize.Default);
                tile.VisualElements.ShowNameOnSquare150x150Logo = true;
                tile.VisualElements.ShowNameOnSquare310x310Logo = true;
                tile.VisualElements.ShowNameOnWide310x150Logo   = true;
                tile.VisualElements.BackgroundColor             = Colors.Transparent;
                await tile.RequestCreateAsync();

                TileUpdateManager.CreateTileUpdaterForSecondaryTile("SecondaryTile").Update(new TileNotification(content.GetXml()));
            }
        }
        public void UpdateSecondaryTile(Tile tile, string tileId)
        {
            var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId);
            TileNotification notification = new TileNotification(tile.ToXmlDocument());

            updater.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);
                }
            }
        }
예제 #8
0
        private void SendTileNotification_Click(object sender, RoutedEventArgs e)
        {
            if (VerifyTileIsPinned())
            {
                var tileContent = new TileContent
                {
                    Visual = new TileVisual
                    {
                        TileWide = new TileBinding
                        {
                            Content = new TileBindingContentAdaptive
                            {
                                Children =
                                {
                                    new AdaptiveText {
                                        Text = "Sent to a secondary tile from NotificationsExtensions!", HintWrap = true
                                    },
                                }
                            }
                        }
                    }
                };
                // Send the notification to the secondary tile by creating a secondary tile updater
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(new TileNotification(tileContent.GetXml()));

                rootPage.NotifyUser("Tile notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
            }
        }
예제 #9
0
        // pin to start
        private async void PinLine(object sender, RoutedEventArgs e, Card card, bool remove)
        {
            string        tileID = $@"MenetrendApp-{card.ParentLine.FromsID}-{card.ParentLine.FromlsID}-{card.ParentLine.TosID}-{card.ParentLine.TolsID}";
            SecondaryTile tile   = new SecondaryTile(tileID, card.ParentLine.Name, $@"{card.ParentLine.From}|{card.ParentLine.To}|{card.ParentLine.Name}", new Uri("ms-appx:///Assets/Wide310x150Secondary.scale-200.png"), TileSize.Wide310x150);

            if (remove)
            {
                try { await tile.RequestDeleteAsync(); } catch (Exception) { }
            }
            else
            {
                var visual = tile.VisualElements;
                visual.ShowNameOnSquare150x150Logo = true;
                visual.ShowNameOnWide310x150Logo   = true;
                visual.Square150x150Logo           = new Uri("ms-appx:///Assets/Square150x150Secondary.scale-200.png");
                visual.Wide310x150Logo             = new Uri("ms-appx:///Assets/Wide310x150Secondary.scale-200.png");
                visual.Square71x71Logo             = new Uri("ms-appx:///Assets/Square70x70Secondary.scale-100.png");

                await tile.RequestCreateAsync();

#if WINDOWS_PHONE_APP
                XmlDocument      tileXml = Utilities.TileData.getXML("", card.LineNumber, card.StartTime, card.From, card.EndTime, card.To, false);
                TileNotification notif   = new TileNotification(tileXml);
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileID).Update(notif);
#elif WINDOWS_UWP
                await App.trigger.RequestAsync(); // run tile updater
#endif
            }
        }
예제 #10
0
        private static async void UpdateNewsTile(ArticlePageWorkMode mode)
        {
            var news = await new MalArticlesIndexQuery(mode).GetArticlesIndex();

            try
            {
                var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(mode == ArticlePageWorkMode.Articles ? ArticlesTileId : NewsTileId);
                updater.EnableNotificationQueue(true);
                updater.Clear();
                foreach (var malNewsUnitModel in news.Take(5))
                {
                    var tileContent = new TileContent
                    {
                        Visual = new TileVisual
                        {
                            TileMedium = GenerateTileBindingMedium(malNewsUnitModel),
                            TileWide   = GenerateTileBindingWide(malNewsUnitModel),
                        }
                    };
                    if (!ViewModelLocator.Mobile)
                    {
                        tileContent.Visual.TileLarge = GenerateTileBindingLarge(malNewsUnitModel);
                    }
                    updater.Update(new TileNotification(tileContent.GetXml()));
                }
            }
            catch (Exception)
            {
                //can carsh due to unknown reasons
            }
            _tileUpdateSemaphore?.Release();
            NotificationTaskManager.StartNotificationTask(BgTasks.Tiles, false);
        }
예제 #11
0
        public void UpdateNewSecondaryTile()
        {
            string      name               = ApplicationSettingsHelper.ReadResetSettingsValue(AppConstants.TileName) as string;
            string      id                 = ApplicationSettingsHelper.ReadResetSettingsValue(AppConstants.TileId) as string;
            string      type               = ApplicationSettingsHelper.ReadResetSettingsValue(AppConstants.TileType) as string;
            XmlDocument tileXml            = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text02);
            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");

            tileTextAttributes[0].InnerText = type;
            tileTextAttributes[1].InnerText = name;

            XmlDocument wideTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text09);
            XmlNodeList textAttr = wideTile.GetElementsByTagName("text");

            textAttr[0].InnerText = type;
            textAttr[1].InnerText = name;

            IXmlNode node = tileXml.ImportNode(wideTile.GetElementsByTagName("binding").Item(0), true);

            tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

            TileNotification tileNotification = new TileNotification(tileXml);

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(id).Update(tileNotification);
        }
예제 #12
0
 public static void CreateSubTileNotification(List <TileContent> list, string tileName)
 {
     if (SecondaryTile.Exists(tileName))
     {
         var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileName);
         updater.EnableNotificationQueue(true);
         int i = 0;
         foreach (var item in list)
         {
             try
             {
                 if (item == null)
                 {
                     continue;
                 }
                 TileNotification n = new TileNotification(item.GetXml());
                 n.Tag = i.ToString();
                 updater.Update(n);
                 i++;
             }
             catch (Exception)
             {
                 continue;
             }
         }
     }
 }
예제 #13
0
        public void UpdateTile()
        {
            if (refreshDate == null || refreshDate.Value.Add(refreshInterval) < DateTime.Now)
            {
                return;
            }
            if (SecondaryTile.Exists(this.Id))
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);
                var         texts   = tileXml.GetElementsByTagName("text");
                texts[0].InnerText = balance.TileString;
                if (balances != null)
                {
                    for (int n = 0; n < Math.Min(texts.Count - 1, balances.Count); n++)
                    {
                        texts[n + 1].InnerText = balances[n].TileString;
                    }
                }

                var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(this.Id);
                updater.Clear();
                updater.Update(new TileNotification(tileXml)
                {
                    // Lai nerādītu, kad nolasīja datus, noņem informāciju pēc lietotāja noteiktā intervāla.
                    ExpirationTime = DateTimeOffset.Now.Add(RefreshInterval)
                });
            }
        }
예제 #14
0
        public static async Task <bool> RefreshCountdown(Countdown countdown)
        {
            var tileId = countdown.Guid;

            var tiles = await SecondaryTile.FindAllAsync();

            var tile = tiles.SingleOrDefault(x => x.TileId == tileId);

            if (tile == null)
            {
                return(await PinCountdown(countdown));
            }

            if (tile.DisplayName != countdown.Name)
            {
                tile.DisplayName = countdown.Name;
                await tile.UpdateAsync();
            }

            var now     = DateTime.Now;
            var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId);

            ClearNotifications(updater);
            UpdateNotification(updater, countdown, now);
            UpdateScheduledNotifications(updater, countdown, now);

            return(true);
        }
예제 #15
0
        internal static async Task UpdateTile(IDisposable CanvasDevice, BookItem Book, string TileId)
        {
            TileUpdater Updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TileId);

            Updater.EnableNotificationQueue(true);
            Updater.Clear();

            StringResources stx = StringResources.Load("Message");

            XmlDocument Template150 = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);

            Template150.GetElementsByTagName("text").First().AppendChild(Template150.CreateTextNode(stx.Str("NewContent")));
            Updater.Update(new TileNotification(Template150));

            XmlDocument Template71 = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare71x71Image);
            IXmlNode    ImgSrc     = Template71.GetElementsByTagName("image")
                                     .FirstOrDefault()?.Attributes
                                     .FirstOrDefault(x => x.NodeName == "src");

            string SmallTile = await Image.LiveTileBadgeImage(CanvasDevice, Book, 150, 150, "\uEDAD");

            if (!string.IsNullOrEmpty(SmallTile))
            {
                ImgSrc.NodeValue = SmallTile;
                Updater.Update(new TileNotification(Template71));
            }
        }
        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());
                }
            }
        }
예제 #17
0
        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:///Assets/squareTile-sdk.png"),
                    TileSize.Wide310x150
                    );
                secondTile.VisualElements.Wide310x150Logo    = new Uri("ms-appx:///Assets/tile-sdk.png");
                secondTile.LockScreenBadgeLogo               = new Uri("ms-appx:///Assets/badgelogo-sdk.png");
                secondTile.LockScreenDisplayBadgeAndTileText = true;

                bool isPinned = await secondTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender), Placement.Above);

                if (isPinned)
                {
                    var tileDOM = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text03);
                    tileDOM.SelectSingleNode("//text[@id=1]").InnerText = "Text for the lock screen";

                    TileUpdateManager.CreateTileUpdaterForSecondaryTile(TEXT_TILE_ID).Update(new TileNotification(tileDOM));
                    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);
            }
        }
예제 #18
0
        private async static void refresh_server()
        {
            foreach (server server in data_trans.server_list)
            {
                await server.connect_server();

                await server.update_player_list();

                string game        = server.Game.TrimEnd('\0');
                string name        = server.Name.TrimEnd('\0');
                string map         = server.Map.TrimEnd('\0');
                string players     = server.Players_maxplayers.TrimEnd('\0');
                string tileId      = server.Ip + server.Port;
                string player_list = "";
                foreach (var player_name in server.Player_list)
                {
                    player_list += player_name.TrimEnd('\0') + "、";
                }
                player_list.TrimEnd('、');
                var tileNotif = tile_content.update_info(game, name, map, players, player_list.TrimEnd('、'));
                tileNotif.Tag = "info";
                if (SecondaryTile.Exists(tileId))
                {
                    // Get its updater
                    var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId);
                    updater.EnableNotificationQueue(true);

                    // And send the notification
                    updater.Update(tileNotif);
                }
            }
        }
예제 #19
0
        static async void SetLiveTileToSingleImage(string wideImageFileName, string mediumImageFileName)
        {
            // Construct the tile content as a string
            string content = $@"
                                <tile>
                                    <visual> 
                                        <binding template='TileSquareImage'>
                                           <image id='1' src='ms-appdata:///local/{mediumImageFileName}' />
                                        </binding> 
                                         <binding  template='TileWideImage' branding='none'>
                                           <image id='1' src='ms-appdata:///local/{wideImageFileName}' />
                                        </binding>
 
                                    </visual>
                                </tile>";

            SecondaryTile sec = new SecondaryTile("tile", "", "prof2", new Uri("ms-appdata:///local/{mediumImageFileName}"), TileSize.Square150x150);
            await sec.RequestCreateAsync();

            // Load the string into an XmlDocument
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(content);

            // Then create the tile notification
            var notification = new TileNotification(doc);

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(sec.TileId).Update(notification);
        }
        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 SendTileNotificationWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                string tileXmlString = "<tile>"
                                       + "<visual version='2'>"
                                       + "<binding template='TileWide310x150Text04' fallback='TileWideText04'>"
                                       + "<text id='1'>Send to a secondary tile from strings</text>"
                                       + "</binding>"
                                       + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                                       + "<text id='1'>Send to a secondary tile from strings</text>"
                                       + "</binding>"
                                       + "</visual>"
                                       + "</tile>";

                Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
                tileDOM.LoadXml(tileXmlString);
                TileNotification tile = new TileNotification(tileDOM);

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

                rootPage.NotifyUser("Tile notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
            }
        }
예제 #22
0
        //Set battery tile to disabled
        XmlDocument RenderTileBatteryDisabled()
        {
            try
            {
                //Reset secondary battery tile
                if (TileBattery_Pinned)
                {
                    Debug.WriteLine("Set battery tile to disabled.");

                    Tile_UpdateManager  = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeBatteryTile");
                    Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();

                    foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates)
                    {
                        try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { }
                    }
                    BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile("TimeMeBatteryTile").Clear();

                    string TileImage         = "<group><subgroup><image src=\"ms-appx:///Assets/BatterySquare/BatteryVerNoBattery.png\"/></subgroup></group>";
                    string BatterySmallTile  = "<binding template=\"TileSmall\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";
                    string BatteryMediumTile = "<binding template=\"TileMedium\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";
                    string BatteryWideTile   = "<binding template=\"TileWide\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
            }
            catch { }
            return(Tile_XmlContent);
        }
        /// <summary>
        /// Delegate to update the secondary tile. This is called from the OnSuspending event handler in App.xaml.cs
        /// </summary>
        private void UpdateTile()
        {
            // Simulate a long-running task. For illustration purposes only.
            if (Debugger.IsAttached)
            {
                // Set a larger delay to give you time to select "Suspend" from the "LifetimeEvents" dropdown in Visual Studio in
                // order to simulate the app being suspended when the new tile is created.
                Task.Delay(5000).Wait();
            }
            else
            {
                // When the app is not attached to the debugger, the app will be suspended so we can use a
                // more realistic delay.
                Task.Delay(2000).Wait();
            }

            // Update the tile we created using a notification.
            var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Image);

            // The TileSquare150x150Image template only contains one image entry, so retrieve it.
            var imageElement = tileXml.GetElementsByTagName("image").Single();

            // Set the src propertry on the image entry. The image in this sample is a lime green image with the word "Updated" in white text
            imageElement.Attributes.GetNamedItem("src").NodeValue = "ms-appx:///Assets/updatedTileImage.png";

            // Create a new tile notification.
            var notification = new Windows.UI.Notifications.TileNotification(tileXml);

            // Create a tile updater.
            var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(SCENARIO2_TILEID);

            // Send the update notification for the tile.
            updater.Update(notification);
        }
예제 #24
0
        //Set tile to failed update
        XmlDocument RenderTileLiveFailed(string TileId)
        {
            try
            {
                Debug.WriteLine("Set tile to failed: " + TileId);

                //Reset primary tile
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
                TileUpdateManager.CreateTileUpdaterForApplication().Clear();

                Tile_UpdateManager  = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TileId);
                Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();

                foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates)
                {
                    try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { }
                }
                BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(TileId).Clear();

                Tile_XmlContent.LoadXml("<tile><visual branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoFailed.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/WideLogoFailed.png\"/></binding></visual></tile>");
                Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
            }
            catch { }
            return(Tile_XmlContent);
        }
        public async void Pin()
        {
            var tileId = Artist.Id.ToString();

            var tile = new SecondaryTile(tileId)
            {
                DisplayName    = Artist.Name,
                VisualElements =
                {
                    BackgroundColor             = Color.FromArgb(255,                        7, 96, 110),
                    Square150x150Logo           = new Uri("ms-appx:///Assets/Logo.png"),
                    ShowNameOnSquare150x150Logo = true,
                    Wide310x150Logo             = new Uri("ms-appx:///Assets/WideLogo.png"),
                    ShowNameOnWide310x150Logo   = true,
                    ForegroundText              = ForegroundText.Light
                },
                Arguments = Artist.Id.ToString()
            };

            await tile.RequestCreateAsync();

            var updater  = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId);
            var template = await GetTemplateDocumentAsync();

            var notification = new TileNotification(template);

            updater.Update(notification);
        }
예제 #26
0
        //Set weather tile to disabled
        XmlDocument RenderTileWeatherDisabled()
        {
            try
            {
                //Reset secondary weather tile
                if (TileWeather_Pinned)
                {
                    Debug.WriteLine("Set weather tile to disabled.");

                    Tile_UpdateManager  = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeWeatherTile");
                    Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();

                    foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates)
                    {
                        try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { }
                    }
                    BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile("TimeMeWeatherTile").Clear();

                    Tile_XmlContent.LoadXml("<tile><visual branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoWeatherDisabled.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/WideLogoWeatherDisabled.png\"/></binding></visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
            }
            catch { }
            return(Tile_XmlContent);
        }
예제 #27
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);
            }
        }
        private async void ButtonPinUpdateTile_Click(object sender, RoutedEventArgs e)
        {
            SecondaryTile tile = new SecondaryTile(DateTime.Now.Ticks.ToString())
            {
                DisplayName = "Seattle",
                Arguments   = "action=viewForecast&zip=98008"
            };

            tile.VisualElements.Square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.png");
            tile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/Square150x150Logo.png");
            tile.VisualElements.Wide310x150Logo   = new Uri("ms-appx:///Assets/Wide310x150Logo.png");

            tile.VisualElements.ShowNameOnSquare150x150Logo = true;
            tile.VisualElements.ShowNameOnSquare310x310Logo = true;
            tile.VisualElements.ShowNameOnWide310x150Logo   = true;

            if (!await tile.RequestCreateAsync())
            {
                return;
            }

            // Generate the notification content as XML
            XmlDocument content = NotificationHelper.GenerateTileContent().GetXml();

            // Create the notification
            TileNotification notif = new TileNotification(content);

            // And update the tile with the notification
            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(notif);
        }
예제 #29
0
        private void UpdateTileButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId);
            var doc         = new XmlDocument();

            doc.LoadXml(
                "<tile version='3'>" +
                "<visual>" +
                "<binding template='TileMedium' branding='None'>" +
                "<group>" +
                "<subgroup>" +
                "<text hint-style='Body' hint-wrap='true'>You have mail</text>" +
                $"<text hint-style='Caption' hint-wrap='true'>{DateTime.Now.ToString()}</text>" +
                "</subgroup>" +
                "</group>" +
                "</binding>" +
                "<binding template='TileWide' branding='None'>" +
                "<group>" +
                "<subgroup hint-weight='40'>" +
                "<image placement='Inline' src='http://fc02.deviantart.net/fs71/i/2013/359/a/4/deadpool_logo_1_fill_by_mr_droy-d5q6y5u.png' />" +
                "</subgroup>" +
                "<subgroup>" +
                "<text hint-style='Body' hint-wrap='true'>You have mail</text>" +
                $"<text hint-style='Caption' hint-wrap='true'>{DateTime.Now.ToString()}</text>" +
                "</subgroup>" +
                "</group>" +
                "</binding>" +
                "</visual>" +
                "</tile>"
                );
            tileUpdater.Update(new TileNotification(doc));
        }
예제 #30
0
        public static void UpdateBatteryTile(int?percentage)
        {
            if (!SecondaryTile.Exists(BatteryTileId))
            {
                return;
            }

            var deviceId   = SettingsHelper.GetValue(Constants.LastSavedDeviceIdSettingKey, string.Empty);
            var deviceName = SettingsHelper.GetValue(Constants.LastSavedDeviceNameSettingKey, string.Empty);

            var tileVisual = new TileVisual
            {
                Branding   = TileBranding.NameAndLogo,
                TileMedium = CreateMediumTileBinding(percentage ?? 0, deviceName),
                TileWide   = CreateWideTileBinding(percentage ?? 0, deviceName),
                TileLarge  = CreateLargeTileBinding(percentage ?? 0, deviceName)
            };

            var tileContent = new TileContent
            {
                Visual = tileVisual
            };

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

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(BatteryTileId).Update(tileNotification);
        }