public void RunScheduler(bool forceImageUpdate = false) { if (!LaunchSequence.IsLocationReady() || !LaunchSequence.IsThemeReady()) { return; } schedulerTimer.Stop(); SolarData data = SunriseSunsetService.GetSolarData(DateTime.Today); isSunUp = (data.sunriseTime <= DateTime.Now && DateTime.Now < data.sunsetTime); DateTime?nextImageUpdateTime = null; if (ThemeManager.currentTheme != null) { if (forceImageUpdate) { lastImagePath = null; } WallpaperShuffler.MaybeShuffleWallpaper(); SchedulerState imageData = GetImageData(data, ThemeManager.currentTheme); SetWallpaper(imageData.imageId); nextImageUpdateTime = new DateTime(imageData.nextUpdateTicks); } SystemThemeChanger.TryUpdateSystemTheme(); if (data.polarPeriod != PolarPeriod.None) { nextUpdateTime = DateTime.Today.AddDays(1); } else if (isSunUp) { nextUpdateTime = data.sunsetTime; } else if (DateTime.Now < data.solarTimes[0]) { nextUpdateTime = data.sunriseTime; } else { SolarData tomorrowsData = SunriseSunsetService.GetSolarData( DateTime.Today.AddDays(1)); nextUpdateTime = tomorrowsData.sunriseTime; } if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value) { nextUpdateTime = nextImageUpdateTime; } StartTimer(nextUpdateTime.Value); }
public void RunScheduler(bool forceImageUpdate = false) { if (!LaunchSequence.IsLocationReady() || !ThemeManager.filesVerified) { return; } schedulerTimer.Stop(); SolarData data = SunriseSunsetService.GetSolarData(DateTime.Today); isSunUp = (data.sunriseTime <= DateTime.Now && DateTime.Now < data.sunsetTime); DateTime?nextImageUpdateTime = null; if (ThemeManager.currentTheme != null) { if (forceImageUpdate) { lastImagePath = null; } Tuple <int, long> imageData = GetImageData(data, ThemeManager.currentTheme, JsonConfig.settings.darkMode); SetWallpaper(imageData.Item1); nextImageUpdateTime = new DateTime(imageData.Item2); } SystemThemeChanger.TryUpdateSystemTheme(); if (isSunUp) { nextUpdateTime = data.sunsetTime; } else if (DateTime.Now < data.solarTimes[0]) { nextUpdateTime = data.sunriseTime; } else { SolarData tomorrowsData = SunriseSunsetService.GetSolarData( DateTime.Today.AddDays(1)); nextUpdateTime = tomorrowsData.sunriseTime; } if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value) { nextUpdateTime = nextImageUpdateTime; } StartTimer(nextUpdateTime.Value); }
private void OnFormClosing(object sender, FormClosingEventArgs e) { if (!LaunchSequence.IsLocationReady()) { DialogResult result = MessageDialog.ShowQuestion(_("WinDynamicDesktop cannot display wallpapers " + "until you have entered a valid location, so that it can calculate sunrise and sunset times for " + "your location. Are you sure you want to cancel and quit the program?"), _("Question"), true); if (result == DialogResult.Yes) { Environment.Exit(0); } else { e.Cancel = true; } } }
public void RunScheduler(bool forceImageUpdate = false) { if (!LaunchSequence.IsLocationReady() || !LaunchSequence.IsThemeReady()) { return; } schedulerTimer.Stop(); DateTimeTZ DateTimeToday = DateTimeTZ.UTC.Today.ConvertTime(JsonConfig.settings.timezone); SolarData data = SunriseSunsetService.GetSolarData(DateTimeToday); DateTimeTZ DateTimeNow = DateTimeTZ.UTC.Now.ConvertTime(JsonConfig.settings.timezone); isSunUp = (data.sunriseTime.Time <= DateTimeNow.Time && DateTimeNow.Time < data.sunsetTime.Time); DateTime?nextImageUpdateTime = null; if (ThemeManager.currentTheme != null) { if (forceImageUpdate) { lastImagePath = null; } WallpaperShuffler.MaybeShuffleWallpaper(); } SchedulerState imageData = GetImageData(data, ThemeManager.currentTheme, DateTimeNow); if (ThemeManager.currentTheme != null) { SetWallpaper(imageData.imageId); nextImageUpdateTime = new DateTimeTZ(JsonConfig.settings.timezone, new DateTime(imageData.nextUpdateTicks)).Time; } ScriptManager.RunScripts(new ScriptArgs { daySegment2 = imageData.daySegment2, daySegment4 = imageData.daySegment4, imagePath = (ThemeManager.currentTheme != null) ? lastImagePath : null }); if (data.polarPeriod != PolarPeriod.None) { nextUpdateTime = DateTimeToday.AddDays(1).Time; } else if (isSunUp) { nextUpdateTime = data.sunsetTime.Time; } else if (DateTimeNow.Time < data.solarTimes[0].Time) { nextUpdateTime = data.sunriseTime.Time; } else { SolarData tomorrowsData = SunriseSunsetService.GetSolarData(DateTimeToday.AddDays(1)); nextUpdateTime = tomorrowsData.sunriseTime.Time; } if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value) { nextUpdateTime = nextImageUpdateTime; } StartTimer(nextUpdateTime.Value); }
public void RunScheduler(bool forceImageUpdate = false) { if (!LaunchSequence.IsLocationReady() || !LaunchSequence.IsThemeReady()) { return; } schedulerTimer.Stop(); SolarData data = SunriseSunsetService.GetSolarData(DateTime.Today); bool isSunUp = IsSunUp(data, DateTime.Now); DateTime? nextImageUpdateTime = null; if (ThemeManager.currentTheme != null) { if (forceImageUpdate) { lastImagePath = null; } WallpaperShuffler.MaybeShuffleWallpaper(); } SchedulerState imageData = GetImageData(data, ThemeManager.currentTheme, DateTime.Now); if (ThemeManager.currentTheme != null) { nextImageUpdateTime = new DateTime(imageData.endTick); if (JsonConfig.settings.enableInterpolation) { SchedulerState nextImageData = GetImageData(data, ThemeManager.currentTheme, nextImageUpdateTime.Value + TimeSpan.FromSeconds(1)); lock (interpolationLock) { interpolation.imageId1 = imageData.imageId; interpolation.imageId2 = nextImageData.imageId; interpolation.lastPercent = -1; interpolation.startTick = imageData.startTick; interpolation.endTick = imageData.endTick; lastImagePath = null; UpdateInterpolation(); } } else { SetWallpaper(imageData.imageId); } } ScriptManager.RunScripts(new ScriptArgs { daySegment2 = imageData.daySegment2, daySegment4 = imageData.daySegment4, imagePath = (ThemeManager.currentTheme != null) ? lastImagePath : null }); if (data.polarPeriod != PolarPeriod.None) { nextUpdateTime = DateTime.Today.AddDays(1); } else if (isSunUp) { nextUpdateTime = data.sunsetTime; } else if (DateTime.Now < data.solarTimes[0]) { nextUpdateTime = data.sunriseTime; } else { SolarData tomorrowsData = SunriseSunsetService.GetSolarData(DateTime.Today.AddDays(1)); nextUpdateTime = tomorrowsData.sunriseTime; } if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value) { nextUpdateTime = nextImageUpdateTime; } StartTimer(nextUpdateTime.Value); }
public void RunScheduler(bool forceImageUpdate = false) { if (!LaunchSequence.IsLocationReady() || !LaunchSequence.IsThemeReady()) { return; } schedulerTimer.Stop(); SolarData data = SunriseSunsetService.GetSolarData(DateTime.Today); isSunUp = (data.sunriseTime <= DateTime.Now && DateTime.Now < data.sunsetTime); DateTime?nextImageUpdateTime = null; //for (int i = 0; i < DisplayDevices.GetAllMonitorsFriendlyNames().Count(); i++) if (ThemeManager.currentTheme != null) { if (forceImageUpdate) { lastImagePath = null; } ThemeShuffler.MaybeShuffleWallpaper(); } SchedulerState imageData = GetImageData(data, ThemeManager.currentTheme, DateTime.Now); if (ThemeManager.currentTheme != null) { SetWallpaper(imageData.imageId); nextImageUpdateTime = new DateTime(imageData.nextUpdateTicks); } ScriptManager.RunScripts(new ScriptArgs { daySegment2 = imageData.daySegment2, daySegment4 = imageData.daySegment4, imagePath = (ThemeManager.currentTheme != null) ? lastImagePath : null }); if (data.polarPeriod != PolarPeriod.None) { nextUpdateTime = DateTime.Today.AddDays(1); } else if (isSunUp) { nextUpdateTime = data.sunsetTime; } else if (DateTime.Now < data.solarTimes[0]) { nextUpdateTime = data.sunriseTime; } else { SolarData tomorrowsData = SunriseSunsetService.GetSolarData(DateTime.Today.AddDays(1)); nextUpdateTime = tomorrowsData.sunriseTime; } if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value) { nextUpdateTime = nextImageUpdateTime; } StartTimer(nextUpdateTime.Value); }