public static void MaybeShuffleWallpaper() { if (!JsonConfig.settings.enableShuffle) { return; } if (JsonConfig.settings.lastShuffleDate != null) { DateTime lastShuffleDate = ConfigMigrator.SafeParse(JsonConfig.settings.lastShuffleDate); if (lastShuffleDate.Date == DateTime.Now.Date) { return; } } ShuffleWallpaper(); }
private static SolarData GetUserProvidedSolarData(DateTime date) { SolarData data = new SolarData(); data.sunriseTime = date.Date + ConfigMigrator.SafeParse(JsonConfig.settings.sunriseTime).TimeOfDay; data.sunsetTime = date.Date + ConfigMigrator.SafeParse(JsonConfig.settings.sunsetTime).TimeOfDay; int halfSunriseSunsetDuration = JsonConfig.settings.sunriseSunsetDuration * 30; data.solarTimes = new DateTime[4] { data.sunriseTime.AddSeconds(-halfSunriseSunsetDuration), data.sunriseTime.AddSeconds(halfSunriseSunsetDuration), data.sunsetTime.AddSeconds(-halfSunriseSunsetDuration), data.sunsetTime.AddSeconds(halfSunriseSunsetDuration) }; return(data); }
public static void TryCheckAuto(bool forceIfEnabled = false) { if (UwpDesktop.IsRunningAsUwp() || JsonConfig.settings.disableAutoUpdate) { return; } if (JsonConfig.settings.lastUpdateCheck != null && !forceIfEnabled) { DateTime lastUpdateCheck = ConfigMigrator.SafeParse(JsonConfig.settings.lastUpdateCheck); TimeSpan timeDiff = new TimeSpan(DateTime.Now.Ticks - lastUpdateCheck.Ticks); if (timeDiff.Days < 7) { return; } } Task.Run(() => CheckAuto()); }
private void InputDialog_Load(object sender, EventArgs e) { if (JsonConfig.settings.location != null) { locationBox.Text = JsonConfig.settings.location; } radioButton2.Enabled = UwpDesktop.IsUwpSupported(); hasLocationPermission = UwpLocation.HasAccess(); sunriseTimePicker.MinDate = DateTime.Today; sunsetTimePicker.MaxDate = DateTime.Today.AddDays(1); if (JsonConfig.settings.sunriseTime != null && JsonConfig.settings.sunsetTime != null) { sunriseTimePicker.Value = ConfigMigrator.SafeParse(JsonConfig.settings.sunriseTime); sunsetTimePicker.Value = ConfigMigrator.SafeParse(JsonConfig.settings.sunsetTime); } else { sunriseTimePicker.Value = DateTime.Today.AddHours(6); sunsetTimePicker.Value = DateTime.Today.AddHours(18); } if (JsonConfig.settings.sunriseSunsetDuration > 0) { sunriseSunsetDurationBox.Value = JsonConfig.settings.sunriseSunsetDuration; } if (JsonConfig.settings.useWindowsLocation) { radioButton2.Checked = true; } else if (JsonConfig.settings.dontUseLocation) { radioButton3.Checked = true; } UpdateGuiState(); isLoaded = true; }