internal async Task PinTile(ForecastData fd) { data = fd; if (data.confidenceDifference > 0.01) { diffDemocrat = " (+" + data.confidenceDifference.ToString("F1") + "%)"; diffRepublican = " (" + (-data.confidenceDifference).ToString("F1") + "%)"; } else if (data.confidenceDifference < -0.01) { diffDemocrat = " (" + data.confidenceDifference.ToString("F1") + "%)"; diffRepublican = " (+" + (-data.confidenceDifference).ToString("F1") + "%)"; } TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); int mode = 0; for (int i = 0; i < 2; i++) { TileContent content = GenerateTileContent(mode); TileNotification t = new TileNotification(content.GetXml()); t.Tag = i.ToString(); TileUpdateManager.CreateTileUpdaterForApplication().Update(t); mode++; } }
public static async void RunFromMainPage(bool doPhoto) { ForecastData data = new ForecastData(); await data.GetData(1); LiveTile tile = new LiveTile(doPhoto); await tile.PinTile(data); }
public async void Run(IBackgroundTaskInstance taskInstance) { // Get a deferral, to prevent the task from closing prematurely // while asynchronous code is still running. BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); ApplicationDataContainer appSettings = ApplicationData.Current.LocalSettings; ForecastData data = new ForecastData(); await data.GetData(1); if (appSettings.Values.ContainsKey("enablePhoto") && (bool)appSettings.Values["enablePhoto"]) { LiveTile tile = new LiveTile(true); await tile.PinTile(data); } else { LiveTile tile = new LiveTile(false); await tile.PinTile(data); } if (appSettings.Values.ContainsKey("enableNotifications")) { if ((bool)appSettings.Values["enableNotifications"] && data.hasChanged) { Notification toast = new Notification(data); } } // Inform the system that the task is finished. deferral.Complete(); }
internal async Task PinTile(ForecastData fd) { data = fd; if (data.confidenceDifference > 0.01) { diffDemocrat = " (+" + data.confidenceDifference.ToString("F1") + "%)"; diffRepublican = " (" + (-data.confidenceDifference).ToString("F1") + "%)"; } else if (data.confidenceDifference < -0.01) { diffDemocrat = " (" + data.confidenceDifference.ToString("F1") + "%)"; diffRepublican = " (+" + (-data.confidenceDifference).ToString("F1") + "%)"; } //EXTRA for (int s = 0; s < 9; s++) { SecondaryTile tile = new SecondaryTile(DateTime.Now.Ticks.ToString()) { DisplayName = "FiveThirtyEight", Arguments = "args" }; tile.VisualElements.Square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.scale-200.png"); tile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-200.png"); tile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/Square150x150Logo.scale-200.png"); tile.VisualElements.ShowNameOnSquare150x150Logo = false; tile.VisualElements.ShowNameOnSquare310x310Logo = true; tile.VisualElements.ShowNameOnWide310x150Logo = false; switch (s) { case 0: tile.VisualElements.BackgroundColor = Colors.Teal; break; case 1: tile.VisualElements.BackgroundColor = Color.FromArgb(255, 209, 52, 56); break; case 2: tile.VisualElements.BackgroundColor = Color.FromArgb(255, 0, 120, 215); break; case 3: tile.VisualElements.BackgroundColor = Color.FromArgb(255, 135, 100, 184); break; case 4: tile.VisualElements.BackgroundColor = Color.FromArgb(255, 16, 137, 62); break; case 5: tile.VisualElements.BackgroundColor = Colors.Teal; break; case 6: tile.VisualElements.BackgroundColor = Color.FromArgb(255, 209, 52, 56); break; case 7: tile.VisualElements.BackgroundColor = Color.FromArgb(255, 0, 120, 215); break; case 8: tile.VisualElements.BackgroundColor = Color.FromArgb(255, 135, 100, 184); break; case 9: tile.VisualElements.BackgroundColor = Color.FromArgb(255, 16, 137, 62); break; } if (!await tile.RequestCreateAsync()) { return; } //EXTRA TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Clear(); TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).EnableNotificationQueue(true); TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); int mode = 0; for (int i = 0; i < 2; i++) { TileContent content = GenerateTileContent(mode, s); TileNotification t = new TileNotification(content.GetXml()); t.Tag = i.ToString(); TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(t); mode++; } } }
public Notification(ForecastData fd) { data = fd; PopToast(); }