//Notification - Network change void ShowNotiNetworkChange() { try { if (setNotiNetworkChange) { if (setNotiStyle == 0) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Icons/Network.png\"/><text id=\"1\">Network has changed</text><text id=\"2\">You are now on: " + TextNetworkName + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T9", Group = "G1" }); } else if (setNotiStyle == 1) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Icons/Network.png\"/><text id=\"1\">Network has changed</text><text id=\"2\">You are now on: " + TextNetworkName + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T9", Group = "G1" }); } else if (setNotiStyle == 2) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Icons/Network.png\"/><text id=\"1\">Network has changed</text><text id=\"2\">You are now on: " + TextNetworkName + "</text></binding></visual><audio silent=\"false\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T9", Group = "G1" }); } } //else { Toast_History.Remove("T9", "G1"); } } catch { } }
//Notification - Bing description void ShowNotiBingDescription() { try { if (setNotiBingDescription) { if (setNotiStyle == 0) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Background.png\"/><text id=\"1\">Daily Bing description</text><text id=\"2\">" + WebUtility.HtmlEncode(BgStatusBingDescription) + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T2", Group = "G1" }); } else if (setNotiStyle == 1) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Background.png\"/><text id=\"1\">Daily Bing description</text><text id=\"2\">" + WebUtility.HtmlEncode(BgStatusBingDescription) + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T2", Group = "G1" }); } else if (setNotiStyle == 2) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Background.png\"/><text id=\"1\">Daily Bing description</text><text id=\"2\">" + WebUtility.HtmlEncode(BgStatusBingDescription) + "</text></binding></visual><audio silent=\"false\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T2", Group = "G1" }); } } //else { Toast_History.Remove("T2", "G1"); } } catch { } }
//Notification - Next calendar time void ShowNotiCalendarTime() { try { if (setNotiCalendarTime && !String.IsNullOrEmpty(CalendarAppoName)) { if (setNotiStyle == 0) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Calendar.png\"/><text id=\"1\">" + WebUtility.HtmlEncode(CalendarAppoName) + "</text><text id=\"2\">" + WebUtility.HtmlEncode(CalendarAppoSummary + "\n" + CalendarAppoEstimated) + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T4", Group = "G1" }); } else if (setNotiStyle == 1) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Calendar.png\"/><text id=\"1\">" + WebUtility.HtmlEncode(CalendarAppoName) + "</text><text id=\"2\">" + WebUtility.HtmlEncode(CalendarAppoSummary + "\n" + CalendarAppoEstimated) + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T4", Group = "G1" }); } else if (setNotiStyle == 2) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Calendar.png\"/><text id=\"1\">" + WebUtility.HtmlEncode(CalendarAppoName) + "</text><text id=\"2\">" + WebUtility.HtmlEncode(CalendarAppoSummary + "\n" + CalendarAppoEstimated) + "</text></binding></visual><audio silent=\"false\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T4", Group = "G1" }); } } //else { Toast_History.Remove("T4", "G1"); } } catch { } }
//Notification - Day time progression void ShowNotiDayTime() { try { if (setNotiDayTime) { //Load Day Time Remaining TimeSpan TimeTomorrow = DateTime.Today.AddDays(1).Subtract(DateTimeNow); int TimeTomorrowHours = TimeTomorrow.Hours; int TimeTomorrowMinutes = TimeTomorrow.Minutes; string TimeTillTomorrow = ""; if (TimeTomorrowHours != 0) { TimeTillTomorrow = TimeTillTomorrow + TimeTomorrowHours + "h "; } if (TimeTomorrowMinutes != 0) { TimeTillTomorrow = TimeTillTomorrow + TimeTomorrowMinutes + "m "; } if (String.IsNullOrEmpty(TimeTillTomorrow)) { TimeTillTomorrow = "a minute "; } //Set Notification Clock Icon string ClockIcon = "ms-appx:///Assets/Analog/Minimal/" + DateTimeNow.ToString("hmm") + ".png"; if (setNotiStyle == 0) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"" + ClockIcon + "\"/><text id=\"1\">The day has progressed " + DayTimeProgress + "%</text><text id=\"2\">And has about " + TimeTillTomorrow + "time remaining, enjoy the rest of your day!</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T5", Group = "G1" }); } else if (setNotiStyle == 1) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"" + ClockIcon + "\"/><text id=\"1\">The day has progressed " + DayTimeProgress + "%</text><text id=\"2\">And has about " + TimeTillTomorrow + "time remaining, enjoy the rest of your day!</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T5", Group = "G1" }); } else if (setNotiStyle == 2) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"" + ClockIcon + "\"/><text id=\"1\">The day has progressed " + DayTimeProgress + "%</text><text id=\"2\">And has about " + TimeTillTomorrow + "time remaining, enjoy the rest of your day!</text></binding></visual><audio silent=\"false\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T5", Group = "G1" }); } } //else { Toast_History.Remove("T5", "G1"); } } catch { } }
//Notification - Current Battery Level void ShowNotiBattery() { try { if (setNotiBattery) { if (BatteryLevel != "error") { string NotiBattery = ""; if (BatteryCharging) { NotiBattery = BatteryLevel + "% left and is now charging"; } else { NotiBattery = BatteryLevel + "% battery life left and " + BatteryTime.ToLower() + "time remaining"; } if (setNotiStyle == 0) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/BatterySquare/BatteryVer" + BatteryIcon + ".png\"/><text id=\"1\">Your battery level now has</text><text id=\"2\">" + NotiBattery + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T3", Group = "G1" }); } else if (setNotiStyle == 1) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/BatterySquare/BatteryVer" + BatteryIcon + ".png\"/><text id=\"1\">Your battery level now has</text><text id=\"2\">" + NotiBattery + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T3", Group = "G1" }); } else if (setNotiStyle == 2) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/BatterySquare/BatteryVer" + BatteryIcon + ".png\"/><text id=\"1\">Your battery level now has</text><text id=\"2\">" + NotiBattery + "</text></binding></visual><audio silent=\"false\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T3", Group = "G1" }); } } else { Toast_History.Remove("T3", "G1"); } } } catch { } }
//Notification - Current Weather void ShowNotiWeatherCurrent() { try { if (setNotiWeatherCurrent) { string NotiRainChance = BgStatusWeatherCurrentRainChance + " chance of rain"; string NotiWindSpeed = "\n" + BgStatusWeatherCurrentWindSpeed + " windspeed"; string NotiLocation = BgStatusWeatherCurrentLocation; if (NotiLocation.Length < 7) { NotiLocation = "\nNear town " + NotiLocation; } else if (NotiLocation.Length < 15) { NotiLocation = "\nNear " + NotiLocation; } if (setNotiStyle == 0) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/WeatherSquare" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\"/><text id=\"1\">" + WebUtility.HtmlEncode(BgStatusWeatherCurrent) + "</text><text id=\"2\">" + WebUtility.HtmlEncode(NotiRainChance) + WebUtility.HtmlEncode(NotiWindSpeed) + WebUtility.HtmlEncode(NotiLocation) + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T1", Group = "G1" }); } else if (setNotiStyle == 1) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/WeatherSquare" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\"/><text id=\"1\">" + WebUtility.HtmlEncode(BgStatusWeatherCurrent) + "</text><text id=\"2\">" + WebUtility.HtmlEncode(NotiRainChance) + WebUtility.HtmlEncode(NotiWindSpeed) + WebUtility.HtmlEncode(NotiLocation) + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T1", Group = "G1" }); } else if (setNotiStyle == 2) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/WeatherSquare" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\"/><text id=\"1\">" + WebUtility.HtmlEncode(BgStatusWeatherCurrent) + "</text><text id=\"2\">" + WebUtility.HtmlEncode(NotiRainChance) + WebUtility.HtmlEncode(NotiWindSpeed) + WebUtility.HtmlEncode(NotiLocation) + "</text></binding></visual><audio silent=\"false\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T1", Group = "G1" }); } } //else { Toast_History.Remove("T1", "G1"); } } catch { } }
//Notification - Countdown Time void ShowNotiCountdownTime() { try { if (setNotiCountdownTime && !String.IsNullOrEmpty(CountdownEventName) && !String.IsNullOrEmpty(CountdownEventDate)) { string CountDownDateText = String.Empty; if (CountdownEventDate == "today") { CountDownDateText = "Is today's event"; } else { CountDownDateText = "Arrives in " + CountdownEventDate + " days"; } if (setNotiStyle == 0) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Countdown.png\"/><text id=\"1\">" + WebUtility.HtmlEncode(CountdownEventName) + "</text><text id=\"2\">" + WebUtility.HtmlEncode(CountDownDateText) + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T7", Group = "G1" }); } else if (setNotiStyle == 1) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Countdown.png\"/><text id=\"1\">" + WebUtility.HtmlEncode(CountdownEventName) + "</text><text id=\"2\">" + WebUtility.HtmlEncode(CountDownDateText) + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T7", Group = "G1" }); } else if (setNotiStyle == 2) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Countdown.png\"/><text id=\"1\">" + WebUtility.HtmlEncode(CountdownEventName) + "</text><text id=\"2\">" + WebUtility.HtmlEncode(CountDownDateText) + "</text></binding></visual><audio silent=\"false\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T7", Group = "G1" }); } } //else { Toast_History.Remove("T7", "G1"); } } catch { } }
//Notification - Current week number void ShowNotiWeekNumber() { try { if (setNotiWeekNumber) { //if (DateTimeNow.DayOfWeek == vCultureInfoReg.DateTimeFormat.FirstDayOfWeek) if (DateTimeNow.DayOfWeek == DayOfWeek.Monday || BgStatusLastRunDate == "Never") { if (BgStatusLastRunDate == "Never" || DateTime.Parse(BgStatusLastRunDate, vCultureInfoEng).Day != DateTimeNow.Day) { if (setNotiStyle == 0) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Week.png\"/><text id=\"1\">Welcome to a new week</text><text id=\"2\">We are in week number " + WeekNumberCurrent + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T6", Group = "G1" }); } else if (setNotiStyle == 1) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Week.png\"/><text id=\"1\">Welcome to a new week</text><text id=\"2\">We are in week number " + WeekNumberCurrent + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T6", Group = "G1" }); } else if (setNotiStyle == 2) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Menu/Week.png\"/><text id=\"1\">Welcome to a new week</text><text id=\"2\">We are in week number " + WeekNumberCurrent + "</text></binding></visual><audio silent=\"false\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T6", Group = "G1" }); } } } } //else { Toast_History.Remove("T6", "G1"); } } catch { } }
//Notification - Battery Saver Warning async Task ShowNotiBatterySaver() { try { if (setNotiBatterySaver && AVFunctions.DevOsVersion() >= 14393) { BackgroundAccessStatus BackgroundManager = await BackgroundExecutionManager.RequestAccessAsync(); if (BatteryLevel != "error" && BackgroundManager != BackgroundAccessStatus.AlwaysAllowed) { if (setNotiStyle == 0) { Tile_XmlContent.LoadXml("<toast launch=\"NotiBatterySaver\"><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Icons/BatteryLevelSquare.png\"/><text id=\"1\">Hello battery device user,</text><text id=\"2\">Please make sure TimeMe is always allowed to run in the background battery saver to keep the tile up-to-date.</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T8", Group = "G1" }); } else if (setNotiStyle == 1) { Tile_XmlContent.LoadXml("<toast launch=\"NotiBatterySaver\"><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Icons/BatteryLevelSquare.png\"/><text id=\"1\">Hello battery device user,</text><text id=\"2\">Please make sure TimeMe is always allowed to run in the background battery saver to keep the tile up-to-date.</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T8", Group = "G1" }); } else if (setNotiStyle == 2) { Tile_XmlContent.LoadXml("<toast launch=\"NotiBatterySaver\"><visual><binding template=\"ToastImageAndText02\"><image id=\"1\" src=\"ms-appx:///Assets/Icons/BatteryLevelSquare.png\"/><text id=\"1\">Hello battery device user,</text><text id=\"2\">Please make sure TimeMe is always allowed to run in the background battery saver to keep the tile up-to-date.</text></binding></visual><audio silent=\"false\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = false, Tag = "T8", Group = "G1" }); } } //else if (!setNotiBattery) { Toast_History.Remove("T8", "G1"); } } } catch { } }
//Plan and render future live tiles async Task PlanLiveTiles() { try { //Show render start debug message if (setAppDebug) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastText02\"><text id=\"1\">Renderstart: " + taskInstanceName + "</text><text id=\"2\">" + DateTimeNow.ToString() + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T1", Group = "G3" }); } //Remove old planned live tiles Debug.WriteLine("Removing " + Tile_PlannedUpdates.Count + " older live task updates."); foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates) { try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { } } //Render future live tile back if (TileLive_BackRender) { Debug.WriteLine("Started rendering back live tile."); await RenderLiveTileBack(); } //Render future live tiles front Debug.WriteLine("Started rendering front live tiles."); TileTimeNow = DateTime.Now; TileTimeMin = TileTimeNow.AddSeconds(-TileTimeNow.Second).AddMinutes(-1); for (int LiveTileRenderId = 0; LiveTileRenderId < 18; LiveTileRenderId++) { try { TileTimeNow = DateTime.Now; TileTimeMin = TileTimeMin.AddMinutes(1); TileContentId = TileTimeMin.Minute.ToString(); TileRenderName = LiveTileRenderId.ToString(); if (TileTimeNow.Minute == TileTimeMin.Minute) { Tile_UpdateManager.Update(new TileNotification(await RenderLiveTile())); } else { Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(await RenderLiveTile(), new DateTimeOffset(TileTimeMin))); } if (TileLive_BackRender) { Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoSize.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appdata:///local/TimeMeBack.png\"/></binding></visual></tile>"); if (TileTimeNow < TileTimeMin.AddSeconds(12)) { Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(12)))); } if (TileTimeNow < TileTimeMin.AddSeconds(32)) { Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(32)))); } if (TileTimeNow < TileTimeMin.AddSeconds(52)) { Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(52)))); } Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoSize.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appdata:///local/TimeMe" + TileRenderName + ".png\"/></binding></visual></tile>"); if (TileTimeNow < TileTimeMin.AddSeconds(20)) { Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(20)))); } if (TileTimeNow < TileTimeMin.AddSeconds(40)) { Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(40)))); } } //Show live tile render debug message if (setAppDebug) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastText02\"><text id=\"1\">Renderedtile: " + taskInstanceName + "</text><text id=\"2\">" + TileRenderName + "/17 at " + DateTimeNow.ToString() + " Mem " + (MemoryManager.AppMemoryUsage / 1024f / 1024f).ToString() + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T2", Group = "G3" }); } } catch { } } ////Add tile will be updated shortly on the end //Tile_DateTimeMin = Tile_DateTimeMin.AddMinutes(1); //Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoUpdate.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/WideLogoUpdate.png\"/></binding></visual></tile>"); //Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(Tile_DateTimeMin))); Debug.WriteLine("Finished rendering live tiles batch."); } catch { Debug.WriteLine("Failed rendering live tiles batch."); } }
//Run Task Agent Update public async void Run(IBackgroundTaskInstance taskInstance) { try { //Set current background task info taskInstanceDeferral = taskInstance.GetDeferral(); taskInstance.Canceled += delegate { DisposeVariables(); taskInstance.Progress = 100; taskInstanceDeferral.Complete(); return; }; taskInstanceName = taskInstance.Task.Name; //Load tile and application settings taskInstance.Progress = 90; if (!LoadAppSettings()) { if (TileLive_Pinned) { RenderTileAppUpdated("TimeMeLiveTile"); } if (TileWeather_Pinned) { RenderTileAppUpdated("TimeMeWeatherTile"); } if (TileBattery_Pinned) { RenderTileAppUpdated("TimeMeBatteryTile"); } DisposeVariables(); taskInstance.Progress = 100; taskInstanceDeferral.Complete(); return; } //Show task start debug message if (setAppDebug) { Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastText02\"><text id=\"1\">Taskstart: " + taskInstanceName + "</text><text id=\"2\">" + DateTimeNow.ToString() + "</text></binding></visual><audio silent=\"true\"/></toast>"); Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent) { SuppressPopup = true, Tag = "T3", Group = "G3" }); } //Load other used data first if (!await LoadOtherDataFirst()) { if (TileLive_Pinned) { RenderTileLiveFailed("TimeMeLiveTile"); } if (TileWeather_Pinned) { RenderTileLiveFailed("TimeMeWeatherTile"); } if (TileBattery_Pinned) { RenderTileLiveFailed("TimeMeBatteryTile"); } DisposeVariables(); taskInstance.Progress = 100; taskInstanceDeferral.Complete(); return; } //Download the background updates taskInstance.Progress = 10; await DownloadBackground(); //Update the lockscreen information taskInstance.Progress = 20; UpdateLockscreen(); //Check if weather tile is pinned if (TileWeather_Pinned) { taskInstance.Progress = 40; Tile_UpdateManager = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeWeatherTile"); Tile_UpdateManager.EnableNotificationQueue(false); Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications(); if (await LoadTileDataWeather()) { RenderWeatherTile(); } else { RenderTileWeatherDisabled(); } } //Check if battery tile is pinned if (TileBattery_Pinned) { taskInstance.Progress = 50; Tile_UpdateManager = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeBatteryTile"); Tile_UpdateManager.EnableNotificationQueue(false); Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications(); if (await LoadTileDataBattery()) { RenderBatteryTile(); } else { RenderTileBatteryDisabled(); } } //Check if live tile is pinned if (TileLive_Pinned) { taskInstance.Progress = 30; Tile_UpdateManager = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeLiveTile"); Tile_UpdateManager.EnableNotificationQueue(false); Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications(); //Delay timer task to avoid collision //if (TaskInstanceName.StartsWith("TimeMeTaskTimer")) { await Task.Delay(1000); } //Check if there is a live tile update needed if (!FreshDeviceBoot && !TileLive_ForceUpdate && taskInstanceName != "TimeMeTaskTimeZone" && BgStatusLastRunDate != "Never" && Tile_PlannedUpdates.Any()) { //Check if the live tile has failed to update if (Tile_PlannedUpdates.Last().DeliveryTime.Subtract(DateTime.Parse(BgStatusLastRunDate, vCultureInfoEng)).TotalMilliseconds <= 960000) { Debug.WriteLine("Live tile has failed to render succesfully."); } else { if (taskInstanceName == "TimeMeTaskUser") { Debug.WriteLine("There is no user live tile update needed."); TileLive_NeedUpdate = false; } else if (taskInstanceName == "TimeMeTaskTimer" && Tile_PlannedUpdates.Last().DeliveryTime.Subtract(DateTimeNow).TotalMilliseconds >= 960000) { Debug.WriteLine("There is no timer live tile update needed."); TileLive_NeedUpdate = false; } } } //Update the live tile if needed if (TileLive_NeedUpdate) { //Load first one time live tile data if (await LoadTileDataFirst()) { //Plan and render future live tiles await PlanLiveTiles(); } else { RenderTileLiveFailed("TimeMeLiveTile"); } } } } catch { } DisposeVariables(); taskInstance.Progress = 100; taskInstanceDeferral.Complete(); return; }
//Load first other used data async Task <bool> LoadOtherDataFirst() { try { Debug.WriteLine("Loading first other miscellaneous data."); //Load and set time splitter character if (setDisplayCurrentTime) { switch (setDisplayTimeSplitter) { case 0: { TextTimeSplit = ":"; break; } case 1: { TextTimeSplit = "."; break; } case 2: { TextTimeSplit = ","; break; } case 3: { TextTimeSplit = "_"; break; } case 4: { TextTimeSplit = "-"; break; } case 5: { TextTimeSplit = "+"; break; } case 6: { TextTimeSplit = "x"; break; } case 7: { TextTimeSplit = "|"; break; } case 8: { TextTimeSplit = "!"; break; } case 9: { TextTimeSplit = "*"; break; } case 10: { TextTimeSplit = "@"; break; } case 11: { TextTimeSplit = "#"; break; } case 12: { TextTimeSplit = "&"; break; } case 13: { TextTimeSplit = "̥"; break; } case 14: { TextTimeSplit = "͓"; break; } case 15: { TextTimeSplit = " "; break; } } } //Check and set the weather icon style if (setDisplayWeatherWhiteIcons) { WeatherIconStyle = "White"; } //Check if current weather icon is available string WeatherIconFormat = "WeatherSquare" + WeatherIconStyle; if (await AVFunctions.AppFileExists("Assets/" + WeatherIconFormat + "/" + BgStatusWeatherCurrentIcon + ".png")) { WeatherIconCurrent = BgStatusWeatherCurrentIcon; } else { WeatherIconCurrent = "0"; } //Check for active alarms and timers if ((setDisplayAlarm || setLockAlarm) && Toast_UpdateManager.GetScheduledToastNotifications().Any(x => x.DeliveryTime > DateTimeNow)) { TimerAlarmActive = true; } //Load and set current battery text if (TextPositionUsed(Setting_TextPositions.Battery) || setLockBattery || setLockBatteryDetailed || setNotiBattery || setNotiLowBattery || TileBattery_Pinned || setDisplayTimeCustomText) { await LoadBatteryLevel(); } //Load and set current network name if (TextPositionUsed(Setting_TextPositions.Network) || setLockNetwork || setNotiNetworkChange || setDisplayTimeCustomText) { //Get and set the current network name TextNetworkName = await AVFunctions.GetNetworkName(); //Set the network name to tile text TextPositionSet(Setting_TextPositions.Network, TextNetworkName); //Check if the network has changed if (TextNetworkName != BgStatusNetworkName) { vApplicationSettings["BgStatusNetworkName"] = TextNetworkName; //Notification - Network change ShowNotiNetworkChange(); } } //Load current week number if (TextPositionUsed(Setting_TextPositions.WeekNumber) || setLockWeekNumber || setDisplayDateWeekNumber || setNotiWeekNumber || setLiveTileSizeName == "WideWords") { DateTime DateTimeWeekNow = DateTimeNow; DayOfWeek DateTimeDay = CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(DateTimeWeekNow); if (DateTimeDay >= DayOfWeek.Monday && DateTimeDay <= DayOfWeek.Wednesday) { DateTimeWeekNow = DateTimeWeekNow.AddDays(3); } WeekNumberCurrent = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(DateTimeWeekNow, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); //Notification - Current week number ShowNotiWeekNumber(); } //Load and set day time progression if (TextPositionUsed(Setting_TextPositions.DayProgress) || setNotiDayTime) { DayTimeProgress = Convert.ToInt32(100 - (((1440 - DateTimeNow.Subtract(DateTime.Today).TotalMinutes) / 1440) * 100)); //Set day time progression to tile text if (DayTimeProgress < 25) { TextPositionSet(Setting_TextPositions.DayProgress, "🕛 " + DayTimeProgress + " %"); } else if (DayTimeProgress < 50) { TextPositionSet(Setting_TextPositions.DayProgress, "🕒 " + DayTimeProgress + " %"); } else if (DayTimeProgress < 75) { TextPositionSet(Setting_TextPositions.DayProgress, "🕕 " + DayTimeProgress + " %"); } else { TextPositionSet(Setting_TextPositions.DayProgress, "🕘 " + DayTimeProgress + " %"); } //Notification - Day time progression ShowNotiDayTime(); } //Load Next calendar time if (TextPositionUsed(Setting_TextPositions.CalendarName) || TextPositionUsed(Setting_TextPositions.CalendarDateTime) || setLockCalendar || setNotiCalendarTime) { await LoadCalendarEvent(); //Notification - Next calendar time ShowNotiCalendarTime(); } //Load countdown event information if (TextPositionUsed(Setting_TextPositions.Countdown) || setLockCountdown || setNotiCountdownTime) { //Load first countdown event from XML using (Stream OpenStreamForReadAsync = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync("TimeMeCountdown.xml")) { XDocument XDocument = XDocument.Load(OpenStreamForReadAsync); OpenStreamForReadAsync.Dispose(); IEnumerable <XElement> XmlCountdownEvents = XDocument.Descendants("TimeMeCountdown").Elements("Count"); if (XmlCountdownEvents.Any()) { XElement FirstEvent = XmlCountdownEvents.Last(); DateTime LoadedDate = DateTime.Parse(FirstEvent.Attribute("CountDate").Value); //Datetime to string string ConvertedDate = ""; if ((bool)vApplicationSettings["DisplayRegionLanguage"]) { ConvertedDate = AVFunctions.ToTitleCase(LoadedDate.Date.ToString("d MMMM yyyy", vCultureInfoReg)); } else { ConvertedDate = LoadedDate.Date.ToString("d MMMM yyyy", vCultureInfoEng); } //Calculate the days left CountdownEventDate = (LoadedDate.Date.Subtract(DateTimeNow.Date).Days).ToString(); if (CountdownEventDate == "0") { CountdownEventDate = "today"; } //Set the countdown name CountdownEventName = FirstEvent.Attribute("CountName").Value; } } //Notification - Countdown Time ShowNotiCountdownTime(); } return(true); } catch { return(false); } }