private void ApplySelectedTheme() { if (selectedIndex > 0) { ThemeManager.currentTheme = ThemeManager.themeSettings[selectedIndex - 1]; } else { ThemeManager.currentTheme = null; } JsonConfig.settings.themeName = ThemeManager.currentTheme?.themeId; if (selectedIndex == 0) { WallpaperApi.SetWallpaper(windowsWallpaper); } else { WallpaperShuffler.AddThemeToHistory(ThemeManager.currentTheme.themeId); AppContext.wpEngine.RunScheduler(); AppContext.ShowPopup(string.Format(_("New theme applied: {0}"), ThemeManager.GetThemeName(ThemeManager.currentTheme))); } }
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); }
private static void OnShuffleItemClick(object sender, EventArgs e) { WallpaperShuffler.ToggleShuffle(); }
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); }